Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/CHANGES.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/CHANGES.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/CHANGES.rst	(revision 12143)
@@ -0,0 +1,7 @@
+*******
+Changes
+*******
+
+.. todo::
+
+   List the main additions of the the new release
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/CONTRIBUTING.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/CONTRIBUTING.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/CONTRIBUTING.rst	(revision 12143)
@@ -3,6 +3,10 @@
 ************
 
+.. todo::
+
+
+
 .. contents::
-	:local:
+   :local:
 
 Sending feedbacks
@@ -17,7 +21,7 @@
 - You have a question: create a topic in the appropriate :forge:`discussion <forum>`
 - You would like to raise and issue: open a new ticket of the right type depending of its severity
-  
+
   - "Unavoidable" :forge:`newticket?type=Bug       <bug>`
-    
+
   - "Workable"    :forge:`newticket?type=Defect <defect>`
 
@@ -27,5 +31,5 @@
 ===============
 
-You have build a development relevant for NEMO shared reference: an addition of the source code,  
+You have build a development relevant for NEMO shared reference: an addition of the source code,
 a full fork of the reference, ...
 
@@ -34,5 +38,5 @@
 
 The proposals for developments to be included in the shared NEMO reference are first examined by NEMO Developers
-Committee / Scientific Advisory Board. 
+Committee / Scientific Advisory Board.
 The implementation of a new development requires some additionnal work from the intial developer.
 These tasks will need to be scheduled with NEMO System Team.
@@ -42,7 +46,7 @@
 ----
 
-You only would like to inform NEMO community about your developments. 
+You only would like to inform NEMO community about your developments.
 You can promote your work on NEMO forum gathering  the contributions fromof the community by creating
-a specific topic here :forge:`discussion/forum/5 <dedicated forum>` 
+a specific topic here :forge:`discussion/forum/5 <dedicated forum>`
 
 
@@ -55,5 +59,5 @@
   routines to the ticket, to highlight the proposed changes by adding to the ticket the output of ``svn diff``
   or ``svn patch`` from your working copy.
-  
+
 | Your development seems relevant for addition into the future release of NEMO shared reference.
   Implementing it into NEMO shared reference following the usual quality control will require some additionnal work
@@ -61,9 +65,9 @@
   your suggestion should be send as a proposed enhancement here :forge:`newticket?type=Enhancement <enhancement>`
   including description of the development, its implementation, and the existing validations.
-  
-  The proposed enhancement will be examined  by NEMO Developers Committee / Scientific Advisory Board. 
+
+  The proposed enhancement will be examined  by NEMO Developers Committee / Scientific Advisory Board.
   Once approved by the  Committee, the assicated development task can be scheduled in NEMO development work plan,
   and tasks distributed between you as initial developer and PI of this development action, and the NEMO System Team.
-  
+
   Once sucessful (meeting the usual quality control steps) this action will allow the merge of these developments with
   other developments of the year, building the future NEMO.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/INSTALL.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/INSTALL.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/INSTALL.rst	(revision 12143)
@@ -3,4 +3,8 @@
 *******************
 
+.. todo::
+
+
+
 .. contents::
    :local:
@@ -10,5 +14,5 @@
 
 | The NEMO source code is written in *Fortran 95* and
-  some of its prerequisite tools and libraries are already included in the ``./ext`` subdirectory.
+  some of its prerequisite tools and libraries are already included in the download.
 | It contains the AGRIF_ preprocessing program ``conv``; the FCM_ build system and
   the IOIPSL_ library for parts of the output.
@@ -23,5 +27,5 @@
 - *Fortran* compiler (``ifort``, ``gfortran``, ``pgfortran``, ...),
 - *Message Passing Interface (MPI)* implementation (e.g. |OpenMPI|_ or |MPICH|_).
-- |NetCDF|_ library with its underlying |HDF|_ 
+- |NetCDF|_ library with its underlying |HDF|_
 
 **NEMO, by default, takes advantage of some MPI features introduced into the MPI-3 standard.**
@@ -40,258 +44,4 @@
    This will limit MPI features to those defined within the MPI-2 standard
    (but will lose some performance benefits).
-
-Specifics for NetCDF and HDF
-----------------------------
-
-NetCDF and HDF versions from .
-However access to all the options available with the XIOS IO-server will require
-the parallel IO support of these libraries which can be unavailable.
-
-| **To satisfy these requirements, it is common to have to compile from source
-  in this order HDF (C library) then NetCDF (C and Fortran libraries)**
-| It is also necessary to compile these libraries with the same version of the MPI implementation that
-  both NEMO and XIOS (see below) are compiled and linked with.
-
-.. hint::
-
-   | It is difficult to define the options for the compilation as
-     they differ from one architecture to another according to
-     the hardware used and the software installed.
-   | The following is provided without any warranty
-
-   .. code-block:: console
-
-      $ ./configure [--{enable-fortran,disable-shared,enable-parallel}] ...
-
-   It is recommended to build the tests ``--enable-parallel-tests`` and run them with ``make check``
-
-Particular versions of these libraries may have their own restrictions.
-State the following requirements for netCDF-4 support:
-
-.. caution::
-
-   | When building NetCDF-C library versions older than 4.4.1, use only HDF5 1.8.x versions.
-   | Combining older NetCDF-C versions with newer HDF5 1.10 versions will create superblock 3 files
-     that are not readable by lots of older software.
-   
-Extract and install XIOS
-========================
-
-With the sole exception of running NEMO in mono-processor mode
-(in which case output options are limited to those supported by the ``IOIPSL`` library),
-diagnostic outputs from NEMO are handled by the third party ``XIOS`` library.
-This can be used in two different modes:
-
-- *attached* - Every NEMO process also acts as a XIOS server
-- *detached* - Every NEMO process runs as a XIOS client.
-  Output is collected and collated by external, stand-alone XIOS server processors.
-
-.. important::
-
-   In either case, XIOS needs to be compiled before NEMO,
-   since the libraries are needed to successfully create the NEMO executable.
-
-Instructions on how to obtain and install the software can be found on the :xios:`XIOS wiki<wiki>`.
-
-.. hint::
-
-   It is recommended to use XIOS version 2.5.
-   This version should be more stable (in terms of future code changes) than the XIOS trunk.
-   It is also the version used by the NEMO system team when testing all developments and new releases.
-   
-   This particular version has its own branch and can be checked out and downloaded with:
-
-   .. code:: console
-
-      $ svn co https://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5
-
-Download the NEMO source code
-=============================
-
-.. code:: console
-
-   $ svn co https://forge.ipsl.jussieu.fr/nemo/svn/NEMO/trunk
-
-Description of directory tree
------------------------------
-
-+-----------+------------------------------------------------------------+
-| Folder    | Purpose                                                    |
-+===========+============================================================+
-| ``arch``  | Settings (per architecture-compiler pair)                  |
-+-----------+------------------------------------------------------------+
-| ``cfgs``  | :doc:`Reference configurations <configurations>`           |
-+-----------+------------------------------------------------------------+
-| ``doc``   | - ``latex``    : LaTex source code for ref. manuals        |
-|           | - ``namelists``: k start guide                             |
-|           | - ``rst``      : ReST files for quick start guide          |
-+-----------+------------------------------------------------------------+
-| ``ext``   | Dependencies included (``AGRIF``, ``FCM`` & ``IOIPSL``)    |
-+-----------+------------------------------------------------------------+
-| ``mk``    | Building  routines                                         |
-+-----------+------------------------------------------------------------+
-| ``src``   | Modelling routines                                         |
-|           |                                                            |
-|           | - ``ICE``: |SI3| for sea ice                               |
-|           | - ``NST``: AGRIF for embedded zooms                        |
-|           | - ``OCE``: |OPA| for ocean dynamics                        |
-|           | - ``TOP``: |TOP| for tracers                               |
-+-----------+------------------------------------------------------------+
-| ``tests`` | :doc:`Test cases <test_cases>` (unsupported)               |
-+-----------+------------------------------------------------------------+
-| ``tools`` | :doc:`Utilities <tools>` to [pre|post]process data         |
-+-----------+------------------------------------------------------------+
-
-Setup your architecture configuration file
-==========================================
-
-All compiler options in NEMO are controlled using files in
-``./arch/arch-'my_arch'.fcm`` where 'my_arch' is the name of the computing
-architecture.  It is recommended to copy and rename an configuration file from
-an architecture similar to your owns. You will need to set appropriate values
-for all of the variables in the file. In particular the FCM variables:
-``%NCDF_HOME``; ``%HDF5_HOME`` and ``%XIOS_HOME`` should be set to the
-installation directories used for XIOS installation.
-
-.. code-block:: sh
-
-        %NCDF_HOME           /opt/local
-        %HDF5_HOME           /opt/local
-        %XIOS_HOME           /Users/$( whoami )/xios-2.5
-        %OASIS_HOME          /not/defined
-
-Compile and create NEMO executable
-==================================
-
-The main script to compile and create executable is called makenemo and located in the CONFIG directory, it is used to identify the routines you need from the source code, to build the makefile and run it.
-As an example, compile GYRE with 'my_arch' to create a 'MY_GYRE' configuration:
-
-.. code-block:: sh
-
-	./makenemo –m 'my_arch' –r GYRE -n 'MY_GYRE'
-
-The image below shows the structure and some content of "MY_CONFIG" directory from the launching of the configuration creation (directories and fundamental files created by makenemo).
-
-+------------+----------------------------------------------------+
-| Folder     | Purpose                                            |
-+============+====================================================+
-| ``BLD``    |                                                    |
-+------------+----------------------------------------------------+
-| ``EXP00``  |                                                    |
-+------------+----------------------------------------------------+
-| ``EXPREF`` |                                                    |
-+------------+----------------------------------------------------+
-| ``MY_SRC`` |                                                    |
-+------------+----------------------------------------------------+
-| ``WORK``   |                                                    |
-+------------+----------------------------------------------------+
-
-Folder with the symbolic links to all unpreprocessed routines considered in the configuration
-Compilation folder (executables, headers files, libraries, preprocessed routines, flags, …)
-Computation folder for running the model (namelists, xml, executables and inputs-outputs)
-Folder intended to contain your customised routines (modified from initial ones or new entire routines)
-
-After successful execution of makenemo command, the executable called opa is created in the EXP00 directory (in the example above, the executable is created in CONFIG/MY_GYRE/EXP00).
-
-More makenemo options
----------------------
-
-``makenemo`` has several other options that can control which source files are selected and
-the operation of the build process itself.
-These are::
-
-   Optional:
-      -d  Set of new sub-components (space separated list from ./src directory)
-      -e  Path for alternative patch  location (default: 'MY_SRC' in configuration folder)
-      -h  Print this help
-      -j  Number of processes to compile (0: no build)
-      -n  Name for new configuration
-      -s  Path for alternative source location (default: 'src' root directory)
-      -t  Path for alternative build  location (default: 'BLD' in configuration folder)
-      -v  Level of verbosity ([0-3])
-
-These options can be useful for maintaining several code versions with only minor differences but
-they should be used sparingly.
-Note however the ``-j`` option which should be used more routinely to speed up the build process.
-For example:
-
-.. code-block:: sh
-
-        ./makenemo –m 'my_arch' –r GYRE -n 'MY_GYRE' -j 8
-
-which will compile up to 8 modules simultaneously.
-
-
-Default behaviour
------------------
-
-At the first use, you need the -m option to specify the architecture
-configuration file (compiler and its options, routines and libraries to
-include), then for next compilation, it is assumed you will be using the
-same compiler.  If the –n option is not specified the last compiled configuration
-will be used.
-
-Tools used during the process
------------------------------
-
-*   functions.sh : bash functions used by makenemo, for instance to create the WORK directory
-*   cfg.txt : text list of configurations and source directories
-*   bld.cfg : FCM rules to compile 
-
-Examples
---------
-
-.. code-block:: sh
-
-        echo "Example to install a new configuration MY_CONFIG";
-        echo "with OPA_SRC and LIM_SRC_2 ";
-        echo "makenemo -n MY_CONFIG -d \"OPA_SRC LIM_SRC_2\"";
-        echo "";
-        echo "Available configurations :"; cat ${CONFIG_DIR}/cfg.txt;
-        echo "";
-        echo "Available unsupported (external) configurations :"; cat ${CONFIG_DIR}/uspcfg.txt;
-        echo "";
-        echo "Example to remove bad configuration ";
-        echo "./makenemo -n MY_CONFIG clean_config";
-        echo "";
-        echo "Example to clean ";
-        echo "./makenemo clean";
-        echo "";
-        echo "Example to list the available keys of a CONFIG ";
-        echo "./makenemo list_key";
-        echo "";
-        echo "Example to add and remove keys";
-        echo "./makenemo add_key \"key_iomput key_mpp_mpi\" del_key \"key_agrif\" ";
-        echo "";
-        echo "Example to add and remove keys for a new configuration, and do not compile";
-        echo "./makenemo -n MY_CONFIG -j0 add_key \"key_iomput key_mpp_mpi\" del_key \"key_agrif\" ";
-
-Running the model
-=================
-
-Once makenemo has run successfully, the opa executable is available in ``CONFIG/MY_CONFIG/EXP00``
-For the reference configurations, the EXP00 folder also contains the initial input files (namelists, \*xml files for the IOs…). If the configuration also needs NetCDF input files, this should be downloaded here from the corresponding tar file, see Users/Reference Configurations
-
-.. code-block:: sh
-
-        cd 'MY_CONFIG'/EXP00
-        mpirun -n $NPROCS ./opa    # $NPROCS is the number of processes ; mpirun is your MPI wrapper
-
-
-Viewing and changing list of active CPP keys
-============================================
-
-For a given configuration (here called MY_CONFIG), the list of active CPP keys can be found in:
-
-.. code-block:: sh
-
-        ./cfgs/'MYCONFIG'/cpp_'MY_CONFIG'.fcm
-
-
-This text file can be edited to change the list of active CPP keys. Once changed, one needs to recompile opa executable using makenemo command in order for this change to be taken in account.
-Note that most NEMO configurations will need to specify the following CPP keys:
-``key_iomput`` and ``key_mpp_mpi``
-
-.. Links and substitutions
 
 .. |OpenMPI| replace:: *OpenMPI*
@@ -300,5 +50,221 @@
 .. _MPICH:   https://www.mpich.org
 .. |NetCDF|  replace:: *Network Common Data Form (NetCDF)*
-.. _NetCDF:  https://www.unidata.ucar.edu/downloads/netcdf
+.. _NetCDF:  https://www.unidata.ucar.edu
 .. |HDF|     replace:: *Hierarchical Data Form (HDF)*
-.. _HDF:     https://www.hdfgroup.org/downloads
+.. _HDF:     https://www.hdfgroup.org
+
+Specifics for NetCDF and HDF
+----------------------------
+
+NetCDF and HDF versions from official repositories may have not been compiled with MPI support.
+However access to all the options available with the XIOS IO-server will require
+the parallelism of these libraries.
+
+| **To satisfy these requirements, it is common to have to compile from source
+  in this order HDF (C library) then NetCDF (C and Fortran libraries)**
+| It is also necessary to compile these libraries with the same version of the MPI implementation that
+  both NEMO and XIOS (see below) have been compiled and linked with.
+
+.. hint::
+
+   | It is difficult to define the options for the compilation as
+     they differ from one architecture to another according to
+     the hardware used and the software installed.
+   | The following is provided without any warranty
+
+   .. code-block:: console
+
+      $ ./configure [--{enable-fortran,disable-shared,enable-parallel}] ...
+
+   It is recommended to build the tests ``--enable-parallel-tests`` and run them with ``make check``
+
+Particular versions of these libraries may have their own restrictions.
+State the following requirements for netCDF-4 support:
+
+.. caution::
+
+   | When building NetCDF-C library versions older than 4.4.1, use only HDF5 1.8.x versions.
+   | Combining older NetCDF-C versions with newer HDF5 1.10 versions will create superblock 3 files
+     that are not readable by lots of older software.
+
+Extract and install XIOS
+========================
+
+With the sole exception of running NEMO in mono-processor mode
+(in which case output options are limited to those supported by the ``IOIPSL`` library),
+diagnostic outputs from NEMO are handled by the third party ``XIOS`` library.
+It can be used in two different modes:
+
+:*attached*:  Every NEMO process also acts as a XIOS server
+:*detached*:  Every NEMO process runs as a XIOS client.
+  Output is collected and collated by external, stand-alone XIOS server processors.
+
+Instructions on how to install XIOS can be found on its :xios:`wiki<>`.
+
+.. hint::
+
+   It is recommended to use XIOS 2.5 release.
+   This version should be more stable (in terms of future code changes) than the XIOS trunk.
+   It is also the one used by the NEMO system team when testing all developments and new releases.
+
+   This particular version has its own branch and can be checked out with:
+
+   .. code:: console
+
+      $ svn co https://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5
+
+Download and install the NEMO code
+==================================
+
+Checkout the NEMO sources
+-------------------------
+
+.. code:: console
+
+   $ svn co https://forge.ipsl.jussieu.fr/nemo/svn/NEMO/trunk
+
+Description of 1\ :sup:`st` level tree structure
+------------------------------------------------
+
++---------------+----------------------------------------+
+| :file:`arch`  | Compilation settings                   |
++---------------+----------------------------------------+
+| :file:`cfgs`  | :doc:`Reference configurations <cfgs>` |
++---------------+----------------------------------------+
+| :file:`doc`   | :doc:`Documentation <doc>`             |
++---------------+----------------------------------------+
+| :file:`ext`   | Dependencies included                  |
+|               | (``AGRIF``, ``FCM`` & ``IOIPSL``)      |
++---------------+----------------------------------------+
+| :file:`mk`    | Compilation scripts                    |
++---------------+----------------------------------------+
+| :file:`src`   | :doc:`Modelling routines <src>`        |
++---------------+----------------------------------------+
+| :file:`tests` | :doc:`Test cases <tests>`              |
+|               | (unsupported)                          |
++---------------+----------------------------------------+
+| :file:`tools` | :doc:`Utilities <tools>`               |
+|               | to {pre,post}process data              |
++---------------+----------------------------------------+
+
+Setup your architecture configuration file
+------------------------------------------
+
+All compiler options in NEMO are controlled using files in :file:`./arch/arch-'my_arch'.fcm` where
+``my_arch`` is the name of the computing architecture
+(generally following the pattern ``HPCC-compiler`` or ``OS-compiler``).
+It is recommended to copy and rename an configuration file from an architecture similar to your owns.
+You will need to set appropriate values for all of the variables in the file.
+In particular the FCM variables:
+``%NCDF_HOME``; ``%HDF5_HOME`` and ``%XIOS_HOME`` should be set to
+the installation directories used for XIOS installation
+
+.. code-block:: sh
+
+   %NCDF_HOME    /usr/local/path/to/netcdf
+   %HDF5_HOME    /usr/local/path/to/hdf5
+   %XIOS_HOME    /home/$( whoami )/path/to/xios-2.5
+   %OASIS_HOME   /home/$( whoami )/path/to/oasis
+
+Create and compile a new configuration
+======================================
+
+The main script to {re}compile and create executable is called :file:`makenemo` located at
+the root of the working copy.
+It is used to identify the routines you need from the source code, to build the makefile and run it.
+As an example, compile a :file:`MY_GYRE` configuration from GYRE with 'my_arch':
+
+.. code-block:: sh
+
+   ./makenemo –m 'my_arch' –r GYRE -n 'MY_GYRE'
+
+Then at the end of the configuration compilation,
+:file:`MY_GYRE` directory will have the following structure.
+
++------------+----------------------------------------------------------------------------+
+| Directory  | Purpose                                                                    |
++============+============================================================================+
+| ``BLD``    | BuiLD folder: target executable, headers, libs, preprocessed routines, ... |
++------------+----------------------------------------------------------------------------+
+| ``EXP00``  | Run   folder: link to executable, namelists, ``*.xml`` and IOs             |
++------------+----------------------------------------------------------------------------+
+| ``EXPREF`` | Files under version control only for :doc:`official configurations <cfgs>` |
++------------+----------------------------------------------------------------------------+
+| ``MY_SRC`` | New routines or modified copies of NEMO sources                            |
++------------+----------------------------------------------------------------------------+
+| ``WORK``   | Links to all raw routines from :file:`./src` considered                    |
++------------+----------------------------------------------------------------------------+
+
+After successful execution of :file:`makenemo` command,
+the executable called `nemo` is available in the :file:`EXP00` directory
+
+More :file:`makenemo` options
+-----------------------------
+
+``makenemo`` has several other options that can control which source files are selected and
+the operation of the build process itself.
+
+.. literalinclude:: ../../../makenemo
+   :language: text
+   :lines: 119-143
+   :caption: Output of ``makenemo -h``
+
+These options can be useful for maintaining several code versions with only minor differences but
+they should be used sparingly.
+Note however the ``-j`` option which should be used more routinely to speed up the build process.
+For example:
+
+.. code-block:: sh
+
+        ./makenemo –m 'my_arch' –r GYRE -n 'MY_GYRE' -j 8
+
+will compile up to 8 processes simultaneously.
+
+Default behaviour
+-----------------
+
+At the first use,
+you need the ``-m`` option to specify the architecture configuration file
+(compiler and its options, routines and libraries to include),
+then for next compilation, it is assumed you will be using the same compiler.
+If the ``-n`` option is not specified the last compiled configuration will be used.
+
+Tools used during the process
+-----------------------------
+
+* :file:`functions.sh`: bash functions used by ``makenemo``, for instance to create the WORK directory
+* :file:`cfg.txt`     : text list of configurations and source directories
+* :file:`bld.cfg`     : FCM rules for compilation
+
+Examples
+--------
+
+.. literalinclude:: ../../../makenemo
+   :language: text
+   :lines: 146-153
+
+Running the model
+=================
+
+Once :file:`makenemo` has run successfully,
+the ``nemo`` executable is available in :file:`./cfgs/MY_CONFIG/EXP00`.
+For the reference configurations, the :file:`EXP00` folder also contains the initial input files
+(namelists, ``*.xml`` files for the IOs, ...).
+If the configuration needs other input files, they have to be placed here.
+
+.. code-block:: sh
+
+   cd 'MY_CONFIG'/EXP00
+   mpirun -n $NPROCS ./nemo   # $NPROCS is the number of processes
+                              # mpirun is your MPI wrapper
+
+Viewing and changing list of active CPP keys
+============================================
+
+For a given configuration (here called ``MY_CONFIG``),
+the list of active CPP keys can be found in :file:`./cfgs/'MYCONFIG'/cpp_MY_CONFIG.fcm`
+
+This text file can be edited by hand or with :file:`makenemo` to change the list of active CPP keys.
+Once changed, one needs to recompile ``nemo`` in order for this change to be taken in account.
+Note that most NEMO configurations will need to specify the following CPP keys:
+``key_iomput`` for IOs and ``key_mpp_mpi`` for parallelism.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/README.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/README.rst	(revision 12143)
@@ -1,7 +1,7 @@
-:Release:  |release|
-:Date:     |today|
-:SVN rev.: |revision|
+.. todo::
 
-NEMO_ for **Nucleus for European Modelling of the Ocean** is a state-of-the-art modelling framework for
+
+
+NEMO_ for *Nucleus for European Modelling of the Ocean* is a state-of-the-art modelling framework for
 research activities and forecasting services in ocean and climate sciences,
 developed in a sustainable way by a European consortium since 2008.
@@ -15,13 +15,14 @@
 The NEMO ocean model has 3 major components:
 
-- |OPA| models the ocean {thermo}dynamics and solves the primitive equations
-  (``./src/OCE``)
-- |SI3| simulates seaice {thermo}dynamics, brine inclusions and subgrid-scale thickness variations
-  (``./src/ICE``)
-- |TOP| models the {on,off}line oceanic tracers transport and biogeochemical processes
-  (``./src/TOP``)
+- |OCE| models the ocean {thermo}dynamics and solves the primitive equations
+  (:file:`./src/OCE`)
+- |ICE| simulates sea-ice {thermo}dynamics, brine inclusions and
+  subgrid-scale thickness variations (:file:`./src/ICE`)
+- |MBG| models the {on,off}line oceanic tracers transport and biogeochemical processes
+  (:file:`./src/TOP`)
 
-These physical core engines are described in their respective `references`_ that
-must be cited for any work related to their use.
+These physical core engines are described in
+their respective `reference publications <#project-documentation>`_ that
+must be cited for any work related to their use (see :doc:`cite`).
 
 Assets and solutions
@@ -33,16 +34,16 @@
 - Create :doc:`embedded zooms<zooms>` seamlessly thanks to 2-way nesting package AGRIF_.
 - Opportunity to integrate an :doc:`external biogeochemistry model<tracers>`
-- Versatile :doc:`data assimilation<data_assimilation>`
-- Generation of :doc:`diagnostics<diagnostics>` through effective XIOS_ system
-- Roll-out Earth system modeling with :doc:`coupling interface<coupling>` based on OASIS_
+- Versatile :doc:`data assimilation<da>`
+- Generation of :doc:`diagnostics<diags>` through effective XIOS_ system
+- Roll-out Earth system modeling with :doc:`coupling interface<cplg>` based on OASIS_
 
-Several :doc:`built-in configurations<configurations>` are provided to
+Several :doc:`built-in configurations<cfgs>` are provided to
 evaluate the skills and performances of the model which
-can be used as templates for setting up a new configurations (``./cfgs``).
+can be used as templates for setting up a new configurations (:file:`./cfgs`).
 
-The user can also checkout available :doc:`idealized test cases<test_cases>` that
-address specific physical processes(``./tests``).
+The user can also checkout available :doc:`idealized test cases<tests>` that
+address specific physical processes (:file:`./tests`).
 
-A set of :doc:`utilities <tools>` is also provided to {pre,post}process your data (``./tools``).
+A set of :doc:`utilities <tools>` is also provided to {pre,post}process your data (:file:`./tools`).
 
 Project documentation
@@ -50,23 +51,20 @@
 
 A walkthrough tutorial illustrates how to get code dependencies, compile and execute NEMO
-(``./INSTALL.rst``) . 
+(:file:`./INSTALL.rst`).
 
 Reference manuals and quick start guide can be build from source and
-exported to HTML or PDF formats (``./doc``) or
-downloaded directly from the :website:`website<bibliography/documentation>`.
+exported to HTML or PDF formats (:file:`./doc`) or
+downloaded directly from the :forge:`development platform<wiki/Documentations>`.
 
-=========== ===================== ===============
- Component   Reference Manual      Quick start
-=========== ===================== ===============
- |OPA|       |NEMO manual|_        |NEMO guide|
-             :cite:`NEMO_manual`
- |SI3|       |SI3 manual|
-             :cite:`SI3_manual`
- |TOP|       |TOP manual|
-             :cite:`TOP_manual`
-=========== ===================== ===============
+============ ================== ===================
+ Component    Reference Manual   Quick Start Guide
+============ ================== ===================
+ |NEMO-OCE|   |DOI man OCE|_     |DOI qsg|
+ |NEMO-ICE|   |DOI man ICE|
+ |NEMO-MBG|   |DOI man MBG|
+============ ================== ===================
 
 Since 2014 the project has a `Special Issue`_ in the open-access journal
-Geoscientific Model Development (GMD) from the European Geosciences Union (EGU).
+Geoscientific Model Development (GMD) from the European Geosciences Union (EGU_).
 The main scope is to collect relevant manuscripts covering various topics and
 to provide a single portal to assess the model potential and evolution.
@@ -79,22 +77,23 @@
 =================
 
-The NEMO Consortium pulling together 5 European institutes (CMCC_, CNRS_, MOI_, `Met Office`_ and NERC_)
-plans the sustainable development in order to keep a reliable evolving framework since 2008.
+The NEMO Consortium pulling together 5 European institutes
+(CMCC_, CNRS_, MOI_, `Met Office`_ and NERC_) plans the sustainable development in order to
+keep a reliable evolving framework since 2008.
 
-It defines the |NEMO strategy|_ that is implemented by the System Team on a yearly basis in order to
-release a new version almost every four years.
+It defines the |DOI dev stgy|_ that is implemented by the System Team on a yearly basis
+in order to release a new version almost every four years.
 
 When the need arises, :forge:`working groups<wiki/WorkingGroups>` are created or resumed to
 gather the community expertise for advising on the development activities.
 
+.. |DOI dev stgy| replace:: multi-year development strategy
 
-.. Substitutions / Links
+Disclaimer
+==========
 
-.. |NEMO manual| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1464816.svg
-.. |NEMO guide|  image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1475325.svg
-.. |SI3 manual|  image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1471689.svg
-.. |TOP manual|  image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1471700.svg
+The NEMO source code is freely available and distributed under
+:download:`CeCILL v2.0 license <../../../LICENSE>` (GNU GPL compatible).
 
-.. |NEMO strategy| replace:: multi-year development strategy
-
-.. _Special Issue: https://www.geosci-model-dev.net/special_issue40.html
+You can use, modify and/or redistribute the software under its terms,
+but users are provided only with a limited warranty and the software's authors and
+the successive licensor's have only limited liability.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/REFERENCES.bib
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/REFERENCES.bib	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/REFERENCES.bib	(revision 12143)
@@ -1,59 +1,46 @@
-@manual{NEMO_manual,
-   title={NEMO ocean engine},
-   author={Madec Gurvan and NEMO System Team},
-   organization={NEMO Consortium},
-   journal={Notes du Pôle de modélisation de l\'Institut Pierre-Simon Laplace (IPSL)},
-   number={27},
-   publisher={Zenodo},
-   abstract={The ocean engine of NEMO is a primitive equation model adapted to regional and
-   global ocean circulation problems.
-   It is intended to be a flexible tool for studying the ocean and its interactions with
-   the others components of the earth climate system over a wide range of space and time scales.},
-   doi={10.5281/zenodo.1464816},
-   edition={},
-   year={}
+@manual{NEMO_man,
+   title="NEMO ocean engine",
+   author="NEMO System Team",
+   series="Scientific Notes of Climate Modelling Center",
+   number="27",
+   institution="Institut Pierre-Simon Laplace (IPSL)",
+   publisher="Zenodo",
+   doi="10.5281/zenodo.1464816",
 }
+%   edition="",
+%   year=""
 
-@manual{SI3_manual,
-   title={SI³ – Sea Ice modelling Integrated Initiative – The NEMO Sea Ice engine},
-   author={NEMO Sea Ice Working Group},
-   organization={NEMO Consortium},
-   journal={Notes du Pôle de modélisation de l\'Institut Pierre-Simon Laplace (IPSL)},
-   number={31},
-   publisher={Zenodo},
-   abstract={SI³ (Sea Ice modelling Integrated Initiative) is the sea ice engine of NEMO
-   (Nucleus for European Modelling of the Ocean).
-   SI³ is based on the Arctic Ice Dynamics Joint EXperiment (AIDJEX) framework,
-   combining the ice thickness distribution framework, the conservation of horizontal momentum,
-   an elastic-viscous plastic rheology, and energy-conserving halo-thermodynamics.
-   SI³ is interfaced with the NEMO ocean engine, and, via the OASIS coupler, with
-   several atmospheric general circulation models.
-   It also supports two-way grid embedding via the AGRIF software.},
-   doi={10.5281/zenodo.1471689},
-   edition={},
-   year={}
+@manual{SI3_man,
+   title="Sea Ice modelling Integrated Initiative (SI$^3$) -- The NEMO Sea Ice engine",
+   author="NEMO Sea Ice Working Group",
+   series="Scientific Notes of Climate Modelling Center",
+   number="31",
+   institution="Institut Pierre-Simon Laplace (IPSL)",
+   publisher="Zenodo",
+   doi="10.5281/zenodo.1471689",
 }
+%   edition="",
+%   year=""
 
-@manual{TOP_manual,
-   title={TOP – Tracers in Ocean Paradigm – The NEMO Tracers engine},
-   author={NEMO TOP Working Group},
-   organization={NEMO Consortium},
-   journal={Notes du Pôle de modélisation de l\'Institut Pierre-Simon Laplace (IPSL)},
-   number={28},
-   publisher={Zenodo},
-   abstract={},
-   doi={10.5281/zenodo.1471700},
-   edition={},
-   year={}
+@manual{TOP_man,
+   title="Tracers in Ocean Paradigm (TOP) -- The NEMO Tracers engine",
+   author="NEMO TOP Working Group",
+   series="Scientific Notes of Climate Modelling Center",
+   number="28",
+   institution="Institut Pierre-Simon Laplace (IPSL)",
+   publisher="Zenodo",
+   doi="10.5281/zenodo.1471700",
 }
+%   edition="",
+%   year=""
 
-@Article{gmd-8-1245-2015,
-   author = {Vidard, A. and Bouttier, P.-A. and Vigilant, F.},
-   title = {{NEMOTAM}: {T}angent and {A}djoint {M}odels for the ocean modelling platform {NEMO}},
-   journal = {Geoscientific Model Development},
-   volume = {8},
-   year = {2015},
-   number = {4},
-   pages = {1245--1257},
-   doi = {10.5194/gmd-8-1245-2015}
+@article{TAM_pub,
+   author = "Vidard, A. and Bouttier, P.-A. and Vigilant, F.",
+   title = "NEMOTAM: Tangent and Adjoint Models for the ocean modelling platform NEMO",
+   journal = "Geoscientific Model Development",
+   volume = "8",
+   year = "2015",
+   number = "4",
+   pages = "1245--1257",
+   doi = "10.5194/gmd-8-1245-2015"
 }
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/RELEASE_NOTES.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/RELEASE_NOTES.rst	(revision 12062)
+++ 	(revision )
@@ -1,129 +1,0 @@
-*************
-Release Notes
-*************
-
-New sea-ice component SI3 (in place of LIMx)
-============================================
-
-- Physics
-
-  - Lateral melting
-  - Melt ponds: constant or :doi:`Holland et al. 2012<10.1175/JCLI-D-11-00078.1>` formulation (and soon topographic melt ponds)
-  - Ice-atm. drags from :doi:`Lupkes et al. 2012<10.1029/2012JD017630>` (depending on ice concentration) or :doi:`Lupkes et al. 2015<10.1002/2014JD022418>` (depending on sea ice concentration and atm. stability)
-  - Landfast ice (:doi:`Lemieux et al. 2016<10.1002/2016JC012006>`)
-
-- Numerics
-
-  - Advection: Ultimate-Macho scheme
-  - Rheology: adaptive EVP (:doi:`Kimmritz et al. 2017<10.1016/j.ocemod.2016.03.004>`)
-  - Coupling interface: conductivity as surface forcing instead of heat fluxes (Met Office requirement)
-
-- Performance: all thermodynamics in 1D and reduced mpp communications
-- Usability (users & developers friendly)
-
-  - Comprehensive set of outputs (universal units and understandable names + includes CMIP)
-  - New architecture and namelist
-  - All processes can be decoupled from each other (switch on/off)
-  - Ice categories bounds can be defined by the user or set automatically
-  - For open boundaries, the number of ice categories from the forcing model can be different from the number of categories in the regional simulation
-  - Fully compatible with AGRIF_
-  - Revised documentation 
-
-AGRIF for embedded zooms
-========================
-
-- Now compatible with new sea ice component
-- Now compatible with z* coordinate
-- Extended ghost cells area to properly handle scheme with spatial order >2
-- Added vertical refinement (beta)
-- Nesting tools for setup now up to date and working 
-
-Enhancements
-============
-
-- Fix for tracer conservation with split explicit free surface
-- Bulk formulae : move to aerobulk package (:doi:`Brodeau et al. 2016<10.1175/JPO-D-16-0169.1>`), i.e. NCAR, COARE and ECMWF bulk (remove Clio and MFS bulk)
-- Wetting and drying
-- Added tidal self attraction and loading either read from a file or from usual "scalar" approximation
-- Add a 4th order centered (CEN) and Flux Corrected Transport (FCT) tracer advection
-  (using a 4th compact in the vertical)
-- iso-neutral mixing (iso and triad operators):
-  add the Method of Stabilizing Correction (MSC) (more accurate calculation) + add a bilaplacian case
-- Lateral physics (``LDF``): scale aware setting of eddy viscosity and diffusivity
-- Vorticity: 2 new energy conserving scheme: ENT with Coriolis defined at T-point (better for Flux form) and EET a variant of EEN where e3t is used instead of e3f (solved the issue with e3f specification but is not enstrophy conserving) 
-
-Test Cases
-==========
-
-The first test cases available for now are:
-
-- ``CANAL``: east-west periodic canal of variable size with several initial states and associated geostrophic currents (zonal jets or vortex)
-- ``ICE_AGRIF``: east-west + north-south periodic channel. The common configuration includes an AGRIF zoom (1:3) in the middle of the basin to test how an ice patch is advected through it but one can also test the advection schemes (Prather and Ultimate-Macho) by removing the ``key_agrif`` in the cpp keys
-- ``ISOMIP``: simple box configuration with an ice shelf with simple geometry on top. The purpose of this test case is to evaluate the impact of various schemes and new development with iceshelf cavities. The exact original setup is described ​here
-- ``LOCK-EXCHANGE``: classical fluid dynamics experiment that has been adapted by Haidvogel and Beckmann (1999) for testing advection schemes in ocean circulation models. It has been used by several authors including Burchard and Bolding (2002) and :doi:`Ilıcak et al. (2012)<10.1016/j.ocemod.2011.10.003>`. The ``LOCK EXCHANGE`` experiment can in particular illustrate the impact of different choices of numerical schemes and/or subgrid closures on spurious interior mixing
-- ``OVERFLOW``: illustrates the impact of different choices of numerical schemes and/or subgrid closures on spurious interior mixing close to bottom topography. It is adapted from the non-rotating overflow configuration described in Haidvogel and Beckmann (1999) and further used by :doi:`Ilıcak et al. (2012)<10.1016/j.ocemod.2011.10.003>`
-- ``VORTEX``: illustrates the propagation of an anticyclonic eddy over a Beta plan and flat bottom. It is implemented here with an online refined subdomain (thanks to ``AGRIF`` library) out of which the vortex propagates. It serves as a benchmark to diagnose nesting errors as in :doi:`Debreu et al. (2012)<10.1016/j.ocemod.2012.03.003>`, :doi:`Penven et al. (2006)<10.1016/j.ocemod.2005.05.002>` and :doi:`Spall and Holland (1991)<10.1175/1520-0485(1991)021<0205:ANPEMF>2.0.CO;2>`
-- ``WAD``: a set of simple closed basin geometries for testing the wetting and drying capabilities. Examples range from a closed channel with EW linear bottom slope to a parabolic EW channel with a Gaussian ridge
-
-New Reference configurations
-============================
-
-``AGRIF_DEMO``: 2 interlocked zooms (1:4 & 1:3) in the Nordic Seas + 1 zoom (1:1) at the equator
-
-``SPITZ12``: regional configuration around the Svalbard archipelago 
-
-Wave coupling
-=============
-
-Coupled interface to external wave model
-
-Large scale wave interaction process added in momentum and tracer equations 
-
-Passive tracer TOP and biogeochemical PISCES components
-=======================================================
-
-- The passive tracers transport component was redesigned toward a modular structure and users can enable each module directly through logical flags in namelist_top (no more fortran macros!)
-- :doc:`TOP on-line user documentation<tracers>`
-- TOP currently accounts for the following 5 modules: ``CFC`` contains inorganic carbon tracers (CFC11/CFC12/SF6), ``MY_TRC`` is a template for new modules (or external couplings), ``AGE`` deals with water age tracking, ``C14`` as a radiocarbon passive tracer, and the companion ecosystem model ``PISCES``
-- A generalized infrastructure was developed to handle the prescription of either surface, coastal, or open boundaries conditions for each passive tracer
-- A new configuration, named ``ORCA2_OFF_TRC``, was created to provide a benchmark simulation environment to deal with inert carbon tracers dynamics by exploiting the offline coupling with NEMO
-- PISCES model contains new developments and modifications:
-
-  - Particulate Organic Carbon (POC) component comes with a new liability scheme, while the former Kriest parametrisation was superseded
-  - A complex iron chemistry scheme is now available, with an improved description of ligands for the marine iron cycle
-  - Carbonate chemistry is based on MOCSY 2.0 routines (see :doi:`10.5194/gmd-8-485-2015 <Orr and Epitalon, 2015>`), by complying also with CMIP6 standards
-  - Ecosystem components can be optionally modelled by means of explicit nutrient quotas (PISCES-QUOTA) 
-
-High Performance Computing (HPC): performances improvements
-===========================================================
-
-- Reduce number of MPI communications
-  (suppression of redundant communications, gather multiple communications into one)
-- Use of MPI-3 asynchronous routines for performance (use ``key_mpi2`` if MPI-3 not available)
-- Back to standard dynamical allocation (remove of wrk_alloc/dealloc statements)
-- :xios:`XIOS software<>` for IOs version 2.5 as default, and optionally available for restarts 
-
-Simplification and robustness
-=============================
-
-- Revised structure of ``namelist_ref`` / ``namelist_cfg`` and default reference values
-- Lateral physics (``LDF``): simplification of user interface and removal of CPP keys
-- Vertical physics (``ZDF``) (modularity, share shear production calculation between TKE and GKS, removal of all ZDF CPP keys, removal of ``avmu`` & ``avmv``, minimization of MPP comm.: ~15 removed)
-- Remove the split-explicit ZDF scheme for both ``TRA`` and ``DYN``
-- Remove the acceleration of convergence
-- Generalised ``lbc_lnk`` and ``lbc_nfd``
-- Unify mppini
-- Use non uniform jpi/jpj with dynamic allocation to avoid ghost rows/columns
-- MPI Message passing re coded
-- Configuration interface completely rewritten (``DOM`` module mainly suppressed , and in place: ``domain_cfg.nc`` file, or ``usr_def`` module) 
-
-Collaborative Development Environment
-=====================================
-
-- Access to information on wiki reorganised through portals for users/developers/System Team and complete refactoring of all pages and their layout
-- Reorganisation of SVN repository to be compliant with usual directory tree and facilitate building of the executable
-- Define and install a separate repository for test cases to all easy contributions from the community
-- :forge:`Forums<discussion>` created
-- :website:`Public web site<>` has been revamped and cleaned using Wordpress
-- New mailing lists have been set up
-- Improvements of reliability through automatic and regular testing of the changes made in repository 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg	(revision 12143)
@@ -52,6 +52,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem = 'data_1m_potential_temperature_nomask',     -1      ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
-   sn_sal = 'data_1m_salinity_nomask'             ,     -1      ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_tem = 'data_1m_potential_temperature_nomask',     -1.     ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal = 'data_1m_salinity_nomask'             ,     -1.     ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
 /
 !!======================================================================
@@ -99,14 +99,14 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !          weights filename            ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6         , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
-   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6         , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
-   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_tair     = 't_10.15JUNE2009_fill'       ,    6         , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6         , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1         , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1         , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_slp      = 'slp.15JUNE2009_fill'        ,    6         , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_tdif     = 'taudif_core'                ,   24         , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6.        , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6.        , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,    6.        , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6.        , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_slp      = 'slp.15JUNE2009_fill'        ,    6.        , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tdif     = 'taudif_core'                ,   24.        , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -122,5 +122,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_chl      ='chlorophyll'            ,        -1         , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_chl      ='chlorophyll'            ,        -1.        , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -135,9 +135,9 @@
    !           !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
    !           !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_rnf      = 'runoff_core_monthly',    -1    , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_cnf      = 'runoff_core_monthly',     0    , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-   sn_s_rnf    = 'runoffs'            ,    24    , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_t_rnf    = 'runoffs'            ,    24    , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_dep_rnf  = 'runoffs'            ,     0    , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_rnf      = 'runoff_core_monthly',    -1.   , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_cnf      = 'runoff_core_monthly',     0.   , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_s_rnf    = 'runoffs'            ,    24.   , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_t_rnf    = 'runoffs'            ,    24.   , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_dep_rnf  = 'runoffs'            ,     0.   , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -363,7 +363,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg	(revision 12143)
@@ -50,6 +50,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem = 'data_1m_potential_temperature_nomask',     -1      ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
-   sn_sal = 'data_1m_salinity_nomask'             ,     -1      ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_tem = 'data_1m_potential_temperature_nomask',     -1.   ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal = 'data_1m_salinity_nomask'             ,     -1.   ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
 /
 !!======================================================================
@@ -95,14 +95,14 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !          weights filename            ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6         , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bicub.nc'     , 'Uwnd'   , ''
-   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6         , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bicub.nc'     , 'Vwnd'   , ''
-   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'     , ''       , ''
-   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'     , ''       , ''
-   sn_tair     = 't_10.15JUNE2009_fill'       ,    6         , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'     , ''       , ''
-   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6         , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'     , ''       , ''
-   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1         , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'     , ''       , ''
-   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1         , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'  , ''       , ''
-   sn_slp      = 'slp.15JUNE2009_fill'        ,    6         , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'  , ''       , ''
-   sn_tdif     = 'taudif_core'                ,   24         , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'  , ''       , ''
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6.        , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bicub.nc'     , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6.        , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bicub.nc'     , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'     , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'     , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,    6.        , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'     , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6.        , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'     , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'     , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'  , ''       , ''
+   sn_slp      = 'slp.15JUNE2009_fill'        ,    6.        , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'  , ''       , ''
+   sn_tdif     = 'taudif_core'                ,   24.        , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic1_bilin.nc'  , ''       , ''
 
 /
@@ -119,5 +119,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !          weights filename            ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_chl      ='chlorophyll'            ,        -1         , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''                                   , ''       , ''
+   sn_chl      ='chlorophyll'            ,        -1.        , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''                                   , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -312,7 +312,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg	(revision 12143)
@@ -50,6 +50,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem = 'data_1m_potential_temperature_nomask',     -1      ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
-   sn_sal = 'data_1m_salinity_nomask'             ,     -1      ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_tem = 'data_1m_potential_temperature_nomask',     -1.     ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal = 'data_1m_salinity_nomask'             ,     -1.     ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
 /
 !!======================================================================
@@ -95,14 +95,14 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !          weights filename            ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6         , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bicub.nc'     , 'Uwnd'   , ''
-   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6         , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bicub.nc'     , 'Vwnd'   , ''
-   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
-   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
-   sn_tair     = 't_10.15JUNE2009_fill'       ,    6         , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
-   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6         , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
-   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1         , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
-   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1         , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
-   sn_slp      = 'slp.15JUNE2009_fill'        ,    6         , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
-   sn_tdif     = 'taudif_core'                ,   24         , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6.        , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bicub.nc'     , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6.        , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bicub.nc'     , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,    6.        , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6.        , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
+   sn_slp      = 'slp.15JUNE2009_fill'        ,    6.        , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
+   sn_tdif     = 'taudif_core'                ,   24.        , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core2_nordic2_bilin.nc'     , ''       , ''
 
 /
@@ -119,5 +119,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !          weights filename            ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_chl      ='chlorophyll'            ,        -1         , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''                                   , ''       , ''
+   sn_chl      ='chlorophyll'            ,        -1.        , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''                                   , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -312,7 +312,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg	(revision 12143)
@@ -52,6 +52,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem = 'data_1m_potential_temperature_nomask',     -1      ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
-   sn_sal = 'data_1m_salinity_nomask'             ,     -1      ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_tem = 'data_1m_potential_temperature_nomask',     -1.     ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal = 'data_1m_salinity_nomask'             ,     -1.     ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
 /
 !!======================================================================
@@ -99,14 +99,14 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !          weights filename            ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6         , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
-   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6         , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
-   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_tair     = 't_10.15JUNE2009_fill'       ,    6         , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6         , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1         , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1         , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_slp      = 'slp.15JUNE2009_fill'        ,    6         , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_tdif     = 'taudif_core'                ,   24         , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6.        , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6.        , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,    6.        , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6.        , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_slp      = 'slp.15JUNE2009_fill'        ,    6.        , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tdif     = 'taudif_core'                ,   24.        , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -122,5 +122,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_chl      ='chlorophyll'            ,        -1         , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_chl      ='chlorophyll'            ,        -1.        , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -135,9 +135,9 @@
    !           !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
    !           !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_rnf      = 'runoff_core_monthly',    -1    , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_cnf      = 'runoff_core_monthly',     0    , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-   sn_s_rnf    = 'runoffs'            ,    24    , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_t_rnf    = 'runoffs'            ,    24    , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_dep_rnf  = 'runoffs'            ,     0    , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_rnf      = 'runoff_core_monthly',    -1.   , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_cnf      = 'runoff_core_monthly',     0.   , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_s_rnf    = 'runoffs'            ,    24.   , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_t_rnf    = 'runoffs'            ,    24.   , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_dep_rnf  = 'runoffs'            ,     0.   , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -363,7 +363,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/namelist_ice_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/namelist_ice_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/EXPREF/namelist_ice_cfg	(revision 12143)
@@ -38,4 +38,5 @@
 &namdyn_rhg     !   Ice rheology
 !------------------------------------------------------------------------------
+      ln_aEVP       = .false.          !     adaptive rheology (Kimmritz et al. 2016 & 2017)
 /
 !------------------------------------------------------------------------------
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/README.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AGRIF_DEMO/README.rst	(revision 12143)
@@ -2,4 +2,8 @@
 Embedded zooms
 **************
+
+.. todo::
+
+
 
 .. contents::
@@ -9,24 +13,26 @@
 ========
 
-AGRIF (Adaptive Grid Refinement In Fortran) is a library that allows the seamless space and time refinement over
-rectangular regions in NEMO.
+AGRIF (Adaptive Grid Refinement In Fortran) is a library that
+allows the seamless space and time refinement over rectangular regions in NEMO.
 Refinement factors can be odd or even (usually lower than 5 to maintain stability).
-Interaction between grid is "two-ways" in the sense that the parent grid feeds the child grid open boundaries and
-the child grid provides volume averages of prognostic variables once a given number of time step is completed.
+Interaction between grid is "two-ways" in the sense that
+the parent grid feeds the child grid open boundaries and
+the child grid provides volume averages of prognostic variables once
+a given number of time step is completed.
 These pages provide guidelines how to use AGRIF in NEMO.
-For a more technical description of the library itself, please refer to http://agrif.imag.fr.
+For a more technical description of the library itself, please refer to AGRIF_.
 
 Compilation
 ===========
 
-Activating AGRIF requires to append the cpp key ``key_agrif`` at compilation time: 
+Activating AGRIF requires to append the cpp key ``key_agrif`` at compilation time:
 
 .. code-block:: sh
 
-	./makenemo add_key 'key_agrif'
+   ./makenemo [...] add_key 'key_agrif'
 
-Although this is transparent to users, the way the code is processed during compilation is different from
-the standard case:
-a preprocessing stage (the so called "conv" program) translates the actual code so that
+Although this is transparent to users,
+the way the code is processed during compilation is different from the standard case:
+a preprocessing stage (the so called ``conv`` program) translates the actual code so that
 saved arrays may be switched in memory space from one domain to an other.
 
@@ -34,25 +40,26 @@
 ================================
 
-An additional text file ``AGRIF_FixedGrids.in`` is required at run time.
+An additional text file :file:`AGRIF_FixedGrids.in` is required at run time.
 This is where the grid hierarchy is defined.
-An example of such a file, here taken from the ``ICEDYN`` test case, is given below::
+An example of such a file, here taken from the ``ICEDYN`` test case, is given below
 
-	1
-	34 63 34 63 3 3 3
-	0
+.. literalinclude:: ../../../tests/ICE_AGRIF/EXPREF/AGRIF_FixedGrids.in
 
 The first line indicates the number of zooms (1).
 The second line contains the starting and ending indices in both directions on the root grid
-(imin=34 imax=63 jmin=34 jmax=63) followed by the space and time refinement factors (3 3 3).
+(``imin=34 imax=63 jmin=34 jmax=63``) followed by the space and time refinement factors (3 3 3).
 The last line is the number of child grid nested in the refined region (0).
 A more complex example with telescoping grids can be found below and
-in the ``AGRIF_DEMO`` reference configuration directory.
+in the :file:`AGRIF_DEMO` reference configuration directory.
 
-[Add some plots here with grid staggering and positioning ?]
+.. todo::
 
-When creating the nested domain, one must keep in mind that the child domain is shifted toward north-east and
-depends on the number of ghost cells as illustrated by the (attempted) drawing below for nbghostcells=1 and
-nbghostcells=3.
-The grid refinement is 3 and nxfin is the number of child grid points in i-direction.  
+   Add some plots here with grid staggering and positioning?
+
+When creating the nested domain, one must keep in mind that
+the child domain is shifted toward north-east and
+depends on the number of ghost cells as illustrated by
+the *attempted* drawing below for ``nbghostcells=1`` and ``nbghostcells=3``.
+The grid refinement is 3 and ``nxfin`` is the number of child grid points in i-direction.
 
 .. image:: _static/agrif_grid_position.jpg
@@ -62,14 +69,15 @@
 boundary data exchange and update being only performed between root and child grids.
 Use of east-west periodic or north-fold boundary conditions is not allowed in child grids either.
-Defining for instance a circumpolar zoom in a global model is therefore not possible. 
+Defining for instance a circumpolar zoom in a global model is therefore not possible.
 
 Preprocessing
 =============
 
-Knowing the refinement factors and area, a ``NESTING`` pre-processing tool may help to create needed input files
+Knowing the refinement factors and area,
+a ``NESTING`` pre-processing tool may help to create needed input files
 (mesh file, restart, climatological and forcing files).
 The key is to ensure volume matching near the child grid interface,
-a step done by invoking the ``Agrif_create_bathy.exe`` program.
-You may use the namelists provided in the ``NESTING`` directory as a guide.
+a step done by invoking the :file:`Agrif_create_bathy.exe` program.
+You may use the namelists provided in the :file:`NESTING` directory as a guide.
 These correspond to the namelists used to create ``AGRIF_DEMO`` inputs.
 
@@ -78,30 +86,21 @@
 
 Each child grid expects to read its own namelist so that different numerical choices can be made
-(these should be stored in the form ``1_namelist_cfg``, ``2_namelist_cfg``, etc... according to their rank in
-the grid hierarchy).
+(these should be stored in the form :file:`1_namelist_cfg`, :file:`2_namelist_cfg`, etc...
+according to their rank in the grid hierarchy).
 Consistent time steps and number of steps with the chosen time refinement have to be provided.
 Specific to AGRIF is the following block:
 
-.. code-block:: fortran
-
-	!-----------------------------------------------------------------------
-	&namagrif      !  AGRIF zoom                                            ("key_agrif")
-	!-----------------------------------------------------------------------
-	   ln_spc_dyn    = .true.  !  use 0 as special value for dynamics
-	   rn_sponge_tra = 2880.   !  coefficient for tracer   sponge layer [m2/s]
-	   rn_sponge_dyn = 2880.   !  coefficient for dynamics sponge layer [m2/s]
-	   ln_chk_bathy  = .false. !  =T  check the parent bathymetry
-	/             
+.. literalinclude:: ../../namelists/namagrif
+   :language: fortran
 
 where sponge layer coefficients have to be chosen according to the child grid mesh size.
 The sponge area is hard coded in NEMO and applies on the following grid points:
-2 x refinement factor (from i=1+nbghostcells+1 to i=1+nbghostcells+sponge_area) 
+2 x refinement factor (from ``i=1+nbghostcells+1`` to ``i=1+nbghostcells+sponge_area``)
 
-References
-==========
+.. rubric:: References
 
 .. bibliography:: zooms.bib
-	:all:
-	:style: unsrt
-	:labelprefix: A
-	:keyprefix: a-
+   :all:
+   :style: unsrt
+   :labelprefix: A
+   :keyprefix: a-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AMM12/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AMM12/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AMM12/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
@@ -18,13 +28,13 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AMM12/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AMM12/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/AMM12/EXPREF/namelist_cfg	(revision 12143)
@@ -77,9 +77,9 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_utau     = 'amm12_utau'            ,          1        , 'utau'    ,  .false.    , .false., 'daily'   ,  ''              ,  ''      , ''
-   sn_vtau     = 'amm12_vtau'            ,          1        , 'vtau'    ,  .false.    , .false., 'daily'   ,  ''              ,  ''      , ''
-   sn_qtot     = 'amm12_flx'             ,          3        , 'sonsfldo',  .true.     , .false., 'daily'   ,  ''              ,  ''      , ''
-   sn_qsr      = 'amm12_flx'             ,          3        , 'soshfldo',  .true.     , .false., 'daily'   ,  ''              ,  ''      , ''
-   sn_emp      = 'amm12_flx'             ,          3        , 'sowafldo',  .true.     , .false., 'daily'   ,  ''              ,  ''      , ''
+   sn_utau     = 'amm12_utau'            ,          1.       , 'utau'    ,  .false.    , .false., 'daily'   ,  ''              ,  ''      , ''
+   sn_vtau     = 'amm12_vtau'            ,          1.       , 'vtau'    ,  .false.    , .false., 'daily'   ,  ''              ,  ''      , ''
+   sn_qtot     = 'amm12_flx'             ,          3.       , 'sonsfldo',  .true.     , .false., 'daily'   ,  ''              ,  ''      , ''
+   sn_qsr      = 'amm12_flx'             ,          3.       , 'soshfldo',  .true.     , .false., 'daily'   ,  ''              ,  ''      , ''
+   sn_emp      = 'amm12_flx'             ,          3.       , 'sowafldo',  .true.     , .false., 'daily'   ,  ''              ,  ''      , ''
 /
 !-----------------------------------------------------------------------
@@ -101,6 +101,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_sst      = 'amm12_sstref'          ,        24         ,  'sst'     ,   .true.   , .false., 'daily'   , ''               , ''       , ''
-   sn_sss      = 'sss_data'              ,        -1         ,  'sss'     ,   .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_sst      = 'amm12_sstref'          ,        24.        ,  'sst'     ,   .true.   , .false., 'daily'   , ''               , ''       , ''
+   sn_sss      = 'sss_data'              ,        -1.        ,  'sss'     ,   .true.   , .true. , 'yearly'  , ''               , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -116,9 +116,9 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_rnf      = 'amm12_rivers'          ,        24         , 'rorunoff',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_cnf      = 'runoff_1m_nomask'      ,         0         , 'socoefr0',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_s_rnf    = 'amm12_rivers'          ,        24         , 'rosaline',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_t_rnf    = 'amm12_rivers'          ,        24         , 'rotemper',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_dep_rnf  = 'amm12_rivers'          ,        24         , 'rodepth' ,   .false.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_rnf      = 'amm12_rivers'          ,        24.        , 'rorunoff',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_cnf      = 'runoff_1m_nomask'      ,         0.        , 'socoefr0',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_s_rnf    = 'amm12_rivers'          ,        24.        , 'rosaline',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_t_rnf    = 'amm12_rivers'          ,        24.        , 'rotemper',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_dep_rnf  = 'amm12_rivers'          ,        24.        , 'rodepth' ,   .false.   , .true. , 'yearly'  , ''               , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -133,5 +133,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_apr      = 'amm12_mslp'            ,          1        ,'p_msl'    ,   .false.   , .false., 'daily'  ,    ''            ,    ''    ,      ''
+   sn_apr      = 'amm12_mslp'            ,          1.       ,'p_msl'    ,   .false.   , .false., 'daily'  ,    ''            ,    ''    ,      ''
 /
 !!======================================================================
@@ -187,17 +187,20 @@
 &nambdy_dta    !  open boundaries - external data                       
 !-----------------------------------------------------------------------
-   ln_full_vel = .false.
-
+   ln_zinterp  = .false.      !  T if a vertical interpolation is required. Variables gdep[tuv] and e3[tuv] must exist in the file
+   !                          !  automatically defined to T if the number of vertical levels in bdy dta /= jpk
+   ln_full_vel = .false.      !  T if [uv]3d are "full" velocities and not only its baroclinic components
+   !                          !  in this case, baroclinic and barotropic velocities will be recomputed -> [uv]2d not needed
+   !
    cn_dir  =    './bdydta/'
    !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   bn_ssh      = 'amm12_bdyT_dyn2d'      ,         24        , 'sossheig',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
-   bn_u2d      = 'amm12_bdyU_dyn2d'      ,         24        , 'vobtcrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
-   bn_v2d      = 'amm12_bdyV_dyn2d'      ,         24        , 'vobtcrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
-   bn_u3d      = 'amm12_bdyU_dyn3d'      ,         24        , 'vozocrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
-   bn_v3d      = 'amm12_bdyV_dyn3d'      ,         24        , 'vomecrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
-   bn_tem      = 'amm12_bdyT_tra'        ,         24        , 'votemper',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
-   bn_sal      = 'amm12_bdyT_tra'        ,         24        , 'vosaline',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
+   bn_ssh      = 'amm12_bdyT_dyn2d'      ,         24.       , 'sossheig',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
+   bn_u2d      = 'amm12_bdyU_dyn2d'      ,         24.       , 'vobtcrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
+   bn_v2d      = 'amm12_bdyV_dyn2d'      ,         24.       , 'vobtcrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
+   bn_u3d      = 'amm12_bdyU_dyn3d'      ,         24.       , 'vozocrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
+   bn_v3d      = 'amm12_bdyV_dyn3d'      ,         24.       , 'vomecrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
+   bn_tem      = 'amm12_bdyT_tra'        ,         24.       , 'votemper',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
+   bn_sal      = 'amm12_bdyT_tra'        ,         24.       , 'vosaline',    .true.   , .false.,  'daily'  ,    ''            ,   ''     , ''
 /
 !-----------------------------------------------------------------------
@@ -347,7 +350,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/C1D_PAPA/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/C1D_PAPA/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/C1D_PAPA/EXPREF/namelist_cfg	(revision 12143)
@@ -65,6 +65,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem      = 'init_PAPASTATION'       ,         24        ,'votemper',  .false.     , .true.,  'daily'  ,    ''            ,    ''    ,    ''
-   sn_sal      = 'init_PAPASTATION'       ,         24        ,'vosaline',  .false.     , .true.,  'daily'  ,    ''            ,    ''    ,    ''
+   sn_tem      = 'init_PAPASTATION'       ,         24.       ,'votemper',  .false.     , .true.,  'daily'  ,    ''            ,    ''    ,    ''
+   sn_sal      = 'init_PAPASTATION'       ,         24.       ,'vosaline',  .false.     , .true.,  'daily'  ,    ''            ,    ''    ,    ''
 /
 !-----------------------------------------------------------------------
@@ -99,6 +99,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_ucur     = 'ucurrent'              ,         -1        ,'u_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Ume'   , ''
-   sn_vcur     = 'vcurrent'              ,         -1        ,'v_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Vme'   , ''
+   sn_ucur     = 'ucurrent'              ,         -1.       ,'u_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Ume'   , ''
+   sn_vcur     = 'vcurrent'              ,         -1.       ,'v_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Vme'   , ''
 /
 
@@ -150,14 +150,14 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !       weights filename               ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_wndi     = 'forcing_C1D_PAPA'   ,  3    , 'sowinu10',   .true.     , .false. , 'yearly'  , ''   ,''   , ''
-   sn_wndj     = 'forcing_C1D_PAPA'   ,  3    , 'sowinv10',   .true.     , .false. , 'yearly'  , ''   ,''   , ''
-   sn_qsr      = 'forcing_C1D_PAPA'   ,  3    , 'sosudosw',   .false.    , .false. , 'yearly'  , ''  , ''   , ''
-   sn_qlw      = 'forcing_C1D_PAPA'   ,  3    , 'sosudolw',   .false.    , .false. , 'yearly'  , ''  , ''   , ''
-   sn_tair     = 'forcing_C1D_PAPA'   ,  3    , 'sotemair',   .true.     , .false. , 'yearly'  , ''  , ''   , ''
-   sn_humi     = 'forcing_C1D_PAPA'   ,  3    , 'sohumspe',   .true.     , .false. , 'yearly'  , ''  , ''   , ''
-   sn_prec     = 'forcing_C1D_PAPA'   ,  3    , 'sowaprec',   .false.    , .false. , 'yearly'  , ''  , ''   , ''
-   sn_snow     = 'forcing_C1D_PAPA'   ,  3    , 'sososnow',   .false.    , .false. , 'yearly'  , ''  , ''   , ''
-   sn_slp      = 'forcing_C1D_PAPA'   ,  3    , 'somslpre',   .true.     , .false. , 'yearly'  , ''  , ''   , ''
-   sn_tdif     = 'forcing_C1D_PAPA'   , 24    , 'taudif'  ,   .false.    , .false. , 'yearly'  , ''  , ''   , ''
+   sn_wndi     = 'forcing_C1D_PAPA'   ,  3.   , 'sowinu10',   .true.     , .false. , 'yearly'  , ''   ,''   , ''
+   sn_wndj     = 'forcing_C1D_PAPA'   ,  3.   , 'sowinv10',   .true.     , .false. , 'yearly'  , ''   ,''   , ''
+   sn_qsr      = 'forcing_C1D_PAPA'   ,  3.   , 'sosudosw',   .false.    , .false. , 'yearly'  , ''  , ''   , ''
+   sn_qlw      = 'forcing_C1D_PAPA'   ,  3.   , 'sosudolw',   .false.    , .false. , 'yearly'  , ''  , ''   , ''
+   sn_tair     = 'forcing_C1D_PAPA'   ,  3.   , 'sotemair',   .true.     , .false. , 'yearly'  , ''  , ''   , ''
+   sn_humi     = 'forcing_C1D_PAPA'   ,  3.   , 'sohumspe',   .true.     , .false. , 'yearly'  , ''  , ''   , ''
+   sn_prec     = 'forcing_C1D_PAPA'   ,  3.   , 'sowaprec',   .false.    , .false. , 'yearly'  , ''  , ''   , ''
+   sn_snow     = 'forcing_C1D_PAPA'   ,  3.   , 'sososnow',   .false.    , .false. , 'yearly'  , ''  , ''   , ''
+   sn_slp      = 'forcing_C1D_PAPA'   ,  3.   , 'somslpre',   .true.     , .false. , 'yearly'  , ''  , ''   , ''
+   sn_tdif     = 'forcing_C1D_PAPA'   , 24.   , 'taudif'  ,   .false.    , .false. , 'yearly'  , ''  , ''   , ''
 
 /
@@ -185,5 +185,5 @@
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
 
-   sn_chl      ='chlorophyll_PAPASTATION',         -1        , 'CHLA'    ,   .true.     , .true. , 'yearly'  ,        ''       ,    ''    , ''
+   sn_chl      ='chlorophyll_PAPASTATION',         -1.       , 'CHLA'    ,   .true.     , .true. , 'yearly'  ,        ''       ,    ''    , ''
 /
 !-----------------------------------------------------------------------
@@ -420,7 +420,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
@@ -445,13 +445,13 @@
 /
 !-----------------------------------------------------------------------
-&namflo        !   float parameters                                     ("key_float")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents              ("key_diaharm")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namdct        ! transports through some sections                       ("key_diadct")
+&namflo        !   float parameters                                     (default: OFF)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_diaharm   !   Harmonic analysis of tidal constituents              (default: OFF)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_diadct    ! transports through some sections                       (default: OFF)
 !-----------------------------------------------------------------------
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/C1D_PAPA/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/C1D_PAPA/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/C1D_PAPA/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -39,5 +39,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -51,5 +51,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -57,16 +56,14 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii   ! Local integer
+      INTEGER ::   ios   ! Local integer
       !!
       NAMELIST/namusr_def/ rn_bathy
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       cd_cfg = 'C1D'               ! name & resolution (not used)
@@ -77,25 +74,24 @@
       kpj = 3
       kpk = 75 
-      !
-      !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                            ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'     ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : C1 case'                                               ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      type of vertical coordinate : '                                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         z-coordinate flag                     ln_zco = ', ln_zco               ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         z-partial-step coordinate flag        ln_zps = ', ln_zps               ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         s-coordinate flag                     ln_sco = ', ln_sco               ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      C1D domain = 3 x 3 x75 grid-points                '                       ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         resulting global domain size :        jpiglo = ', kpi                  ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpjglo = ', kpj                  ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpkglo = ', kpk                  ;   ii = ii + 1
-
-      !
       !                             ! Set the lateral boundary condition of the global domain
       kperio =  7                   ! C1D configuration : 3x3 basin with cyclic Est-West and Norht-South condition
       !
-      WRITE(ldtxt(ii),*) '   Lateral boundary condition of the global domain'                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      C1D : closed basin                 jperio = ', kperio                   ;   ii = ii + 1
+      !                             ! control print
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : C1 case'
+         WRITE(numout,*) '      type of vertical coordinate : '
+         WRITE(numout,*) '         z-coordinate flag                     ln_zco = ', ln_zco
+         WRITE(numout,*) '         z-partial-step coordinate flag        ln_zps = ', ln_zps
+         WRITE(numout,*) '         s-coordinate flag                     ln_sco = ', ln_sco
+         WRITE(numout,*) '      C1D domain = 3 x 3 x75 grid-points                '
+         WRITE(numout,*) '         resulting global domain size :        jpiglo = ', kpi
+         WRITE(numout,*) '                                               jpjglo = ', kpj
+         WRITE(numout,*) '                                               jpkglo = ', kpk
+         WRITE(numout,*) '   Lateral boundary condition of the global domain'
+         WRITE(numout,*) '      C1D : closed basin                       jperio = ', kperio
+      ENDIF
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_BFM/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_BFM/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_BFM/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
@@ -19,13 +29,13 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_BFM/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_BFM/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_BFM/EXPREF/namelist_cfg	(revision 12143)
@@ -227,7 +227,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_PISCES/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_PISCES/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_PISCES/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
@@ -19,13 +29,13 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_PISCES/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_PISCES/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/GYRE_PISCES/EXPREF/namelist_cfg	(revision 12143)
@@ -221,7 +221,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>    <!--  NEMO ocean dynamics     --> 
@@ -22,14 +32,14 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="profsed" long_name="Vertical S levels" unit="cm" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="profsed" long_name="Vertical S levels" unit="cm" positive="down"/>
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-ice.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-ice.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-ice.xml	(revision 12143)
@@ -78,5 +78,5 @@
        <field field_ref="vfxice"           name="vfxice" />
        <field field_ref="vfxsnw"           name="vfxsnw" />
-       
+
        <!-- categories -->
        <field field_ref="icemask_cat"      name="simskcat"/>
@@ -93,25 +93,25 @@
      <file id="file22" name_suffix="_SBC_scalar" description="scalar variables" enabled=".true." >
        <!-- global contents -->
-       <field field_ref="ibgvol_tot"     grid_ref="grid_1point"   name="ibgvol_tot"   />
-       <field field_ref="sbgvol_tot"     grid_ref="grid_1point"   name="sbgvol_tot"   />
-       <field field_ref="ibgarea_tot"    grid_ref="grid_1point"   name="ibgarea_tot"  />
-       <field field_ref="ibgsalt_tot"    grid_ref="grid_1point"   name="ibgsalt_tot"  />
-       <field field_ref="ibgheat_tot"    grid_ref="grid_1point"   name="ibgheat_tot"  />
-       <field field_ref="sbgheat_tot"    grid_ref="grid_1point"   name="sbgheat_tot"  />
+       <field field_ref="ibgvol_tot"     name="ibgvol_tot"   />
+       <field field_ref="sbgvol_tot"     name="sbgvol_tot"   />
+       <field field_ref="ibgarea_tot"    name="ibgarea_tot"  />
+       <field field_ref="ibgsalt_tot"    name="ibgsalt_tot"  />
+       <field field_ref="ibgheat_tot"    name="ibgheat_tot"  />
+       <field field_ref="sbgheat_tot"    name="sbgheat_tot"  />
        
        <!-- global drifts (conservation checks) -->
-       <field field_ref="ibgvolume"      grid_ref="grid_1point"   name="ibgvolume"    />
-       <field field_ref="ibgsaltco"      grid_ref="grid_1point"   name="ibgsaltco"    />
-       <field field_ref="ibgheatco"      grid_ref="grid_1point"   name="ibgheatco"    />
-       <field field_ref="ibgheatfx"      grid_ref="grid_1point"   name="ibgheatfx"    />
+       <field field_ref="ibgvolume"      name="ibgvolume"    />
+       <field field_ref="ibgsaltco"      name="ibgsaltco"    />
+       <field field_ref="ibgheatco"      name="ibgheatco"    />
+       <field field_ref="ibgheatfx"      name="ibgheatfx"    />
        
        <!-- global forcings  -->
-       <field field_ref="ibgfrcvoltop"   grid_ref="grid_1point"   name="ibgfrcvoltop" />
-       <field field_ref="ibgfrcvolbot"   grid_ref="grid_1point"   name="ibgfrcvolbot" />
-       <field field_ref="ibgfrctemtop"   grid_ref="grid_1point"   name="ibgfrctemtop" />
-       <field field_ref="ibgfrctembot"   grid_ref="grid_1point"   name="ibgfrctembot" />
-       <field field_ref="ibgfrcsal"      grid_ref="grid_1point"   name="ibgfrcsal"    />
-       <field field_ref="ibgfrchfxtop"   grid_ref="grid_1point"   name="ibgfrchfxtop" />
-       <field field_ref="ibgfrchfxbot"   grid_ref="grid_1point"   name="ibgfrchfxbot" />
+       <field field_ref="ibgfrcvoltop"   name="ibgfrcvoltop" />
+       <field field_ref="ibgfrcvolbot"   name="ibgfrcvolbot" />
+       <field field_ref="ibgfrctemtop"   name="ibgfrctemtop" />
+       <field field_ref="ibgfrctembot"   name="ibgfrctembot" />
+       <field field_ref="ibgfrcsal"      name="ibgfrcsal"    />
+       <field field_ref="ibgfrchfxtop"   name="ibgfrchfxtop" />
+       <field field_ref="ibgfrchfxbot"   name="ibgfrchfxbot" />
      </file>
      
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-oce.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-oce.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-oce.xml	(revision 12143)
@@ -37,5 +37,4 @@
 	  <field field_ref="wspd"         name="windsp"   />
 	  <field field_ref="precip"       name="precip"   />
-	  <field field_ref="berg_melt_qlat"  name="berg_melt_qlat" />
 	  <!-- ice and snow -->
 	  <field field_ref="snowpre" />
@@ -82,17 +81,17 @@
         <file id="file15" name_suffix="_scalar" description="scalar variables" >
           <!-- global drifts (conservation checks) -->
-          <field field_ref="bgtemper"     grid_ref="grid_1point"   name="bgtemper"    />
-          <field field_ref="bgsaline"     grid_ref="grid_1point"   name="bgsaline"    />
-          <field field_ref="bgheatco"     grid_ref="grid_1point"   name="bgheatco"    />
-          <field field_ref="bgheatfx"     grid_ref="grid_1point"   name="bgheatfx"    />
-          <field field_ref="bgsaltco"     grid_ref="grid_1point"   name="bgsaltco"    />
-          <field field_ref="bgvolssh"     grid_ref="grid_1point"   name="bgvolssh"    />
-          <field field_ref="bgvole3t"     grid_ref="grid_1point"   name="bgvole3t"    />
+          <field field_ref="bgtemper"     name="bgtemper"    />
+          <field field_ref="bgsaline"     name="bgsaline"    />
+          <field field_ref="bgheatco"     name="bgheatco"    />
+          <field field_ref="bgheatfx"     name="bgheatfx"    />
+          <field field_ref="bgsaltco"     name="bgsaltco"    />
+          <field field_ref="bgvolssh"     name="bgvolssh"    />
+          <field field_ref="bgvole3t"     name="bgvole3t"    />
 
           <!-- global surface forcings  -->
-          <field field_ref="bgfrcvol"     grid_ref="grid_1point"   name="bgfrcvol"    />
-          <field field_ref="bgfrctem"     grid_ref="grid_1point"   name="bgfrctem"    />
-          <field field_ref="bgfrchfx"     grid_ref="grid_1point"   name="bgfrchfx"    />
-          <field field_ref="bgfrcsal"     grid_ref="grid_1point"   name="bgfrcsal"    />
+          <field field_ref="bgfrcvol"     name="bgfrcvol"    />
+          <field field_ref="bgfrctem"     name="bgfrctem"    />
+          <field field_ref="bgfrchfx"     name="bgfrchfx"    />
+          <field field_ref="bgfrcsal"     name="bgfrcsal"    />
         </file>
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-pisces.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-pisces.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-pisces.xml	(revision 12143)
@@ -14,15 +14,15 @@
 
         <file id="file31" name_suffix="_bioscalar" description="pisces sms variables" >
-          <field field_ref="tdenit"   name="tdenit"   grid_ref="grid_1point" unit="TgN/yr" operation="instant" > tdenit * 14. * 86400. * 365. / 1e12 </field>
-          <field field_ref="tnfix"    name="tnfix"    grid_ref="grid_1point" unit="TgN/yr" operation="instant" > tnfix * 14. * 86400. * 365. / 1e12 </field>
-          <field field_ref="tcflx"    name="tcflx"    grid_ref="grid_1point" unit="PgC/yr" operation="instant" > tcflx * -1. * 12. * 86400. * 365. / 1e15 </field>
-          <field field_ref="tcflxcum" name="tcflxcum" grid_ref="grid_1point" unit="PgC"    operation="instant" > tcflxcum * -1. * 12. / 1e15 </field>
-          <field field_ref="tcexp"    name="tcexp"    grid_ref="grid_1point" unit="PgC/yr" operation="instant" > tcexp * 12. * 86400. * 365. / 1e15 </field>
-          <field field_ref="tintpp"   name="tintpp"   grid_ref="grid_1point" unit="PgC/yr" operation="instant" > tintpp * 12. * 86400. * 365. / 1e15 </field>
-          <field field_ref="pno3tot"  name="pno3tot"  grid_ref="grid_1point" unit="umolN"  > pno3tot * 16. / 122. * 1e6 </field>
-          <field field_ref="ppo4tot"  name="ppo4tot"  grid_ref="grid_1point" unit="umolP"  > ppo4tot * 1. / 122. * 1e6 </field>
-          <field field_ref="psiltot"  name="psiltot"  grid_ref="grid_1point" unit="umolC"  > psiltot * 1e6  </field>
-          <field field_ref="palktot"  name="palktot"  grid_ref="grid_1point" unit="umolC"  > palktot * 1e6  </field>
-          <field field_ref="pfertot"  name="pfertot"  grid_ref="grid_1point" unit="nmolFe" > pfertot * 1e9  </field>
+          <field field_ref="tdenit"   name="tdenit"    unit="TgN/yr" operation="instant" > tdenit * 14. * 86400. * 365. / 1e12 </field>
+          <field field_ref="tnfix"    name="tnfix"     unit="TgN/yr" operation="instant" > tnfix * 14. * 86400. * 365. / 1e12 </field>
+          <field field_ref="tcflx"    name="tcflx"     unit="PgC/yr" operation="instant" > tcflx * -1. * 12. * 86400. * 365. / 1e15 </field>
+          <field field_ref="tcflxcum" name="tcflxcum"  unit="PgC"    operation="instant" > tcflxcum * -1. * 12. / 1e15 </field>
+          <field field_ref="tcexp"    name="tcexp"     unit="PgC/yr" operation="instant" > tcexp * 12. * 86400. * 365. / 1e15 </field>
+          <field field_ref="tintpp"   name="tintpp"    unit="PgC/yr" operation="instant" > tintpp * 12. * 86400. * 365. / 1e15 </field>
+          <field field_ref="pno3tot"  name="pno3tot"   unit="umolN"  > pno3tot * 16. / 122. * 1e6 </field>
+          <field field_ref="ppo4tot"  name="ppo4tot"   unit="umolP"  > ppo4tot * 1. / 122. * 1e6 </field>
+          <field field_ref="psiltot"  name="psiltot"   unit="umolC"  > psiltot * 1e6  </field>
+          <field field_ref="palktot"  name="palktot"   unit="umolC"  > palktot * 1e6  </field>
+          <field field_ref="pfertot"  name="pfertot"   unit="nmolFe" > pfertot * 1e9  </field>
         </file>
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg	(revision 12143)
@@ -50,6 +50,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem = 'data_1m_potential_temperature_nomask',     -1      ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
-   sn_sal = 'data_1m_salinity_nomask'             ,     -1      ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_tem = 'data_1m_potential_temperature_nomask',     -1.     ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal = 'data_1m_salinity_nomask'             ,     -1.     ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
 /
 !!======================================================================
@@ -109,14 +109,14 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !          weights filename            ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6         , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
-   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6         , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
-   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_tair     = 't_10.15JUNE2009_fill'       ,    6         , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6         , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1         , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1         , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_slp      = 'slp.15JUNE2009_fill'        ,    6         , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_tdif     = 'taudif_core'                ,   24         , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6.        , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6.        , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,    6.        , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6.        , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_slp      = 'slp.15JUNE2009_fill'        ,    6.        , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tdif     = 'taudif_core'                ,   24.        , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -132,5 +132,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_chl      ='chlorophyll'            ,        -1         , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_chl      ='chlorophyll'            ,        -1.        , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -154,9 +154,9 @@
    !           !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
    !           !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_rnf      = 'runoff_core_monthly',    -1    , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_cnf      = 'runoff_core_monthly',     0    , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
-   sn_s_rnf    = 'runoffs'            ,    24    , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_t_rnf    = 'runoffs'            ,    24    , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_dep_rnf  = 'runoffs'            ,     0    , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_rnf      = 'runoff_core_monthly',    -1.   , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_cnf      = 'runoff_core_monthly',     0.   , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_s_rnf    = 'runoffs'            ,    24.   , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_t_rnf    = 'runoffs'            ,    24.   , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_dep_rnf  = 'runoffs'            ,     0.   , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -173,5 +173,5 @@
    !      ! file name ! frequency (hours) !   variable   ! time interp. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
    !      !           !  (if <0  months)  !     name     !   (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_icb =  'calving',       -1          , 'calving'    ,   .true.     , .true.  , 'yearly'  , ''       , ''       , ''
+   sn_icb =  'calving',       -1.         , 'calving'    ,   .true.     , .true.  , 'yearly'  , ''       , ''       , ''
 /
 !!======================================================================
@@ -391,7 +391,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_ice_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_ice_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_ice_cfg	(revision 12143)
@@ -38,4 +38,5 @@
 &namdyn_rhg     !   Ice rheology
 !------------------------------------------------------------------------------
+      ln_aEVP       = .false.          !     adaptive rheology (Kimmritz et al. 2016 & 2017)
 /
 !------------------------------------------------------------------------------
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_top_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_top_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_top_cfg	(revision 12143)
@@ -57,12 +57,12 @@
 !          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_trcdta(1)  = 'data_DIC_nomask'        ,        -12        ,  'DIC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(2)  = 'data_Alkalini_nomask'   ,        -12        ,  'Alkalini',    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(3)  = 'data_O2_nomask'         ,        -1         ,  'O2'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(5)  = 'data_PO4_nomask'        ,        -1         ,  'PO4'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(7)  = 'data_Si_nomask'         ,        -1         ,  'Si'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(10) = 'data_DOC_nomask'        ,        -12        ,  'DOC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(14) = 'data_Fer_nomask'        ,        -12        ,  'Fer'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(23) = 'data_NO3_nomask'        ,        -1         ,  'NO3'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(1)  = 'data_DIC_nomask'        ,        -12.       ,  'DIC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(2)  = 'data_Alkalini_nomask'   ,        -12.       ,  'Alkalini',    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(3)  = 'data_O2_nomask'         ,        -1.        ,  'O2'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(5)  = 'data_PO4_nomask'        ,        -1.        ,  'PO4'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(7)  = 'data_Si_nomask'         ,        -1.        ,  'Si'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(10) = 'data_DOC_nomask'        ,        -12.       ,  'DOC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(14) = 'data_Fer_nomask'        ,        -12.       ,  'Fer'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(23) = 'data_NO3_nomask'        ,        -1.        ,  'NO3'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
    rn_trfac(1)   =   1.0e-06  !  multiplicative factor
    rn_trfac(2)   =   1.0e-06  !  -      -      -     -
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  Ocean biology                     -->
@@ -19,14 +29,14 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="profsed" long_name="Vertical S levels" unit="cm" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="profsed" long_name="Vertical S levels" unit="cm" positive="down"/>
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/file_def_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/file_def_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/file_def_nemo.xml	(revision 12143)
@@ -19,15 +19,15 @@
       <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE."> <!-- 1d files -->
         <file id="file1" name_suffix="_bioscalar" description="pisces sms variables" >
-           <field field_ref="tdenit"   name="tdenit"   grid_ref="grid_1point" unit="TgN/yr" operation="instant" > tdenit * 14. * 86400. * 365. / 1e12 </field>
-           <field field_ref="tnfix"    name="tnfix"    grid_ref="grid_1point" unit="TgN/yr" operation="instant" > tnfix * 14. * 86400. * 365. / 1e12 </field>
-           <field field_ref="tcflx"    name="tcflx"    grid_ref="grid_1point" unit="PgC/yr" operation="instant" > tcflx * -1. * 12. * 86400. * 365. / 1e15 </field>
-           <field field_ref="tcflxcum" name="tcflxcum" grid_ref="grid_1point" unit="PgC"    operation="instant" > tcflxcum * -1. * 12. / 1e15 </field>
-           <field field_ref="tcexp"    name="tcexp"    grid_ref="grid_1point" unit="PgC/yr" operation="instant" > tcexp * 12. * 86400. * 365. / 1e15 </field>
-           <field field_ref="tintpp"   name="tintpp"   grid_ref="grid_1point" unit="PgC/yr" operation="instant" > tintpp * 12. * 86400. * 365. / 1e15 </field>
-           <field field_ref="pno3tot"  name="pno3tot"  grid_ref="grid_1point" unit="umolN"  > pno3tot * 16. / 122. * 1e6 </field>
-           <field field_ref="ppo4tot"  name="ppo4tot"  grid_ref="grid_1point" unit="umolP"  > ppo4tot * 1. / 122. * 1e6 </field>
-           <field field_ref="psiltot"  name="psiltot"  grid_ref="grid_1point" unit="umolC"  > psiltot * 1e6  </field>
-           <field field_ref="palktot"  name="palktot"  grid_ref="grid_1point" unit="umolC"  > palktot * 1e6  </field>
-           <field field_ref="pfertot"  name="pfertot"  grid_ref="grid_1point" unit="nmolFe" > pfertot * 1e9  </field>
+           <field field_ref="tdenit"   name="tdenit"    unit="TgN/yr" operation="instant" > tdenit * 14. * 86400. * 365. / 1e12 </field>
+           <field field_ref="tnfix"    name="tnfix"     unit="TgN/yr" operation="instant" > tnfix * 14. * 86400. * 365. / 1e12 </field>
+           <field field_ref="tcflx"    name="tcflx"     unit="PgC/yr" operation="instant" > tcflx * -1. * 12. * 86400. * 365. / 1e15 </field>
+           <field field_ref="tcflxcum" name="tcflxcum"  unit="PgC"    operation="instant" > tcflxcum * -1. * 12. / 1e15 </field>
+           <field field_ref="tcexp"    name="tcexp"     unit="PgC/yr" operation="instant" > tcexp * 12. * 86400. * 365. / 1e15 </field>
+           <field field_ref="tintpp"   name="tintpp"    unit="PgC/yr" operation="instant" > tintpp * 12. * 86400. * 365. / 1e15 </field>
+           <field field_ref="pno3tot"  name="pno3tot"   unit="umolN"  > pno3tot * 16. / 122. * 1e6 </field>
+           <field field_ref="ppo4tot"  name="ppo4tot"   unit="umolP"  > ppo4tot * 1. / 122. * 1e6 </field>
+           <field field_ref="psiltot"  name="psiltot"   unit="umolC"  > psiltot * 1e6  </field>
+           <field field_ref="palktot"  name="palktot"   unit="umolC"  > palktot * 1e6  </field>
+           <field field_ref="pfertot"  name="pfertot"   unit="nmolFe" > pfertot * 1e9  </field>
         </file>
       </file_group>
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_cfg	(revision 12143)
@@ -318,18 +318,18 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem      = 'dyna_grid_T'           ,       120         , 'votemper'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_sal      = 'dyna_grid_T'           ,       120         , 'vosaline'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_mld      = 'dyna_grid_T'           ,       120         , 'somixhgt'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_emp      = 'dyna_grid_T'           ,       120         , 'sowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_fmf      = 'dyna_grid_T'           ,       120         , 'iowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_ice      = 'dyna_grid_T'           ,       120         , 'soicecov'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_qsr      = 'dyna_grid_T'           ,       120         , 'soshfldo'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_wnd      = 'dyna_grid_T'           ,       120         , 'sowindsp'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_uwd      = 'dyna_grid_U'           ,       120         , 'uocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_vwd      = 'dyna_grid_V'           ,       120         , 'vocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_wwd      = 'dyna_grid_W'           ,       120         , 'wocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_avt      = 'dyna_grid_W'           ,       120         , 'voddmavs'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_ubl      = 'dyna_grid_U'           ,       120         , 'sobblcox'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_vbl      = 'dyna_grid_V'           ,       120         , 'sobblcoy'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_tem      = 'dyna_grid_T'           ,       120.        , 'votemper'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_sal      = 'dyna_grid_T'           ,       120.        , 'vosaline'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_mld      = 'dyna_grid_T'           ,       120.        , 'somixhgt'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_emp      = 'dyna_grid_T'           ,       120.        , 'sowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_fmf      = 'dyna_grid_T'           ,       120.        , 'iowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_ice      = 'dyna_grid_T'           ,       120.        , 'soicecov'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_qsr      = 'dyna_grid_T'           ,       120.        , 'soshfldo'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_wnd      = 'dyna_grid_T'           ,       120.        , 'sowindsp'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_uwd      = 'dyna_grid_U'           ,       120.        , 'uocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_vwd      = 'dyna_grid_V'           ,       120.        , 'vocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_wwd      = 'dyna_grid_W'           ,       120.        , 'wocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_avt      = 'dyna_grid_W'           ,       120.        , 'voddmavs'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_ubl      = 'dyna_grid_U'           ,       120.        , 'sobblcox'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_vbl      = 'dyna_grid_V'           ,       120.        , 'sobblcoy'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
 /
 !!======================================================================
@@ -376,7 +376,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
@@ -401,13 +401,13 @@
 /
 !-----------------------------------------------------------------------
-&namflo        !   float parameters                                     ("key_float")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents              ("key_diaharm")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namdct        ! transports through some sections                       ("key_diadct")
+&namflo        !   float parameters                                     (default: OFF)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_diaharm   !   Harmonic analysis of tidal constituents              (default: OFF)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_diadct    !   transports through some sections                     (default: OFF)
 !-----------------------------------------------------------------------
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_top_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_top_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_top_cfg	(revision 12143)
@@ -56,12 +56,12 @@
 !          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_trcdta(1)  = 'data_DIC_nomask'        ,        -12        ,  'DIC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(2)  = 'data_Alkalini_nomask'   ,        -12        ,  'Alkalini',    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(3)  = 'data_O2_nomask'         ,        -1         ,  'O2'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(5)  = 'data_PO4_nomask'        ,        -1         ,  'PO4'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(7)  = 'data_Si_nomask'         ,        -1         ,  'Si'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(10) = 'data_DOC_nomask'        ,        -12        ,  'DOC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(14) = 'data_Fer_nomask'        ,        -12        ,  'Fer'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(23) = 'data_NO3_nomask'        ,        -1         ,  'NO3'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(1)  = 'data_DIC_nomask'        ,        -12.       ,  'DIC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(2)  = 'data_Alkalini_nomask'   ,        -12.       ,  'Alkalini',    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(3)  = 'data_O2_nomask'         ,        -1.        ,  'O2'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(5)  = 'data_PO4_nomask'        ,        -1.        ,  'PO4'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(7)  = 'data_Si_nomask'         ,        -1.        ,  'Si'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(10) = 'data_DOC_nomask'        ,        -12.       ,  'DOC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(14) = 'data_Fer_nomask'        ,        -12.       ,  'Fer'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(23) = 'data_NO3_nomask'        ,        -1.        ,  'NO3'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
    rn_trfac(1)   =   1.0e-06  !  multiplicative factor
    rn_trfac(2)   =   1.0e-06  !  -      -      -     -
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_TRC/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_TRC/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_TRC/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  Ocean biology                     -->
@@ -19,13 +29,13 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_TRC/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_TRC/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_OFF_TRC/EXPREF/namelist_cfg	(revision 12143)
@@ -316,18 +316,18 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem      = 'dyna_grid_T'           ,       120         , 'votemper'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_sal      = 'dyna_grid_T'           ,       120         , 'vosaline'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_mld      = 'dyna_grid_T'           ,       120         , 'somixhgt'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_emp      = 'dyna_grid_T'           ,       120         , 'sowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_fmf      = 'dyna_grid_T'           ,       120         , 'iowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_ice      = 'dyna_grid_T'           ,       120         , 'soicecov'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_qsr      = 'dyna_grid_T'           ,       120         , 'soshfldo'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_wnd      = 'dyna_grid_T'           ,       120         , 'sowindsp'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_uwd      = 'dyna_grid_U'           ,       120         , 'uocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_vwd      = 'dyna_grid_V'           ,       120         , 'vocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_wwd      = 'dyna_grid_W'           ,       120         , 'wocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_avt      = 'dyna_grid_W'           ,       120         , 'voddmavs'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_ubl      = 'dyna_grid_U'           ,       120         , 'sobblcox'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_vbl      = 'dyna_grid_V'           ,       120         , 'sobblcoy'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_tem      = 'dyna_grid_T'           ,       120.        , 'votemper'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_sal      = 'dyna_grid_T'           ,       120.        , 'vosaline'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_mld      = 'dyna_grid_T'           ,       120.        , 'somixhgt'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_emp      = 'dyna_grid_T'           ,       120.        , 'sowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_fmf      = 'dyna_grid_T'           ,       120.        , 'iowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_ice      = 'dyna_grid_T'           ,       120.        , 'soicecov'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_qsr      = 'dyna_grid_T'           ,       120.        , 'soshfldo'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_wnd      = 'dyna_grid_T'           ,       120.        , 'sowindsp'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_uwd      = 'dyna_grid_U'           ,       120.        , 'uocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_vwd      = 'dyna_grid_V'           ,       120.        , 'vocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_wwd      = 'dyna_grid_W'           ,       120.        , 'wocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_avt      = 'dyna_grid_W'           ,       120.        , 'voddmavs'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_ubl      = 'dyna_grid_U'           ,       120.        , 'sobblcox'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_vbl      = 'dyna_grid_V'           ,       120.        , 'sobblcoy'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
 /
 !!======================================================================
@@ -374,5 +374,5 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
+!!   namflo       float parameters                                      (default: OFF)
 !!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
 !!   namdct       transports through some sections                      ("key_diadct")
@@ -399,5 +399,5 @@
 /
 !-----------------------------------------------------------------------
-&namflo        !   float parameters                                     ("key_float")
+&namflo        !   float parameters                                     (default: OFF)
 !-----------------------------------------------------------------------
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg	(revision 12143)
@@ -70,14 +70,14 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !       weights filename               ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6         , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
-   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6         , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
-   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_tair     = 't_10.15JUNE2009_fill'       ,    6         , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6         , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1         , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1         , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_slp      = 'slp.15JUNE2009_fill'        ,    6         , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_tdif     = 'taudif_core'                ,   24         , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6.        , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6.        , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,    6.        , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6.        , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_slp      = 'slp.15JUNE2009_fill'        ,    6.        , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tdif     = 'taudif_core'                ,   24.        , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -96,11 +96,11 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_usp      = 'sas_grid_U'            ,       120         , 'uos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_vsp      = 'sas_grid_V'            ,       120         , 'vos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_tem      = 'sas_grid_T'            ,       120         , 'sosstsst',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_sal      = 'sas_grid_T'            ,       120         , 'sosaline',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_ssh      = 'sas_grid_T'            ,       120         , 'sossheig',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_e3t      = 'sas_grid_T'            ,       120         , 'e3t_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_frq      = 'sas_grid_T'            ,       120         , 'frq_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_usp      = 'sas_grid_U'            ,       120.        , 'uos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_vsp      = 'sas_grid_V'            ,       120.        , 'vos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_tem      = 'sas_grid_T'            ,       120.        , 'sosstsst',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_sal      = 'sas_grid_T'            ,       120.        , 'sosaline',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_ssh      = 'sas_grid_T'            ,       120.        , 'sossheig',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_e3t      = 'sas_grid_T'            ,       120.        , 'e3t_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_frq      = 'sas_grid_T'            ,       120.        , 'frq_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
 /
 !!======================================================================
@@ -177,7 +177,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/README.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/README.rst	(revision 12143)
@@ -1,5 +1,9 @@
-************************
-Reference configurations
-************************
+********************************
+Run the Reference configurations
+********************************
+
+.. todo::
+
+   Lack of illustrations for ref. cfgs, and more generally in the guide.
 
 NEMO is distributed with a set of reference configurations allowing both
@@ -7,4 +11,8 @@
 the developer to test/validate his NEMO developments (using SETTE package).
 
+.. contents::
+   :local:
+   :depth: 1
+
 .. attention::
 
@@ -21,42 +29,49 @@
 ===========================================================
 
-A user who wants to compile the ORCA2_ICE_PISCES_ reference configuration using ``makenemo``
-should use the following, by selecting among available architecture file or providing a user defined one:
+To compile the ORCA2_ICE_PISCES_ reference configuration using :file:`makenemo`,
+one should use the following, by selecting among available architecture file or
+providing a user defined one:
 
 .. code-block:: console
-                
-   $ ./makenemo -r 'ORCA2_ICE_PISCES' -m 'my-fortran.fcm' -j '4'
+
+   $ ./makenemo -r 'ORCA2_ICE_PISCES' -m 'my_arch' -j '4'
 
 A new ``EXP00`` folder will be created within the selected reference configurations,
-namely ``./cfgs/ORCA2_ICE_PISCES/EXP00``,
-where it will be necessary to uncompress the Input & Forcing Files listed in the above table.
+namely ``./cfgs/ORCA2_ICE_PISCES/EXP00``.
+It will be necessary to uncompress the archives listed in the above table for
+the given reference configuration that includes input & forcing files.
 
 Then it will be possible to launch the execution of the model through a runscript
 (opportunely adapted to the user system).
-   
+
 List of Configurations
 ======================
 
-All forcing files listed below in the table are available from |NEMO archives URL|_
-
-.. |NEMO archives URL| image:: https://www.zenodo.org/badge/DOI/10.5281/zenodo.1472245.svg
-.. _NEMO archives URL: https://doi.org/10.5281/zenodo.1472245
-
-====================== ===== ===== ===== ======== ======= ================================================
- Configuration                     Component(s)                            Input & Forcing File(s)
----------------------- ---------------------------------- ------------------------------------------------
- Name                   OPA   SI3   TOP   PISCES   AGRIF
-====================== ===== ===== ===== ======== ======= ================================================
- AGRIF_DEMO_             X     X                     X     AGRIF_DEMO_v4.0.tar, ORCA2_ICE_v4.0.tar
- AMM12_                  X                                 AMM12_v4.0.tar
- C1D_PAPA_               X                                 INPUTS_C1D_PAPA_v4.0.tar
- GYRE_BFM_               X           X                     *none*
- GYRE_PISCES_            X           X      X              *none*
- ORCA2_ICE_PISCES_       X     X     X      X              ORCA2_ICE_v4.0.tar, INPUTS_PISCES_v4.0.tar
- ORCA2_OFF_PISCES_                   X      X              ORCA2_OFF_v4.0.tar, INPUTS_PISCES_v4.0.tar
- ORCA2_OFF_TRC_                      X                     ORCA2_OFF_v4.0.tar
- ORCA2_SAS_ICE_                X                           ORCA2_ICE_v4.0.tar, INPUTS_SAS_v4.0.tar
- SPITZ12_                X     X                           SPITZ12_v4.0.tar
-====================== ===== ===== ===== ======== ======= ================================================
+All forcing files listed below in the table are available from |DOI data|_
+
+=================== === === === === === ==================================
+ Configuration       Component(s)        Archives (input & forcing files)
+------------------- ------------------- ----------------------------------
+ Name                O   S   T   P   A
+=================== === === === === === ==================================
+ AGRIF_DEMO_         X   X           X   AGRIF_DEMO_v4.0.tar,
+                                         ORCA2_ICE_v4.0.tar
+ AMM12_              X                   AMM12_v4.0.tar
+ C1D_PAPA_           X                   INPUTS_C1D_PAPA_v4.0.tar
+ GYRE_BFM_           X       X           *none*
+ GYRE_PISCES_        X       X   X       *none*
+ ORCA2_ICE_PISCES_   X   X   X   X       ORCA2_ICE_v4.0.tar,
+                                         INPUTS_PISCES_v4.0.tar
+ ORCA2_OFF_PISCES_           X   X       ORCA2_OFF_v4.0.tar,
+                                         INPUTS_PISCES_v4.0.tar
+ ORCA2_OFF_TRC_              X           ORCA2_OFF_v4.0.tar
+ ORCA2_SAS_ICE_          X               ORCA2_ICE_v4.0.tar,
+                                         INPUTS_SAS_v4.0.tar
+ SPITZ12_            X   X               SPITZ12_v4.0.tar
+=================== === === === === === ==================================
+
+.. admonition:: Legend for component combination
+
+   O for OCE, S for SI\ :sup:`3`, T for TOP, P for PISCES and A for AGRIF
 
 AGRIF_DEMO
@@ -72,9 +87,14 @@
 particular interest to test sea ice coupling.
 
+.. image:: _static/AGRIF_DEMO_no_cap.jpg
+   :scale: 66%
+   :align: center
+
 The 1:1 grid can be used alone as a benchmark to check that
-the model solution is not corrupted by grid exchanges. 
+the model solution is not corrupted by grid exchanges.
 Note that since grids interact only at the baroclinic time level,
 numerically exact results can not be achieved in the 1:1 case.
-Perfect reproducibility is obtained only by switching to a fully explicit setup instead of a split explicit free surface scheme.
+Perfect reproducibility is obtained only by switching to a fully explicit setup instead of
+a split explicit free surface scheme.
 
 AMM12
@@ -85,5 +105,8 @@
 a regular horizontal grid of ~12 km of resolution (see :cite:`ODEA2012`).
 
-This configuration allows to tests several features of NEMO specifically addressed to the shelf seas. 
+.. image:: _static/AMM_domain.png
+   :align: center
+
+This configuration allows to tests several features of NEMO specifically addressed to the shelf seas.
 In particular, ``AMM12`` accounts for vertical s-coordinates system, GLS turbulence scheme,
 tidal lateral boundary conditions using a flather scheme (see more in ``BDY``).
@@ -99,21 +122,33 @@
 --------
 
-``C1D_PAPA`` is a 1D configuration for the `PAPA station <http://www.pmel.noaa.gov/OCS/Papa/index-Papa.shtml>`_ located in the northern-eastern Pacific Ocean at 50.1°N, 144.9°W.
-See `Reffray et al. (2015) <http://www.geosci-model-dev.net/8/69/2015>`_ for the description of its physical and numerical turbulent-mixing behaviour.
-
-The water column setup, called NEMO1D, is activated with the inclusion of the CPP key ``key_c1d`` and
-has a horizontal domain of 3x3 grid points.
-
-This reference configuration uses 75 vertical levels grid (1m at the surface), GLS turbulence scheme with K-epsilon closure and the NCAR bulk formulae.
+.. figure:: _static/Papa2015.jpg
+   :height: 225px
+   :align:  left
+
+``C1D_PAPA`` is a 1D configuration for the `PAPA station`_ located in
+the northern-eastern Pacific Ocean at 50.1°N, 144.9°W.
+See :gmd:`Reffray et al. (2015) <8/69/2015>` for the description of
+its physical and numerical turbulent-mixing behaviour.
+
+| The water column setup, called NEMO1D, is activated with
+  the inclusion of the CPP key ``key_c1d`` and
+  has a horizontal domain of 3x3 grid points.
+| This reference configuration uses 75 vertical levels grid (1m at the surface),
+  GLS turbulence scheme with K-epsilon closure and the NCAR bulk formulae.
+
 Data provided with ``INPUTS_C1D_PAPA_v4.0.tar`` file account for:
 
-- ``forcing_PAPASTATION_1h_y201[0-1].nc`` : ECMWF operational analysis atmospheric forcing rescaled to 1h (with long and short waves flux correction) for years 2010 and 2011
-- ``init_PAPASTATION_m06d15.nc`` : Initial Conditions from observed data and Levitus 2009 climatology
-- ``chlorophyll_PAPASTATION.nc`` : surface chlorophyll file from Seawifs data
+- :file:`forcing_PAPASTATION_1h_y201[0-1].nc`:
+  ECMWF operational analysis atmospheric forcing rescaled to 1h
+  (with long and short waves flux correction) for years 2010 and 2011
+- :file:`init_PAPASTATION_m06d15.nc`: Initial Conditions from
+  observed data and Levitus 2009 climatology
+- :file:`chlorophyll_PAPASTATION.nc`: surface chlorophyll file from Seawifs data
 
 GYRE_BFM
 --------
 
-``GYRE_BFM`` shares the same physical setup of GYRE_PISCES_, but NEMO is coupled with the `BFM <http://www.bfm-community.eu/>`_ biogeochemical model as described in ``./cfgs/GYRE_BFM/README``.
+``GYRE_BFM`` shares the same physical setup of GYRE_PISCES_,
+but NEMO is coupled with the `BFM`_ biogeochemical model as described in ``./cfgs/GYRE_BFM/README``.
 
 GYRE_PISCES
@@ -123,43 +158,42 @@
 in the Beta-plane approximation with a regular 1° horizontal resolution and 31 vertical levels,
 with PISCES BGC model :cite:`gmd-8-2465-2015`.
-Analytical forcing for heat, freshwater and wind-stress fields are applied.  
-
-This configuration acts also as demonstrator of the **user defined setup** (``ln_read_cfg = .false.``) and
-grid setting are handled through the ``&namusr_def`` controls in ``namelist_cfg``:
+Analytical forcing for heat, freshwater and wind-stress fields are applied.
+
+This configuration acts also as demonstrator of the **user defined setup**
+(``ln_read_cfg = .false.``) and grid setting are handled through
+the ``&namusr_def`` controls in :file:`namelist_cfg`:
 
 .. literalinclude:: ../../../cfgs/GYRE_PISCES/EXPREF/namelist_cfg
    :language: fortran
-   :lines: 34-42
+   :lines:    35-41
 
 Note that, the default grid size is 30x20 grid points (with ``nn_GYRE = 1``) and
 vertical levels are set by ``jpkglo``.
-The specific code changes can be inspected in ``./src/OCE/USR``.
-
-**Running GYRE as a benchmark** :
-this simple configuration can be used as a benchmark since it is easy to increase resolution,
-with the drawback of getting results that have a very limited physical meaning.
-
-GYRE grid resolution can be increased at runtime by setting a different value of ``nn_GYRE`` (integer multiplier scaling factor), as described in the following table: 
-
-=========== ========= ========== ============ ===================
-``nn_GYRE``  *jpiglo*  *jpjglo*   ``jpkglo``   **Equivalent to**
-=========== ========= ========== ============ ===================
- 1           30        20         31           GYRE 1°
- 25          750       500        101          ORCA 1/2°
- 50          1500      1000       101          ORCA 1/4°
- 150         4500      3000       101          ORCA 1/12°
- 200         6000      4000       101          ORCA 1/16°
-=========== ========= ========== ============ ===================
-
-Note that, it is necessary to set ``ln_bench = .true.`` in ``namusr_def`` to
-avoid problems in the physics computation and that
-the model timestep should be adequately rescaled. 
-
-For example if ``nn_GYRE = 150``, equivalent to an ORCA 1/12° grid,
-the timestep ``rn_rdt = 1200`` should be set to 1200 seconds
-
-Differently from previous versions of NEMO,
-the code uses by default the time-splitting scheme and
-internally computes the number of sub-steps. 
+The specific code changes can be inspected in :file:`./src/OCE/USR`.
+
+.. rubric:: Running GYRE as a benchmark
+
+| This simple configuration can be used as a benchmark since it is easy to increase resolution,
+  with the drawback of getting results that have a very limited physical meaning.
+| GYRE grid resolution can be increased at runtime by setting a different value of ``nn_GYRE``
+  (integer multiplier scaling factor), as described in the following table:
+
+=========== ============ ============ ============ ===============
+``nn_GYRE``  ``jpiglo``   ``jpjglo``   ``jpkglo``   Equivalent to
+=========== ============ ============ ============ ===============
+ 1           30           20           31           GYRE 1°
+ 25          750          500          101          ORCA 1/2°
+ 50          1500         1000         101          ORCA 1/4°
+ 150         4500         3000         101          ORCA 1/12°
+ 200         6000         4000         101          ORCA 1/16°
+=========== ============ ============ ============ ===============
+
+| Note that, it is necessary to set ``ln_bench = .true.`` in ``&namusr_def`` to
+  avoid problems in the physics computation and that
+  the model timestep should be adequately rescaled.
+| For example if ``nn_GYRE = 150``, equivalent to an ORCA 1/12° grid,
+  the timestep ``rn_rdt`` should be set to 1200 seconds
+  Differently from previous versions of NEMO, the code uses by default the time-splitting scheme and
+  internally computes the number of sub-steps.
 
 ORCA2_ICE_PISCES
@@ -174,41 +208,37 @@
 the ratio of anisotropy is nearly one everywhere
 
-this configuration uses the three components 
-
-- |OPA|, the ocean dynamical core 
-- |SI3|, the thermodynamic-dynamic sea ice model.
-- |TOP|, passive tracer transport module and PISCES BGC model :cite:`gmd-8-2465-2015`
+This configuration uses the three components
+
+- |OCE|, the ocean dynamical core
+- |ICE|, the thermodynamic-dynamic sea ice model.
+- |MBG|, passive tracer transport module and PISCES BGC model :cite:`gmd-8-2465-2015`
 
 All components share the same grid.
-
 The model is forced with CORE-II normal year atmospheric forcing and
 it uses the NCAR bulk formulae.
 
-In this ``ORCA2_ICE_PISCES`` configuration,
-AGRIF nesting can be activated that includes a nested grid in the Agulhas region.
-
-To set up this configuration, after extracting NEMO:
-
-Build your AGRIF configuration directory from ``ORCA2_ICE_PISCES``,
-with the ``key_agrif`` CPP key activated:
-
-.. code-block:: console
-                
-        $ ./makenemo -r 'ORCA2_ICE_PISCES' -n 'AGRIF' add_key 'key_agrif'
-
-By using the input files and namelists for ``ORCA2_ICE_PISCES``,
-the AGRIF test configuration is ready to run.
-
-**Ocean Physics**
-
-- *horizontal diffusion on momentum*: the eddy viscosity coefficient depends on the geographical position. It is taken as 40000 m^2/s, reduced in the equator regions (2000 m^2/s) excepted near the western boundaries.
-- *isopycnal diffusion on tracers*: the diffusion acts along the isopycnal surfaces (neutral surface) with an eddy diffusivity coefficient of 2000 m^2/s.
-- *Eddy induced velocity parametrization* with a coefficient that depends on the growth rate of baroclinic instabilities (it usually varies from 15 m^2/s to 3000 m^2/s).
-- *lateral boundary conditions* : zero fluxes of heat and salt and no-slip conditions are applied through lateral solid boundaries.
-- *bottom boundary condition* : zero fluxes of heat and salt are applied through the ocean bottom.
-  The Beckmann [19XX] simple bottom boundary layer parameterization is applied along continental slopes.
-  A linear friction is applied on momentum.
-- *convection*: the vertical eddy viscosity and diffusivity coefficients are increased to 1 m^2/s in case of static instability.
-- *time step* is 5760sec (1h36') so that there is 15 time steps in one day.
+.. rubric:: Ocean Physics
+
+:horizontal diffusion on momentum:
+   the eddy viscosity coefficient depends on the geographical position.
+   It is taken as 40000 m\ :sup:`2`/s, reduced in the equator regions (2000 m\ :sup:`2`/s)
+   excepted near the western boundaries.
+:isopycnal diffusion on tracers:
+   the diffusion acts along the isopycnal surfaces (neutral surface) with
+   an eddy diffusivity coefficient of 2000 m\ :sup:`2`/s.
+:Eddy induced velocity parametrization:
+   With a coefficient that depends on the growth rate of baroclinic instabilities
+   (it usually varies from 15 m\ :sup:`2`/s to 3000 m\ :sup:`2`/s).
+:lateral boundary conditions:
+   Zero fluxes of heat and salt and no-slip conditions are applied through lateral solid boundaries.
+:bottom boundary condition:
+   Zero fluxes of heat and salt are applied through the ocean bottom.
+   The Beckmann [19XX] simple bottom boundary layer parameterization is applied along
+   continental slopes.
+   A linear friction is applied on momentum.
+:convection:
+   The vertical eddy viscosity and diffusivity coefficients are increased to 1 m\ :sup:`2`/s in
+   case of static instability.
+:time step: is 5760sec (1h36') so that there is 15 time steps in one day.
 
 ORCA2_OFF_PISCES
@@ -218,34 +248,34 @@
 but only PISCES model is an active component of TOP.
 
-
 ORCA2_OFF_TRC
 -------------
 
-``ORCA2_OFF_TRC`` is based on the ORCA2 global ocean configuration
-(see ORCA2_ICE_PISCES_ for general description) along with the tracer passive transport module (TOP), but dynamical fields are pre-calculated and read with specific time frequency.
-
-This enables for an offline coupling of TOP components,
-here specifically inorganic carbon compounds (cfc11, cfc12, sf6, c14) and water age module (age).
-See ``namelist_top_cfg`` to inspect the selection of each component with the dedicated logical keys.
+| ``ORCA2_OFF_TRC`` is based on the ORCA2 global ocean configuration
+  (see ORCA2_ICE_PISCES_ for general description) along with
+  the tracer passive transport module (TOP),
+  but dynamical fields are pre-calculated and read with specific time frequency.
+| This enables for an offline coupling of TOP components,
+  here specifically inorganic carbon compounds (CFC11, CFC12, SF6, C14) and water age module (age).
+  See :file:`namelist_top_cfg` to inspect the selection of
+  each component with the dedicated logical keys.
 
 Pre-calculated dynamical fields are provided to NEMO using
-the namelist ``&namdta_dyn``  in ``namelist_cfg``,
+the namelist ``&namdta_dyn``  in :file:`namelist_cfg`,
 in this case with a 5 days frequency (120 hours):
 
-.. literalinclude:: ../../../cfgs/GYRE_PISCES/EXPREF/namelist_ref
+.. literalinclude:: ../../namelists/namdta_dyn
    :language: fortran
-   :lines: 935-960
-
-Input dynamical fields for this configuration (``ORCA2_OFF_v4.0.tar``) comes from
+
+Input dynamical fields for this configuration (:file:`ORCA2_OFF_v4.0.tar`) comes from
 a 2000 years long climatological simulation of ORCA2_ICE using ERA40 atmospheric forcing.
 
-Note that, this configuration default uses linear free surface (``ln_linssh = .true.``) assuming that
-model mesh is not varying in time and
-it includes the bottom boundary layer parameterization (``ln_trabbl = .true.``) that
-requires the provision of bbl coefficients through ``sn_ubl`` and ``sn_vbl`` fields.
-
-It is also possible to activate PISCES model (see ``ORCA2_OFF_PISCES``) or
-a user defined set of tracers and source-sink terms with ``ln_my_trc = .true.``
-(and adaptation of ``./src/TOP/MY_TRC`` routines).
+| Note that,
+  this configuration default uses linear free surface (``ln_linssh = .true.``) assuming that
+  model mesh is not varying in time and
+  it includes the bottom boundary layer parameterization (``ln_trabbl = .true.``) that
+  requires the provision of BBL coefficients through ``sn_ubl`` and ``sn_vbl`` fields.
+| It is also possible to activate PISCES model (see ``ORCA2_OFF_PISCES``) or
+  a user defined set of tracers and source-sink terms with ``ln_my_trc = .true.``
+  (and adaptation of ``./src/TOP/MY_TRC`` routines).
 
 In addition, the offline module (OFF) allows for the provision of further fields:
@@ -254,34 +284,32 @@
    by including an input datastream similarly to the following:
 
-.. code-block:: fortran
-
-   sn_rnf  = 'dyna_grid_T', 120, 'sorunoff' , .true., .true., 'yearly', '', '', ''
-
-2. **VVL dynamical fields**,
-   in the case input data were produced by a dyamical core using variable volume (``ln_linssh = .false.``)
-   it necessary to provide also diverce and E-P at before timestep by
+   .. code-block:: fortran
+
+      sn_rnf  = 'dyna_grid_T', 120, 'sorunoff' , .true., .true., 'yearly', '', '', ''
+
+2. **VVL dynamical fields**, in the case input data were produced by a dyamical core using
+   variable volume (``ln_linssh = .false.``)
+   it is necessary to provide also diverce and E-P at before timestep by
    including input datastreams similarly to the following
 
-.. code-block:: fortran
-
-   sn_div  = 'dyna_grid_T', 120, 'e3t'      , .true., .true., 'yearly', '', '', ''
-   sn_empb = 'dyna_grid_T', 120, 'sowaflupb', .true., .true., 'yearly', '', '', ''
-
+   .. code-block:: fortran
+
+      sn_div  = 'dyna_grid_T', 120, 'e3t'      , .true., .true., 'yearly', '', '', ''
+      sn_empb = 'dyna_grid_T', 120, 'sowaflupb', .true., .true., 'yearly', '', '', ''
 
 More details can be found by inspecting the offline data manager in
-the routine ``./src/OFF/dtadyn.F90``.
+the routine :file:`./src/OFF/dtadyn.F90`.
 
 ORCA2_SAS_ICE
 -------------
 
-ORCA2_SAS_ICE is a demonstrator of the Stand-Alone Surface (SAS) module and
-it relies on ORCA2 global ocean configuration (see ORCA2_ICE_PISCES_ for general description).
-
-The standalone surface module allows surface elements such as sea-ice, iceberg drift, and
-surface fluxes to be run using prescribed model state fields.
-It can profitably be used to compare different bulk formulae or
-adjust the parameters of a given bulk formula.
-
-More informations about SAS can be found in NEMO manual.
+| ORCA2_SAS_ICE is a demonstrator of the Stand-Alone Surface (SAS) module and
+  it relies on ORCA2 global ocean configuration (see ORCA2_ICE_PISCES_ for general description).
+| The standalone surface module allows surface elements such as sea-ice, iceberg drift, and
+  surface fluxes to be run using prescribed model state fields.
+  It can profitably be used to compare different bulk formulae or
+  adjust the parameters of a given bulk formula.
+
+More informations about SAS can be found in :doc:`NEMO manual <cite>`.
 
 SPITZ12
@@ -290,5 +318,5 @@
 ``SPITZ12`` is a regional configuration around the Svalbard archipelago
 at 1/12° of horizontal resolution and 75 vertical levels.
-See `Rousset et al. (2015) <https://www.geosci-model-dev.net/8/2991/2015/>`_ for more details.
+See :gmd:`Rousset et al. (2015) <8/2991/2015>` for more details.
 
 This configuration references to year 2002,
@@ -296,12 +324,8 @@
 while lateral boundary conditions for dynamical fields have 3 days time frequency.
 
-References
-==========
-
-.. bibliography:: configurations.bib
+.. rubric:: References
+
+.. bibliography:: cfgs.bib
    :all:
    :style: unsrt
    :labelprefix: C
-
-.. Links and substitutions
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/README.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/README.rst	(revision 12143)
@@ -3,39 +3,58 @@
 ***********
 
+.. todo::
+
+
+
 .. contents::
-           :local:
+   :local:
 
 Output of diagnostics in NEMO is usually done using XIOS.
-This is an efficient way of writing diagnostics because the time averaging, file writing and even some simple arithmetic or regridding is carried out in parallel to the NEMO model run.
+This is an efficient way of writing diagnostics because
+the time averaging, file writing and even some simple arithmetic or regridding is carried out in
+parallel to the NEMO model run.
 This page gives a basic introduction to using XIOS with NEMO.
-Much more information is available from the XIOS homepage above and from the NEMO manual.
+Much more information is available from the :xios:`XIOS homepage<>` above and from the NEMO manual.
 
-Use of XIOS for diagnostics is activated using the pre-compiler key ``key_iomput``. 
+Use of XIOS for diagnostics is activated using the pre-compiler key ``key_iomput``.
 
 Extracting and installing XIOS
-------------------------------
+==============================
 
 1. Install the NetCDF4 library.
-   If you want to use single file output you will need to compile the HDF & NetCDF libraries to allow parallel IO.
-2. Download the version of XIOS that you wish to use. The recommended version is now XIOS 2.5:
-   
-.. code-block:: console
+   If you want to use single file output you will need to compile the HDF & NetCDF libraries to
+   allow parallel IO.
+2. Download the version of XIOS that you wish to use.
+   The recommended version is now XIOS 2.5:
 
-	$ svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5 xios-2.5
+   .. code-block:: console
 
-and follow the instructions in `XIOS documentation <http://forge.ipsl.jussieu.fr/ioserver/wiki/documentation>`_ to compile it.
-   If you find problems at this stage, support can be found by subscribing to the `XIOS mailing list <http://forge.ipsl.jussieu.fr/mailman/listinfo.cgi/xios-users>`_ and sending a mail message to it. 
+      $ svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5
+
+and follow the instructions in :xios:`XIOS documentation <wiki/documentation>` to compile it.
+If you find problems at this stage, support can be found by subscribing to
+the :xios:`XIOS mailing list <../mailman/listinfo.cgi/xios-users>` and sending a mail message to it.
 
 XIOS Configuration files
 ------------------------
 
-XIOS is controlled using xml input files that should be copied to your model run directory before running the model.
-Examples of these files can be found in the reference configurations (``cfgs``). The XIOS executable expects to find a file called ``iodef.xml`` in the model run directory.
-In NEMO we have made the decision to use include statements in the ``iodef.xml`` file to include ``field_def_nemo-oce.xml`` (for physics), ``field_def_nemo-ice.xml`` (for ice), ``field_def_nemo-pisces.xml`` (for biogeochemistry) and ``domain_def.xml`` from the /cfgs/SHARED directory.
-Most users will not need to modify ``domain_def.xml`` or ``field_def_nemo-???.xml`` unless they want to add new diagnostics to the NEMO code.
-The definition of the output files is organized into separate ``file_definition.xml`` files which are included in the ``iodef.xml`` file.
+XIOS is controlled using XML input files that should be copied to
+your model run directory before running the model.
+Examples of these files can be found in the reference configurations (:file:`./cfgs`).
+The XIOS executable expects to find a file called :file:`iodef.xml` in the model run directory.
+In NEMO we have made the decision to use include statements in the :file:`iodef.xml` file to include:
+
+- :file:`field_def_nemo-oce.xml` (for physics),
+- :file:`field_def_nemo-ice.xml` (for ice),
+- :file:`field_def_nemo-pisces.xml` (for biogeochemistry) and
+- :file:`domain_def.xml` from the :file:`./cfgs/SHARED` directory.
+
+Most users will not need to modify :file:`domain_def.xml` or :file:`field_def_nemo-???.xml` unless
+they want to add new diagnostics to the NEMO code.
+The definition of the output files is organized into separate :file:`file_definition.xml` files which
+are included in the :file:`iodef.xml` file.
 
 Modes
------
+=====
 
 Detached Mode
@@ -44,11 +63,12 @@
 In detached mode the XIOS executable is executed on separate cores from the NEMO model.
 This is the recommended method for using XIOS for realistic model runs.
-To use this mode set ``using_server`` to ``true`` at the bottom of the ``iodef.xml`` file:
+To use this mode set ``using_server`` to ``true`` at the bottom of the :file:`iodef.xml` file:
 
 .. code-block:: xml
 
-	<variable id="using_server" type="boolean">true</variable>
+   <variable id="using_server" type="boolean">true</variable>
 
-Make sure there is a copy (or link to) your XIOS executable in the working directory and in your job submission script allocate processors to XIOS.
+Make sure there is a copy (or link to) your XIOS executable in the working directory and
+in your job submission script allocate processors to XIOS.
 
 Attached Mode
@@ -56,33 +76,44 @@
 
 In attached mode XIOS runs on each of the cores used by NEMO.
-This method is less efficient than the detached mode but can be more convenient for testing or with small configurations.
-To activate this mode simply set ``using_server`` to false in the ``iodef.xml`` file
+This method is less efficient than the detached mode but can be more convenient for testing or
+with small configurations.
+To activate this mode simply set ``using_server`` to false in the :file:`iodef.xml` file
 
 .. code-block:: xml
 
-	<variable id="using_server" type="boolean">false</variable>
+   <variable id="using_server" type="boolean">false</variable>
 
 and don't allocate any cores to XIOS.
-Note that due to the different domain decompositions between XIOS and NEMO if the total number of cores is larger than the number of grid points in the j direction then the model run will fail.
+
+.. note::
+
+   Due to the different domain decompositions between XIOS and NEMO,
+   if the total number of cores is larger than the number of grid points in the ``j`` direction then
+   the model run will fail.
 
 Adding new diagnostics
-----------------------
+======================
 
 If you want to add a NEMO diagnostic to the NEMO code you will need to do the following:
 
 1. Add any necessary code to calculate you new diagnostic in NEMO
-2. Send the field to XIOS using ``CALL iom_put( 'field_id', variable )`` where ``field_id`` is a unique id for your new diagnostics and variable is the fortran variable containing the data.
-   This should be called at every model timestep regardless of how often you want to output the field. No time averaging should be done in the model code. 
-3. If it is computationally expensive to calculate your new diagnostic you should also use "iom_use" to determine if it is requested in the current model run. For example,
-   
-.. code-block:: fortran
+2. Send the field to XIOS using ``CALL iom_put( 'field_id', variable )`` where
+   ``field_id`` is a unique id for your new diagnostics and
+   variable is the fortran variable containing the data.
+   This should be called at every model timestep regardless of how often you want to output the field.
+   No time averaging should be done in the model code.
+3. If it is computationally expensive to calculate your new diagnostic
+   you should also use "iom_use" to determine if it is requested in the current model run.
+   For example,
 
-		IF iom_use('field_id') THEN
-		   !Some expensive computation
-	   	!...
-		   !...
-	   	iom_put('field_id', variable)
-		ENDIF
+   .. code-block:: fortran
 
-4. Add a variable definition to the ``field_def_nemo-???.xml`` file.
-5. Add the variable to the ``iodef.xml`` or ``file_definition.xml`` file.
+      IF iom_use('field_id') THEN
+         !Some expensive computation
+         !...
+         !...
+	 iom_put('field_id', variable)
+      ENDIF
+
+4. Add a variable definition to the :file:`field_def_nemo-???.xml` file.
+5. Add the variable to the :file:`iodef.xml` or :file:`file_definition.xml` file.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/domain_def_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/domain_def_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/domain_def_nemo.xml	(revision 12143)
@@ -10,7 +10,4 @@
      </domain>
 
-     <domain id="1point" domain_ref="grid_T" >
-       <zoom_domain ibegin="1" jbegin="1" ni="1" nj="1"/>
-     </domain>
      <!--   Eq section -->
      <domain id="EqT" domain_ref="grid_T" > <zoom_domain id="EqT"/> </domain>
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-ice.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-ice.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-ice.xml	(revision 12143)
@@ -32,33 +32,33 @@
  
 	  <!-- general fields -->
-          <field id="icemass"      long_name="Sea-ice mass per area"                                   standard_name="sea_ice_amount"                            unit="kg/m2"/>
+          <field id="icemass"      long_name="Sea-ice mass per gridcell area"                          standard_name="sea_ice_amount"                            unit="kg/m2"/>
           <field id="snwmass"      long_name="Snow mass per area"                                      standard_name="liquid_water_content_of_surface_snow"      unit="kg/m2"/>
-          <field id="iceconc"      long_name="Sea-ice area fraction"                                   standard_name="sea_ice_area_fraction"                     unit=""    />
-          <field id="icevolu"      long_name="Sea-ice volume per area"                                 standard_name="sea_ice_thickness"                         unit="m"   />
-          <field id="icethic"      long_name="Sea-ice thickness per area"                              standard_name="sea_ice_thickness"                         unit="m"   />
-          <field id="snwthic"      long_name="Snow thickness per area"                                 standard_name="snow_thickness"                            unit="m"   />
-          <field id="icebrv"       long_name="brine volume"                                                                                                      unit="%"   />
-          <field id="iceage"       long_name="ice age"                                                                                                           unit="days"/>
-          <field id="icehnew"      long_name="frazil ice collection thickness"                                                                                   unit="m"   />
-          <field id="snwvolu"      long_name="snow volume"                                                                                                       unit="m"   />
-          <field id="icefrb"       long_name="Sea-ice freeboard"                                       standard_name="sea_ice_freeboard"                         unit="m"   />
-          <field id="icealb"       long_name="Sea-ice or snow albedo"                                  standard_name="sea_ice_albedo"                            unit=""    />
-          <field id="tau_icebfr"   long_name="ice friction on ocean bottom for landfast ice"                                                                     unit="N/2" />
+          <field id="iceconc"      long_name="Sea-ice area fraction"                                   standard_name="sea_ice_area_fraction"                     unit=""     />
+          <field id="icevolu"      long_name="Sea-ice volume per area"                                 standard_name="sea_ice_thickness"                         unit="m"    />
+          <field id="icethic"      long_name="Sea-ice thickness"                                       standard_name="sea_ice_thickness"                         unit="m"    />
+          <field id="snwthic"      long_name="Snow thickness"                                          standard_name="snow_thickness"                            unit="m"    />
+          <field id="icebrv"       long_name="brine volume"                                                                                                      unit="%"    />
+          <field id="iceage"       long_name="ice age"                                                                                                           unit="days" detect_missing_value="true"/>
+          <field id="icehnew"      long_name="frazil ice collection thickness"                                                                                   unit="m"    />
+          <field id="snwvolu"      long_name="snow volume"                                                                                                       unit="m"    />
+          <field id="icefrb"       long_name="Sea-ice freeboard"                                       standard_name="sea_ice_freeboard"                         unit="m"    />
+          <field id="icealb"       long_name="Sea-ice or snow albedo"                                  standard_name="sea_ice_albedo"                            unit=""    detect_missing_value="true" />
 	  
 	  <!-- melt ponds -->
-	  <field id="iceapnd"      long_name="melt pond fraction"                                      standard_name="sea_ice_meltpond_fraction"                 unit="%" /> 
+	  <field id="iceapnd"      long_name="melt pond concentration"                                 standard_name="sea_ice_meltpond_concentration"            unit=""  /> 
+          <field id="icehpnd"      long_name="melt pond depth"                                         standard_name="sea_ice_meltpond_depth"                    unit="m" /> 
           <field id="icevpnd"      long_name="melt pond volume"                                        standard_name="sea_ice_meltpond_volume"                   unit="m" /> 
 	  
 	  <!-- heat -->
-          <field id="icetemp"      long_name="Mean ice temperature"                                                                                              unit="degC" />
-          <field id="snwtemp"      long_name="Mean snow temperature"                                                                                             unit="degC" />
-          <field id="icettop"      long_name="temperature at the ice surface"                                                                                    unit="degC" />
-          <field id="icetbot"      long_name="temperature at the ice bottom"                                                                                     unit="degC" />
-          <field id="icetsni"      long_name="temperature at the snow-ice interface"                                                                             unit="degC" />
+          <field id="icetemp"      long_name="Mean ice temperature"                                                                                              unit="degC" detect_missing_value="true" />
+          <field id="snwtemp"      long_name="Mean snow temperature"                                                                                             unit="degC" detect_missing_value="true" />
+          <field id="icettop"      long_name="temperature at the ice surface"                                                                                    unit="degC" detect_missing_value="true" />
+          <field id="icetbot"      long_name="temperature at the ice bottom"                                                                                     unit="degC" detect_missing_value="true" />
+          <field id="icetsni"      long_name="temperature at the snow-ice interface"                                                                             unit="degC" detect_missing_value="true" />
           <field id="icehc"        long_name="ice heat content"                                                                                                  unit="J/m2" /> 
           <field id="snwhc"        long_name="snow heat content"                                                                                                 unit="J/m2" />
 	  
 	  <!-- salt -->
-          <field id="icesalt"      long_name="Sea ice salinity"                                                                                                  unit="g/kg"  />
+          <field id="icesalt"      long_name="Sea ice salinity"                                                                                                  unit="g/kg"  detect_missing_value="true" />
           <field id="icesalm"      long_name="Mass of salt in sea ice per area"                        standard_name="sea_ice_salt_mass"                         unit="kg/m2" />
 	  
@@ -71,4 +71,6 @@
           <field id="utau_oi"      long_name="X-component of ocean stress on sea ice"                  standard_name="sea_ice_base_upward_x_stress"              unit="N/m2" />
           <field id="vtau_oi"      long_name="Y-component of ocean stress on sea ice"                  standard_name="sea_ice_base_upward_y_stress"              unit="N/m2" />
+          <field id="utau_bi"      long_name="X-component of ocean bottom stress on sea ice -landfast" standard_name="ocean_bottom_upward_x_stress"              unit="N/m2" />
+          <field id="vtau_bi"      long_name="Y-component of ocean bottom stress on sea ice -landfast" standard_name="ocean_bottom_upward_y_stress"              unit="N/m2" />
           <field id="isig1"        long_name="1st principal stress component for EVP rhg"                                                                        unit=""     />
           <field id="isig2"        long_name="2nd principal stress component for EVP rhg"                                                                        unit=""     />
@@ -92,7 +94,7 @@
 	  
 	  <!-- trends -->
-          <field id="afxthd"       long_name="sea-ice area fraction change from thermodynamics"  standard_name="tendency_of_sea_ice_area_fraction_due_to_dynamics" unit="s-1" />
-          <field id="afxdyn"       long_name="sea-ice area fraction change from dynamics"        standard_name="tendency_of_sea_ice_area_fraction_due_to_dynamics" unit="s-1" />
-	  <field id="afxtot"       long_name="area tendency (total)"                                                                                               unit="s-1" />
+          <field id="afxthd"       long_name="sea-ice area fraction change from thermodynamics" standard_name="tendency_of_sea_ice_area_fraction_due_to_dynamics" unit="s-1" />
+          <field id="afxdyn"       long_name="sea-ice area fraction change from dynamics"       standard_name="tendency_of_sea_ice_area_fraction_due_to_dynamics" unit="s-1" />
+	  <field id="afxtot"       long_name="area tendency (total)"                                                                                              unit="s-1" />
 	  
 	  <!-- momentum (advection) -->
@@ -168,19 +170,4 @@
           <field id="e3t_m"    unit="m"    />
           <field id="frq_m"    unit="-"    />
-
-	  <!-- categories -->
-	  <field id="iceconc_cat"  long_name="Sea-ice concentration per category"                unit=""       grid_ref="grid_T_3D_ncatice" />
-          <field id="icethic_cat"  long_name="Sea-ice thickness per category"                    unit="m"      grid_ref="grid_T_3D_ncatice" />
-          <field id="snwthic_cat"  long_name="Snow thickness per category"                       unit="m"      grid_ref="grid_T_3D_ncatice" />
-          <field id="icesalt_cat"  long_name="Sea-Ice Bulk salinity per category"                unit="g/kg"   grid_ref="grid_T_3D_ncatice" />
-          <field id="icetemp_cat"  long_name="Ice temperature per category"                      unit="degC"   grid_ref="grid_T_3D_ncatice" />
-          <field id="snwtemp_cat"  long_name="Snow temperature per category"                     unit="degC"   grid_ref="grid_T_3D_ncatice" />
-          <field id="icettop_cat"  long_name="Ice/snow surface temperature per category"         unit="degC"   grid_ref="grid_T_3D_ncatice" />
-          <field id="iceapnd_cat"  long_name="Ice melt pond concentration per category"          unit="%"      grid_ref="grid_T_3D_ncatice" /> 
-          <field id="icehpnd_cat"  long_name="Ice melt pond thickness per category"              unit="m"      grid_ref="grid_T_3D_ncatice" /> 
-          <field id="iceafpnd_cat" long_name="Ice melt pond fraction per category"               unit="m"      grid_ref="grid_T_3D_ncatice" /> 
-          <field id="icemask_cat"  long_name="Fraction of time step with sea ice (per category)" unit=""       grid_ref="grid_T_3D_ncatice" />
-          <field id="iceage_cat"   long_name="Ice age per category"                              unit="days"   grid_ref="grid_T_3D_ncatice" />
-          <field id="icebrv_cat"   long_name="Brine volume per category"                         unit="%"      grid_ref="grid_T_3D_ncatice" />
 
 	  <!-- ================= -->
@@ -249,15 +236,43 @@
           <field id="xmtrptot"     long_name="X-component of sea-ice mass transport"                   standard_name="sea_ice_x_transport"                   unit="kg/s" > xmtrpice + xmtrpsnw </field>
           <field id="ymtrptot"     long_name="Y-component of sea-ice mass transport"                   standard_name="sea_ice_y_transport"                   unit="kg/s" > ymtrpice + ymtrpsnw </field>
-
-	  <!-- categories -->
-          <field id="iceconc_cat_cmip"     long_name="Sea-ice area fractions in thickness categories"  standard_name="sea_ice_area_fraction_over_categories" detect_missing_value="true" unit=""  grid_ref="grid_T_3D_ncatice" > iceconc_cat      * icemask_cat + $missval * (1.-icemask_cat) </field>
-          <field id="icethic_cat_cmip"     long_name="Sea-ice thickness in thickness categories"       standard_name="sea_ice_thickness_over_categories"     detect_missing_value="true" unit="m" grid_ref="grid_T_3D_ncatice" > icethic_cat      * icemask_cat + $missval * (1.-icemask_cat) </field>
-          <field id="snwthic_cat_cmip"     long_name="Snow thickness in thickness categories"          standard_name="snow_thickness_over_categories"        detect_missing_value="true" unit="m" grid_ref="grid_T_3D_ncatice" > snwthic_cat      * icemask_cat + $missval * (1.-icemask_cat) </field>
-          <field id="iceconc_cat_pct_cmip" long_name="Sea-ice area fractions in thickness categories"  standard_name="sea_ice_area_fraction_over_categories" detect_missing_value="true" unit="%" grid_ref="grid_T_3D_ncatice" > iceconc_cat*100. * icemask_cat + $missval * (1.-icemask_cat) </field>
 	 
 	</field_group> <!-- SBC_2D -->
 
+	<!-- categories -->
+        <field_group id="SBC_3D" grid_ref="grid_T_ncatice" >
+
+          <!-- standard ice fields -->  
+	  <field id="iceconc_cat"  long_name="Sea-ice concentration per category"                unit=""        />
+          <field id="icethic_cat"  long_name="Sea-ice thickness per category"                    unit="m"       detect_missing_value="true" />
+          <field id="snwthic_cat"  long_name="Snow thickness per category"                       unit="m"       detect_missing_value="true" />
+          <field id="icesalt_cat"  long_name="Sea-Ice Bulk salinity per category"                unit="g/kg"    detect_missing_value="true" />
+          <field id="icetemp_cat"  long_name="Ice temperature per category"                      unit="degC"    detect_missing_value="true" />
+          <field id="snwtemp_cat"  long_name="Snow temperature per category"                     unit="degC"    detect_missing_value="true" />
+          <field id="icettop_cat"  long_name="Ice/snow surface temperature per category"         unit="degC"    detect_missing_value="true" />
+          <field id="iceapnd_cat"  long_name="Ice melt pond concentration per category"          unit=""        /> 
+          <field id="icehpnd_cat"  long_name="Ice melt pond thickness per category"              unit="m"       detect_missing_value="true" /> 
+          <field id="iceafpnd_cat" long_name="Ice melt pond fraction per category"               unit=""        /> 
+          <field id="icemask_cat"  long_name="Fraction of time step with sea ice (per category)" unit=""        />
+          <field id="iceage_cat"   long_name="Ice age per category"                              unit="days"    detect_missing_value="true" />
+          <field id="icebrv_cat"   long_name="Brine volume per category"                         unit="%"       detect_missing_value="true" />
+          <field id="icealb_cat"   long_name="Sea-ice or snow albedo"                            unit=""        detect_missing_value="true" />
+
+          <!-- Add-ons for SIMIP -->
+          <field id="iceconc_cat_cmip"     long_name="Sea-ice area fractions in thickness categories"  standard_name="sea_ice_area_fraction_over_categories" detect_missing_value="true" unit=""   > iceconc_cat      * icemask_cat + $missval * (1.-icemask_cat) </field>
+          <field id="icethic_cat_cmip"     long_name="Sea-ice thickness in thickness categories"       standard_name="sea_ice_thickness_over_categories"     detect_missing_value="true" unit="m"  > icethic_cat      * icemask_cat + $missval * (1.-icemask_cat) </field>
+          <field id="snwthic_cat_cmip"     long_name="Snow thickness in thickness categories"          standard_name="snow_thickness_over_categories"        detect_missing_value="true" unit="m"  > snwthic_cat      * icemask_cat + $missval * (1.-icemask_cat) </field>
+          <field id="iceconc_cat_pct_cmip" long_name="Sea-ice area fractions in thickness categories"  standard_name="sea_ice_area_fraction_over_categories" detect_missing_value="true" unit="%"  > iceconc_cat*100. * icemask_cat + $missval * (1.-icemask_cat) </field>
+
+	</field_group> <!-- SBC_3D -->
+	
 	<!-- scalar variables -->
-	<field_group id="SBC_0D"  grid_ref="grid_1point" >
+	<field_group id="SBC_scalar"  grid_ref="grid_scalar" >
+          <field id="NH_iceextt"      long_name="Sea ice extent North"                   standard_name="sea_ice_extent_n"                   unit="1e6_km2"  />
+          <field id="SH_iceextt"      long_name="Sea ice extent South"                   standard_name="sea_ice_extent_s"                   unit="1e6_km2"  />
+          <field id="NH_icevolu"      long_name="Sea ice volume North"                   standard_name="sea_ice_volume_n"                   unit="1e3_km3"  />
+          <field id="SH_icevolu"      long_name="Sea ice volume South"                   standard_name="sea_ice_volume_s"                   unit="1e3_km3"  />
+          <field id="NH_icearea"      long_name="Sea ice area North"                     standard_name="sea_ice_area_n"                     unit="1e6_km2"  />
+          <field id="SH_icearea"      long_name="Sea ice area South"                     standard_name="sea_ice_area_s"                     unit="1e6_km2"  />
+
           <!-- available with ln_icediaout -->
           <field id="ibgfrcvoltop"    long_name="global mean ice/snow forcing at interface ice/snow-atm (volume equivalent ocean volume)"   unit="km3"      />
@@ -281,15 +296,11 @@
           <field id="sbgheat_tot"     long_name="global mean snow heat content"                                                             unit="1e20J"    />
 
-          <field id="NH_iceextt"      long_name="Sea ice extent North"                   standard_name="sea_ice_extent_n"                   unit="1e6_km2"  />
-          <field id="SH_iceextt"      long_name="Sea ice extent South"                   standard_name="sea_ice_extent_s"                   unit="1e6_km2"  />
-          <field id="NH_icevolu"      long_name="Sea ice volume North"                   standard_name="sea_ice_volume_n"                   unit="1e3_km3"  />
-          <field id="SH_icevolu"      long_name="Sea ice volume South"                   standard_name="sea_ice_volume_s"                   unit="1e3_km3"  />
-          <field id="NH_icearea"      long_name="Sea ice area North"                     standard_name="sea_ice_area_n"                     unit="1e6_km2"  />
-          <field id="SH_icearea"      long_name="Sea ice area South"                     standard_name="sea_ice_area_s"                     unit="1e6_km2"  />
-
+	  <!-- available later -->
+	  <!--
           <field id="strait_mifl"     long_name="Sea ice mass flux through straits"      standard_name="sea_ice_mass_transport_across_line" unit="kg/s"  grid_ref="grid_4strait" />
           <field id="strait_arfl"     long_name="Sea ice area flux through straits"      standard_name="sea_ice_area_transport_across_line" unit="m2/s"  grid_ref="grid_4strait" />  
           <field id="strait_msfl"     long_name="Sea ice snow flux through straits"      standard_name="snow_mass_transport_across_line"    unit="kg/s"  grid_ref="grid_4strait" />
-	</field_group> <!-- SBC_0D -->
+          -->
+	</field_group>
   
 	<!-- 
@@ -299,10 +310,132 @@
       
 	<field_group id="myvarICE"        grid_ref="grid_T_2D" >
-          <field field_ref="icethic"          name="sithic"  />
-          <field field_ref="icevolu"          name="sivolu"  />
-          <field field_ref="iceconc"          name="siconc"  />
+	  <!-- ice mask -->
+	  <field field_ref="icemask"          name="simsk"   />
+	  <field field_ref="icemask05"        name="simsk05" />
+	  <field field_ref="icemask15"        name="simsk15" />
+	  
+	  <!-- general -->
+	  <field field_ref="snwvolu"          name="snvolu" />
+	  <field field_ref="snwthic"          name="snthic" />
+	  <field field_ref="icethic"          name="sithic" />
+<!--
+	  <field field_ref="icethic"          name="sithic_max" operation="maximum" />
+	  <field field_ref="icethic"          name="sithic_min" operation="minimum" />
+-->
+	  <field field_ref="fasticepres"      name="fasticepres" />
+	  <field field_ref="icevolu"          name="sivolu" />
+	  <field field_ref="iceconc"          name="siconc" />
+	  <field field_ref="icesalt"          name="sisali" />
+	  <field field_ref="iceapnd"          name="siapnd" />
+	  <field field_ref="icehpnd"          name="sihpnd" />
+	  <field field_ref="icevpnd"          name="sivpnd" />
+          <field field_ref="iceage"           name="siage"  />
+	  <field field_ref="sst_m"            name="sst_m"  />
+	  <field field_ref="sss_m"            name="sss_m"  />
+	  
+	  <!-- heat -->
+	  <field field_ref="icetemp"          name="sitemp" />
+	  <field field_ref="snwtemp"          name="sntemp" />
+	  <field field_ref="icettop"          name="sittop" />
+	  <field field_ref="icetbot"          name="sitbot" />
+	  <field field_ref="icetsni"          name="sitsni" />
+	  
+	  <!-- momentum -->
+	  <field field_ref="uice"             name="sivelu"  />
+	  <field field_ref="vice"             name="sivelv"  />
+	  <field field_ref="icevel"           name="sivelo"  />
+	  <field field_ref="utau_ai"          name="utau_ai" />
+	  <field field_ref="vtau_ai"          name="vtau_ai" />
+	  <field field_ref="utau_oi"          name="utau_oi" />
+	  <field field_ref="vtau_oi"          name="vtau_oi" />
+	  
+	  <!-- rheology -->
+	  <field field_ref="icediv"           name="sidive"  />
+	  <field field_ref="iceshe"           name="sishea"  />
+	  <field field_ref="icestr"           name="sistre"  />
+	  <field field_ref="normstr"          name="normstr" />
+	  <field field_ref="sheastr"          name="sheastr" />
+	  <field field_ref="isig1"            name="isig1"   />
+	  <field field_ref="isig2"            name="isig2"   />
+	  <field field_ref="isig3"            name="isig3"   />
+	  
+	  <!-- heat fluxes -->
+	  <field field_ref="qt_oce_ai"        name="qt_oce_ai"  />
+	  <field field_ref="qt_atm_oi"        name="qt_atm_oi"  />
+	  <field field_ref="qtr_ice_top"      name="qtr_ice_top"/>
+	  <field field_ref="qtr_ice_bot"      name="qtr_ice_bot"/>
+	  <field field_ref="qt_ice"           name="qt_ice"     />
+	  <field field_ref="qsr_ice"          name="qsr_ice"    />
+	  <field field_ref="qns_ice"          name="qns_ice"    />
+	  <field field_ref="qemp_ice"         name="qemp_ice"   />
+	  <field field_ref="albedo"           name="albedo"     />
+          <field field_ref="icealb"           name="icealb"     />
+	  
+	  <field field_ref="hfxcndtop"        name="hfxcndtop"  />
+	  <field field_ref="hfxcndbot"        name="hfxcndbot"  />
+	  <field field_ref="hfxsensib"        name="hfxsensib"  />
+
+	  <field field_ref="icehc"         name="icehc"  />
+	  <field field_ref="snwhc"         name="snwhc"  />
+	  <field field_ref="hfxbog"        name="hfxbog"  />
+	  <field field_ref="hfxbom"        name="hfxbom"  />
+	  <field field_ref="hfxsum"        name="hfxsum"  />
+	  <field field_ref="hfxopw"        name="hfxopw"  />
+	  <field field_ref="hfxdif"        name="hfxdif"  />
+	  <field field_ref="hfxsnw"        name="hfxsnw"  />
+	  <field field_ref="hfxerr"        name="hfxerr"  />
+	  <field field_ref="hfxthd"        name="hfxthd"  />
+	  <field field_ref="hfxdyn"        name="hfxdyn"  />
+	  <field field_ref="hfxres"        name="hfxres"  />
+	  <field field_ref="hfxsub"        name="hfxsub"  />
+	  <field field_ref="hfxspr"        name="hfxspr"  />
+
+<!--
+	  <field field_ref="hfxdhc"        name="hfxbudget"  operation="average" freq_op="1d" > @qt_atm_oi - @qt_oce_ai -@hfxdhc </field>
+-->
+	  
+	  <!-- salt fluxes -->
+	  <field field_ref="sfxice"           name="sfxice" />
+	  
+	  <!-- mass fluxes -->
+	  <field field_ref="vfxice"           name="vfxice" />
+	  <field field_ref="vfxsnw"           name="vfxsnw" />
+
+	  <field field_ref="vfxbom"           name="vfxbom" />
+	  <field field_ref="vfxbog"           name="vfxbog" />
+	  <field field_ref="vfxsum"           name="vfxsum" />
+	  <field field_ref="vfxopw"           name="vfxopw" />
+	  <field field_ref="vfxlam"           name="vfxlam" />
+	  <field field_ref="vfxsni"           name="vfxsni" />
+	  <field field_ref="vfxdyn"           name="vfxdyn" />
+	  <field field_ref="vfxres"           name="vfxres" />
+	  <field field_ref="vfxpnd"           name="vfxpnd" />
+	  <field field_ref="vfxsub"           name="vfxsub" />
+	  <field field_ref="vfxsub_err"       name="vfxsub_err" />
+          <field field_ref="vfxthin"          name="vfxthin" />
+	
+	  <!-- diag error for negative ice volume after advection -->
+	  <field field_ref="iceneg_pres"      name="sineg_pres" />
+	  <field field_ref="iceneg_volu"      name="sineg_volu" />
+	  <field field_ref="iceneg_hfx"       name="sineg_hfx"  />
+        </field_group>
+
+
+        <field_group id="myvarICE_cat"        grid_ref="grid_T_ncatice" >
+
+	  <!-- categories -->
+	  <field field_ref="icemask_cat"      name="simskcat"/>
+	  <field field_ref="snwthic_cat"      name="snthicat"/>
+	  <field field_ref="iceconc_cat"      name="siconcat"/>
+	  <field field_ref="icethic_cat"      name="sithicat"/>
+	  <field field_ref="icesalt_cat"      name="sisalcat"/>
+	  <field field_ref="icetemp_cat"      name="sitemcat"/>
+	  <field field_ref="snwtemp_cat"      name="sntemcat"/>
+	  <field field_ref="icettop_cat"      name="sitopcat"/>
+
 	</field_group>    
 
-	<field_group id="ICE_globalbudget"  grid_ref="grid_1point" >
+	<field_group id="ICE_globalbudget"  grid_ref="grid_scalar" >
+	  <!-- global contents -->
     	  <field field_ref="ibgvol_tot"       name="ibgvol_tot"   />
 	  <field field_ref="sbgvol_tot"       name="sbgvol_tot"   />
@@ -312,9 +445,11 @@
     	  <field field_ref="sbgheat_tot"      name="sbgheat_tot"  />
 
-     	  <field field_ref="ibgvolume"        name="ibgvolume"    />
+	  <!-- global drifts (conservation checks) -->
+	  <field field_ref="ibgvolume"        name="ibgvolume"    />
     	  <field field_ref="ibgsaltco"        name="ibgsaltco"    />
     	  <field field_ref="ibgheatco"        name="ibgheatco"    />
           <field field_ref="ibgheatfx"        name="ibgheatfx"    />
 
+	  <!-- global forcings  -->
     	  <field field_ref="ibgfrcvoltop"     name="ibgfrcvoltop" />
     	  <field field_ref="ibgfrcvolbot"     name="ibgfrcvolbot" />
@@ -333,5 +468,5 @@
 
 	<!-- SIMIP monthly scalar variables -->
-	<field_group id="SImon_scalars"   grid_ref="grid_1point" >
+	<field_group id="SImon_scalars"   grid_ref="grid_scalar" >
           <!-- Integrated quantities -->
           <field field_ref="NH_iceextt"       name="siextentn"    />
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-oce.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-oce.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-oce.xml	(revision 12143)
@@ -356,7 +356,4 @@
 	</field_group>
 	
-	<!-- scalar variables -->
-	<field_group id="SBC_0D"  grid_ref="grid_1point" >
-	</field_group>
 
       </field_group> <!-- SBC -->
@@ -513,5 +510,5 @@
       <field id="ahmf_3d"      long_name=" 3D      f-eddy viscosity coefficient"   unit="m2/s or m4/s"  grid_ref="grid_T_3D"/>
 
-      <field_group id="scalar"  grid_ref="grid_T_2D"  >
+      <field_group id="scalar"  grid_ref="grid_scalar"  >
       	<!-- Need to have a salinity reference climatological file : sali_ref_clim_monthly -->
         <field id="voltot"     long_name="global total volume"                          standard_name="sea_water_volume"                               unit="m3"   />
@@ -540,5 +537,5 @@
       </field_group>
       
-      <!-- variables available with key_float -->
+      <!-- variables available with ln_floats -->
 
       <field_group id="floatvar" grid_ref="grid_T_nfloat"  operation="instant" >
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-pisces.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-pisces.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/field_def_nemo-pisces.xml	(revision 12143)
@@ -290,5 +290,5 @@
      </field_group>
 
-     <field_group id="tracer_scalar"  grid_ref="grid_T_2D"  >
+     <field_group id="tracer_scalar"  grid_ref="grid_scalar"  >
      <!-- PISCES scalar  -->
        <field id="pno3tot"         long_name="Global mean nitrate concentration"                  unit="mol/m3"   />
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/grid_def_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/grid_def_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/grid_def_nemo.xml	(revision 12143)
@@ -7,5 +7,5 @@
        </grid>
         <!--  -->
-       <grid id="grid_T_3D_ncatice" >
+       <grid id="grid_T_ncatice" >
          <domain id="grid_T" />
          <axis id="ncatice" />
@@ -49,12 +49,12 @@
        </grid>
         <!--  -->
-       <grid id="grid_1point" >
-         <domain domain_ref="1point"/>
-       </grid>
-        <!--  -->
        <grid id="grid_T_nfloat" >
          <domain id="grid_T" />
          <axis id="nfloat" />
        </grid>
+      <!-- scalars -->
+      <grid id="grid_scalar" >
+        <scalar/>
+      </grid>
 
     </grid_definition>
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_ice_ref
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_ice_ref	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_ice_ref	(revision 12143)
@@ -56,12 +56,9 @@
    rn_ishlat        =   2.            !  lbc : free slip (0) ; partial slip (0-2) ; no slip (2) ; strong slip (>2)
    ln_landfast_L16  = .false.         !  landfast: parameterization from Lemieux 2016
-   ln_landfast_home = .false.         !  landfast: parameterization from "home made"
       rn_depfra     =   0.125         !        fraction of ocean depth that ice must reach to initiate landfast
-                                      !          recommended range: [0.1 ; 0.25] - L16=0.125 - home=0.15
-      rn_icebfr     =  15.            !        ln_landfast_L16:  maximum bottom stress per unit volume [N/m3]
-                                      !        ln_landfast_home: maximum bottom stress per unit area of contact [N/m2]
-                                      !          recommended range: ?? L16=15 - home=10
+                                      !          recommended range: [0.1 ; 0.25]
+      rn_icebfr     =  15.            !        maximum bottom stress per unit volume [N/m3]
       rn_lfrelax    =   1.e-5         !        relaxation time scale to reach static friction [s-1]
-      rn_tensile    =   0.2           !        ln_landfast_L16: isotropic tensile strength
+      rn_tensile    =   0.05          !        isotropic tensile strength [0-0.5??]
 /
 !------------------------------------------------------------------------------
@@ -94,5 +91,5 @@
 !------------------------------------------------------------------------------
    ln_rhg_EVP       = .true.          !  EVP rheology
-      ln_aEVP       = .false.         !     adaptive rheology (Kimmritz et al. 2016 & 2017)
+      ln_aEVP       = .true.          !     adaptive rheology (Kimmritz et al. 2016 & 2017)
       rn_creepl     =   2.0e-9        !     creep limit [1/s]
       rn_ecc        =   2.0           !     eccentricity of the elliptical yield curve          
@@ -104,6 +101,6 @@
 &namdyn_adv     !   Ice advection
 !------------------------------------------------------------------------------
-   ln_adv_Pra       = .false.         !  Advection scheme (Prather)
-   ln_adv_UMx       = .true.          !  Advection scheme (Ultimate-Macho)
+   ln_adv_Pra       = .true.         !  Advection scheme (Prather)
+   ln_adv_UMx       = .false.          !  Advection scheme (Ultimate-Macho)
       nn_UMx        =   5             !     order of the scheme for UMx (1-5 ; 20=centered 2nd order)
 /
@@ -178,9 +175,10 @@
 &namthd_pnd     !   Melt ponds
 !------------------------------------------------------------------------------
-   ln_pnd_H12       = .false.         !  activate evolutive melt ponds (from Holland et al 2012)
-   ln_pnd_CST       = .false.         !  activate constant  melt ponds
-      rn_apnd       =   0.2           !     prescribed pond fraction, at Tsu=0 degC
-      rn_hpnd       =   0.05          !     prescribed pond depth,    at Tsu=0 degC
-   ln_pnd_alb       = .false.         !  melt ponds affect albedo or not
+   ln_pnd           = .false.         !  activate melt ponds or not
+     ln_pnd_H12     = .false.         !  activate evolutive melt ponds (from Holland et al 2012)
+     ln_pnd_CST     = .false.         !  activate constant  melt ponds
+       rn_apnd      =   0.2           !     prescribed pond fraction, at Tsu=0 degC
+       rn_hpnd      =   0.05          !     prescribed pond depth,    at Tsu=0 degC
+     ln_pnd_alb     = .false.         !  melt ponds affect albedo or not
 /
 !------------------------------------------------------------------------------
@@ -189,22 +187,34 @@
    ln_iceini        = .true.          !  activate ice initialization (T) or not (F)
    ln_iceini_file   = .false.         !  netcdf file provided for initialization (T) or not (F)
-   rn_thres_sst     =   2.0           !  max delta temp. above Tfreeze with initial ice = (sst - tfreeze)
-   rn_hts_ini_n     =   0.3           !  initial real snow thickness (m), North
+   rn_thres_sst     =   2.0           !  max temp. above Tfreeze with initial ice = (sst - tfreeze)
+   rn_hti_ini_n     =   3.0           !  initial ice thickness       (m), North
+   rn_hti_ini_s     =   1.0           !        "            "             South
+   rn_hts_ini_n     =   0.3           !  initial snow thickness      (m), North
    rn_hts_ini_s     =   0.3           !        "            "             South
-   rn_hti_ini_n     =   3.0           !  initial real ice thickness  (m), North
-   rn_hti_ini_s     =   1.0           !        "            "             South
    rn_ati_ini_n     =   0.9           !  initial ice concentration   (-), North
    rn_ati_ini_s     =   0.9           !        "            "             South
    rn_smi_ini_n     =   6.3           !  initial ice salinity     (g/kg), North
    rn_smi_ini_s     =   6.3           !        "            "             South
-   rn_tmi_ini_n     = 270.            !  initial ice/snw temperature (K), North
+   rn_tmi_ini_n     = 270.            !  initial ice temperature     (K), North
    rn_tmi_ini_s     = 270.            !        "            "             South
-
+   rn_tsu_ini_n     = 270.            !  initial surface temperature (K), North
+   rn_tsu_ini_s     = 270.            !        "            "             South
+   rn_tms_ini_n     = 270.            !  initial snw temperature     (K), North
+   rn_tms_ini_s     = 270.            !        "            "             South
+   rn_apd_ini_n     =   0.2           !  initial pond fraction       (-), North
+   rn_apd_ini_s     =   0.2           !        "            "             South
+   rn_hpd_ini_n     =   0.05          !  initial pond depth          (m), North
+   rn_hpd_ini_s     =   0.05          !        "            "             South
+   ! -- for ln_iceini_file = T
    sn_hti = 'Ice_initialization'    , -12 ,'hti'   ,  .false.  , .true., 'yearly'  , '' , '', ''
    sn_hts = 'Ice_initialization'    , -12 ,'hts'   ,  .false.  , .true., 'yearly'  , '' , '', ''
    sn_ati = 'Ice_initialization'    , -12 ,'ati'   ,  .false.  , .true., 'yearly'  , '' , '', ''
+   sn_smi = 'Ice_initialization'    , -12 ,'smi'   ,  .false.  , .true., 'yearly'  , '' , '', ''
+   sn_tmi = 'Ice_initialization'    , -12 ,'tmi'   ,  .false.  , .true., 'yearly'  , '' , '', ''
    sn_tsu = 'Ice_initialization'    , -12 ,'tsu'   ,  .false.  , .true., 'yearly'  , '' , '', ''
-   sn_tmi = 'Ice_initialization'    , -12 ,'tmi'   ,  .false.  , .true., 'yearly'  , '' , '', ''
-   sn_smi = 'Ice_initialization'    , -12 ,'smi'   ,  .false.  , .true., 'yearly'  , '' , '', ''
+   sn_tms = 'NOT USED'              , -12 ,'tms'   ,  .false.  , .true., 'yearly'  , '' , '', ''
+   !      melt ponds (be careful, sn_apd is the pond concentration (not fraction), so it differs from rn_apd)
+   sn_apd = 'NOT USED'              , -12 ,'apd'   ,  .false.  , .true., 'yearly'  , '' , '', ''
+   sn_hpd = 'NOT USED'              , -12 ,'hpd'   ,  .false.  , .true., 'yearly'  , '' , '', ''
    cn_dir='./'
 /
@@ -222,5 +232,8 @@
 &namdia         !   Diagnostics
 !------------------------------------------------------------------------------
-   ln_icediachk     = .false.         !  check online the heat, mass & salt budgets (T) or not (F)
+   ln_icediachk     = .false.         !  check online heat, mass & salt budgets
+      !                               !   rate of ice spuriously gained/lost at each time step => rn_icechk=1 <=> 1.e-6 m/hour
+      rn_icechk_cel =  100.           !     check at each gridcell          (1.e-4m/h)=> stops the code if violated (and writes a file)
+      rn_icechk_glo =  1.             !     check over the entire ice cover (1.e-6m/h)=> only prints warnings
    ln_icediahsb     = .false.         !  output the heat, mass & salt budgets (T) or not (F)
    ln_icectl        = .false.         !  ice points output for debug (T or F)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_pisces_ref
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_pisces_ref	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_pisces_ref	(revision 12143)
@@ -34,6 +34,6 @@
 !              !  file name   ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !              !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_patm     = 'presatm'    ,     -1            , 'patm'    ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
-   sn_atmco2   = 'presatmco2' ,     -1            , 'xco2'    ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
+   sn_patm     = 'presatm'    ,     -1.           , 'patm'    ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
+   sn_atmco2   = 'presatmco2' ,     -1.           , 'xco2'    ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
    cn_dir      = './'     !  root directory for the location of the dynamical files
 !
@@ -141,5 +141,5 @@
 !              !  file name       ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                  !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_par      = 'par.orca'       ,     24            , 'fr_par'  ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
+   sn_par      = 'par.orca'       ,     24.           , 'fr_par'  ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
    cn_dir      = './'      !  root directory for the location of the dynamical files
    ln_varpar   =  .true.   ! boolean for PAR variable
@@ -347,16 +347,16 @@
 !              !  file name        ! frequency (hours) ! variable      ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                   !  (if <0  months)  !   name        !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_dust     = 'dust.orca'       ,     -1            , 'dust'        ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_solub    = 'solubility.orca' ,    -12            , 'solubility1' ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdic = 'river.orca'      ,    120            , 'riverdic'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdoc = 'river.orca'      ,    120            , 'riverdoc'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdin = 'river.orca'      ,    120            , 'riverdin'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdon = 'river.orca'      ,    120            , 'riverdon'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdip = 'river.orca'      ,    120            , 'riverdip'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdop = 'river.orca'      ,    120            , 'riverdop'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdsi = 'river.orca'      ,    120            , 'riverdsi'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_ndepo    = 'ndeposition.orca',    -12            , 'ndep'        ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
-   sn_ironsed  = 'bathy.orca'      ,    -12            , 'bathy'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
-   sn_hydrofe  = 'hydrofe.orca'    ,    -12            , 'epsdb'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+   sn_dust     = 'dust.orca'       ,     -1.           , 'dust'        ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_solub    = 'solubility.orca' ,    -12.           , 'solubility1' ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdic = 'river.orca'      ,    120.           , 'riverdic'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdoc = 'river.orca'      ,    120.           , 'riverdoc'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdin = 'river.orca'      ,    120.           , 'riverdin'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdon = 'river.orca'      ,    120.           , 'riverdon'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdip = 'river.orca'      ,    120.           , 'riverdip'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdop = 'river.orca'      ,    120.           , 'riverdop'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdsi = 'river.orca'      ,    120.           , 'riverdsi'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_ndepo    = 'ndeposition.orca',    -12.           , 'ndep'        ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+   sn_ironsed  = 'bathy.orca'      ,    -12.           , 'bathy'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+   sn_hydrofe  = 'hydrofe.orca'    ,    -12.           , 'epsdb'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
 !
    cn_dir      = './'      !  root directory for the location of the dynamical files
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_ref
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_ref	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_ref	(revision 12143)
@@ -50,11 +50,15 @@
       cn_ocerst_indir = "."         !  directory from which to read input ocean restarts
       cn_ocerst_out   = "restart"   !  suffix of ocean restart name (output)
-      cn_ocerst_outdir = "."         !  directory in which to write output ocean restarts
+      cn_ocerst_outdir = "."        !  directory in which to write output ocean restarts
    nn_istate   =       1   !  output the initial state (1) or not (0)
    ln_rst_list = .false.   !  output restarts at list of times using nn_stocklist (T) or at set frequency with nn_stock (F)
-   nn_stock    =    5840   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_stock    =       0   !  used only if ln_rst_list = F: output restart freqeuncy (modulo referenced to 1)
+      !                          !    =  0 force to write restart files only at the end of the run
+      !                          !    = -1 do not do any restart
    nn_stocklist = 0,0,0,0,0,0,0,0,0,0 ! List of timesteps when a restart file is to be written
-   nn_write    =    5840   !  frequency of write in the output file   (modulo referenced to nn_it000)
-   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   nn_write    =       0   !  used only if key_iomput is not defined: output frequency (modulo referenced to nn_it000)
+      !                          !    =  0 force to write output files only at the end of the run
+      !                          !    = -1 do not do any output file
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs
    ln_cfmeta   = .false.   !  output additional data to netCDF files required for compliance with the CF metadata standard
    ln_clobber  = .true.    !  clobber (overwrite) an existing file
@@ -105,6 +109,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem = 'data_1m_potential_temperature_nomask',  -1      , 'votemper',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_sal = 'data_1m_salinity_nomask'             ,  -1      , 'vosaline',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_tem = 'data_1m_potential_temperature_nomask',  -1.     , 'votemper',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_sal = 'data_1m_salinity_nomask'             ,  -1.     , 'vosaline',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
 /
 !-----------------------------------------------------------------------
@@ -161,6 +165,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_ucur     = 'ucurrent'              ,         -1        ,'u_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Ume'   , ''
-   sn_vcur     = 'vcurrent'              ,         -1        ,'v_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Vme'   , ''
+   sn_ucur     = 'ucurrent'              ,         -1.       ,'u_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Ume'   , ''
+   sn_vcur     = 'vcurrent'              ,         -1.       ,'v_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Vme'   , ''
 /
 
@@ -234,9 +238,9 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_utau     = 'utau'                  ,        24         , 'utau'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
-   sn_vtau     = 'vtau'                  ,        24         , 'vtau'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
-   sn_qtot     = 'qtot'                  ,        24         , 'qtot'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
-   sn_qsr      = 'qsr'                   ,        24         , 'qsr'     , .false.     , .false., 'yearly'  , ''               , ''       , ''
-   sn_emp      = 'emp'                   ,        24         , 'emp'     , .false.     , .false., 'yearly'  , ''               , ''       , ''
+   sn_utau     = 'utau'                  ,        24.        , 'utau'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
+   sn_vtau     = 'vtau'                  ,        24.        , 'vtau'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
+   sn_qtot     = 'qtot'                  ,        24.        , 'qtot'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
+   sn_qsr      = 'qsr'                   ,        24.        , 'qsr'     , .false.     , .false., 'yearly'  , ''               , ''       , ''
+   sn_emp      = 'emp'                   ,        24.        , 'emp'     , .false.     , .false., 'yearly'  , ''               , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -263,13 +267,13 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !       weights filename               ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6         , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
-   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6         , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
-   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_tair     = 't_10.15JUNE2009_fill'       ,    6         , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6         , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1         , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1         , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_slp      = 'slp.15JUNE2009_fill'        ,    6         , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6.        , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6.        , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,    6.        , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6.        , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_slp      = 'slp.15JUNE2009_fill'        ,    6.        , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
    sn_tdif     = 'taudif_core'                ,   24         , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
 /
@@ -281,5 +285,4 @@
    !                       !   -> file cplmask.nc with the float variable called cplmask (jpi,jpj,nn_cplmodel)
    nn_cats_cpl   =     5   !  Number of sea ice categories over which coupling is to be carried out (if not 1)
-
    !_____________!__________________________!____________!_____________!______________________!________!
    !             !        description       !  multiple  !    vector   !       vector         ! vector !
@@ -318,5 +321,5 @@
    sn_rcv_wper   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
    sn_rcv_wnum   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
-   sn_rcv_wstrf  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_wfreq  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
    sn_rcv_wdrag  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
    sn_rcv_ts_ice =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
@@ -338,11 +341,11 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_usp      = 'sas_grid_U'            ,       120         , 'uos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_vsp      = 'sas_grid_V'            ,       120         , 'vos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_tem      = 'sas_grid_T'            ,       120         , 'sosstsst',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_sal      = 'sas_grid_T'            ,       120         , 'sosaline',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_ssh      = 'sas_grid_T'            ,       120         , 'sossheig',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_e3t      = 'sas_grid_T'            ,       120         , 'e3t_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_frq      = 'sas_grid_T'            ,       120         , 'frq_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_usp      = 'sas_grid_U'            ,       120.        , 'uos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_vsp      = 'sas_grid_V'            ,       120.        , 'vos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_tem      = 'sas_grid_T'            ,       120.        , 'sosstsst',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_sal      = 'sas_grid_T'            ,       120.        , 'sosaline',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_ssh      = 'sas_grid_T'            ,       120.        , 'sossheig',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_e3t      = 'sas_grid_T'            ,       120.        , 'e3t_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_frq      = 'sas_grid_T'            ,       120.        , 'frq_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
 /
 !-----------------------------------------------------------------------
@@ -372,5 +375,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_chl      ='chlorophyll'            ,        -1         , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_chl      ='chlorophyll'            ,        -1.        , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -389,6 +392,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_sst      = 'sst_data'              ,        24         ,  'sst'    ,    .false.  , .false., 'yearly'  ,    ''            ,    ''    ,     ''
-   sn_sss      = 'sss_data'              ,        -1         ,  'sss'    ,    .true.   , .true. , 'yearly'  ,    ''            ,    ''    ,     ''
+   sn_sst      = 'sst_data'              ,        24.        ,  'sst'    ,    .false.  , .false., 'yearly'  ,    ''            ,    ''    ,     ''
+   sn_sss      = 'sss_data'              ,        -1.        ,  'sss'    ,    .true.   , .true. , 'yearly'  ,    ''            ,    ''    ,     ''
 /
 !-----------------------------------------------------------------------
@@ -411,9 +414,9 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_rnf      = 'runoff_core_monthly'   ,        -1         , 'sorunoff',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
-   sn_cnf      = 'runoff_core_monthly'   ,         0         , 'socoefr0',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_s_rnf    = 'runoffs'               ,        24         , 'rosaline',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
-   sn_t_rnf    = 'runoffs'               ,        24         , 'rotemper',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
-   sn_dep_rnf  = 'runoffs'               ,         0         , 'rodepth' ,   .false.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_rnf      = 'runoff_core_monthly'   ,        -1.        , 'sorunoff',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_cnf      = 'runoff_core_monthly'   ,         0.        , 'socoefr0',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_s_rnf    = 'runoffs'               ,        24.        , 'rosaline',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_t_rnf    = 'runoffs'               ,        24.        , 'rotemper',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_dep_rnf  = 'runoffs'               ,         0.        , 'rodepth' ,   .false.   , .true. , 'yearly'  , ''               , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -428,5 +431,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_apr      = 'patm'                  ,         -1        ,'somslpre' ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,      ''
+   sn_apr      = 'patm'                  ,         -1.       ,'somslpre' ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,      ''
 /
 !-----------------------------------------------------------------------
@@ -503,14 +506,14 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_cdg      =  'sdw_ecwaves_orca2'    ,        6          , 'drag_coeff' ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_usd      =  'sdw_ecwaves_orca2'    ,        6          , 'u_sd2d'     ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_vsd      =  'sdw_ecwaves_orca2'    ,        6          , 'v_sd2d'     ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_hsw      =  'sdw_ecwaves_orca2'    ,        6          , 'hs'         ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_wmp      =  'sdw_ecwaves_orca2'    ,        6          , 'wmp'        ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_wfr      =  'sdw_ecwaves_orca2'    ,        6          , 'wfr'        ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_wnum     =  'sdw_ecwaves_orca2'    ,        6          , 'wave_num'   ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_tauwoc   =  'sdw_ecwaves_orca2'    ,        6          , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_tauwx    =  'sdw_ecwaves_orca2'    ,        6          , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_tauwy    =  'sdw_ecwaves_orca2'    ,        6          , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_cdg      =  'sdw_ecwaves_orca2'    ,        6.         , 'drag_coeff' ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_usd      =  'sdw_ecwaves_orca2'    ,        6.         , 'u_sd2d'     ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_vsd      =  'sdw_ecwaves_orca2'    ,        6.         , 'v_sd2d'     ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_hsw      =  'sdw_ecwaves_orca2'    ,        6.         , 'hs'         ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_wmp      =  'sdw_ecwaves_orca2'    ,        6.         , 'wmp'        ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_wfr      =  'sdw_ecwaves_orca2'    ,        6.         , 'wfr'        ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_wnum     =  'sdw_ecwaves_orca2'    ,        6.         , 'wave_num'   ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_tauwoc   =  'sdw_ecwaves_orca2'    ,        6.         , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_tauwx    =  'sdw_ecwaves_orca2'    ,        6.         , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_tauwy    =  'sdw_ecwaves_orca2'    ,        6.         , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -552,5 +555,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_icb     =  'calving'              ,         -1         ,'calvingmask',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_icb     =  'calving'              ,         -1.        ,'calvingmask',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
 /
 
@@ -618,37 +621,49 @@
    nn_ice_dta    =  0         !  = 0, bdy data are equal to the initial state
    !                          !  = 1, bdy data are read in 'bdydata   .nc' files
-   rn_ice_tem    = 270.       !  si3 only: arbitrary temperature of incoming sea ice
-   rn_ice_sal    = 10.        !  si3 only:      --   salinity           --
-   rn_ice_age    = 30.        !  si3 only:      --   age                --
    !
    ln_tra_dmp    =.false.     !  open boudaries conditions for tracers
    ln_dyn3d_dmp  =.false.     !  open boundary condition for baroclinic velocities
    rn_time_dmp   =  1.        !  Damping time scale in days
-   rn_time_dmp_out = 1.        !  Outflow damping time scale
+   rn_time_dmp_out = 1.       !  Outflow damping time scale
    nn_rimwidth   = 10         !  width of the relaxation zone
    ln_vol        = .false.    !  total volume correction (see nn_volctl parameter)
    nn_volctl     =  1         !  = 0, the total water flux across open boundaries is zero
-   nb_jpk_bdy    = -1         ! number of levels in the bdy data (set < 0 if consistent with planned run)
 /
 !-----------------------------------------------------------------------
 &nambdy_dta    !  open boundaries - external data                       (see nam_bdy)
 !-----------------------------------------------------------------------
-   ln_full_vel = .false.      !  ???
-
+   ln_zinterp  = .false.      !  T if a vertical interpolation is required. Variables gdep[tuv] and e3[tuv] must exist in the file
+   !                          !  automatically defined to T if the number of vertical levels in bdy dta /= jpk
+   ln_full_vel = .false.      !  T if [uv]3d are "full" velocities and not only its baroclinic components
+   !                          !  in this case, baroclinic and barotropic velocities will be recomputed -> [uv]2d not needed
+   !
    cn_dir      = 'bdydta/'    !  root directory for the BDY data location
    !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   bn_ssh      = 'amm12_bdyT_u2d'        ,         24        , 'sossheig',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_u2d      = 'amm12_bdyU_u2d'        ,         24        , 'vobtcrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_v2d      = 'amm12_bdyV_u2d'        ,         24        , 'vobtcrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_u3d      = 'amm12_bdyU_u3d'        ,         24        , 'vozocrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_v3d      = 'amm12_bdyV_u3d'        ,         24        , 'vomecrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_tem      = 'amm12_bdyT_tra'        ,         24        , 'votemper',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_sal      = 'amm12_bdyT_tra'        ,         24        , 'vosaline',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_ssh      = 'amm12_bdyT_u2d'        ,         24.       , 'sossheig',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_u2d      = 'amm12_bdyU_u2d'        ,         24.       , 'vobtcrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_v2d      = 'amm12_bdyV_u2d'        ,         24.       , 'vobtcrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_u3d      = 'amm12_bdyU_u3d'        ,         24.       , 'vozocrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_v3d      = 'amm12_bdyV_u3d'        ,         24.       , 'vomecrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_tem      = 'amm12_bdyT_tra'        ,         24.       , 'votemper',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_sal      = 'amm12_bdyT_tra'        ,         24.       , 'vosaline',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
 !* for si3
-!   bn_a_i     = 'amm12_bdyT_ice'        ,         24        , 'ileadfra',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-!   bn_h_i     = 'amm12_bdyT_ice'        ,         24        , 'iicethic',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-!   bn_h_s     = 'amm12_bdyT_ice'        ,         24        , 'isnowthi',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_a_i      = 'amm12_bdyT_ice'        ,         24.       , 'siconc'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_h_i      = 'amm12_bdyT_ice'        ,         24.       , 'sithic'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_h_s      = 'amm12_bdyT_ice'        ,         24.       , 'snthic'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_t_i      = 'NOT USED'              ,         24.       , 'sitemp'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_t_s      = 'NOT USED'              ,         24.       , 'sntemp'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_tsu      = 'NOT USED'              ,         24.       , 'sittop'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_s_i      = 'NOT USED'              ,         24.       , 'sisalt'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   ! melt ponds (be careful, bn_aip is the pond concentration (not fraction), so it differs from rn_iceapnd)
+   bn_aip      = 'NOT USED'              ,         24.       , 'siapnd'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_hip      = 'NOT USED'              ,         24.       , 'sihpnd'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   ! if bn_t_i etc are "not used", then define arbitrary temperatures and salinity and ponds
+   rn_ice_tem  = 270.         !  arbitrary temperature               of incoming sea ice
+   rn_ice_sal  = 10.          !       --   salinity                            --
+   rn_ice_age  = 30.          !       --   age                                 --
+   rn_ice_apnd = 0.2          !       --   pond fraction = a_ip/a_i            --
+   rn_ice_hpnd = 0.05         !       --   pond depth                          --
 /
 !-----------------------------------------------------------------------
@@ -964,18 +979,18 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem      = 'dyna_grid_T'           ,       120         , 'votemper'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_sal      = 'dyna_grid_T'           ,       120         , 'vosaline'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_mld      = 'dyna_grid_T'           ,       120         , 'somixhgt'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_emp      = 'dyna_grid_T'           ,       120         , 'sowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_fmf      = 'dyna_grid_T'           ,       120         , 'iowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_ice      = 'dyna_grid_T'           ,       120         , 'soicecov'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_qsr      = 'dyna_grid_T'           ,       120         , 'soshfldo'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_wnd      = 'dyna_grid_T'           ,       120         , 'sowindsp'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_uwd      = 'dyna_grid_U'           ,       120         , 'uocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_vwd      = 'dyna_grid_V'           ,       120         , 'vocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_wwd      = 'dyna_grid_W'           ,       120         , 'wocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_avt      = 'dyna_grid_W'           ,       120         , 'voddmavs'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_ubl      = 'dyna_grid_U'           ,       120         , 'sobblcox'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_vbl      = 'dyna_grid_V'           ,       120         , 'sobblcoy'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_tem      = 'dyna_grid_T'           ,       120.        , 'votemper'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_sal      = 'dyna_grid_T'           ,       120.        , 'vosaline'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_mld      = 'dyna_grid_T'           ,       120.        , 'somixhgt'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_emp      = 'dyna_grid_T'           ,       120.        , 'sowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_fmf      = 'dyna_grid_T'           ,       120.        , 'iowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_ice      = 'dyna_grid_T'           ,       120.        , 'soicecov'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_qsr      = 'dyna_grid_T'           ,       120.        , 'soshfldo'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_wnd      = 'dyna_grid_T'           ,       120.        , 'sowindsp'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_uwd      = 'dyna_grid_U'           ,       120.        , 'uocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_vwd      = 'dyna_grid_V'           ,       120.        , 'vocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_wwd      = 'dyna_grid_W'           ,       120.        , 'wocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_avt      = 'dyna_grid_W'           ,       120.        , 'voddmavs'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_ubl      = 'dyna_grid_U'           ,       120.        , 'sobblcox'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_vbl      = 'dyna_grid_V'           ,       120.        , 'sobblcoy'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
 /
 
@@ -1122,7 +1137,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
@@ -1159,5 +1174,5 @@
 &namhsb        !  Heat and salt budgets                                 (default: OFF)
 !-----------------------------------------------------------------------
-   ln_diahsb   = .false.   !  check the heat and salt budgets (T) or not (F)
+   ln_diahsb   = .false.   !  output the heat and salt budgets (T) or not (F)
 /
 !-----------------------------------------------------------------------
@@ -1168,34 +1183,37 @@
 /
 !-----------------------------------------------------------------------
-&namflo        !   float parameters                                     ("key_float")
-!-----------------------------------------------------------------------
-   jpnfl       = 1         !  total number of floats during the run
-   jpnnewflo   = 0         !  number of floats for the restart
-   ln_rstflo   = .false.   !  float restart (T) or not (F)
-   nn_writefl  =      75   !  frequency of writing in float output file
-   nn_stockfl  =    5475   !  frequency of creation of the float restart file
-   ln_argo     = .false.   !  Argo type floats (stay at the surface each 10 days)
-   ln_flork4   = .false.   !  trajectories computed with a 4th order Runge-Kutta (T)
-   !                       !  or computed with Blanke' scheme (F)
-   ln_ariane   = .true.    !  Input with Ariane tool convention(T)
-   ln_flo_ascii = .true.    !  Output with Ariane tool netcdf convention(F) or ascii file (T)
-/
-!-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents              ("key_diaharm")
-!-----------------------------------------------------------------------
-    nit000_han = 1         ! First time step used for harmonic analysis
-    nitend_han = 75        ! Last time step used for harmonic analysis
-    nstep_han  = 15        ! Time step frequency for harmonic analysis
-    tname(1)   = 'M2'      ! Name of tidal constituents
-    tname(2)   = 'K1'
-/
-!-----------------------------------------------------------------------
-&namdct        ! transports through some sections                       ("key_diadct")
-!-----------------------------------------------------------------------
-    nn_dct     = 15        !  time step frequency for transports computing
-    nn_dctwri  = 15        !  time step frequency for transports writing
-    nn_secdebug = 112       !      0 : no section to debug
-    !                      !     -1 : debug all section
-    !                      !  0 < n : debug section number n
+&namflo        !   float parameters                                     (default: OFF)
+!-----------------------------------------------------------------------
+   ln_floats   = .false.      ! activate floats or not
+      jpnfl       = 1         !    total number of floats during the run
+      jpnnewflo   = 0         !    number of floats for the restart
+      ln_rstflo   = .false.   !    float restart (T) or not (F)
+      nn_writefl  =      75   !    frequency of writing in float output file
+      nn_stockfl  =    5475   !    frequency of creation of the float restart file
+      ln_argo     = .false.   !    Argo type floats (stay at the surface each 10 days)
+      ln_flork4   = .false.   !    trajectories computed with a 4th order Runge-Kutta (T)
+      !                       !    or computed with Blanke' scheme (F)
+      ln_ariane   = .true.    !    Input with Ariane tool convention(T)
+      ln_flo_ascii= .true.    !    Output with Ariane tool netcdf convention(F) or ascii file (T)
+/
+!-----------------------------------------------------------------------
+&nam_diaharm   !   Harmonic analysis of tidal constituents              (default: OFF)
+!-----------------------------------------------------------------------
+    ln_diaharm = .false.   ! Choose tidal harmonic output or not
+       nit000_han = 1      !    First time step used for harmonic analysis
+       nitend_han = 75     !    Last time step used for harmonic analysis
+       nstep_han  = 15     !    Time step frequency for harmonic analysis
+       tname(1)   = 'M2'   !    Name of tidal constituents
+       tname(2)   = 'K1'   !              ---
+/
+!-----------------------------------------------------------------------
+&nam_diadct    !   transports through some sections                     (default: OFF)
+!-----------------------------------------------------------------------
+    ln_diadct  = .false.   ! Calculate transport thru sections or not
+       nn_dct     = 15     !  time step frequency for transports computing
+       nn_dctwri  = 15     !  time step frequency for transports writing
+       nn_secdebug = 112   !      0 : no section to debug
+       !                   !     -1 : debug all section
+       !                   !  0 < n : debug section number n
 /
 !-----------------------------------------------------------------------
@@ -1315,10 +1333,9 @@
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
 !-----------------------------------------------------------------------
-   cn_mpi_send =  'I'      !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
-   !                       !  buffer blocking send or immediate non-blocking sends, resp.
-   nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
+   ln_listonly =  .false.  !  do nothing else than listing the best domain decompositions (with land domains suppression)
+   !                       !  if T: the largest number of cores tested is defined by max(mppsize, jpni*jpnj)
    ln_nnogather =  .true.  !  activate code to avoid mpi_allgather use at the northfold
-   jpni        =   0       !  jpni   number of processors following i (set automatically if < 1)
-   jpnj        =   0       !  jpnj   number of processors following j (set automatically if < 1)
+   jpni        =   0       !  number of processors following i (set automatically if < 1), see also ln_listonly = T
+   jpnj        =   0       !  number of processors following j (set automatically if < 1), see also ln_listonly = T
 /
 !-----------------------------------------------------------------------
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_top_ref
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_top_ref	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SHARED/namelist_top_ref	(revision 12143)
@@ -59,5 +59,5 @@
 !                !  file name        ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !                !                   !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_trcdta(1)  = 'data_TRC_nomask' ,        -12        ,  'TRC'    ,    .false.   , .true. , 'yearly'  , ''       , ''       , ''
+   sn_trcdta(1)  = 'data_TRC_nomask' ,        -12.       ,  'TRC'    ,    .false.   , .true. , 'yearly'  , ''       , ''       , ''
    !
    cn_dir        =  './'     !  root directory for the location of the data files
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/file_def_nemo-ice.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/file_def_nemo-ice.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/file_def_nemo-ice.xml	(revision 12143)
@@ -93,25 +93,25 @@
      <file id="file22" name_suffix="_SBC_scalar" description="scalar variables" enabled=".true." >
        <!-- global contents -->
-       <field field_ref="ibgvol_tot"     grid_ref="grid_1point"   name="ibgvol_tot"   />
-       <field field_ref="sbgvol_tot"     grid_ref="grid_1point"   name="sbgvol_tot"   />
-       <field field_ref="ibgarea_tot"    grid_ref="grid_1point"   name="ibgarea_tot"  />
-       <field field_ref="ibgsalt_tot"    grid_ref="grid_1point"   name="ibgsalt_tot"  />
-       <field field_ref="ibgheat_tot"    grid_ref="grid_1point"   name="ibgheat_tot"  />
-       <field field_ref="sbgheat_tot"    grid_ref="grid_1point"   name="sbgheat_tot"  />
+       <field field_ref="ibgvol_tot"     name="ibgvol_tot"   />
+       <field field_ref="sbgvol_tot"     name="sbgvol_tot"   />
+       <field field_ref="ibgarea_tot"    name="ibgarea_tot"  />
+       <field field_ref="ibgsalt_tot"    name="ibgsalt_tot"  />
+       <field field_ref="ibgheat_tot"    name="ibgheat_tot"  />
+       <field field_ref="sbgheat_tot"    name="sbgheat_tot"  />
        
        <!-- global drifts (conservation checks) -->
-       <field field_ref="ibgvolume"      grid_ref="grid_1point"   name="ibgvolume"    />
-       <field field_ref="ibgsaltco"      grid_ref="grid_1point"   name="ibgsaltco"    />
-       <field field_ref="ibgheatco"      grid_ref="grid_1point"   name="ibgheatco"    />
-       <field field_ref="ibgheatfx"      grid_ref="grid_1point"   name="ibgheatfx"    />
+       <field field_ref="ibgvolume"      name="ibgvolume"    />
+       <field field_ref="ibgsaltco"      name="ibgsaltco"    />
+       <field field_ref="ibgheatco"      name="ibgheatco"    />
+       <field field_ref="ibgheatfx"      name="ibgheatfx"    />
        
        <!-- global forcings  -->
-       <field field_ref="ibgfrcvoltop"   grid_ref="grid_1point"   name="ibgfrcvoltop" />
-       <field field_ref="ibgfrcvolbot"   grid_ref="grid_1point"   name="ibgfrcvolbot" />
-       <field field_ref="ibgfrctemtop"   grid_ref="grid_1point"   name="ibgfrctemtop" />
-       <field field_ref="ibgfrctembot"   grid_ref="grid_1point"   name="ibgfrctembot" />
-       <field field_ref="ibgfrcsal"      grid_ref="grid_1point"   name="ibgfrcsal"    />
-       <field field_ref="ibgfrchfxtop"   grid_ref="grid_1point"   name="ibgfrchfxtop" />
-       <field field_ref="ibgfrchfxbot"   grid_ref="grid_1point"   name="ibgfrchfxbot" />
+       <field field_ref="ibgfrcvoltop"   name="ibgfrcvoltop" />
+       <field field_ref="ibgfrcvolbot"   name="ibgfrcvolbot" />
+       <field field_ref="ibgfrctemtop"   name="ibgfrctemtop" />
+       <field field_ref="ibgfrctembot"   name="ibgfrctembot" />
+       <field field_ref="ibgfrcsal"      name="ibgfrcsal"    />
+       <field field_ref="ibgfrchfxtop"   name="ibgfrchfxtop" />
+       <field field_ref="ibgfrchfxbot"   name="ibgfrchfxbot" />
      </file>
      
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/file_def_nemo-oce.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/file_def_nemo-oce.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/file_def_nemo-oce.xml	(revision 12143)
@@ -81,17 +81,17 @@
         <file id="file15" name_suffix="_scalar" description="scalar variables" >
           <!-- global drifts (conservation checks) -->
-          <field field_ref="bgtemper"     grid_ref="grid_1point"   name="bgtemper"    />
-          <field field_ref="bgsaline"     grid_ref="grid_1point"   name="bgsaline"    />
-          <field field_ref="bgheatco"     grid_ref="grid_1point"   name="bgheatco"    />
-          <field field_ref="bgheatfx"     grid_ref="grid_1point"   name="bgheatfx"    />
-          <field field_ref="bgsaltco"     grid_ref="grid_1point"   name="bgsaltco"    />
-          <field field_ref="bgvolssh"     grid_ref="grid_1point"   name="bgvolssh"    />
-          <field field_ref="bgvole3t"     grid_ref="grid_1point"   name="bgvole3t"    />
+          <field field_ref="bgtemper"     name="bgtemper"    />
+          <field field_ref="bgsaline"     name="bgsaline"    />
+          <field field_ref="bgheatco"     name="bgheatco"    />
+          <field field_ref="bgheatfx"     name="bgheatfx"    />
+          <field field_ref="bgsaltco"     name="bgsaltco"    />
+          <field field_ref="bgvolssh"     name="bgvolssh"    />
+          <field field_ref="bgvole3t"     name="bgvole3t"    />
 
           <!-- global surface forcings  -->
-          <field field_ref="bgfrcvol"     grid_ref="grid_1point"   name="bgfrcvol"    />
-          <field field_ref="bgfrctem"     grid_ref="grid_1point"   name="bgfrctem"    />
-          <field field_ref="bgfrchfx"     grid_ref="grid_1point"   name="bgfrchfx"    />
-          <field field_ref="bgfrcsal"     grid_ref="grid_1point"   name="bgfrcsal"    />
+          <field field_ref="bgfrcvol"     name="bgfrcvol"    />
+          <field field_ref="bgfrctem"     name="bgfrctem"    />
+          <field field_ref="bgfrchfx"     name="bgfrchfx"    />
+          <field field_ref="bgfrcsal"     name="bgfrcsal"    />
         </file>
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/namelist_cfg	(revision 12143)
@@ -47,6 +47,6 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem    = 'T_SPITZ12'   ,  24           ,'votemper',    .false.   , .false., 'daily'   , ''      , '' ,    ''
-   sn_sal    = 'S_SPITZ12'   ,  24           ,'vosaline',    .false.   , .false., 'daily'   , ''      , '' ,    ''
+   sn_tem    = 'T_SPITZ12'   ,  24.          ,'votemper',    .false.   , .false., 'daily'   , ''      , '' ,    ''
+   sn_sal    = 'S_SPITZ12'   ,  24.          ,'vosaline',    .false.   , .false., 'daily'   , ''      , '' ,    ''
 /
 !!======================================================================
@@ -98,14 +98,14 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !          weights filename            ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_wndi     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,   2 ,  'u10'     ,   .true.    , .false. , 'yearly'  , 'weights_bicub', 'Uwnd' , ''
-   sn_wndj     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,   2 ,  'v10'     ,   .true.    , .false. , 'yearly'  , 'weights_bicub', 'Vwnd' , ''
-   sn_qsr      = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,   2 ,  'ssrd'    ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
-   sn_qlw      = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,   2 ,  'strd'    ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
-   sn_tair     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,   2 ,  't10'     ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
-   sn_humi     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,   2 ,  'humi'    ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
-   sn_prec     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,   2 ,  'precip'  ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
-   sn_snow     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,   2 ,  'snow'    ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
-   sn_slp      = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,   2 ,  'slp'     ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
-   sn_tdif     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,   2 ,  'tdif'    ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
+   sn_wndi     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,  2. ,  'u10'     ,   .true.    , .false. , 'yearly'  , 'weights_bicub', 'Uwnd' , ''
+   sn_wndj     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,  2. ,  'v10'     ,   .true.    , .false. , 'yearly'  , 'weights_bicub', 'Vwnd' , ''
+   sn_qsr      = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,  2. ,  'ssrd'    ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
+   sn_qlw      = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,  2. ,  'strd'    ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
+   sn_tair     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,  2. ,  't10'     ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
+   sn_humi     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,  2. ,  'humi'    ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
+   sn_prec     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,  2. ,  'precip'  ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
+   sn_snow     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,  2. ,  'snow'    ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
+   sn_slp      = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,  2. ,  'slp'     ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
+   sn_tdif     = 'MARv3.6-9km-Svalbard-2hourly_spitz' ,  2. ,  'tdif'    ,   .true.    , .false. , 'yearly'  , 'weights_bilin', '' , ''
 /
 !-----------------------------------------------------------------------
@@ -171,30 +171,28 @@
    nn_ice_dta    =  1         !  = 0, bdy data are equal to the initial state
    !                          !  = 1, bdy data are read in 'bdydata   .nc' files
-   rn_ice_tem    = 267.       !  si3 only: arbitrary temperature of incoming sea ice
-   rn_ice_sal    =   6.       !  si3 only:      --   salinity           --
-   rn_ice_age    = 365.       !  si3 only:      --   age                --
-   !
    nn_rimwidth   = 1          !  width of the relaxation zone
    ln_vol        = .false.    !  total volume correction (see nn_volctl parameter)
-   nb_jpk_bdy    = -1         ! number of levels in the bdy data (set < 0 if consistent with planned run)
 /
 !-----------------------------------------------------------------------
 &nambdy_dta    !  open boundaries - external data                       (see nam_bdy)
 !-----------------------------------------------------------------------
-   ln_full_vel = .false.      !  ???
-
+   ln_zinterp  = .false.      !  T if a vertical interpolation is required. Variables gdep[tuv] and e3[tuv] must exist in the file
+   !                          !  automatically defined to T if the number of vertical levels in bdy dta /= jpk
+   ln_full_vel = .false.      !  T if [uv]3d are "full" velocities and not only its baroclinic components
+   !                          !  in this case, baroclinic and barotropic velocities will be recomputed -> [uv]2d not needed
+   !
    cn_dir  =  './'
 !              !  file name      ! frequency (hours) ! variable  ! time interp. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                 !  (if <0  months)  !   name    !  (logical)   !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
-   bn_ssh =   'bdyT_u2d_grid12' ,         72       , 'sossheig' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
-   bn_u2d =   'bdyU_u2d_grid12' ,         72       , 'vobtcrtx' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
-   bn_v2d =   'bdyV_u2d_grid12' ,         72       , 'vobtcrty' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
-   bn_u3d  =  'bdyU_u3d_grid12' ,         72       , 'vozocrtx' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
-   bn_v3d  =  'bdyV_u3d_grid12' ,         72       , 'vomecrty' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
-   bn_tem  =  'bdyT_tem_grid12' ,         72       , 'votemper' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
-   bn_sal  =  'bdyT_sal_grid12' ,         72       , 'vosaline' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
-   bn_a_i  =  'bdyT_ice_grid12' ,         72       , 'ileadfra' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
-   bn_h_i  =  'bdyT_ice_grid12' ,         72       , 'iicethic' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
-   bn_h_s  =  'bdyT_ice_grid12' ,         72       , 'isnowthi' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
+   bn_ssh =   'bdyT_u2d_grid12' ,         72.      , 'sossheig' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
+   bn_u2d =   'bdyU_u2d_grid12' ,         72.      , 'vobtcrtx' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
+   bn_v2d =   'bdyV_u2d_grid12' ,         72.      , 'vobtcrty' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
+   bn_u3d  =  'bdyU_u3d_grid12' ,         72.      , 'vozocrtx' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
+   bn_v3d  =  'bdyV_u3d_grid12' ,         72.      , 'vomecrty' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
+   bn_tem  =  'bdyT_tem_grid12' ,         72.      , 'votemper' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
+   bn_sal  =  'bdyT_sal_grid12' ,         72.      , 'vosaline' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
+   bn_a_i  =  'bdyT_ice_grid12' ,         72.      , 'ileadfra' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
+   bn_h_i  =  'bdyT_ice_grid12' ,         72.      , 'iicethic' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
+   bn_h_s  =  'bdyT_ice_grid12' ,         72.      , 'isnowthi' ,     .true.     , .false. ,  'yearly'  ,    ''    ,   ''   , ''
 /
 !-----------------------------------------------------------------------
@@ -350,7 +348,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/namelist_ice_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/namelist_ice_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/SPITZ12/EXPREF/namelist_ice_cfg	(revision 12143)
@@ -44,10 +44,11 @@
 &namdyn_rhg     !   Ice rheology
 !------------------------------------------------------------------------------
-   ln_rhg_EVP       = .true.          !  EVP rheology
-      ln_aEVP       = .true.          !     adaptive rheology (Kimmritz et al. 2016 & 2017)
 /
 !------------------------------------------------------------------------------
 &namdyn_adv     !   Ice advection
 !------------------------------------------------------------------------------
+   ln_adv_Pra       = .false.         !  Advection scheme (Prather)
+   ln_adv_UMx       = .true.          !  Advection scheme (Ultimate-Macho)
+      nn_UMx        =   5             !     order of the scheme for UMx (1-5 ; 20=centered 2nd order)
 /
 !------------------------------------------------------------------------------
@@ -80,6 +81,7 @@
 &namthd_pnd     !   Melt ponds
 !------------------------------------------------------------------------------
-   ln_pnd_H12       = .true.          !  activate evolutive melt ponds (from Holland et al 2012)
-   ln_pnd_alb       = .true.          !  melt ponds affect albedo or not
+   ln_pnd           = .true.          !  activate melt ponds or not
+     ln_pnd_H12     = .true.          !  activate evolutive melt ponds (from Holland et al 2012)
+     ln_pnd_alb     = .true.          !  melt ponds affect albedo or not
 /
 
@@ -102,4 +104,3 @@
 &namdia         !   Diagnostics
 !------------------------------------------------------------------------------
-   ln_icediachk     = .true.         !  check online the heat, mass & salt budgets (T) or not (F)
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/WED025/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/WED025/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/cfgs/WED025/EXPREF/namelist_cfg	(revision 12143)
@@ -328,8 +328,4 @@
    nn_ice_dta    =  1         !  = 0, bdy data are equal to the initial state
    !                          !  = 1, bdy data are read in 'bdydata   .nc' files
-   rn_ice_tem    = 267.0      !  si3 only: arbitrary temperature of incoming sea ice
-   rn_ice_sal    = 6.0        !  si3 only:      --   salinity           --
-   rn_ice_age    = 45.0       !  si3 only:      --   age                --
-   !
    nn_rimwidth   = 1          !  width of the relaxation zone
 /
@@ -354,4 +350,8 @@
    bn_h_i      =    'bdyT_ice_WED025'    ,         -1        , 'iicethic' ,     .true. , .false., 'yearly'  ,    ''            ,   ''     ,     ''
    bn_h_s      =    'bdyT_ice_WED025'    ,         -1        , 'isnowthi' ,     .true. , .false., 'yearly'  ,    ''            ,   ''     ,     ''
+   !
+   rn_ice_tem    = 267.0      !  si3 only: arbitrary temperature of incoming sea ice
+   rn_ice_sal    = 6.0        !  si3 only:      --   salinity           --
+   rn_ice_age    = 45.0       !  si3 only:      --   age                --
 /
 !-----------------------------------------------------------------------
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/README.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/README.rst	(revision 12143)
@@ -1,3 +1,17 @@
+**************************
+Building the documentation
+**************************
 
+.. todo::
+
+
+
+:file:`latex`    : LaTeX sources and Latexmk configuration to build reference manuals with :file:`manual_build.sh`
+
+:file:`namelists`: Namelist blocks included in the documentation
+
+:file:`rst`      : |RST man|_ sources and Sphinx configuration to build this guide hereby with :file:`guide_build.sh`
+
+.. |RST man| replace:: reStructuredText (rst)
 
 .. warning::
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/.svnignore
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/.svnignore	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/.svnignore	(revision 12143)
@@ -8,7 +8,5 @@
 *.ilg
 *.ind
-*.lof
-*.log
-*.lot
+*.lo*
 *.maf
 *.mtc*
@@ -16,3 +14,4 @@
 *.pdf
 *.toc
+*.xdv
 _minted-*
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/NEMO_manual.ist
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/NEMO_manual.ist	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../global/index.ist
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/abstract.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/abstract.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/abstract.tex	(revision 12143)
@@ -0,0 +1,27 @@
+%% ================================================================
+%% Abstract
+%% ================================================================
+
+%% Common part between NEMO-SI3-TOP
+\NEMO\ (``Nucleus for European Modelling of the Ocean'') is a framework of ocean-related engines.
+It is intended to be a flexible tool for studying the ocean dynamics and thermodynamics (``blue ocean''),
+as well as its interactions with the components of the Earth climate system over
+a wide range of space and time scales.
+Within \NEMO, the ocean engine is interfaced with a sea-ice model (\SIcube\ or
+\href{http://github.com/CICE-Consortium/CICE}{CICE}),
+passive tracers and biogeochemical models (\TOP) and,
+via the \href{http://portal.enes.org/oasis}{OASIS} coupler,
+with several atmospheric general circulation models.
+It also supports two-way grid embedding by means of the \href{http://agrif.imag.fr}{AGRIF} software.
+
+%% Specific part
+The primitive equation model is adapted to regional and global ocean circulation problems down to
+kilometric scale.
+Prognostic variables are the three-dimensional velocity field, a non-linear sea surface height,
+the \textit{Conservative} Temperature and the \textit{Absolute} Salinity.
+In the horizontal direction, the model uses a curvilinear orthogonal grid and
+in the vertical direction, a full or partial step $z$-coordinate, or $s$-coordinate, or
+a mixture of the two.
+The distribution of variables is a three-dimensional Arakawa C-type grid.
+Various physical choices are available to describe ocean physics,
+so as various HPC functionalities to improve performances.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/appendices.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/appendices.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/appendices.tex	(revision 12143)
@@ -1,7 +1,8 @@
 
-\subfile{../subfiles/annex_A}             %% Generalised vertical coordinate
-\subfile{../subfiles/annex_B}             %% Diffusive operator
-\subfile{../subfiles/annex_C}             %% Discrete invariants of the eqs.
-\subfile{../subfiles/annex_iso}	          %% Isoneutral diffusion using triads
+\subfile{../subfiles/apdx_s_coord}      %% A. Generalised vertical coordinate
+\subfile{../subfiles/apdx_diff_opers}   %% B. Diffusive operators
+\subfile{../subfiles/apdx_invariants}   %% C. Discrete invariants of the eqs.
+\subfile{../subfiles/apdx_triads}       %% D. Isoneutral diffusion using triads
+\subfile{../subfiles/apdx_DOMAINcfg}    %% E. Brief notes on DOMAINcfg
 
 %% Not included
@@ -9,4 +10,3 @@
 %\subfile{../subfiles/chap_DIU}
 %\subfile{../subfiles/chap_conservation}
-%\subfile{../subfiles/annex_E}				%% Notes on some on going staff
-
+%\subfile{../subfiles/apdx_algos}   %% Notes on some on going staff
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/authors.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/authors.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/authors.tex	(revision 12143)
@@ -0,0 +1,50 @@
+%Romain Bourdall\'{e}-Badie
+%\orcid{0000-0002-8742-3289} \\
+%Mike Bell                   \\
+%J\'{e}r\^{o}me Chanut       \\
+%Emanuela Clementi
+%\orcid{0000-0002-5752-1849} \\
+%Andrew Coward
+%\orcid{0000-0002-0456-129X} \\
+%Massimiliano Drudi
+%\orcid{0000-0002-9951-740X} \\
+%Christian \'{E}th\'{e}      \\
+%Doroteaciro Iovino
+%\orcid{0000-0001-5132-7255} \\
+%Dan Lea                     \\
+%Claire L\'{e}vy
+%\orcid{0000-0003-2518-6692} \\
+%Gurvan Madec
+%\orcid{0000-0002-6447-4198} \\
+%Nicolas Martin              \\
+%S\'{e}bastien Masson
+%\orcid{0000-0002-1694-8117} \\
+%Pierre Mathiot              \\
+%Silvia Mocavero
+%\orcid{0000-0002-6309-8282} \\
+%Simon M\"{u}ller            \\
+%George Nurser               \\
+%Guillaume Samson
+%\orcid{0000-0001-7481-6369} \\
+%Dave Storkey
+
+\orcid{0000-0002-8742-3289} Romain Bourdall\'{e}-Badie  \\
+                            Mike Bell                   \\
+                            J\'{e}r\^{o}me Chanut       \\
+\orcid{0000-0002-5752-1849} Emanuela Clementi           \\
+\orcid{0000-0002-0456-129X} Andrew Coward               \\
+\orcid{0000-0002-9951-740X} Massimiliano Drudi          \\
+                            Christian \'{E}th\'{e}      \\
+\orcid{0000-0001-5132-7255} Doroteaciro Iovino          \\
+                            Dan Lea                     \\
+\orcid{0000-0003-2518-6692} Claire L\'{e}vy             \\
+\orcid{0000-0002-6447-4198} Gurvan Madec                \\
+                            Nicolas Martin              \\
+\orcid{0000-0002-1694-8117} S\'{e}bastien Masson        \\
+                            Pierre Mathiot              \\
+\orcid{0000-0002-6309-8282} Silvia Mocavero             \\
+                            Simon M\"{u}ller            \\
+                            George Nurser               \\
+\orcid{0000-0001-7481-6369} Guillaume Samson            \\
+                            Dave Storkey                \\
+%% Don't forget the last break for the right alignment
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/bibliography.bib
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/bibliography.bib	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/bibliography.bib	(revision 12143)
@@ -188,4 +188,18 @@
 }
 
+@article{ beljaars_QJRMS95,
+title = "The parametrization of surface fluxes in large-scale models under free convection",
+pages = "255--270",
+journal = "Quarterly Journal of the Royal Meteorological Society",
+volume = "121",
+number = "522",
+author = "Beljaars, Anton C. M.",
+year = "1995",
+month = "jan",
+ publisher     = "Wiley",
+issn = "00359009",
+doi = "10.1002/qj.49712152203"
+}
+
 @article{         bernie.guilyardi.ea_CD07,
   title         = "Impact of resolving the diurnal cycle in an
@@ -386,4 +400,18 @@
 }
 
+@article{         brodeau.barnier.ea_JPO16,
+  title         = "Climatologically Significant Effects of Some Approximations in the Bulk Parameterizations of Turbulent Air–Sea Fluxes",
+  pages         = "5--28",
+  journal       = "Journal of Physical Oceanography",
+  volume        = "47",
+  number        = "1",
+  author        = "Brodeau, Laurent and Barnier, Bernard and Gulev, Sergey K. and Woods, Cian",
+  year          = "2016",
+  month         = "jan",
+  publisher     = "American Meteorological Society",
+  issn          = "0022-3670",
+  doi           = "10.1175/jpo-d-16-0169.1",
+}
+
 @article{         brown.campana_MWR78,
   title         = "An economical time-differencing system for numerical
@@ -745,4 +773,18 @@
 }
 
+@article{ edson.jampana.ea_JPO13,
+title = "On the Exchange of Momentum over the Open Ocean",
+pages = "1589--1610",
+journal = "Journal of Physical Oceanography",
+volume = "43",
+number = "8",
+author = "Edson, James B. and Jampana, Venkata and Weller, Robert A. and Bigorre, Sebastien P. and Plueddemann, Albert J. and Fairall, Christopher W. and Miller, Scott D. and Mahrt, Larry and Vickers, Dean and Hersbach, Hans",
+year = "2013",
+month = "aug",
+publisher = "American Meteorological Society",
+issn = "0022-3670",
+doi = "10.1175/JPO-D-12-0173.1"
+}
+
 @article{         egbert.ray_JGR01,
   title         = "Estimates of {M2} tidal energy dissipation from
@@ -819,4 +861,17 @@
 }
 
+@article{ fairall.bradley.ea_JC03,
+title = "Bulk parameterization of air-sea fluxes: Updates and verification for the COARE algorithm",
+pages = "571--591",
+journal = "Journal of Climate",
+volume = "16",
+number = "4",
+author = "Fairall, C. W. and Bradley, E. F. and Hare, J. E. and Grachev, A. A. and Edson, J. B.",
+year = "2003",
+publisher = "American Meteorological Society",
+issn = "08948755",
+doi = "10.1175/1520-0442(2003)016<0571:BPOASF>2.0.CO;2"
+}
+
 @phdthesis{       farge-coulombier_phd87,
   title         = "Dynamique non-lin\'{e}aire des ondes et des tourbillons
@@ -871,4 +926,18 @@
   publisher     = "UNESCO",
   url           = "https://unesdoc.unesco.org/ark:/48223/pf0000059832.locale=en"
+}
+
+@article{         foxkemper.ferrari_JPO08,
+  title         = "Parameterization of Mixed Layer Eddies. Part I: Theory and Diagnosis",
+  pages         = "1145--1165",
+  journal       = "Journal of Physical Oceanography",
+  volume        = "38",
+  number        = "6",
+  author        = "B. Fox-Kemper and R. Ferrari and B. Hallberg",
+  year          = "2008",
+  month         = "jun",
+  publisher     = "American Meteorological Society",
+  issn          = "1520-0485",
+  doi           = "10.1175/2007JPO3792.1"
 }
 
@@ -1545,4 +1614,24 @@
 }
 
+@article{         kraus.turner_tellus67,
+  author = {Kraus, E.B. and Turner, J.},
+  journal = {Tellus},
+  pages = {98--106},
+  title = {A one dimensional model of the seasonal thermocline {II}. {T}he general theory and its consequences},
+  volume = {19},
+  year = {1967}
+}
+
+@article{        large.ea_RG97,
+  author        = "Large, W. G. and McWilliams, J. C. and Doney, S. C.",
+  doi           = "10.1029/94RG01872",
+  journal       = "Reviews of Geophysics",
+  number        = {4},
+  pages         = {363--403},
+  publisher     = {AGU},
+  title         = "Oceanic vertical mixing: {A} review and a model with a nonlocal boundary layer parameterization",
+  year          = "1994"
+}
+
 @techreport{      large.yeager_rpt04,
   title         = "Diurnal to decadal global forcing for ocean and sea-ice
@@ -1839,4 +1928,28 @@
   author        = "F. Lott and G. Madec and J. Verron",
   year          = "1990"
+}
+
+@article{	  lupkes.gryanik.ea_JGR12,
+  author 	= "L{\"{u}}pkes, Christof and Gryanik, Vladimir M. and Hartmann, J{\"{o}}rg and Andreas, Edgar L.",
+  doi 		= "10.1029/2012JD017630",
+  issn 		= "01480227",
+  journal 	= "Journal of Geophysical Research Atmospheres",
+  number 	= "13",
+  pages 	= "1--18",
+  title 	= "A parametrization, based on sea ice morphology, of the neutral atmospheric drag coefficients for weather prediction and climate models",
+  volume 	= "117",
+  year 		= "2012"
+}
+
+@article{	  lupkes.gryanik_JGR15,
+  author 	= "L{\"{u}}pkes, Christof and Gryanik, Vladimir M.",
+  doi 		= "10.1002/2014JD022418",
+  issn 		= "21562202",
+  journal 	= "Journal of Geophysical Research",
+  number 	= "2",
+  pages 	= "552--581",
+  title 	= "A stability-dependent parametrization of transfer coefficients formomentum and heat over polar sea ice to be used in climate models",
+  volume 	= "120",
+  year 		= "2015"
 }
 
@@ -2091,4 +2204,13 @@
 }
 
+@article{mcwilliams.ea_JFM97,
+	author = {McWilliams, James C. and Sullivan, Peter P. and Moeng, Chin-Hoh},
+	doi = {10.1017/S0022112096004375},
+	journal = {Journal of Fluid Mechanics},
+	pages = {1--30},
+	title = {Langmuir turbulence in the ocean},
+	volume = {334},
+	year = {1997},
+}
 @article{         mellor.blumberg_JPO04,
   title         = "Wave Breaking and Ocean Surface Layer Thermal Response",
@@ -2304,4 +2426,20 @@
   issn          = "0002-9947",
   doi           = "10.1090/s0002-9947-1959-0104919-1"
+}
+
+@article{         qiao.yuan.ea_OD10,
+  title         = "A three-dimensional surface wave–ocean circulation coupled 
+                  model and its initial testing",
+  pages         = "1339--1335",
+  journal       = "Ocean Dynamics",
+  volume        = "60",
+  number        = "5",
+  author        = "F. Qiao and Y. Yuan and T. Ezer and C. Xia and 
+                   Y. Yang and X. Lu and Z. Song ",
+  year          = "2010",
+  month         = "oct",
+  publisher     = "Springer-Verlag",
+  issn          = "1616-7341",
+  doi           = "10.1007/s10236-010-0326-y"
 }
 
@@ -2544,4 +2682,18 @@
 }
 
+@article{         smagorinsky_MW63,
+  title         = "General circulation experiments with the primitive equations: I. The basic experiment ",
+  pages         = "99--164",
+  journal       = "Monthly Weather Review",
+  volume        = "91",
+  number        = "3",
+  author        = "J. Smagorinsky",
+  year          = "1963",
+  month         = "mar",
+  publisher     = "American Meteorological Society",
+  issn          = "1520-0493",
+  doi           = "10.1175/1520-0493(1963)091<0099:GCEWTP>2.3.CO;2"
+}
+
 @article{         song.haidvogel_JCP94,
   title         = "A semi-implicit ocean circulation model using a
@@ -2896,4 +3048,15 @@
 }
 
+@article{         white.hoskins.ea_QJRMS05,
+  title         = "Consistent approximate models of the global atmosphere: shallow, deep,
+                  hydrostatic, quasi-hydrostatic and non-hydrostatic",
+  pages         = "2081--2107",
+  journal       = "Quarterly Journal of the Royal Meteorological Society",
+  volume        = "131",
+  author        = "A. A. White and B. J. Hoskins and I. Roulstone and A. Staniforth",
+  year          = "2005",
+  doi           = "10.1256/qj.04.49"
+}
+
 @article{         white.adcroft.ea_JCP09,
   title         = "High-order regridding-remapping schemes for continuous
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/chapters.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/chapters.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/chapters.tex	(revision 12143)
@@ -1,16 +1,20 @@
-\subfile{../subfiles/introduction}        %% Introduction
-\subfile{../subfiles/chap_model_basics}
-\subfile{../subfiles/chap_time_domain}    %% Time discretisation (time stepping strategy)
-\subfile{../subfiles/chap_DOM}            %% Space discretisation
-\subfile{../subfiles/chap_TRA}            %% Tracer advection/diffusion equation
-\subfile{../subfiles/chap_DYN}            %% Dynamics : momentum equation
-\subfile{../subfiles/chap_SBC}            %% Surface Boundary Conditions
-\subfile{../subfiles/chap_LBC}            %% Lateral Boundary Conditions
-\subfile{../subfiles/chap_LDF}            %% Lateral diffusion
-\subfile{../subfiles/chap_ZDF}            %% Vertical diffusion
-\subfile{../subfiles/chap_DIA}            %% Outputs and Diagnostics
-\subfile{../subfiles/chap_OBS}            %% Observation operator
-\subfile{../subfiles/chap_ASM}            %% Assimilation increments
-\subfile{../subfiles/chap_STO}            %% Stochastic param.
-\subfile{../subfiles/chap_misc}           %% Miscellaneous topics
-\subfile{../subfiles/chap_CONFIG}         %% Predefined configurations
+\subfile{../subfiles/chap_model_basics}   %% 1.
+\subfile{../subfiles/chap_time_domain}    %% 2.  Time discretisation (time stepping strategy)
+\subfile{../subfiles/chap_DOM}            %% 3.  Space discretisation
+\subfile{../subfiles/chap_TRA}            %% 4.  Tracer advection/diffusion equation
+\subfile{../subfiles/chap_DYN}            %% 5.  Dynamics : momentum equation
+\subfile{../subfiles/chap_SBC}            %% 6.  Surface Boundary Conditions
+\subfile{../subfiles/chap_LBC}            %% 7.  Lateral Boundary Conditions
+\subfile{../subfiles/chap_LDF}            %% 8.  Lateral diffusion
+\subfile{../subfiles/chap_ZDF}            %% 9.  Vertical diffusion
+\subfile{../subfiles/chap_DIA}            %% 10. Outputs and Diagnostics
+\subfile{../subfiles/chap_OBS}            %% 11. Observation operator
+\subfile{../subfiles/chap_ASM}            %% 12. Assimilation increments
+\subfile{../subfiles/chap_STO}            %% 13. Stochastic param.
+\subfile{../subfiles/chap_misc}           %% 14. Miscellaneous topics
+\subfile{../subfiles/chap_cfgs}           %% 15. Predefined configurations
+
+%% Not included
+%\subfile{../subfiles/chap_model_basics_zstar}
+%\subfile{../subfiles/chap_DIU}
+%\subfile{../subfiles/chap_conservation}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/definitions.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/definitions.tex	(revision 12062)
+++ 	(revision )
@@ -1,15 +1,0 @@
-%% Engine (folder name)
-\def \engine{NEMO}
-
-%% Title (variable name already use by 'titling' pkg)
-\def \heading{NEMO ocean engine}
-
-%% Authors (thanks will apply to the second author)
-\def \firstauthor{Gurvan Madec~}
-\def \secondauthor{NEMO System Team}
-
-%% IPSL publication number
-\def \ipslnum{27}
-
-%% Zenodo ID, i.e. doi:10.5281/zenodo.\([0-9]*\)
-\def \zid{1464816}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/foreword.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/foreword.tex	(revision 12062)
+++ 	(revision )
@@ -1,22 +1,0 @@
-% ================================================================
-% Foreword
-% ================================================================
-\chapter*{Foreword}
-
-The ocean engine of NEMO (Nucleus for European Modelling of the Ocean) is a primitive equation model adapted to
-regional and global ocean circulation problems.
-It is intended to be a flexible tool for studying the ocean and its interactions with the others components of
-the earth climate system over a wide range of space and time scales.
-
-Prognostic variables are the three-dimensional velocity field, a non-linear sea surface height,
-the \textit{Conservative} Temperature and the \textit{Absolute} Salinity.
-In the horizontal direction, the model uses a curvilinear orthogonal grid and in the vertical direction,
-a full or partial step $z$-coordinate, or $s$-coordinate, or a mixture of the two.
-The distribution of variables is a three-dimensional Arakawa C-type grid.
-Various physical choices are available to describe ocean physics, including TKE, and GLS vertical physics.
-
-Within NEMO, the ocean is interfaced with a sea-ice model (SI$^3$)
- %or \href{https://github.com/CICE-Consortium/CICE}{CICE}),
-passive tracer and biogeochemical models (TOP-PISCES) and,
-via the \href{https://portal.enes.org/oasis}{OASIS} coupler, with several atmospheric general circulation models.
-It also support two-way grid embedding via the \href{http://agrif.imag.fr}{AGRIF} software.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/introduction.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/introduction.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/introduction.tex	(revision 12143)
@@ -0,0 +1,142 @@
+
+\chapter*{Introduction}
+
+%\chaptertoc
+
+%\paragraph{Changes record} ~\\
+
+%\thispagestyle{plain}
+
+%{\footnotesize
+%  \begin{tabularx}{\textwidth}{l||X|X}
+%    Release & Author(s) & Modifications \\
+%    \hline
+%    {\em x.x} & {\em ...} & {\em ...}   \\
+%    {\em ...} & {\em ...} & {\em ...}   \\
+%  \end{tabularx}
+%}
+
+%\clearpage
+
+The \textbf{N}ucleus for \textbf{E}uropean \textbf{M}odelling of the \textbf{O}cean (\NEMO) is
+a framework of ocean related engines, namely the aforementioned for
+the ocean dynamics and thermodynamics,
+\SIcube \footnote{\textbf{S}ea-\textbf{I}ce modelling \textbf{I}ntegrated \textbf{I}nitiative}
+for the sea-ice dynamics and thermodynamics,
+\TOP \footnote{\textbf{T}racer in the \textbf{O}cean \textbf{P}aradigm} for
+the biogeochemistry (both transport and sources minus sinks
+(\PISCES \footnote{
+  \textbf{P}elagic \textbf{I}nteractions \textbf{S}cheme for
+  \textbf{C}arbon and \textbf{E}cosystem \textbf{S}tudies
+}
+)).
+The ocean component has been developed from the legacy of
+the \OPA \footnote{\textbf{O}c\'{e}an \textbf{PA}rall\'{e}lis\'{e} (French)}
+model, described in \citet{madec.delecluse.ea_NPM98}.
+This model has been used for a wide range of applications, both regional or global,
+as a forced ocean model and as a model coupled with the sea-ice and/or the atmosphere.
+
+This manual provides information about the physics represented by the ocean component of \NEMO\ and
+the rationale for the choice of numerical schemes and the model design.
+For the use of framework,
+a guide which gathers the \texttt{README} files spread out in the source code can be build and
+exported in a web or printable format (see \path{./doc/rst}).
+Also a online copy is available on the \href{http://forge.ipsl.jussieu.fr/nemo}{forge platform}.
+
+%% =================================================================================================
+\section*{Manual outline}
+
+\subsection*{Chapters}
+
+The manual mirrors the organization of the model and it is organised in as follows:
+after the presentation of the continuous equations
+(primitive equations with temperature and salinity, and an equation of seawater) in the next chapter,
+the following chapters refer to specific terms of the equations each associated with
+a group of modules.
+
+\begin{description}
+\item [\nameref{chap:MB}] presents the equations and their assumptions, the vertical coordinates used,
+and the subgrid scale physics.
+The equations are written in a curvilinear coordinate system, with a choice of vertical coordinates
+($z$, $s$, \zstar, \sstar, \ztilde, \stilde, and a mix of them).
+Momentum equations are formulated in vector invariant or flux form.
+Dimensional units in the meter, kilogram, second (MKS) international system are used throughout.
+The following chapters deal with the discrete equations.
+\item [\nameref{chap:TD}] presents the model time stepping environment.
+it is a three level scheme in which the tendency terms of the equations are evaluated either
+centered in time, or forward, or backward depending of the nature of the term.
+\item [\nameref{chap:DOM}] presents the model \textbf{DOM}ain.
+It is discretised on a staggered grid (Arakawa C grid) with masking of land areas.
+Vertical discretisation used depends on both how the bottom topography is represented and whether
+the free surface is linear or not.
+Full step or partial step $z$-coordinate or $s$- (terrain-following) coordinate is used with
+linear free surface (level position are then fixed in time).
+In non-linear free surface, the corresponding rescaled height coordinate formulation
+(\zstar or \sstar) is used
+(the level position then vary in time as a function of the sea surface heigh).
+\item [\nameref{chap:TRA} and \nameref{chap:DYN}] describe the discretisation of
+the prognostic equations for the active \textbf{TRA}cers (potential temperature and salinity) and
+the momentum (\textbf{DYN}amic).
+Explicit, split-explicit and filtered free surface formulations are implemented.
+A number of numerical schemes are available for momentum advection,
+for the computation of the pressure gradients, as well as for the advection of tracers
+(second or higher order advection schemes, including positive ones).
+\item [\nameref{chap:SBC}] can be implemented as prescribed fluxes,
+or bulk formulations for the surface fluxes (wind stress, heat, freshwater).
+The model allows penetration of solar radiation.
+There is an optional geothermal heating at the ocean bottom.
+Within the \NEMO\ system the ocean model is interactively coupled with
+a sea ice model (\SIcube) and a biogeochemistry model (\PISCES).
+Interactive coupling to Atmospheric models is possible via the \OASIS\ coupler.
+Two-way nesting is also available through an interface to the \AGRIF\ package,
+\ie\ \textbf{A}daptative \textbf{G}rid \textbf{R}efinement in \textbf{F}ortran
+\citep{debreu.vouland.ea_CG08}.
+The interface code for coupling to an alternative sea ice model (\CICE) has now been upgraded so that
+it works for both global and regional domains.
+\item [\nameref{chap:LBC}] presents the \textbf{L}ateral
+\textbf{B}oun\textbf{D}ar\textbf{Y} \textbf{C}onditions.
+Global configurations of the model make use of the ORCA tripolar grid,
+with special north fold boundary condition.
+Free-slip or no-slip boundary conditions are allowed at land boundaries.
+Closed basin geometries as well as periodic domains and open boundary conditions are possible.
+\item [\nameref{chap:LDF} and \nameref{chap:ZDF}] describe the physical parameterisations
+(\textbf{L}ateral \textbf{D}i\textbf{F}fusion and vertical \textbf{Z} \textbf{D}i\textbf{F}fusion)
+The model includes an implicit treatment of vertical viscosity and diffusivity.
+The lateral Laplacian and biharmonic viscosity and diffusion can be rotated following
+a geopotential or neutral direction.
+There is an optional eddy induced velocity \citep{gent.mcwilliams_JPO90} with
+a space and time variable coefficient \citet{treguier.held.ea_JPO97}.
+The model has vertical harmonic viscosity and diffusion with a space and time variable coefficient,
+with options to compute the coefficients with \citet{blanke.delecluse_JPO93},
+\citet{pacanowski.philander_JPO81}, or \citet{umlauf.burchard_JMR03} mixing schemes.
+\item [\nameref{chap:DIA}] describes model \textbf{I}n-\textbf{O}utputs \textbf{M}anagement and
+specific online \textbf{DIA}gnostics.
+The diagnostics includes the output of all the tendencies of the momentum and tracers equations,
+the output of tracers \textbf{TR}en\textbf{D}s averaged over the time evolving mixed layer,
+the output of the tendencies of the barotropic vorticity equation,
+the computation of on-line \textbf{FLO}ats trajectories...
+\item [\nameref{chap:OBS}] describes a tool which reads in \textbf{OBS}ervation files
+(profile temperature and salinity, sea surface temperature, sea level anomaly and
+sea ice concentration) and calculates an interpolated model equivalent value at
+the observation location and nearest model timestep.
+Originally developed of data assimilation, it is a fantastic tool for model and data comparison.
+\item [\nameref{chap:ASM}] describes how increments produced by
+data \textbf{A}s\textbf{S}i\textbf{M}ilation may be applied to the model equations.
+\item [\nameref{chap:STO}]
+\item [\nameref{chap:MISC}] (including solvers)
+\item [\nameref{chap:CFGS}] provides finally a brief introduction to
+the pre-defined model configurations
+(water column model \texttt{C1D}, ORCA and GYRE families of configurations).
+\end{description}
+
+%% =================================================================================================
+\subsection*{Appendices}
+
+\begin{description}
+\item [\nameref{apdx:SCOORD}]
+\item [\nameref{apdx:DIFFOPERS}]
+\item [\nameref{apdx:INVARIANTS}]
+\item [\nameref{apdx:TRIADS}]
+\item [\nameref{apdx:DOMCFG}]
+\item [\nameref{apdx:CODING}]
+\end{description}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/settings.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/settings.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/settings.tex	(revision 12143)
@@ -0,0 +1,20 @@
+%% Engine (subfolder name)
+\def \engine{NEMO}
+
+%% Cover page settings
+\def \spacetop{  \vspace*{1.85cm} }
+\def \heading{NEMO ocean engine}
+%\def \subheading{}
+\def \spacedown{ \vspace*{0.75cm } }
+\def \authorswidth{ 0.3\linewidth}
+\def \rulelenght{270pt}
+\def \abstractwidth{0.6\linewidth}
+
+%% Manual color (frontpage banner, links  and chapter boxes)
+\def \setmanualcolor{ \definecolor{manualcolor}{cmyk}{1, .60, 0, .4} }
+
+%% IPSL publication number
+\def \ipslnum{27}
+
+%% Zenodo ID, i.e. doi:10.5281/zenodo.\([0-9]*\)
+\def \zid{1464816}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/thanks.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/main/thanks.tex	(revision 12062)
+++ 	(revision )
@@ -1,2 +1,0 @@
-J\'{e}r\^{o}me Chanut,
-Silvia Mocavero
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/annex_A.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/annex_A.tex	(revision 12062)
+++ 	(revision )
@@ -1,544 +1,0 @@
-\documentclass[../main/NEMO_manual]{subfiles}
-
-\begin{document}
-
-% ================================================================
-% Chapter Appendix A : Curvilinear s-Coordinate Equations
-% ================================================================
-\chapter{Curvilinear $s-$Coordinate Equations}
-\label{apdx:A}
-
-\minitoc
-
-\newpage
-
-% ================================================================
-% Chain rule
-% ================================================================
-\section{Chain rule for $s-$coordinates}
-\label{sec:A_chain}
-
-In order to establish the set of Primitive Equation in curvilinear $s$-coordinates
-(\ie an orthogonal curvilinear coordinate in the horizontal and
-an Arbitrary Lagrangian Eulerian (ALE) coordinate in the vertical),
-we start from the set of equations established in \autoref{subsec:PE_zco_Eq} for
-the special case $k = z$ and thus $e_3 = 1$,
-and we introduce an arbitrary vertical coordinate $a = a(i,j,z,t)$.
-Let us define a new vertical scale factor by $e_3 = \partial z / \partial s$ (which now depends on $(i,j,z,t)$) and
-the horizontal slope of $s-$surfaces by:
-\begin{equation}
-  \label{apdx:A_s_slope}
-  \sigma_1 =\frac{1}{e_1 }\;\left. {\frac{\partial z}{\partial i}} \right|_s
-  \quad \text{and} \quad
-  \sigma_2 =\frac{1}{e_2 }\;\left. {\frac{\partial z}{\partial j}} \right|_s
-\end{equation}
-
-The chain rule to establish the model equations in the curvilinear $s-$coordinate system is:
-\begin{equation}
-  \label{apdx:A_s_chain_rule}
-  \begin{aligned}
-    &\left. {\frac{\partial \bullet }{\partial t}} \right|_z  =
-    \left. {\frac{\partial \bullet }{\partial t}} \right|_s
-	 -\frac{\partial \bullet }{\partial s}\;\frac{\partial s}{\partial t} \\
-    &\left. {\frac{\partial \bullet }{\partial i}} \right|_z  =
-    \left. {\frac{\partial \bullet }{\partial i}} \right|_s
-    -\frac{\partial \bullet }{\partial s}\;\frac{\partial s}{\partial i}=
-    \left. {\frac{\partial \bullet }{\partial i}} \right|_s
-    -\frac{e_1 }{e_3 }\sigma_1 \frac{\partial \bullet }{\partial s} \\
-    &\left. {\frac{\partial \bullet }{\partial j}} \right|_z  =
-    \left. {\frac{\partial \bullet }{\partial j}} \right|_s
-    - \frac{\partial \bullet }{\partial s}\;\frac{\partial s}{\partial j}=
-    \left. {\frac{\partial \bullet }{\partial j}} \right|_s
-    - \frac{e_2 }{e_3 }\sigma_2 \frac{\partial \bullet }{\partial s} \\
-    &\;\frac{\partial \bullet }{\partial z}  \;\; = \frac{1}{e_3 }\frac{\partial \bullet }{\partial s}
-  \end{aligned}
-\end{equation}
-
-In particular applying the time derivative chain rule to $z$ provides the expression for $w_s$,
-the vertical velocity of the $s-$surfaces referenced to a fix z-coordinate:
-\begin{equation}
-  \label{apdx:A_w_in_s}
-  w_s   =  \left.   \frac{\partial z }{\partial t}   \right|_s
-  = \frac{\partial z}{\partial s} \; \frac{\partial s}{\partial t}
-  = e_3 \, \frac{\partial s}{\partial t}
-\end{equation}
-
-% ================================================================
-% continuity equation
-% ================================================================
-\section{Continuity equation in $s-$coordinates}
-\label{sec:A_continuity}
-
-Using (\autoref{apdx:A_s_chain_rule}) and
-the fact that the horizontal scale factors $e_1$ and $e_2$ do not depend on the vertical coordinate,
-the divergence of the velocity relative to the ($i$,$j$,$z$) coordinate system is transformed as follows in order to
-obtain its expression in the curvilinear $s-$coordinate system:
-
-\begin{subequations}
-  \begin{align*}
-    {
-    \begin{array}{*{20}l}
-      \nabla \cdot {\mathrm {\mathbf U}}
-      &= \frac{1}{e_1 \,e_2 }  \left[ \left. {\frac{\partial (e_2 \,u)}{\partial i}} \right|_z
-        +\left. {\frac{\partial(e_1 \,v)}{\partial j}} \right|_z  \right]
-        + \frac{\partial w}{\partial z} \\ \\
-      &     = \frac{1}{e_1 \,e_2 }  \left[
-		  \left.   \frac{\partial (e_2 \,u)}{\partial i}    \right|_s
-		  - \frac{e_1 }{e_3 } \sigma_1 \frac{\partial (e_2 \,u)}{\partial s}
-        + \left.   \frac{\partial (e_1 \,v)}{\partial j}    \right|_s
-		  - \frac{e_2 }{e_3 } \sigma_2 \frac{\partial (e_1 \,v)}{\partial s}	\right]
-        + \frac{\partial w}{\partial s} \; \frac{\partial s}{\partial z} \\ \\
-      &     = \frac{1}{e_1 \,e_2 }   \left[
-		  \left.   \frac{\partial (e_2 \,u)}{\partial i}    \right|_s
-        + \left.   \frac{\partial (e_1 \,v)}{\partial j}    \right|_s       	\right]
-        + \frac{1}{e_3 }\left[        \frac{\partial w}{\partial s}
-        -  \sigma_1 \frac{\partial u}{\partial s}
-        -  \sigma_2 \frac{\partial v}{\partial s}      \right] \\ \\
-      &     = \frac{1}{e_1 \,e_2 \,e_3 }   \left[
-		  \left.   \frac{\partial (e_2 \,e_3 \,u)}{\partial i}    \right|_s
-		  -\left.    e_2 \,u    \frac{\partial e_3 }{\partial i}     \right|_s
-        + \left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j}    \right|_s
-		  - \left.    e_1 v      \frac{\partial e_3 }{\partial j}    \right|_s   \right] \\
-      & \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad
-        + \frac{1}{e_3 } \left[        \frac{\partial w}{\partial s}
-        -  \sigma_1 \frac{\partial u}{\partial s}
-        -  \sigma_2 \frac{\partial v}{\partial s}      \right]      \\
-      %
-      \intertext{Noting that $
-      \frac{1}{e_1} \left.{ \frac{\partial e_3}{\partial i}} \right|_s
-      =\frac{1}{e_1} \left.{ \frac{\partial^2 z}{\partial i\,\partial s}} \right|_s
-      =\frac{\partial}{\partial s} \left( {\frac{1}{e_1 } \left.{ \frac{\partial z}{\partial i} }\right|_s } \right)
-      =\frac{\partial \sigma_1}{\partial s}
-      $ and $
-      \frac{1}{e_2 }\left. {\frac{\partial e_3 }{\partial j}} \right|_s
-      =\frac{\partial \sigma_2}{\partial s}
-      $, it becomes:}
-    %
-      \nabla \cdot {\mathrm {\mathbf U}}
-      & = \frac{1}{e_1 \,e_2 \,e_3 }  \left[
-		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s
-        +\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right] \\
-      & \qquad \qquad \qquad \qquad \quad
-        +\frac{1}{e_3 }\left[ {\frac{\partial w}{\partial s}-u\frac{\partial \sigma_1 }{\partial s}-v\frac{\partial \sigma_2 }{\partial s}-\sigma_1 \frac{\partial u}{\partial s}-\sigma_2 \frac{\partial v}{\partial s}} \right] \\
-      \\
-      & = \frac{1}{e_1 \,e_2 \,e_3 }  \left[
-		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s
-        +\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]
-        + \frac{1}{e_3 } \; \frac{\partial}{\partial s}   \left[  w -  u\;\sigma_1  - v\;\sigma_2  \right]
-    \end{array}
-        }
-  \end{align*}
-\end{subequations}
-
-Here, $w$ is the vertical velocity relative to the $z-$coordinate system.
-Introducing the dia-surface velocity component,
-$\omega $, defined as the volume flux across the moving $s$-surfaces per unit horizontal area:
-\begin{equation}
-  \label{apdx:A_w_s}
-  \omega  = w - w_s - \sigma_1 \,u - \sigma_2 \,v    \\
-\end{equation}
-with $w_s$ given by \autoref{apdx:A_w_in_s},
-we obtain the expression for the divergence of the velocity in the curvilinear $s-$coordinate system:
-\begin{subequations}
-  \begin{align*}
-    {
-    \begin{array}{*{20}l}
-      \nabla \cdot {\mathrm {\mathbf U}}
-      &= \frac{1}{e_1 \,e_2 \,e_3 }    \left[
-		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s
-        +\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]
-        + \frac{1}{e_3 } \frac{\partial \omega }{\partial s}
-        + \frac{1}{e_3 } \frac{\partial w_s       }{\partial s} \\ \\
-      &= \frac{1}{e_1 \,e_2 \,e_3 }    \left[
-		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s
-        +\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]
-        + \frac{1}{e_3 } \frac{\partial \omega }{\partial s}
-        + \frac{1}{e_3 } \frac{\partial}{\partial s}  \left(  e_3 \; \frac{\partial s}{\partial t}   \right) \\ \\
-      &= \frac{1}{e_1 \,e_2 \,e_3 }    \left[
-		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s
-        +\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]
-        + \frac{1}{e_3 } \frac{\partial \omega }{\partial s}
-        + \frac{\partial}{\partial s} \frac{\partial s}{\partial t}
-        + \frac{1}{e_3 } \frac{\partial s}{\partial t} \frac{\partial e_3}{\partial s} \\ \\
-      &= \frac{1}{e_1 \,e_2 \,e_3 }    \left[
-		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s
-        +\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]
-        + \frac{1}{e_3 } \frac{\partial \omega }{\partial s}
-        + \frac{1}{e_3 } \frac{\partial e_3}{\partial t}
-    \end{array}
-        }
-  \end{align*}
-\end{subequations}
-
-As a result, the continuity equation \autoref{eq:PE_continuity} in the $s-$coordinates is:
-\begin{equation}
-  \label{apdx:A_sco_Continuity}
-  \frac{1}{e_3 } \frac{\partial e_3}{\partial t}
-  + \frac{1}{e_1 \,e_2 \,e_3 }\left[
-    {\left. {\frac{\partial (e_2 \,e_3 \,u)}{\partial i}} \right|_s
-      +  \left. {\frac{\partial (e_1 \,e_3 \,v)}{\partial j}} \right|_s } \right]
-  +\frac{1}{e_3 }\frac{\partial \omega }{\partial s} = 0
-\end{equation}
-A additional term has appeared that take into account
-the contribution of the time variation of the vertical coordinate to the volume budget.
-
-
-% ================================================================
-% momentum equation
-% ================================================================
-\section{Momentum equation in $s-$coordinate}
-\label{sec:A_momentum}
-
-Here we only consider the first component of the momentum equation,
-the generalization to the second one being straightforward.
-
-$\bullet$ \textbf{Total derivative in vector invariant form}
-
-Let us consider \autoref{eq:PE_dyn_vect}, the first component of the momentum equation in the vector invariant form.
-Its total $z-$coordinate time derivative,
-$\left. \frac{D u}{D t} \right|_z$ can be transformed as follows in order to obtain
-its expression in the curvilinear $s-$coordinate system:
-
-\begin{subequations}
-  \begin{align*}
-    {
-    \begin{array}{*{20}l}
-      \left. \frac{D u}{D t} \right|_z
-      &= \left. {\frac{\partial u }{\partial t}} \right|_z
-        - \left. \zeta \right|_z v
-        + \frac{1}{2e_1} \left.{ \frac{\partial (u^2+v^2)}{\partial i}} \right|_z
-        + w \;\frac{\partial u}{\partial z} \\ \\
-      &= \left. {\frac{\partial u }{\partial t}} \right|_z
-        - \left. \zeta \right|_z v
-        +  \frac{1}{e_1 \,e_2 }\left[ { \left.{ \frac{\partial (e_2 \,v)}{\partial i} }\right|_z
-        -\left.{ \frac{\partial (e_1 \,u)}{\partial j} }\right|_z } \right] \; v
-        +  \frac{1}{2e_1} \left.{ \frac{\partial (u^2+v^2)}{\partial i} } \right|_z
-        +  w \;\frac{\partial u}{\partial z}      \\
-        %
-      \intertext{introducing the chain rule (\autoref{apdx:A_s_chain_rule}) }
-      %
-      &= \left. {\frac{\partial u }{\partial t}} \right|_z
-        - \frac{1}{e_1\,e_2}\left[ { \left.{ \frac{\partial (e_2 \,v)}{\partial i} } \right|_s
-        -\left.{ \frac{\partial (e_1 \,u)}{\partial j} } \right|_s } \right.
-        \left. {-\frac{e_1}{e_3}\sigma_1 \frac{\partial (e_2 \,v)}{\partial s}
-        +\frac{e_2}{e_3}\sigma_2 \frac{\partial (e_1 \,u)}{\partial s}} \right] \; v  \\
-      & \qquad \qquad \qquad \qquad
-        {
-        + \frac{1}{2e_1} \left(                                  \left.  \frac{\partial (u^2+v^2)}{\partial i} \right|_s
-        - \frac{e_1}{e_3}\sigma_1 \frac{\partial (u^2+v^2)}{\partial s}               \right)
-        + \frac{w}{e_3 } \;\frac{\partial u}{\partial s}
-        } \\ \\
-      &= \left. {\frac{\partial u }{\partial t}} \right|_z
-        + \left. \zeta \right|_s \;v
-        + \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s \\
-      &\qquad \qquad \qquad \quad
-        + \frac{w}{e_3 } \;\frac{\partial u}{\partial s}
-        - \left[   {\frac{\sigma_1 }{e_3 }\frac{\partial v}{\partial s}
-        - \frac{\sigma_2 }{e_3 }\frac{\partial u}{\partial s}}   \right]\;v
-        - \frac{\sigma_1 }{2e_3 }\frac{\partial (u^2+v^2)}{\partial s} \\ \\
-      &= \left. {\frac{\partial u }{\partial t}} \right|_z
-        + \left. \zeta \right|_s \;v
-        + \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s \\
-      &\qquad \qquad \qquad \quad
-        + \frac{1}{e_3} \left[    {w\frac{\partial u}{\partial s}
-        +\sigma_1 v\frac{\partial v}{\partial s} - \sigma_2 v\frac{\partial u}{\partial s}
-        - \sigma_1 u\frac{\partial u}{\partial s} - \sigma_1 v\frac{\partial v}{\partial s}} \right] \\ \\
-      &= \left. {\frac{\partial u }{\partial t}} \right|_z
-        + \left. \zeta \right|_s \;v
-        + \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s
-        + \frac{1}{e_3} \left[  w - \sigma_2 v - \sigma_1 u  \right]
-        \; \frac{\partial u}{\partial s}   \\
-        %
-      \intertext{Introducing $\omega$, the dia-a-surface velocity given by (\autoref{apdx:A_w_s}) }
-      %
-      &= \left. {\frac{\partial u }{\partial t}} \right|_z
-        + \left. \zeta \right|_s \;v
-        + \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s
-        + \frac{1}{e_3 } \left( \omega - w_s \right) \frac{\partial u}{\partial s}   \\
-    \end{array}
-    }
-  \end{align*}
-\end{subequations}
-%
-Applying the time derivative chain rule (first equation of (\autoref{apdx:A_s_chain_rule})) to $u$ and
-using (\autoref{apdx:A_w_in_s}) provides the expression of the last term of the right hand side,
-\[
-  {
-    \begin{array}{*{20}l}
-      w_s  \;\frac{\partial u}{\partial s}
-      = \frac{\partial s}{\partial t} \;  \frac{\partial u }{\partial s}
-      = \left. {\frac{\partial u }{\partial t}} \right|_s  - \left. {\frac{\partial u }{\partial t}} \right|_z \quad ,
-    \end{array}
-  }
-\]
-leads to the $s-$coordinate formulation of the total $z-$coordinate time derivative,
-\ie the total $s-$coordinate time derivative :
-\begin{align}
-  \label{apdx:A_sco_Dt_vect}
-  \left. \frac{D u}{D t} \right|_s
-  = \left. {\frac{\partial u }{\partial t}} \right|_s
-  + \left. \zeta \right|_s \;v
-  + \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s
-  + \frac{1}{e_3 } \omega \;\frac{\partial u}{\partial s}
-\end{align}
-Therefore, the vector invariant form of the total time derivative has exactly the same mathematical form in
-$z-$ and $s-$coordinates.
-This is not the case for the flux form as shown in next paragraph.
-
-$\bullet$ \textbf{Total derivative in flux form}
-
-Let us start from the total time derivative in the curvilinear $s-$coordinate system we have just establish.
-Following the procedure used to establish (\autoref{eq:PE_flux_form}), it can be transformed into :
-% \begin{subequations}
-\begin{align*}
-  {
-  \begin{array}{*{20}l}
-    \left. \frac{D u}{D t} \right|_s  &= \left. {\frac{\partial u }{\partial t}} \right|_s
-    & -  \zeta \;v
-      + \frac{1}{2\;e_1 } \frac{\partial \left( {u^2+v^2} \right)}{\partial i}
-      + \frac{1}{e_3} \omega \;\frac{\partial u}{\partial s} \\ \\
-                                      &= \left. {\frac{\partial u }{\partial t}} \right|_s
-    &+\frac{1}{e_1\;e_2}  \left(    \frac{\partial \left( {e_2 \,u\,u } \right)}{\partial i}
-      + \frac{\partial \left( {e_1 \,u\,v } \right)}{\partial j}     \right)
-      + \frac{1}{e_3 } \frac{\partial \left( {\omega\,u} \right)}{\partial s} \\ \\
-                                      &&- \,u \left[     \frac{1}{e_1 e_2 } \left(    \frac{\partial(e_2 u)}{\partial i}
-                                         + \frac{\partial(e_1 v)}{\partial j}    \right)
-                                         + \frac{1}{e_3}        \frac{\partial \omega}{\partial s}                       \right] \\ \\
-                                      &&- \frac{v}{e_1 e_2 }\left(    v	\;\frac{\partial e_2 }{\partial i}
-                                         -u	\;\frac{\partial e_1 }{\partial j} 	\right) \\
-  \end{array}
-  }
-\end{align*}
-%
-Introducing the vertical scale factor inside the horizontal derivative of the first two terms 
-(\ie the horizontal divergence), it becomes :
-\begin{align*}
-  {
-  \begin{array}{*{20}l}
-    % \begin{align*} {\begin{array}{*{20}l}
-    %     {\begin{array}{*{20}l} \left. \frac{D u}{D t} \right|_s  
-    &= \left. {\frac{\partial u }{\partial t}} \right|_s
-    &+ \frac{1}{e_1\,e_2\,e_3}  \left(  \frac{\partial( e_2 e_3 \,u^2 )}{\partial i}
-      + \frac{\partial( e_1 e_3 \,u v )}{\partial j}
-      -  e_2 u u \frac{\partial e_3}{\partial i}
-      -  e_1 u v \frac{\partial e_3 }{\partial j}    \right)
-      + \frac{1}{e_3} \frac{\partial \left( {\omega\,u} \right)}{\partial s} \\ \\
-    && - \,u \left[  \frac{1}{e_1 e_2 e_3} \left(   \frac{\partial(e_2 e_3 \, u)}{\partial i}
-       + \frac{\partial(e_1 e_3 \, v)}{\partial j}
-       -  e_2 u \;\frac{\partial e_3 }{\partial i}
-       -  e_1 v \;\frac{\partial e_3 }{\partial j}   \right)
-       -\frac{1}{e_3}        \frac{\partial \omega}{\partial s}                       \right] \\ \\
-    && - \frac{v}{e_1 e_2 }\left( 	v  \;\frac{\partial e_2 }{\partial i}
-       -u  \;\frac{\partial e_1 }{\partial j} 	\right) \\ \\
-    &= \left. {\frac{\partial u }{\partial t}} \right|_s
-    &+ \frac{1}{e_1\,e_2\,e_3}  \left(  \frac{\partial( e_2 e_3 \,u\,u )}{\partial i}
-      + \frac{\partial( e_1 e_3 \,u\,v )}{\partial j}    \right)
-      + \frac{1}{e_3 } \frac{\partial \left( {\omega\,u} \right)}{\partial s} \\ \\
-    && - \,u \left[  \frac{1}{e_1 e_2 e_3} \left(   \frac{\partial(e_2 e_3 \, u)}{\partial i}
-       + \frac{\partial(e_1 e_3 \, v)}{\partial j}  \right)
-       -\frac{1}{e_3}        \frac{\partial \omega}{\partial s}                       \right]
-       - \frac{v}{e_1 e_2 }\left( 	v   \;\frac{\partial e_2 }{\partial i}
-       -u   \;\frac{\partial e_1 }{\partial j} 	\right)                  \\
-     %
-    \intertext {Introducing a more compact form for the divergence of the momentum fluxes,
-    and using (\autoref{apdx:A_sco_Continuity}), the $s-$coordinate continuity equation,
-    it becomes : }
-  %
-    &= \left. {\frac{\partial u }{\partial t}} \right|_s
-    &+ \left.  \nabla \cdot \left(   {{\mathrm {\mathbf U}}\,u}   \right)    \right|_s
-      + \,u \frac{1}{e_3 } \frac{\partial e_3}{\partial t}
-      - \frac{v}{e_1 e_2 }\left(    v  \;\frac{\partial e_2 }{\partial i}
-      -u  \;\frac{\partial e_1 }{\partial j} 	\right)
-    \\
-  \end{array}
-  }
-\end{align*}
-which leads to the $s-$coordinate flux formulation of the total $s-$coordinate time derivative, 
-\ie the total $s-$coordinate time derivative in flux form:
-\begin{flalign}
-  \label{apdx:A_sco_Dt_flux}
-  \left. \frac{D u}{D t} \right|_s   = \frac{1}{e_3}  \left. \frac{\partial ( e_3\,u)}{\partial t} \right|_s
-  + \left.  \nabla \cdot \left(   {{\mathrm {\mathbf U}}\,u}   \right)    \right|_s
-  - \frac{v}{e_1 e_2 }\left(    v  \;\frac{\partial e_2 }{\partial i}
-    -u  \;\frac{\partial e_1 }{\partial j}            \right)
-\end{flalign}
-which is the total time derivative expressed in the curvilinear $s-$coordinate system.
-It has the same form as in the $z-$coordinate but for
-the vertical scale factor that has appeared inside the time derivative which
-comes from the modification of (\autoref{apdx:A_sco_Continuity}),
-the continuity equation.
-
-$\bullet$ \textbf{horizontal pressure gradient}
-
-The horizontal pressure gradient term can be transformed as follows:
-\[
-  \begin{split}
-    -\frac{1}{\rho_o \, e_1 }\left. {\frac{\partial p}{\partial i}} \right|_z
-    & =-\frac{1}{\rho_o e_1 }\left[ {\left. {\frac{\partial p}{\partial i}} \right|_s -\frac{e_1 }{e_3 }\sigma_1 \frac{\partial p}{\partial s}} \right] \\
-    & =-\frac{1}{\rho_o \,e_1 }\left. {\frac{\partial p}{\partial i}} \right|_s +\frac{\sigma_1 }{\rho_o \,e_3 }\left( {-g\;\rho \;e_3 } \right) \\
-    &=-\frac{1}{\rho_o \,e_1 }\left. {\frac{\partial p}{\partial i}} \right|_s -\frac{g\;\rho }{\rho_o }\sigma_1
-  \end{split}
-\]
-Applying similar manipulation to the second component and
-replacing $\sigma_1$ and $\sigma_2$ by their expression \autoref{apdx:A_s_slope}, it comes:
-\begin{equation}
-  \label{apdx:A_grad_p_1}
-  \begin{split}
-    -\frac{1}{\rho_o \, e_1 } \left. {\frac{\partial p}{\partial i}} \right|_z
-    &=-\frac{1}{\rho_o \,e_1 } \left(     \left.              {\frac{\partial p}{\partial i}} \right|_s
-      + g\;\rho  \;\left. {\frac{\partial z}{\partial i}} \right|_s    \right) \\
-             %
-    -\frac{1}{\rho_o \, e_2 }\left. {\frac{\partial p}{\partial j}} \right|_z
-    &=-\frac{1}{\rho_o \,e_2 } \left(    \left.               {\frac{\partial p}{\partial j}} \right|_s
-      + g\;\rho \;\left. {\frac{\partial z}{\partial j}} \right|_s   \right) \\
-  \end{split}
-\end{equation}
-
-An additional term appears in (\autoref{apdx:A_grad_p_1}) which accounts for
-the tilt of $s-$surfaces with respect to geopotential $z-$surfaces.
-
-As in $z$-coordinate,
-the horizontal pressure gradient can be split in two parts following \citet{marsaleix.auclair.ea_OM08}.
-Let defined a density anomaly, $d$, by $d=(\rho - \rho_o)/ \rho_o$,
-and a hydrostatic pressure anomaly, $p_h'$, by $p_h'= g \; \int_z^\eta d \; e_3 \; dk$.
-The pressure is then given by:
-\[
-  \begin{split}
-    p &= g\; \int_z^\eta \rho \; e_3 \; dk = g\; \int_z^\eta \left(  \rho_o \, d + 1 \right) \; e_3 \; dk   \\
-    &= g \, \rho_o \; \int_z^\eta d \; e_3 \; dk + g \, \int_z^\eta e_3 \; dk
-  \end{split}
-\]
-Therefore, $p$ and $p_h'$ are linked through:
-\begin{equation}
-  \label{apdx:A_pressure}
-  p = \rho_o \; p_h' + g \, ( z + \eta )
-\end{equation}
-and the hydrostatic pressure balance expressed in terms of $p_h'$ and $d$ is:
-\[
-  \frac{\partial p_h'}{\partial k} = - d \, g \, e_3
-\]
-
-Substituing \autoref{apdx:A_pressure} in \autoref{apdx:A_grad_p_1} and
-using the definition of the density anomaly it comes the expression in two parts:
-\begin{equation}
-  \label{apdx:A_grad_p_2}
-  \begin{split}
-    -\frac{1}{\rho_o \, e_1 } \left. {\frac{\partial p}{\partial i}} \right|_z
-    &=-\frac{1}{e_1 } \left(     \left.              {\frac{\partial p_h'}{\partial i}} \right|_s
-      + g\; d  \;\left. {\frac{\partial z}{\partial i}} \right|_s    \right)  - \frac{g}{e_1 } \frac{\partial \eta}{\partial i} \\
-             %
-    -\frac{1}{\rho_o \, e_2 }\left. {\frac{\partial p}{\partial j}} \right|_z
-    &=-\frac{1}{e_2 } \left(    \left.               {\frac{\partial p_h'}{\partial j}} \right|_s
-      + g\; d \;\left. {\frac{\partial z}{\partial j}} \right|_s   \right)  - \frac{g}{e_2 } \frac{\partial \eta}{\partial j}\\
-  \end{split}
-\end{equation}
-This formulation of the pressure gradient is characterised by the appearance of
-a term depending on the sea surface height only
-(last term on the right hand side of expression \autoref{apdx:A_grad_p_2}).
-This term will be loosely termed \textit{surface pressure gradient} whereas
-the first term will be termed the \textit{hydrostatic pressure gradient} by analogy to
-the $z$-coordinate formulation.
-In fact, the true surface pressure gradient is $1/\rho_o \nabla (\rho \eta)$,
-and $\eta$ is implicitly included in the computation of $p_h'$ through the upper bound of the vertical integration.
-
-$\bullet$ \textbf{The other terms of the momentum equation}
-
-The coriolis and forcing terms as well as the the vertical physics remain unchanged as
-they involve neither time nor space derivatives.
-The form of the lateral physics is discussed in \autoref{apdx:B}.
-
-$\bullet$ \textbf{Full momentum equation}
-
-To sum up, in a curvilinear $s$-coordinate system,
-the vector invariant momentum equation solved by the model has the same mathematical expression as
-the one in a curvilinear $z-$coordinate, except for the pressure gradient term:
-\begin{subequations}
-  \label{apdx:A_dyn_vect}
-  \begin{multline}
-    \label{apdx:A_PE_dyn_vect_u}
-    \frac{\partial u}{\partial t}=
-    +   \left( {\zeta +f} \right)\,v
-    -   \frac{1}{2\,e_1} \frac{\partial}{\partial i} \left(  u^2+v^2   \right)
-    -   \frac{1}{e_3} \omega \frac{\partial u}{\partial k}       \\
-    -   \frac{1}{e_1 } \left(    \frac{\partial p_h'}{\partial i} + g\; d  \; \frac{\partial z}{\partial i}    \right)
-    -   \frac{g}{e_1 } \frac{\partial \eta}{\partial i}
-    +   D_u^{\vect{U}}  +   F_u^{\vect{U}}
-  \end{multline}
-  \begin{multline}
-    \label{apdx:A_dyn_vect_v}
-    \frac{\partial v}{\partial t}=
-    -   \left( {\zeta +f} \right)\,u
-    -   \frac{1}{2\,e_2 }\frac{\partial }{\partial j}\left(  u^2+v^2  \right)
-    -   \frac{1}{e_3 } \omega \frac{\partial v}{\partial k}         \\
-    -   \frac{1}{e_2 } \left(    \frac{\partial p_h'}{\partial j} + g\; d  \; \frac{\partial z}{\partial j}    \right)
-    -   \frac{g}{e_2 } \frac{\partial \eta}{\partial j}
-    +  D_v^{\vect{U}}  +   F_v^{\vect{U}}
-  \end{multline}
-\end{subequations}
-whereas the flux form momentum equation differs from it by
-the formulation of both the time derivative and the pressure gradient term:
-\begin{subequations}
-  \label{apdx:A_dyn_flux}
-  \begin{multline}
-    \label{apdx:A_PE_dyn_flux_u}
-    \frac{1}{e_3} \frac{\partial \left(  e_3\,u  \right) }{\partial t} =
-    \nabla \cdot \left(   {{\mathrm {\mathbf U}}\,u}   \right)
-    +   \left\{ {f + \frac{1}{e_1 e_2 }\left(    v  \;\frac{\partial e_2 }{\partial i}
-          -u  \;\frac{\partial e_1 }{\partial j}            \right)} \right\} \,v     \\
-    -   \frac{1}{e_1 } \left(    \frac{\partial p_h'}{\partial i} + g\; d  \; \frac{\partial z}{\partial i}    \right)
-    -   \frac{g}{e_1 } \frac{\partial \eta}{\partial i}
-    +   D_u^{\vect{U}}  +   F_u^{\vect{U}}
-  \end{multline}
-  \begin{multline}
-    \label{apdx:A_dyn_flux_v}
-    \frac{1}{e_3}\frac{\partial \left(  e_3\,v  \right) }{\partial t}=
-    -  \nabla \cdot \left(   {{\mathrm {\mathbf U}}\,v}   \right)
-    +   \left\{ {f + \frac{1}{e_1 e_2 }\left(    v  \;\frac{\partial e_2 }{\partial i}
-          -u  \;\frac{\partial e_1 }{\partial j}            \right)} \right\} \,u     \\
-    -   \frac{1}{e_2 } \left(    \frac{\partial p_h'}{\partial j} + g\; d  \; \frac{\partial z}{\partial j}    \right)
-    -   \frac{g}{e_2 } \frac{\partial \eta}{\partial j}
-    +  D_v^{\vect{U}}  +   F_v^{\vect{U}}
-  \end{multline}
-\end{subequations}
-Both formulation share the same hydrostatic pressure balance expressed in terms of
-hydrostatic pressure and density anomalies, $p_h'$ and $d=( \frac{\rho}{\rho_o}-1 )$:
-\begin{equation}
-  \label{apdx:A_dyn_zph}
-  \frac{\partial p_h'}{\partial k} = - d \, g \, e_3
-\end{equation}
-
-It is important to realize that the change in coordinate system has only concerned the position on the vertical.
-It has not affected (\textbf{i},\textbf{j},\textbf{k}), the orthogonal curvilinear set of unit vectors.
-($u$,$v$) are always horizontal velocities so that their evolution is driven by \emph{horizontal} forces,
-in particular the pressure gradient.
-By contrast, $\omega$ is not $w$, the third component of the velocity, but the dia-surface velocity component,
-\ie the volume flux across the moving $s$-surfaces per unit horizontal area. 
-
-
-% ================================================================
-% Tracer equation
-% ================================================================
-\section{Tracer equation}
-\label{sec:A_tracer}
-
-The tracer equation is obtained using the same calculation as for the continuity equation and then
-regrouping the time derivative terms in the left hand side :
-
-\begin{multline}
-  \label{apdx:A_tracer}
-  \frac{1}{e_3} \frac{\partial \left(  e_3 T  \right)}{\partial t}
-  = -\frac{1}{e_1 \,e_2 \,e_3}
-  \left[           \frac{\partial }{\partial i} \left( {e_2 \,e_3 \;Tu} \right)
-    +   \frac{\partial }{\partial j} \left( {e_1 \,e_3 \;Tv} \right)               \right]       \\
-  +  \frac{1}{e_3}  \frac{\partial }{\partial k} \left(                   Tw  \right)
-  +  D^{T} +F^{T}
-\end{multline}
-
-The expression for the advection term is a straight consequence of (A.4),
-the expression of the 3D divergence in the $s-$coordinates established above. 
-
-\biblio
-
-\pindex
-
-\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/annex_B.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/annex_B.tex	(revision 12062)
+++ 	(revision )
@@ -1,406 +1,0 @@
-\documentclass[../main/NEMO_manual]{subfiles}
-
-\begin{document}
-% ================================================================
-% Chapter Appendix B : Diffusive Operators
-% ================================================================
-\chapter{Appendix B : Diffusive Operators}
-\label{apdx:B}
-
-\minitoc
-
-\newpage
-
-% ================================================================
-% Horizontal/Vertical 2nd Order Tracer Diffusive Operators
-% ================================================================
-\section{Horizontal/Vertical $2^{nd}$ order tracer diffusive operators}
-\label{sec:B_1}
-
-\subsubsection*{In z-coordinates}
-
-In $z$-coordinates, the horizontal/vertical second order tracer diffusion operator is given by:
-\begin{align}
-  \label{apdx:B1}
-  &D^T = \frac{1}{e_1 \, e_2}      \left[
-    \left. \frac{\partial}{\partial i} \left( 	\frac{e_2}{e_1}A^{lT} \;\left. \frac{\partial T}{\partial i} \right|_z   \right)   \right|_z      \right.
-    \left.
-    + \left. \frac{\partial}{\partial j} \left(  \frac{e_1}{e_2}A^{lT} \;\left. \frac{\partial T}{\partial j} \right|_z   \right)   \right|_z      \right]
-    + \frac{\partial }{\partial z}\left( {A^{vT} \;\frac{\partial T}{\partial z}} \right)
-\end{align}
-
-\subsubsection*{In generalized vertical coordinates}
-
-In $s$-coordinates, we defined the slopes of $s$-surfaces, $\sigma_1$ and $\sigma_2$ by \autoref{apdx:A_s_slope} and
-the vertical/horizontal ratio of diffusion coefficient by $\epsilon = A^{vT} / A^{lT}$.
-The diffusion operator is given by:
-
-\begin{equation}
-  \label{apdx:B2}
-  D^T = \left. \nabla \right|_s \cdot
-  \left[ A^{lT} \;\Re \cdot \left. \nabla \right|_s T  \right] \\
-  \;\;\text{where} \;\Re =\left( {{
-        \begin{array}{*{20}c}
-          1 \hfill & 0 \hfill & {-\sigma_1 } \hfill \\
-          0 \hfill & 1 \hfill & {-\sigma_2 } \hfill \\
-          {-\sigma_1 } \hfill & {-\sigma_2 } \hfill & {\varepsilon +\sigma_1
-                                                      ^2+\sigma_2 ^2} \hfill \\
-        \end{array}
-      }} \right)
-\end{equation}
-or in expanded form:
-\begin{align*}
-  {
-  \begin{array}{*{20}l}
-    D^T=& \frac{1}{e_1\,e_2\,e_3 }\;\left[ {\ \ \ \ e_2\,e_3\,A^{lT} \;\left.
-          {\frac{\partial }{\partial i}\left( {\frac{1}{e_1}\;\left. {\frac{\partial T}{\partial i}} \right|_s -\frac{\sigma_1 }{e_3 }\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right.  \\
-        &\qquad \quad \ \ \ +e_1\,e_3\,A^{lT} \;\left. {\frac{\partial }{\partial j}\left( {\frac{1}{e_2 }\;\left. {\frac{\partial T}{\partial j}} \right|_s -\frac{\sigma_2 }{e_3 }\;\frac{\partial T}{\partial s}} \right)} \right|_s \\
-        &\qquad \quad \ \ \ + e_1\,e_2\,A^{lT} \;\frac{\partial }{\partial s}\left( {-\frac{\sigma_1 }{e_1 }\;\left. {\frac{\partial T}{\partial i}} \right|_s -\frac{\sigma_2 }{e_2 }\;\left. {\frac{\partial T}{\partial j}} \right|_s } \right.
-          \left. {\left. {+\left( {\varepsilon +\sigma_1^2+\sigma_2 ^2} \right)\;\frac{1}{e_3 }\;\frac{\partial T}{\partial s}} \right)\;\;} \right]
-  \end{array}
-          }
-\end{align*}
-
-Equation \autoref{apdx:B2} is obtained from \autoref{apdx:B1} without any additional assumption.
-Indeed, for the special case $k=z$ and thus $e_3 =1$,
-we introduce an arbitrary vertical coordinate $s = s (i,j,z)$ as in \autoref{apdx:A} and
-use \autoref{apdx:A_s_slope} and \autoref{apdx:A_s_chain_rule}.
-Since no cross horizontal derivative $\partial _i \partial _j $ appears in \autoref{apdx:B1},
-the ($i$,$z$) and ($j$,$z$) planes are independent.
-The derivation can then be demonstrated for the ($i$,$z$)~$\to$~($j$,$s$) transformation without
-any loss of generality:
-
-\begin{align*}
-  {
-  \begin{array}{*{20}l}
-    D^T&=\frac{1}{e_1\,e_2} \left. {\frac{\partial }{\partial i}\left( {\frac{e_2}{e_1}A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_z } \right)} \right|_z
-         +\frac{\partial }{\partial z}\left( {A^{vT}\;\frac{\partial T}{\partial z}} \right) \\ \\
-         %
-       &=\frac{1}{e_1\,e_2 }\left[ {\left. {\;\frac{\partial }{\partial i}\left( {\frac{e_2}{e_1}A^{lT}\;\left( {\left. {\frac{\partial T}{\partial i}} \right|_s
-         -\frac{e_1\,\sigma_1 }{e_3 }\frac{\partial T}{\partial s}} \right)} \right)} \right|_s } \right. \\
-       & \qquad \qquad \left. { -\frac{e_1\,\sigma_1 }{e_3 }\frac{\partial }{\partial s}\left( {\frac{e_2 }{e_1 }A^{lT}\;\left. {\left( {\left. {\frac{\partial T}{\partial i}} \right|_s -\frac{e_1 \,\sigma_1 }{e_3 }\frac{\partial T}{\partial s}} \right)} \right|_s } \right)\;} \right]
-         \shoveright{ +\frac{1}{e_3 }\frac{\partial }{\partial s}\left[ {\frac{A^{vT}}{e_3 }\;\frac{\partial T}{\partial s}} \right]}  \qquad \qquad \qquad \\ \\
-         %
-       &=\frac{1}{e_1 \,e_2 \,e_3 }\left[ {\left. {\;\;\frac{\partial }{\partial i}\left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)} \right|_s -\left. {\frac{e_2 }{e_1}A^{lT}\;\frac{\partial e_3 }{\partial i}} \right|_s \left. {\frac{\partial T}{\partial i}} \right|_s } \right. \\
-       &  \qquad \qquad \quad \left. {-e_3 \frac{\partial }{\partial i}\left( {\frac{e_2 \,\sigma_1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s -e_1 \,\sigma_1 \frac{\partial }{\partial s}\left( {\frac{e_2 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right) \\
-       &  \qquad \qquad \quad \shoveright{ -e_1 \,\sigma_1 \frac{\partial }{\partial s}\left( {-\frac{e_2 \,\sigma_1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)\;\,\left. {+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 }{e_3 }A^{vT}\;\frac{\partial T}{\partial s}} \right)\quad} \right] }\\
-  \end{array}
-  } 		\\
-  %
-  {
-  \begin{array}{*{20}l}
-    \intertext{Noting that $\frac{1}{e_1} \left. \frac{\partial e_3 }{\partial i} \right|_s = \frac{\partial \sigma_1 }{\partial s}$, it becomes:}
-    %
-    & =\frac{1}{e_1\,e_2\,e_3 }\left[ {\left. {\;\;\;\frac{\partial }{\partial i}\left( {\frac{e_2\,e_3 }{e_1}\,A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)} \right|_s \left. -\, {e_3 \frac{\partial }{\partial i}\left( {\frac{e_2 \,\sigma_1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right. \\
-    & \qquad \qquad \quad -e_2 A^{lT}\;\frac{\partial \sigma_1 }{\partial s}\left. {\frac{\partial T}{\partial i}} \right|_s -e_1 \,\sigma_1 \frac{\partial }{\partial s}\left( {\frac{e_2 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right) \\
-    & \qquad \qquad \quad\shoveright{ \left. { +e_1 \,\sigma_1 \frac{\partial }{\partial s}\left( {\frac{e_2 \,\sigma_1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 }{e_3 }A^{vT}\;\frac{\partial T}{\partial z}} \right)\;\;\;} \right] }\\
-    \\
-    &=\frac{1}{e_1 \,e_2 \,e_3 } \left[ {\left. {\;\;\;\frac{\partial }{\partial i} \left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)} \right|_s \left. {-\frac{\partial }{\partial i}\left( {e_2 \,\sigma_1 A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right. \\
-    & \qquad \qquad \quad \left. {+\frac{e_2 \,\sigma_1 }{e_3}A^{lT}\;\frac{\partial T}{\partial s} \;\frac{\partial e_3 }{\partial i}}  \right|_s -e_2 A^{lT}\;\frac{\partial \sigma_1 }{\partial s}\left. {\frac{\partial T}{\partial i}} \right|_s \\
-    & \qquad \qquad \quad-e_2 \,\sigma_1 \frac{\partial}{\partial s}\left( {A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 \,\sigma_1 ^2}{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right) \\
-    & \qquad \qquad \quad\shoveright{ \left. {-\frac{\partial \left( {e_1 \,e_2 \,\sigma_1 } \right)}{\partial s} \left( {\frac{\sigma_1 }{e_3}A^{lT}\;\frac{\partial T}{\partial s}} \right) + \frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 }{e_3 }A^{vT}\;\frac{\partial T}{\partial s}} \right)\;\;\;} \right]}
-  \end{array}
-      } \\
-  {
-  \begin{array}{*{20}l}
-    %
-    \intertext{using the same remark as just above, it becomes:}
-    %
-    &= \frac{1}{e_1 \,e_2 \,e_3 } \left[ {\left. {\;\;\;\frac{\partial }{\partial i} \left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s -e_2 \,\sigma_1 A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right.\;\;\; \\
-    & \qquad \qquad \quad+\frac{e_1 \,e_2 \,\sigma_1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}\;\frac{\partial \sigma_1 }{\partial s} - \frac {\sigma_1 }{e_3} A^{lT} \;\frac{\partial \left( {e_1 \,e_2 \,\sigma_1 } \right)}{\partial s}\;\frac{\partial T}{\partial s} \\
-    & \qquad \qquad \quad-e_2 \left( {A^{lT}\;\frac{\partial \sigma_1 }{\partial s}\left. {\frac{\partial T}{\partial i}} \right|_s +\frac{\partial }{\partial s}\left( {\sigma_1 A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)-\frac{\partial \sigma_1 }{\partial s}\;A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right) \\
-    & \qquad \qquad \quad\shoveright{\left. {+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 \,\sigma_1 ^2}{e_3 }A^{lT}\;\frac{\partial T}{\partial s}+\frac{e_1 \,e_2}{e_3 }A^{vT}\;\frac{\partial T}{\partial s}} \right)\;\;\;} \right] }
-  \end{array}
-      } \\
-  {
-  \begin{array}{*{20}l}
-    %
-    \intertext{Since the horizontal scale factors do not depend on the vertical coordinate,
-    the last term of the first line and the first term of the last line cancel, while
-    the second line reduces to a single vertical derivative, so it becomes:}
-  %
-    & =\frac{1}{e_1 \,e_2 \,e_3 }\left[ {\left. {\;\;\;\frac{\partial }{\partial i}\left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s -e_2 \,\sigma_1 \,A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right. \\
-    & \qquad \qquad \quad \shoveright{ \left. {+\frac{\partial }{\partial s}\left( {-e_2 \,\sigma_1 \,A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s +A^{lT}\frac{e_1 \,e_2 }{e_3 }\;\left( {\varepsilon +\sigma_1 ^2} \right)\frac{\partial T}{\partial s}} \right)\;\;\;} \right]} \\
-    %
-    \intertext{in other words, the horizontal/vertical Laplacian operator in the ($i$,$s$) plane takes the following form:}
-  \end{array}
-  } \\
-  %
-  {\frac{1}{e_1\,e_2\,e_3}}
-  \left( {{
-  \begin{array}{*{30}c}
-    {\left. {\frac{\partial \left( {e_2 e_3 \bullet } \right)}{\partial i}} \right|_s } \hfill \\
-    {\frac{\partial \left( {e_1 e_2 \bullet } \right)}{\partial s}} \hfill \\
-  \end{array}}}
-  \right)
-  \cdot \left[ {A^{lT}
-  \left( {{
-  \begin{array}{*{30}c}
-    {1} \hfill & {-\sigma_1 } \hfill \\
-    {-\sigma_1} \hfill & {\varepsilon + \sigma_1^2} \hfill \\
-  \end{array}
-  }} \right)
-  \cdot
-  \left( {{
-  \begin{array}{*{30}c}
-    {\frac{1}{e_1 }\;\left. {\frac{\partial \bullet }{\partial i}} \right|_s } \hfill \\
-    {\frac{1}{e_3 }\;\frac{\partial \bullet }{\partial s}} \hfill \\
-  \end{array}
-  }}       \right) \left( T \right)} \right]
-\end{align*}
-%\addtocounter{equation}{-2}
-
-% ================================================================
-% Isopycnal/Vertical 2nd Order Tracer Diffusive Operators
-% ================================================================
-\section{Iso/Diapycnal $2^{nd}$ order tracer diffusive operators}
-\label{sec:B_2}
-
-\subsubsection*{In z-coordinates}
-
-The iso/diapycnal diffusive tensor $\textbf {A}_{\textbf I}$ expressed in
-the ($i$,$j$,$k$) curvilinear coordinate system in which
-the equations of the ocean circulation model are formulated,
-takes the following form \citep{redi_JPO82}:
-
-\begin{equation}
-  \label{apdx:B3}
-  \textbf {A}_{\textbf I} = \frac{A^{lT}}{\left( {1+a_1 ^2+a_2 ^2} \right)}
-  \left[ {{
-        \begin{array}{*{20}c}
-          {1+a_1 ^2} \hfill & {-a_1 a_2 } \hfill & {-a_1 } \hfill \\
-          {-a_1 a_2 } \hfill & {1+a_2 ^2} \hfill & {-a_2 } \hfill \\
-          {-a_1 } \hfill & {-a_2 } \hfill & {\varepsilon +a_1 ^2+a_2 ^2} \hfill \\
-        \end{array}
-      }} \right]
-\end{equation}
-where ($a_1$, $a_2$) are the isopycnal slopes in ($\textbf{i}$, $\textbf{j}$) directions, relative to geopotentials:
-\[
-  a_1 =\frac{e_3 }{e_1 }\left( {\frac{\partial \rho }{\partial i}} \right)\left( {\frac{\partial \rho }{\partial k}} \right)^{-1}
-  \qquad , \qquad
-  a_2 =\frac{e_3 }{e_2 }\left( {\frac{\partial \rho }{\partial j}}
-  \right)\left( {\frac{\partial \rho }{\partial k}} \right)^{-1}
-\]
-
-In practice, isopycnal slopes are generally less than $10^{-2}$ in the ocean,
-so $\textbf {A}_{\textbf I}$ can be simplified appreciably \citep{cox_OM87}:
-\begin{subequations}
-  \label{apdx:B4}
-  \begin{equation}
-    \label{apdx:B4a}
-    {\textbf{A}_{\textbf{I}}} \approx A^{lT}\;\Re\;\text{where} \;\Re =
-    \left[ {{
-          \begin{array}{*{20}c}
-            1 \hfill & 0 \hfill & {-a_1 } \hfill \\
-            0 \hfill & 1 \hfill & {-a_2 } \hfill \\
-            {-a_1 } \hfill & {-a_2 } \hfill & {\varepsilon +a_1 ^2+a_2 ^2} \hfill \\
-          \end{array}
-        }} \right],
-  \end{equation}
-  and the iso/dianeutral diffusive operator in $z$-coordinates is then
-  \begin{equation}
-    \label{apdx:B4b}
-    D^T = \left. \nabla \right|_z \cdot
-    \left[ A^{lT} \;\Re \cdot \left. \nabla \right|_z T  \right]. \\
-  \end{equation}
-\end{subequations}
-
-Physically, the full tensor \autoref{apdx:B3} represents strong isoneutral diffusion on a plane parallel to
-the isoneutral surface and weak dianeutral diffusion perpendicular to this plane.
-However,
-the approximate `weak-slope' tensor \autoref{apdx:B4a} represents strong diffusion along the isoneutral surface,
-with weak \emph{vertical} diffusion -- the principal axes of the tensor are no longer orthogonal.
-This simplification also decouples the ($i$,$z$) and ($j$,$z$) planes of the tensor.
-The weak-slope operator therefore takes the same form, \autoref{apdx:B4}, as \autoref{apdx:B2},
-the diffusion operator for geopotential diffusion written in non-orthogonal $i,j,s$-coordinates.
-Written out explicitly,
-
-\begin{multline}
-  \label{apdx:B_ldfiso}
-  D^T=\frac{1}{e_1 e_2 }\left\{
-    {\;\frac{\partial }{\partial i}\left[ {A_h \left( {\frac{e_2}{e_1}\frac{\partial T}{\partial i}-a_1 \frac{e_2}{e_3}\frac{\partial T}{\partial k}} \right)} \right]}
-    {+\frac{\partial}{\partial j}\left[ {A_h \left( {\frac{e_1}{e_2}\frac{\partial T}{\partial j}-a_2 \frac{e_1}{e_3}\frac{\partial T}{\partial k}} \right)} \right]\;} \right\} \\
-  \shoveright{+\frac{1}{e_3 }\frac{\partial }{\partial k}\left[ {A_h \left( {-\frac{a_1 }{e_1 }\frac{\partial T}{\partial i}-\frac{a_2 }{e_2 }\frac{\partial T}{\partial j}+\frac{\left( {a_1 ^2+a_2 ^2+\varepsilon} \right)}{e_3 }\frac{\partial T}{\partial k}} \right)} \right]}. \\
-\end{multline}
-
-The isopycnal diffusion operator \autoref{apdx:B4},
-\autoref{apdx:B_ldfiso} conserves tracer quantity and dissipates its square.
-The demonstration of the first property is trivial as \autoref{apdx:B4} is the divergence of fluxes.
-Let us demonstrate the second one:
-\[
-  \iiint\limits_D T\;\nabla .\left( {\textbf{A}}_{\textbf{I}} \nabla T \right)\,dv
-  = -\iiint\limits_D \nabla T\;.\left( {\textbf{A}}_{\textbf{I}} \nabla T \right)\,dv,
-\]
-and since
-\begin{align*}
-  {
-  \begin{array}{*{20}l}
-    \nabla T\;.\left( {{\mathrm {\mathbf A}}_{\mathrm {\mathbf I}} \nabla T}
-    \right)&=A^{lT}\left[ {\left( {\frac{\partial T}{\partial i}} \right)^2-2a_1
-             \frac{\partial T}{\partial i}\frac{\partial T}{\partial k}+\left(
-             {\frac{\partial T}{\partial j}} \right)^2} \right. \\
-           &\qquad \qquad \qquad
-             { \left. -\,{2a_2 \frac{\partial T}{\partial j}\frac{\partial T}{\partial k}+\left( {a_1 ^2+a_2 ^2+\varepsilon} \right)\left( {\frac{\partial T}{\partial k}} \right)^2} \right]} \\
-           &=A_h \left[ {\left( {\frac{\partial T}{\partial i}-a_1 \frac{\partial
-             T}{\partial k}} \right)^2+\left( {\frac{\partial T}{\partial
-             j}-a_2 \frac{\partial T}{\partial k}} \right)^2}
-             +\varepsilon \left(\frac{\partial T}{\partial k}\right) ^2\right]      \\
-           & \geq 0
-  \end{array}
-             }
-\end{align*}
-%\addtocounter{equation}{-1}
-the property becomes obvious.
-
-\subsubsection*{In generalized vertical coordinates}
-
-Because the weak-slope operator \autoref{apdx:B4},
-\autoref{apdx:B_ldfiso} is decoupled in the ($i$,$z$) and ($j$,$z$) planes,
-it may be transformed into generalized $s$-coordinates in the same way as
-\autoref{sec:B_1} was transformed into \autoref{sec:B_2}.
-The resulting operator then takes the simple form
-
-\begin{equation}
-  \label{apdx:B_ldfiso_s}
-  D^T = \left. \nabla \right|_s \cdot
-  \left[ A^{lT} \;\Re \cdot \left. \nabla \right|_s T  \right] \\
-  \;\;\text{where} \;\Re =\left( {{
-        \begin{array}{*{20}c}
-          1 \hfill & 0 \hfill & {-r _1 } \hfill \\
-          0 \hfill & 1 \hfill & {-r _2 } \hfill \\
-          {-r _1 } \hfill & {-r _2 } \hfill & {\varepsilon +r _1
-                                              ^2+r _2 ^2} \hfill \\
-        \end{array}
-      }} \right),
-\end{equation}
-
-where ($r_1$, $r_2$) are the isopycnal slopes in ($\textbf{i}$, $\textbf{j}$) directions,
-relative to $s$-coordinate surfaces:
-\[
-  r_1 =\frac{e_3 }{e_1 }\left( {\frac{\partial \rho }{\partial i}} \right)\left( {\frac{\partial \rho }{\partial s}} \right)^{-1}
-  \qquad , \qquad
-  r_2 =\frac{e_3 }{e_2 }\left( {\frac{\partial \rho }{\partial j}}
-  \right)\left( {\frac{\partial \rho }{\partial s}} \right)^{-1}.
-\]
-
-To prove \autoref{apdx:B5} by direct re-expression of \autoref{apdx:B_ldfiso} is straightforward, but laborious.
-An easier way is first to note (by reversing the derivation of \autoref{sec:B_2} from \autoref{sec:B_1} ) that
-the weak-slope operator may be \emph{exactly} reexpressed in non-orthogonal $i,j,\rho$-coordinates as
-
-\begin{equation}
-  \label{apdx:B5}
-  D^T = \left. \nabla \right|_\rho \cdot
-  \left[ A^{lT} \;\Re \cdot \left. \nabla \right|_\rho T  \right] \\
-  \;\;\text{where} \;\Re =\left( {{
-        \begin{array}{*{20}c}
-          1 \hfill & 0 \hfill &0 \hfill \\
-          0 \hfill & 1 \hfill & 0 \hfill \\
-          0 \hfill & 0 \hfill & \varepsilon \hfill \\
-        \end{array}
-      }} \right).
-\end{equation}
-Then direct transformation from $i,j,\rho$-coordinates to $i,j,s$-coordinates gives
-\autoref{apdx:B_ldfiso_s} immediately.
-
-Note that the weak-slope approximation is only made in transforming from
-the (rotated,orthogonal) isoneutral axes to the non-orthogonal $i,j,\rho$-coordinates.
-The further transformation into $i,j,s$-coordinates is exact, whatever the steepness of the $s$-surfaces,
-in the same way as the transformation of horizontal/vertical Laplacian diffusion in $z$-coordinates,
-\autoref{sec:B_1} onto $s$-coordinates is exact, however steep the $s$-surfaces.
-
-
-% ================================================================
-% Lateral/Vertical Momentum Diffusive Operators
-% ================================================================
-\section{Lateral/Vertical momentum diffusive operators}
-\label{sec:B_3}
-
-The second order momentum diffusion operator (Laplacian) in the $z$-coordinate is found by
-applying \autoref{eq:PE_lap_vector}, the expression for the Laplacian of a vector,
-to the horizontal velocity vector:
-\begin{align*}
-  \Delta {\textbf{U}}_h
-  &=\nabla \left( {\nabla \cdot {\textbf{U}}_h } \right)-
-    \nabla \times \left( {\nabla \times {\textbf{U}}_h } \right) \\ \\
-  &=\left( {{
-    \begin{array}{*{20}c}
-      {\frac{1}{e_1 }\frac{\partial \chi }{\partial i}} \hfill \\
-      {\frac{1}{e_2 }\frac{\partial \chi }{\partial j}} \hfill \\
-      {\frac{1}{e_3 }\frac{\partial \chi }{\partial k}} \hfill \\
-    \end{array}
-  }} \right)
-  -\left( {{
-  \begin{array}{*{20}c}
-    {\frac{1}{e_2 }\frac{\partial \zeta }{\partial j}-\frac{1}{e_3
-    }\frac{\partial }{\partial k}\left( {\frac{1}{e_3 }\frac{\partial
-    u}{\partial k}} \right)} \hfill \\
-    {\frac{1}{e_3 }\frac{\partial }{\partial k}\left( {-\frac{1}{e_3
-    }\frac{\partial v}{\partial k}} \right)-\frac{1}{e_1 }\frac{\partial \zeta
-    }{\partial i}} \hfill \\
-    {\frac{1}{e_1 e_2 }\left[ {\frac{\partial }{\partial i}\left( {\frac{e_2
-    }{e_3 }\frac{\partial u}{\partial k}} \right)-\frac{\partial }{\partial
-    j}\left( {-\frac{e_1 }{e_3 }\frac{\partial v}{\partial k}} \right)} \right]}
-    \hfill \\
-  \end{array}
-  }} \right) \\ \\
-  &=\left( {{
-    \begin{array}{*{20}c}
-      {\frac{1}{e_1 }\frac{\partial \chi }{\partial i}-\frac{1}{e_2 }\frac{\partial \zeta }{\partial j}} \\
-      {\frac{1}{e_2 }\frac{\partial \chi }{\partial j}+\frac{1}{e_1 }\frac{\partial \zeta }{\partial i}} \\
-      0 \\
-    \end{array}
-  }} \right)
-  +\frac{1}{e_3 }
-  \left( {{
-  \begin{array}{*{20}c}
-    {\frac{\partial }{\partial k}\left( {\frac{1}{e_3 }\frac{\partial u}{\partial k}} \right)} \\
-    {\frac{\partial }{\partial k}\left( {\frac{1}{e_3 }\frac{\partial v}{\partial k}} \right)} \\
-    {\frac{\partial \chi }{\partial k}-\frac{1}{e_1 e_2 }\left( {\frac{\partial ^2\left( {e_2 \,u} \right)}{\partial i\partial k}+\frac{\partial ^2\left( {e_1 \,v} \right)}{\partial j\partial k}} \right)} \\
-  \end{array}
-  }} \right)
-\end{align*}
-Using \autoref{eq:PE_div}, the definition of the horizontal divergence,
-the third componant of the second vector is obviously zero and thus :
-\[
-  \Delta {\textbf{U}}_h = \nabla _h \left( \chi \right) - \nabla _h \times \left( \zeta \right) + \frac {1}{e_3 } \frac {\partial }{\partial k} \left( {\frac {1}{e_3 } \frac{\partial {\textbf{ U}}_h }{\partial k}} \right)
-\]
-
-Note that this operator ensures a full separation between
-the vorticity and horizontal divergence fields (see \autoref{apdx:C}).
-It is only equal to a Laplacian applied to each component in Cartesian coordinates, not on the sphere.
-
-The horizontal/vertical second order (Laplacian type) operator used to diffuse horizontal momentum in
-the $z$-coordinate therefore takes the following form:
-\begin{equation}
-  \label{apdx:B_Lap_U}
-  {
-    \textbf{D}}^{\textbf{U}} =
-  \nabla _h \left( {A^{lm}\;\chi } \right)
-  - \nabla _h \times \left( {A^{lm}\;\zeta \;{\textbf{k}}} \right)
-  + \frac{1}{e_3 }\frac{\partial }{\partial k}\left( {\frac{A^{vm}\;}{e_3 }
-      \frac{\partial {\mathrm {\mathbf U}}_h }{\partial k}} \right) \\
-\end{equation}
-that is, in expanded form:
-\begin{align*}
-  D^{\textbf{U}}_u
-  & = \frac{1}{e_1} \frac{\partial \left( {A^{lm}\chi   } \right)}{\partial i}
-    -\frac{1}{e_2} \frac{\partial \left( {A^{lm}\zeta } \right)}{\partial j}
-    +\frac{1}{e_3} \frac{\partial u}{\partial k}      \\
-  D^{\textbf{U}}_v
-  & = \frac{1}{e_2 }\frac{\partial \left( {A^{lm}\chi   } \right)}{\partial j}
-    +\frac{1}{e_1 }\frac{\partial \left( {A^{lm}\zeta } \right)}{\partial i}
-    +\frac{1}{e_3} \frac{\partial v}{\partial k}
-\end{align*}
-
-Note Bene: introducing a rotation in \autoref{apdx:B_Lap_U} does not lead to
-a useful expression for the iso/diapycnal Laplacian operator in the $z$-coordinate.
-Similarly, we did not found an expression of practical use for
-the geopotential horizontal/vertical Laplacian operator in the $s$-coordinate.
-Generally, \autoref{apdx:B_Lap_U} is used in both $z$- and $s$-coordinate systems,
-that is a Laplacian diffusion is applied on momentum along the coordinate directions.
-
-\biblio
-
-\pindex
-
-\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/annex_C.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/annex_C.tex	(revision 12062)
+++ 	(revision )
@@ -1,1534 +1,0 @@
-\documentclass[../main/NEMO_manual]{subfiles}
-
-\begin{document}
-% ================================================================
-% Chapter Ñ Appendix C : Discrete Invariants of the Equations
-% ================================================================
-\chapter{Discrete Invariants of the Equations}
-\label{apdx:C}
-
-\minitoc
-
-%%%  Appendix put in gmcomment as it has not been updated for \zstar and s coordinate
-%I'm writting this appendix. It will be available in a forthcoming release of the documentation
-
-%\gmcomment{
-
-\newpage
-
-% ================================================================
-% Introduction / Notations
-% ================================================================
-\section{Introduction / Notations}
-\label{sec:C.0}
-
-Notation used in this appendix in the demonstations:
-
-fluxes at the faces of a $T$-box:
-\[
-  U = e_{2u}\,e_{3u}\; u  \qquad  V = e_{1v}\,e_{3v}\; v  \qquad W = e_{1w}\,e_{2w}\; \omega
-\]
-
-volume of cells at $u$-, $v$-, and $T$-points:
-\[
-  b_u = e_{1u}\,e_{2u}\,e_{3u}  \qquad  b_v = e_{1v}\,e_{2v}\,e_{3v}  \qquad b_t = e_{1t}\,e_{2t}\,e_{3t}
-\]
-
-partial derivative notation: $\partial_\bullet = \frac{\partial}{\partial \bullet}$
-
-$dv=e_1\,e_2\,e_3 \,di\,dj\,dk$  is the volume element, with only $e_3$ that depends on time.
-$D$ and $S$ are the ocean domain volume and surface, respectively.
-No wetting/drying is allow (\ie $\frac{\partial S}{\partial t} = 0$).
-Let $k_s$ and $k_b$ be the ocean surface and bottom, resp.
-(\ie $s(k_s) = \eta$ and $s(k_b)=-H$, where $H$ is the bottom depth).
-\begin{flalign*}
-  z(k) = \eta - \int\limits_{\tilde{k}=k}^{\tilde{k}=k_s}  e_3(\tilde{k}) \;d\tilde{k}
-  = \eta - \int\limits_k^{k_s}  e_3 \;d\tilde{k}
-\end{flalign*}
-
-Continuity equation with the above notation:
-\[
-  \frac{1}{e_{3t}} \partial_t (e_{3t})+ \frac{1}{b_t}  \biggl\{  \delta_i [U] + \delta_j [V] + \delta_k [W] \biggr\} = 0
-\]
-
-A quantity, $Q$ is conserved when its domain averaged time change is zero, that is when:
-\[
-  \partial_t \left( \int_D{ Q\;dv } \right) =0
-\]
-Noting that the coordinate system used ....  blah blah
-\[
-  \partial_t \left( \int_D {Q\;dv} \right) =  \int_D { \partial_t \left( e_3 \, Q \right) e_1e_2\;di\,dj\,dk }
-  =  \int_D { \frac{1}{e_3} \partial_t \left( e_3 \, Q \right) dv } =0
-\]
-equation of evolution of $Q$ written as
-the time evolution of the vertical content of $Q$ like for tracers, or momentum in flux form,
-the quadratic quantity $\frac{1}{2}Q^2$ is conserved when:
-\begin{flalign*}
-  \partial_t \left(   \int_D{ \frac{1}{2} \,Q^2\;dv }   \right)
-  =&  \int_D{ \frac{1}{2} \partial_t \left( \frac{1}{e_3}\left( e_3 \, Q \right)^2 \right) e_1e_2\;di\,dj\,dk } \\
-  =&  \int_D {         Q   \;\partial_t\left( e_3 \, Q \right) e_1e_2\;di\,dj\,dk }
-  -  \int_D { \frac{1}{2} Q^2 \,\partial_t  (e_3) \;e_1e_2\;di\,dj\,dk } \\
-\end{flalign*}
-that is in a more compact form :
-\begin{flalign}
-  \label{eq:Q2_flux}
-  \partial_t \left( \int_D {\frac{1}{2} Q^2\;dv} \right)
-  =&                   \int_D { \frac{Q}{e_3}  \partial_t \left( e_3 \, Q \right) dv }
-  -   \frac{1}{2} \int_D {  \frac{Q^2}{e_3} \partial_t (e_3) \;dv }
-\end{flalign}
-equation of evolution of $Q$ written as the time evolution of $Q$ like for momentum in vector invariant form,
-the quadratic quantity $\frac{1}{2}Q^2$ is conserved when:
-\begin{flalign*}
-  \partial_t \left( \int_D {\frac{1}{2} Q^2\;dv} \right)
-  =&  \int_D { \frac{1}{2} \partial_t \left( e_3 \, Q^2 \right) \;e_1e_2\;di\,dj\,dk } \\
-  =& \int_D {         Q      \partial_t Q  \;e_1e_2e_3\;di\,dj\,dk }
-  +  \int_D { \frac{1}{2} Q^2 \, \partial_t e_3  \;e_1e_2\;di\,dj\,dk } \\
-\end{flalign*}
-that is in a more compact form:
-\begin{flalign}
-  \label{eq:Q2_vect}
-  \partial_t \left( \int_D {\frac{1}{2} Q^2\;dv} \right)
-  =& \int_D {         Q   \,\partial_t Q  \;dv }
-  +   \frac{1}{2} \int_D { \frac{1}{e_3} Q^2 \partial_t e_3 \;dv }
-\end{flalign}
-
-% ================================================================
-% Continuous Total energy Conservation
-% ================================================================
-\section{Continuous conservation}
-\label{sec:C.1}
-
-The discretization of pimitive equation in $s$-coordinate (\ie time and space varying vertical coordinate)
-must be chosen so that the discrete equation of the model satisfy integral constrains on energy and enstrophy. 
-
-Let us first establish those constraint in the continuous world.
-The total energy (\ie kinetic plus potential energies) is conserved:
-\begin{flalign}
-  \label{eq:Tot_Energy}
-  \partial_t \left( \int_D \left( \frac{1}{2} {\textbf{U}_h}^2 +  \rho \, g \, z \right) \;dv \right)  = & 0
-\end{flalign}
-under the following assumptions: no dissipation, no forcing (wind, buoyancy flux, atmospheric pressure variations),
-mass conservation, and closed domain. 
-
-This equation can be transformed to obtain several sub-equalities.
-The transformation for the advection term depends on whether the vector invariant form or
-the flux form is used for the momentum equation.
-Using \autoref{eq:Q2_vect} and introducing \autoref{apdx:A_dyn_vect} in
-\autoref{eq:Tot_Energy} for the former form and
-using \autoref{eq:Q2_flux} and introducing \autoref{apdx:A_dyn_flux} in
-\autoref{eq:Tot_Energy} for the latter form leads to:
-
-% \label{eq:E_tot}
-advection term (vector invariant form):
-\[
-  % \label{eq:E_tot_vect_vor_1}
-  \int\limits_D  \zeta \; \left( \textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv   = 0   \\
-\]
-%
-\[
-  % \label{eq:E_tot_vect_adv_1}
-  \int\limits_D  \textbf{U}_h \cdot \nabla_h \left( \frac{{\textbf{U}_h}^2}{2} \right)     dv
-  + \int\limits_D  \textbf{U}_h \cdot \nabla_z \textbf{U}_h  \;dv
-  -  \int\limits_D { \frac{{\textbf{U}_h}^2}{2} \frac{1}{e_3} \partial_t e_3 \;dv }   = 0
-\]
-advection term (flux form):
-\[
-  % \label{eq:E_tot_flux_metric}
-  \int\limits_D  \frac{1} {e_1 e_2 } \left( v \,\partial_i e_2 - u \,\partial_j e_1  \right)\;
-  \left(  \textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv   = 0
-\]
-\[
-  % \label{eq:E_tot_flux_adv}
-  \int\limits_D \textbf{U}_h \cdot     \left(                 {{
-        \begin{array} {*{20}c}
-          \nabla \cdot \left( \textbf{U}\,u \right) \hfill \\
-          \nabla \cdot \left( \textbf{U}\,v \right) \hfill
-        \end{array}}
-    }           \right)   \;dv
-  +   \frac{1}{2} \int\limits_D {  {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t e_3 \;dv } =\;0
-\]
-coriolis term
-\[
-  % \label{eq:E_tot_cor}
-  \int\limits_D  f   \; \left( \textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv   = 0
-\]
-pressure gradient:
-\[
-  % \label{eq:E_tot_pg_1}
-  - \int\limits_D  \left. \nabla p \right|_z \cdot \textbf{U}_h \;dv
-  = - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
-  + \int\limits_D g\, \rho \; \partial_t z  \;dv
-\]
-
-where $\nabla_h = \left. \nabla \right|_k$ is the gradient along the $s$-surfaces.
-
-blah blah....
-
-The prognostic ocean dynamics equation can be summarized as follows:
-\[
-  \text{NXT} = \dbinom	{\text{VOR} + \text{KEG} + \text {ZAD} }
-  {\text{COR} + \text{ADV}                       }
-  + \text{HPG} + \text{SPG} + \text{LDF} + \text{ZDF}
-\]
-
-Vector invariant form:
-% \label{eq:E_tot_vect}
-\[
-  % \label{eq:E_tot_vect_vor_2}
-  \int\limits_D   \textbf{U}_h \cdot \text{VOR} \;dv   = 0
-\]
-\[
-  % \label{eq:E_tot_vect_adv_2}
-  \int\limits_D  \textbf{U}_h \cdot \text{KEG}  \;dv
-  + \int\limits_D  \textbf{U}_h \cdot \text{ZAD}  \;dv
-  -  \int\limits_D { \frac{{\textbf{U}_h}^2}{2} \frac{1}{e_3} \partial_t e_3 \;dv }   = 0
-\]
-\[
-  % \label{eq:E_tot_pg_2}
-  - \int\limits_D  \textbf{U}_h \cdot (\text{HPG}+ \text{SPG}) \;dv
-  = - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
-  + \int\limits_D g\, \rho \; \partial_t z  \;dv
-\]
-
-Flux form:
-\begin{subequations}
-  \label{eq:E_tot_flux}
-  \[
-    % \label{eq:E_tot_flux_metric_2}
-    \int\limits_D  \textbf{U}_h \cdot \text {COR} \;  dv   = 0
-  \]
-  \[
-    % \label{eq:E_tot_flux_adv_2}
-    \int\limits_D \textbf{U}_h \cdot \text{ADV}   \;dv
-    +   \frac{1}{2} \int\limits_D {  {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t e_3  \;dv } =\;0
-  \]
-  \begin{equation}
-    \label{eq:E_tot_pg_3}
-    - \int\limits_D  \textbf{U}_h \cdot (\text{HPG}+ \text{SPG}) \;dv
-    = - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
-    + \int\limits_D g\, \rho \; \partial_t  z  \;dv
-  \end{equation}
-\end{subequations}
-
-\autoref{eq:E_tot_pg_3} is the balance between the conversion KE to PE and PE to KE. 
-Indeed the left hand side of \autoref{eq:E_tot_pg_3} can be transformed as follows:
-\begin{flalign*}
-  \partial_t  \left( \int\limits_D { \rho \, g \, z  \;dv} \right)
-  &= + \int\limits_D \frac{1}{e_3} \partial_t (e_3\,\rho) \;g\;z\;\;dv
-  +  \int\limits_D g\, \rho \; \partial_t z  \;dv   &&&\\
-  &= - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
-  + \int\limits_D g\, \rho \; \partial_t z \;dv   &&&\\
-  &= + \int\limits_D  \rho \,g \left( \textbf {U}_h \cdot \nabla_h z + \omega \frac{1}{e_3} \partial_k z \right)  \;dv
-  + \int\limits_D g\, \rho \; \partial_t z \;dv   &&&\\
-  &= + \int\limits_D  \rho \,g \left( \omega + \partial_t z + \textbf {U}_h \cdot \nabla_h z  \right)  \;dv  &&&\\
-  &=+  \int\limits_D g\, \rho \; w \; dv   &&&\\
-\end{flalign*}
-where the last equality is obtained by noting that the brackets is exactly the expression of $w$, 
-the vertical velocity referenced to the fixe $z$-coordinate system (see \autoref{apdx:A_w_s}). 
- 
-The left hand side of \autoref{eq:E_tot_pg_3} can be transformed as follows:
-\begin{flalign*}
-  - \int\limits_D  \left. \nabla p \right|_z & \cdot \textbf{U}_h \;dv
-  = - \int\limits_D  \left( \nabla_h p + \rho \, g \nabla_h z \right) \cdot \textbf{U}_h \;dv   &&&\\
-  \allowdisplaybreaks
-  &= - \int\limits_D  \nabla_h  p \cdot \textbf{U}_h \;dv   - \int\limits_D  \rho \, g \, \nabla_h z \cdot \textbf{U}_h \;dv   &&&\\
-  \allowdisplaybreaks
-  &= +\int\limits_D p \,\nabla_h \cdot \textbf{U}_h \;dv   + \int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
-  \allowdisplaybreaks
-  &= -\int\limits_D p \left( \frac{1}{e_3} \partial_t e_3 + \frac{1}{e_3} \partial_k \omega  \right) \;dv
-  +\int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
-  \allowdisplaybreaks
-  &= -\int\limits_D \frac{p}{e_3} \partial_t e_3  \;dv
-  +\int\limits_D \frac{1}{e_3} \partial_k p\; \omega \;dv
-  +\int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
-  &= -\int\limits_D \frac{p}{e_3} \partial_t e_3  \;dv
-  -\int\limits_D \rho \, g \, \omega \;dv
-  +\int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
-  &= - \int\limits_D \frac{p}{e_3} \partial_t e_3 \; \;dv
-  - \int\limits_D  \rho \, g \, w \;dv
-  + \int\limits_D   \rho \, g \, \partial_t z \;dv   &&&\\
-  \allowdisplaybreaks
-  \intertext{introducing the hydrostatic balance $\partial_k p=-\rho \,g\,e_3$ in the last term,
-    it becomes:}
-  &= - \int\limits_D \frac{p}{e_3} \partial_t e_3 \;dv
-  - \int\limits_D  \rho \, g \, w \;dv
-  - \int\limits_D  \frac{1}{e_3} \partial_k p\, \partial_t z \;dv   &&&\\
-  &= - \int\limits_D \frac{p}{e_3} \partial_t e_3 \;dv
-  - \int\limits_D  \rho \, g \, w \;dv
-  + \int\limits_D \,\frac{p}{e_3}\partial_t ( \partial_k z )  dv   &&&\\
-  %
-  &= - \int\limits_D  \rho \, g \, w \;dv   &&&\\
-\end{flalign*}
-
-%gm comment
-\gmcomment{
-%
-The last equality comes from the following equation,
-\begin{flalign*}
-  \int\limits_D p \frac{1}{e_3} \frac{\partial e_3}{\partial t}\; \;dv
-  = \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv \quad,
-\end{flalign*}
-that can be demonstrated as follows:
-
-\begin{flalign*}
-  \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv
-  &= \int\limits_D    \rho \, g \, \frac{\partial \eta}{\partial t} \;dv
-  -  \int\limits_D    \rho \, g \, \frac{\partial}{\partial t} \left(  \int\limits_k^{k_s}  e_3 \;d\tilde{k} \right) \;dv   &&&\\
-  &= \int\limits_D    \rho \, g \, \frac{\partial \eta}{\partial t} \;dv
-  -  \int\limits_D    \rho \, g    \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right) \;dv   &&&\\
-  %
-  \allowdisplaybreaks
-  \intertext{The second term of the right hand side can be transformed by applying the integration by part rule:
-    $\left[ a\,b \right]_{k_b}^{k_s} = \int_{k_b}^{k_s}  a\,\frac{\partial b}{\partial k}       \;dk
-    + \int_{k_b}^{k_s}      \frac{\partial a}{\partial k} \,b \;dk $
-    to the following function: $a=  \int_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k}$
-    and $b=  \int_k^{k_s}  \rho \, e_3 \;d\tilde{k}$
-    (note that $\frac{\partial}{\partial k} \left(  \int_k^{k_s}  a \;d\tilde{k}  \right) = - a$ as $k$ is the lower bound of the integral).
-    This leads to:  }
-\end{flalign*}
-\begin{flalign*}
-  &\left[ \int\limits_{k}^{k_s}  \frac{\partial e_3}{\partial t} \,dk \cdot \int\limits_{k}^{k_s}  \rho \, e_3 \,dk   \right]_{k_b}^{k_s}
-  =-\int\limits_{k_b}^{k_s} \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right)  \rho \,e_3 \;dk
-  -\int\limits_{k_b}^{k_s}  \frac{\partial e_3}{\partial t}  \left(  \int\limits_k^{k_s}  \rho \, e_3 \;d\tilde{k} \right)   dk  &&&\\
-  \allowdisplaybreaks
-  \intertext{Noting that $\frac{\partial \eta}{\partial t}
-    = \frac{\partial}{\partial t}  \left( \int_{k_b}^{k_s}   e_3  \;d\tilde{k}  \right)
-    = \int_{k_b}^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k}$
-    and
-    $p(k) = \int_k^{k_s}  \rho \,g \, e_3 \;d\tilde{k} $,
-    but also that $\frac{\partial \eta}{\partial t}$ does not depends on $k$, it comes:
-  }
-  & - \int\limits_{k_b}^{k_s}  \rho \, \frac{\partial \eta}{\partial t} \, e_3 \;dk
-  = - \int\limits_{k_b}^{k_s} \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right)   \, \rho \, g   e_3\;dk
-  - \int\limits_{k_b}^{k_s}  \frac{\partial e_3}{\partial t} \frac{p}{g}         \;dk       &&&\\
-\end{flalign*}
-Mutliplying by $g$ and integrating over the $(i,j)$ domain it becomes:
-\begin{flalign*}
-  \int\limits_D  \rho \, g \, \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right)    \;dv
-  =  \int\limits_D  \rho \, g \, \frac{\partial \eta}{\partial t} dv
-  - \int\limits_D  \frac{p}{e_3}\frac{\partial e_3}{\partial t}         \;dv
-\end{flalign*}
-Using this property, we therefore have:
-\begin{flalign*}
-  \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv
-  &= \int\limits_D    \rho \, g \, \frac{\partial \eta}{\partial t}   \;dv
-  - \left(  \int\limits_D  \rho \, g \, \frac{\partial \eta}{\partial t} dv
-    - \int\limits_D  \frac{p}{e_3}\frac{\partial e_3}{\partial t}   \;dv  \right)    &&&\\
-  %
-  &=\int\limits_D \frac{p}{e_3} \frac{\partial (e_3\,\rho)}{\partial t}\; \;dv
-\end{flalign*}
-% end gm comment
-}
-%
-
-% ================================================================
-% Discrete Total energy Conservation : vector invariant form
-% ================================================================
-\section{Discrete total energy conservation: vector invariant form}
-\label{sec:C.2}
-
-% -------------------------------------------------------------------------------------------------------------
-%       Total energy conservation
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Total energy conservation}
-\label{subsec:C_KE+PE_vect}
-
-The discrete form of the total energy conservation, \autoref{eq:Tot_Energy}, is given by:
-\begin{flalign*}
-  \partial_t  \left(  \sum\limits_{i,j,k} \biggl\{ \frac{u^2}{2} \,b_u + \frac{v^2}{2}\, b_v +  \rho \, g \, z_t \,b_t  \biggr\} \right) &=0
-\end{flalign*}
-which in vector invariant forms, it leads to:
-\begin{equation}
-  \label{eq:KE+PE_vect_discrete}
-  \begin{split}
-    \sum\limits_{i,j,k} \biggl\{   u\,                        \partial_t u         \;b_u
-    + v\,                        \partial_t v          \;b_v  \biggr\}
-    + \frac{1}{2} \sum\limits_{i,j,k} \biggl\{  \frac{u^2}{e_{3u}}\partial_t e_{3u} \;b_u
-    +  \frac{v^2}{e_{3v}}\partial_t e_{3v} \;b_v   \biggr\}      \\
-    = - \sum\limits_{i,j,k} \biggl\{ \frac{1}{e_{3t}}\partial_t (e_{3t} \rho) \, g \, z_t \;b_t  \biggr\}
-    - \sum\limits_{i,j,k} \biggl\{ \rho \,g\,\partial_t (z_t) \,b_t  \biggr\}
-  \end{split}
-\end{equation}
-
-Substituting the discrete expression of the time derivative of the velocity either in vector invariant,
-leads to the discrete equivalent of the four equations \autoref{eq:E_tot_flux}.
-
-% -------------------------------------------------------------------------------------------------------------
-%       Vorticity term (coriolis + vorticity part of the advection)
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Vorticity term (coriolis + vorticity part of the advection)}
-\label{subsec:C_vor}
-
-Let $q$, located at $f$-points, be either the relative ($q=\zeta / e_{3f}$),
-or the planetary ($q=f/e_{3f}$), or the total potential vorticity ($q=(\zeta +f) /e_{3f}$).
-Two discretisation of the vorticity term (ENE and EEN) allows the conservation of the kinetic energy.
-% -------------------------------------------------------------------------------------------------------------
-%       Vorticity Term with ENE scheme
-% -------------------------------------------------------------------------------------------------------------
-\subsubsection{Vorticity term with ENE scheme (\protect\np{ln\_dynvor\_ene}\forcode{ = .true.})}
-\label{subsec:C_vorENE} 
-
-For the ENE scheme, the two components of the vorticity term are given by:
-\[
-  - e_3 \, q \;{\textbf{k}}\times {\textbf {U}}_h    \equiv
-  \left( {{
-        \begin{array} {*{20}c}
-          + \frac{1} {e_{1u}} \;
-          \overline {\, q \ \overline {\left( e_{1v}\,e_{3v}\,v \right)}^{\,i+1/2}} ^{\,j}        \hfill \\
-          - \frac{1} {e_{2v}} \;
-          \overline {\, q \ \overline {\left( e_{2u}\,e_{3u}\,u \right)}^{\,j+1/2}} ^{\,i}       \hfill
-        \end{array}
-      } }    \right)
-\]
-
-This formulation does not conserve the enstrophy but it does conserve the total kinetic energy.
-Indeed, the kinetic energy tendency associated to the vorticity term and
-averaged over the ocean domain can be transformed as follows:
-\begin{flalign*}
-  &\int\limits_D -  \left(  e_3 \, q \;\textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv &&  \\
-  & \qquad \qquad
-  {
-    \begin{array}{*{20}l}
-      &\equiv \sum\limits_{i,j,k} 	\biggl\{
-        \frac{1} {e_{1u}} \overline { \,q\ \overline{ V }^{\,i+1/2}} ^{\,j} \, u \; b_u
-        - \frac{1} {e_{2v}}\overline { \, q\ \overline{ U }^{\,j+1/2}} ^{\,i} \, v \; b_v \; \biggr\}    \\
-      &\equiv  \sum\limits_{i,j,k} 	\biggl\{
-        \overline { \,q\ \overline{ V }^{\,i+1/2}}^{\,j} \; U
-        - \overline { \,q\ \overline{ U }^{\,j+1/2}}^{\,i} \; V  \; \biggr\}     \\
-      &\equiv \sum\limits_{i,j,k} q \  \biggl\{  \overline{ V }^{\,i+1/2}\; \overline{ U }^{\,j+1/2}
-        - \overline{ U }^{\,j+1/2}\; \overline{ V }^{\,i+1/2}         \biggr\}  \quad  \equiv 0
-    \end{array}
-  } 		
-\end{flalign*}
-In other words, the domain averaged kinetic energy does not change due to the vorticity term.
-
-% -------------------------------------------------------------------------------------------------------------
-%       Vorticity Term with EEN scheme
-% -------------------------------------------------------------------------------------------------------------
-\subsubsection{Vorticity term with EEN scheme (\protect\np{ln\_dynvor\_een}\forcode{ = .true.})}
-\label{subsec:C_vorEEN_vect} 
-
-With the EEN scheme, the vorticity terms are represented as: 
-\begin{equation}
-  \tag{\ref{eq:dynvor_een}}
-  \left\{ {
-      \begin{aligned}
-        +q\,e_3 \, v 	&\equiv +\frac{1}{e_{1u} }   \sum_{\substack{i_p,\,k_p}}
-        {^{i+1/2-i_p}_j}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{1v} e_{3v} \ v  \right)^{i+i_p-1/2}_{j+j_p}   \\
-        - q\,e_3 \, u     &\equiv -\frac{1}{e_{2v} }    \sum_{\substack{i_p,\,k_p}}
-        {^i_{j+1/2-j_p}}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{2u} e_{3u} \ u  \right)^{i+i_p}_{j+j_p-1/2}
-      \end{aligned}
-    } \right.
-\end{equation} 
-where the indices $i_p$ and $j_p$ take the following value: $i_p = -1/2$ or $1/2$ and $j_p = -1/2$ or $1/2$,
-and the vorticity triads, ${^i_j}\mathbb{Q}^{i_p}_{j_p}$, defined at $T$-point, are given by: 
-\begin{equation}
-  \tag{\ref{eq:Q_triads}}
-  _i^j \mathbb{Q}^{i_p}_{j_p}
-  = \frac{1}{12} \ \left(   q^{i-i_p}_{j+j_p} + q^{i+j_p}_{j+i_p} + q^{i+i_p}_{j-j_p}  \right)
-\end{equation}
-
-This formulation does conserve the total kinetic energy.
-Indeed,
-\begin{flalign*}
-  &\int\limits_D - \textbf{U}_h \cdot   \left(  \zeta \;\textbf{k} \times \textbf{U}_h  \right)  \;  dv &&  \\
-  \equiv \sum\limits_{i,j,k} &	\biggl\{
-  \left[  \sum_{\substack{i_p,\,k_p}}
-    {^{i+1/2-i_p}_j}\mathbb{Q}^{i_p}_{j_p} \; V^{i+1/2-i_p}_{j+j_p} \right] U^{i+1/2}_{j}    %   &&\\
-  - \left[  \sum_{\substack{i_p,\,k_p}}
-    {^i_{j+1/2-j_p}}\mathbb{Q}^{i_p}_{j_p} \; U^{i+i_p}_{j+1/2-j_p}  \right] V^{i}_{j+1/2}    \biggr\}     && \\ \\
-  \equiv \sum\limits_{i,j,k} &  \sum_{\substack{i_p,\,k_p}} \biggl\{  \ \
-  {^{i+1/2-i_p}_j}\mathbb{Q}^{i_p}_{j_p} \; V^{i+1/2-i_p}_{j+j_p}  \, U^{i+1/2}_{j}     %  &&\\
-  - {^i_{j+1/2-j_p}}\mathbb{Q}^{i_p}_{j_p} \; U^{i+i_p}_{j+1/2-j_p} \, V^{i}_{j+1/2}     \ \;     \biggr\}     &&  \\
-  %
-  \allowdisplaybreaks
-  \intertext{ Expending the summation on $i_p$ and $k_p$, it becomes:}
-  %
-  \equiv \sum\limits_{i,j,k} & \biggl\{  \ \
-  {^{i+1}_j     }\mathbb{Q}^{-1/2}_{+1/2} \;V^{i+1}_{j+1/2} \; U^{\,i+1/2}_{j}
-  -  {^i_{j}\quad}\mathbb{Q}^{-1/2}_{+1/2} \; U^{i-1/2}_{j}    \; V^{\,i}_{j+1/2}         &&  \\
-  &       + {^{i+1}_j     }\mathbb{Q}^{-1/2}_{-1/2} \; V^{i+1}_{j-1/2} \; U^{\,i+1/2}_{j}
-  - {^i_{j+1}     }\mathbb{Q}^{-1/2}_{-1/2} \; U^{i-1/2}_{j+1} \; V^{\,i}_{j+1/2}        \biggr.     &&  \\
-  &       + {^{i}_j\quad}\mathbb{Q}^{+1/2}_{+1/2} \; V^{i}_{j+1/2}   \; U^{\,i+1/2}_{j}
-  - {^i_{j}\quad}\mathbb{Q}^{+1/2}_{+1/2} \; U^{i+1/2}_{j}   \; V^{\,i}_{j+1/2}          \biggr.        &&  \\
-  &       + {^{i}_j\quad}\mathbb{Q}^{+1/2}_{-1/2} \; V^{i}_{j-1/2}     \; U^{\,i+1/2}_{j}
-  -  {^i_{j+1}     }\mathbb{Q}^{+1/2}_{-1/2} \; U^{i+1/2}_{j+1}\; V^{\,i}_{j+1/2}  \ \;     \biggr\}     &&  \\
-  %
-  \allowdisplaybreaks
-  \intertext{The summation is done over all $i$ and $j$ indices, it is therefore possible to introduce
-    a shift of $-1$ either in $i$ or $j$ direction in some of the term of the summation (first term of the
-    first and second lines, second term of the second and fourth lines). By doning so, we can regroup
-    all the terms of the summation by triad at a ($i$,$j$) point. In other words, we regroup all the terms
-    in the neighbourhood  that contain a triad at the same ($i$,$j$) indices. It becomes: }
-  \allowdisplaybreaks
-  %
-  \equiv \sum\limits_{i,j,k} & \biggl\{  \ \
-  {^{i}_j}\mathbb{Q}^{-1/2}_{+1/2}  \left[  V^{i}_{j+1/2}\, U^{\,i-1/2}_{j}
-    -  U^{i-1/2}_{j} \, V^{\,i}_{j+1/2}      \right]    &&  \\
-  &       + {^{i}_j}\mathbb{Q}^{-1/2}_{-1/2}  \left[  V^{i}_{j-1/2} \, U^{\,i-1/2}_{j}
-    -    U^{i-1/2}_{j} \, V^{\,i}_{j-1/2}      \right]    \biggr.   &&  \\
-  &      + {^{i}_j}\mathbb{Q}^{+1/2}_{+1/2}  \left[  V^{i}_{j+1/2} \, U^{\,i+1/2}_{j}
-    -    U^{i+1/2}_{j} \, V^{\,i}_{j+1/2}     \right]  \biggr.  &&  \\
-  &     + {^{i}_j}\mathbb{Q}^{+1/2}_{-1/2}  \left[   V^{i}_{j-1/2} \, U^{\,i+1/2}_{j}
-    -    U^{i+1/2}_{j-1} \, V^{\,i}_{j-1/2}  \right]  \ \;   \biggr\}   \qquad
-  \equiv \ 0   &&
-\end{flalign*}
-
-% -------------------------------------------------------------------------------------------------------------
-%       Gradient of Kinetic Energy / Vertical Advection
-% -------------------------------------------------------------------------------------------------------------
-\subsubsection{Gradient of kinetic energy / Vertical advection}
-\label{subsec:C_zad} 
-
-The change of Kinetic Energy (KE) due to the vertical advection is exactly balanced by the change of KE due to the horizontal gradient of KE~:
-\[
-  \int_D \textbf{U}_h \cdot \frac{1}{e_3 } \omega \partial_k \textbf{U}_h \;dv
-  =  -   \int_D \textbf{U}_h \cdot \nabla_h \left( \frac{1}{2}\;{\textbf{U}_h}^2 \right)\;dv
-  +   \frac{1}{2} \int_D {  \frac{{\textbf{U}_h}^2}{e_3} \partial_t ( e_3) \;dv }
-\]
-Indeed, using successively \autoref{eq:DOM_di_adj} (\ie the skew symmetry property of the $\delta$ operator)
-and the continuity equation, then \autoref{eq:DOM_di_adj} again,
-then the commutativity of operators $\overline {\,\cdot \,}$ and $\delta$, and finally \autoref{eq:DOM_mi_adj}
-(\ie the symmetry property of the $\overline {\,\cdot \,}$ operator)
-applied in the horizontal and vertical directions, it becomes:
-\begin{flalign*}
-  & - \int_D \textbf{U}_h \cdot \text{KEG}\;dv
-  = - \int_D \textbf{U}_h \cdot \nabla_h \left( \frac{1}{2}\;{\textbf{U}_h}^2 \right)\;dv    &&&\\
-  %
-  \equiv  & -  \sum\limits_{i,j,k} \frac{1}{2}  \biggl\{
-  \frac{1} {e_{1u}}  \delta_{i+1/2}   \left[   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right]  u \ b_u
-  + \frac{1} {e_{2v}}  \delta_{j+1/2}   \left[   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right]  v \ b_v   \biggr\}  	&&&  \\
-  %
-  \equiv & + \sum\limits_{i,j,k} \frac{1}{2}  \left(   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right)\;
-  \biggl\{ \delta_{i} \left[  U   \right] +  \delta_{j} \left[  V  \right]    \biggr\}       &&&  \\
-  \allowdisplaybreaks
-  %
-  \equiv   & - \sum\limits_{i,j,k}  \frac{1}{2}
-  \left(       \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right)  \;
-  \biggl\{   \frac{b_t}{e_{3t}} \partial_t (e_{3t})  +  \delta_k \left[  W   \right]    \biggr\}    &&&\\
-  \allowdisplaybreaks
-  %
-  \equiv & +  \sum\limits_{i,j,k} \frac{1}{2} \delta_{k+1/2}   \left[ \overline{ u^2}^{\,i} + \overline{ v^2}^{\,j}   \right] \;  W
-  -  \sum\limits_{i,j,k} \frac{1}{2} \left(   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right) \;\partial_t b_t   &&& \\
-  \allowdisplaybreaks
-  %
-  \equiv   & + \sum\limits_{i,j,k} \frac{1} {2} \left(    \overline{\delta_{k+1/2} \left[ u^2 \right]}^{\,i}
-    + \overline{\delta_{k+1/2} \left[ v^2 \right]}^{\,j}    \right) \; W
-  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t \overline{b_t}^{\,{i+1/2}}
-    + \frac{v^2}{2}\,\partial_t \overline{b_t}^{\,{j+1/2}}   \right)    &&& \\
-  \allowdisplaybreaks
-  \intertext{Assuming that $b_u= \overline{b_t}^{\,i+1/2}$ and $b_v= \overline{b_t}^{\,j+1/2}$, or at least that the time
-    derivative of these two equations is satisfied, it becomes:}
-  %
-  \equiv &     \sum\limits_{i,j,k} \frac{1} {2}
-  \biggl\{ \; \overline{W}^{\,i+1/2}\;\delta_{k+1/2} \left[ u^2 \right]
-  + \overline{W}^{\,j+1/2}\;\delta_{k+1/2} \left[ v^2 \right]  \;  \biggr\}
-  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t b_u
-    + \frac{v^2}{2}\,\partial_t b_v   \right)    &&& \\
-  \allowdisplaybreaks
-  %
-  \equiv &     \sum\limits_{i,j,k}
-  \biggl\{ \; \overline{W}^{\,i+1/2}\; \overline {u}^{\,k+1/2}\; \delta_{k+1/2}[ u ]
-  + \overline{W}^{\,j+1/2}\; \overline {v}^{\,k+1/2}\; \delta_{k+1/2}[ v ]  \;  \biggr\}
-  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t b_u
-    + \frac{v^2}{2}\,\partial_t b_v   \right)    &&& \\
-  %
-  \allowdisplaybreaks
-  \equiv  &  \sum\limits_{i,j,k}
-  \biggl\{ \; \frac{1} {b_u } \; \overline { \overline{W}^{\,i+1/2}\,\delta_{k+1/2}  \left[ u \right] }^{\,k} \;u\;b_u
-  + \frac{1} {b_v } \; \overline { \overline{W}^{\,j+1/2} \delta_{k+1/2}  \left[ v \right]  }^{\,k} \;v\;b_v  \; \biggr\}
-  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t b_u
-    + \frac{v^2}{2}\,\partial_t b_v   \right)    &&& \\
-  %
-  \intertext{The first term provides the discrete expression for the vertical advection of momentum (ZAD),
-    while the second term corresponds exactly to \autoref{eq:KE+PE_vect_discrete}, therefore:}
-  \equiv&                   \int\limits_D \textbf{U}_h \cdot \text{ZAD} \;dv
-  + \frac{1}{2} \int_D { {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t  (e_3)  \;dv }    &&&\\
-  \equiv&                   \int\limits_D \textbf{U}_h \cdot w \partial_k \textbf{U}_h \;dv
-  + \frac{1}{2} \int_D { {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t  (e_3)  \;dv }    &&&\\
-\end{flalign*}
-
-There is two main points here.
-First, the satisfaction of this property links the choice of the discrete formulation of the vertical advection and
-of the horizontal gradient of KE.
-Choosing one imposes the other.
-For example KE can also be discretized as $1/2\,({\overline u^{\,i}}^2 + {\overline v^{\,j}}^2)$.
-This leads to the following expression for the vertical advection:
-\[
-  \frac{1} {e_3 }\; \omega\; \partial_k \textbf{U}_h
-  \equiv \left( {{
-        \begin{array} {*{20}c}
-          \frac{1} {e_{1u}\,e_{2u}\,e_{3u}} \;  \overline{\overline {e_{1t}\,e_{2t} \,\omega\;\delta_{k+1/2}
-          \left[ \overline u^{\,i+1/2} \right]}}^{\,i+1/2,k}  \hfill \\
-          \frac{1} {e_{1v}\,e_{2v}\,e_{3v}} \;   \overline{\overline {e_{1t}\,e_{2t} \,\omega \;\delta_{k+1/2}
-          \left[ \overline v^{\,j+1/2} \right]}}^{\,j+1/2,k} \hfill
-        \end{array}
-      } } \right)
-\]
-a formulation that requires an additional horizontal mean in contrast with the one used in NEMO.
-Nine velocity points have to be used instead of 3.
-This is the reason why it has not been chosen.
-
-Second, as soon as the chosen $s$-coordinate depends on time,
-an extra constraint arises on the time derivative of the volume at $u$- and $v$-points:
-\begin{flalign*}
-  e_{1u}\,e_{2u}\,\partial_t (e_{3u}) =\overline{ e_{1t}\,e_{2t}\;\partial_t (e_{3t}) }^{\,i+1/2}    \\
-  e_{1v}\,e_{2v}\,\partial_t (e_{3v})  =\overline{ e_{1t}\,e_{2t}\;\partial_t (e_{3t}) }^{\,j+1/2}
-\end{flalign*}
-which is (over-)satified by defining the vertical scale factor as follows:
-\begin{flalign*}
-  % \label{eq:e3u-e3v}
-  e_{3u} = \frac{1}{e_{1u}\,e_{2u}}\;\overline{ e_{1t}^{ }\,e_{2t}^{ }\,e_{3t}^{ } }^{\,i+1/2}    \\
-  e_{3v} = \frac{1}{e_{1v}\,e_{2v}}\;\overline{ e_{1t}^{ }\,e_{2t}^{ }\,e_{3t}^{ } }^{\,j+1/2}
-\end{flalign*}
-
-Blah blah required on the the step representation of bottom topography.....
-
-
-% -------------------------------------------------------------------------------------------------------------
-%       Pressure Gradient Term
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Pressure gradient term}
-\label{subsec:C.2.6}
-
-\gmcomment{
-  A pressure gradient has no contribution to the evolution of the vorticity as the curl of a gradient is zero.
-  In the $z$-coordinate, this property is satisfied locally on a C-grid with 2nd order finite differences
-  (property \autoref{eq:DOM_curl_grad}). 
-}
-
-When the equation of state is linear
-(\ie when an advection-diffusion equation for density can be derived from those of temperature and salinity)
-the change of KE due to the work of pressure forces is balanced by
-the change of potential energy due to buoyancy forces: 
-\[
-  - \int_D  \left. \nabla p \right|_z \cdot \textbf{U}_h \;dv
-  = - \int_D \nabla \cdot \left( \rho \,\textbf {U} \right) \,g\,z \;dv
-  + \int_D g\, \rho \; \partial_t (z)  \;dv
-\]
-
-This property can be satisfied in a discrete sense for both $z$- and $s$-coordinates.
-Indeed, defining the depth of a $T$-point, $z_t$,
-as the sum of the vertical scale factors at $w$-points starting from the surface,
-the work of pressure forces can be written as:
-\begin{flalign*}
-  &- \int_D  \left. \nabla p \right|_z \cdot \textbf{U}_h \;dv
-  \equiv \sum\limits_{i,j,k} \biggl\{ \;  - \frac{1} {e_{1u}}   \Bigl(
-  \delta_{i+1/2} [p_t] - g\;\overline \rho^{\,i+1/2}\;\delta_{i+1/2} [z_t]     \Bigr)  \; u\;b_u && \\
-  & \qquad \qquad  \qquad \qquad  \qquad \quad \ \,
-  - \frac{1} {e_{2v}}    \Bigl(
-  \delta_{j+1/2} [p_t] - g\;\overline \rho^{\,j+1/2}\delta_{j+1/2} [z_t]      \Bigr)  \; v\;b_v \;  \biggr\}   && \\
-  %
-  \allowdisplaybreaks
-  \intertext{Using successively \autoref{eq:DOM_di_adj}, \ie the skew symmetry property of
-    the $\delta$ operator, \autoref{eq:wzv}, the continuity equation, \autoref{eq:dynhpg_sco},
-    the hydrostatic equation in the $s$-coordinate, and $\delta_{k+1/2} \left[ z_t \right] \equiv e_{3w} $,
-    which comes from the definition of $z_t$, it becomes: }
-  \allowdisplaybreaks
-  %
-  \equiv& +  \sum\limits_{i,j,k}   g  \biggl\{
-  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
-  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
-  +\Bigl(  \delta_i[U] + \delta_j [V]  \Bigr)\;\frac{p_t}{g} \biggr\}  &&\\
-  %
-  \equiv& +  \sum\limits_{i,j,k}   g   \biggl\{
-  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
-  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
-  -       \left(   \frac{b_t}{e_{3t}} \partial_t (e_{3t})  +  \delta_k \left[ W \right]    \right) \frac{p_t}{g}    \biggr\}   &&&\\
-  %
-  \equiv& +  \sum\limits_{i,j,k}  g   \biggl\{
-  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
-  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
-  +	\frac{W}{g}\;\delta_{k+1/2} [p_t]
-  -        \frac{p_t}{g}\,\partial_t b_t    \biggr\}    &&&\\
-  %
-  \equiv& +  \sum\limits_{i,j,k}  g   \biggl\{
-  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
-  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
-  - 	W\;e_{3w} \overline \rho^{\,k+1/2}
-  -        \frac{p_t}{g}\,\partial_t b_t    \biggr\}    &&&\\
-  %
-  \equiv& +  \sum\limits_{i,j,k}    g   \biggl\{
-  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
-  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
-  + 	W\; \overline \rho^{\,k+1/2}\;\delta_{k+1/2} [z_t]
-  -        \frac{p_t}{g}\,\partial_t b_t    \biggr\}    &&&\\
-  %
-  \allowdisplaybreaks
-  %
-  \equiv& - \sum\limits_{i,j,k}   g \; z_t      \biggl\{
-  \delta_i 	\left[ U\;	\overline \rho^{\,i+1/2} 	\right]
-  + 	\delta_j 	\left[ V\;	\overline \rho^{\,j+1/2} 	\right]
-  + 	\delta_k 	\left[ W\;	\overline \rho^{\,k+1/2} 	\right]       \biggr\}
-  - \sum\limits_{i,j,k}       \biggl\{ p_t\;\partial_t b_t    \biggr\}   &&&\\
-  %
-  \equiv& + \sum\limits_{i,j,k}   g \; z_t    \biggl\{      \partial_t ( e_{3t} \,\rho)    \biggr\}  \; b_t
-  -  \sum\limits_{i,j,k}                 \biggl\{  p_t\;\partial_t b_t                     \biggr\}              &&&\\
-  %
-\end{flalign*}
-The first term is exactly the first term of the right-hand-side of \autoref{eq:KE+PE_vect_discrete}.
-It remains to demonstrate that the last term,
-which is obviously a discrete analogue of $\int_D \frac{p}{e_3} \partial_t (e_3)\;dv$ is equal to
-the last term of \autoref{eq:KE+PE_vect_discrete}.
-In other words, the following property must be satisfied:
-\begin{flalign*}
-  \sum\limits_{i,j,k}  \biggl\{  p_t\;\partial_t b_t                  \biggr\}
-  \equiv  \sum\limits_{i,j,k}  \biggl\{ \rho \,g\,\partial_t (z_t) \,b_t  \biggr\}
-\end{flalign*}
-
-Let introduce $p_w$ the pressure at $w$-point such that $\delta_k [p_w] = - \rho \,g\,e_{3t}$.
-The right-hand-side of the above equation can be transformed as follows:
-
-\begin{flalign*}
-  \sum\limits_{i,j,k}  \biggl\{ \rho \,g\,\partial_t (z_t) \,b_t  \biggr\}
-  &\equiv   - \sum\limits_{i,j,k}  \biggl\{ \delta_k [p_w]\,\partial_t (z_t) \,e_{1t}\,e_{2t}  \biggr\}        &&&\\
-  %
-  &\equiv  + \sum\limits_{i,j,k}  \biggl\{  p_w\, \delta_{k+1/2} [\partial_t (z_t)] \,e_{1t}\,e_{2t}  \biggr\}
-  \equiv  + \sum\limits_{i,j,k}  \biggl\{  p_w\, \partial_t (e_{3w}) \,e_{1t}\,e_{2t}  \biggr\}        &&&\\
-  &\equiv  + \sum\limits_{i,j,k}  \biggl\{  p_w\, \partial_t (b_w) \biggr\}
-  %
-  % & \equiv     \sum\limits_{i,j,k} \biggl\{  \frac{1}{e_{3t}} \delta_k [p_w]\;\partial_t (z_t) \,b_w   \right)   \biggr\}           &&&\\
-  % & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t \left(    \delta_k [z_t]   \right)  e_{1w}\,e_{2w}   \biggr\}           &&&\\
-  % & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t b_w   \biggr\}
-\end{flalign*}
-therefore, the balance to be satisfied is:
-\begin{flalign*}
-  \sum\limits_{i,j,k}  \biggl\{  p_t\;\partial_t (b_t) \biggr\}  \equiv  \sum\limits_{i,j,k}  \biggl\{  p_w\, \partial_t (b_w) \biggr\}
-\end{flalign*}
-which is a purely vertical balance:
-\begin{flalign*}
-  \sum\limits_{k}  \biggl\{  p_t\;\partial_t (e_{3t}) \biggr\}  \equiv  \sum\limits_{k}  \biggl\{  p_w\, \partial_t (e_{3w}) \biggr\}
-\end{flalign*}
-Defining $p_w = \overline{p_t}^{\,k+1/2}$
-
-%gm comment
-\gmcomment{
-  \begin{flalign*}
-    \sum\limits_{i,j,k} \biggl\{   p_t\;\partial_t b_t   \biggr\}                                &&&\\
-    %
-    & \equiv     \sum\limits_{i,j,k} \biggl\{  \frac{1}{e_{3t}} \delta_k [p_w]\;\partial_t (z_t) \,b_w    \biggr\}           &&&\\
-    & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t \left(    \delta_{k+1/2} [z_t]   \right)  e_{1w}\,e_{2w}   \biggr\}           &&&\\
-    & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t b_w   \biggr\}
-  \end{flalign*}
-
-  \begin{flalign*}
-    \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv
-    \equiv&  \sum\limits_{i,j,k}   \biggl\{  \frac{1}{e_{3t}} \frac{\partial e_{3t}}{\partial t} p   \biggr\} \; b_t   &&&\\
-    \equiv&  \sum\limits_{i,j,k}   \biggl\{      \biggr\} \; b_t   &&&\\
-  \end{flalign*}
-
-  %
-  \begin{flalign*}
-    \equiv& - \int_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
-    + \int\limits_D g\, \rho \; \frac{\partial z}{\partial t}  \;dv     &&& \\
-  \end{flalign*}
-  %
-}
-%end gm comment
-
-Note that this property strongly constrains the discrete expression of both the depth of $T-$points and
-of the term added to the pressure gradient in the $s$-coordinate.
-Nevertheless, it is almost never satisfied since a linear equation of state is rarely used.
-
-% ================================================================
-% Discrete Total energy Conservation : flux form
-% ================================================================
-\section{Discrete total energy conservation: flux form}
-\label{sec:C.3}
-
-% -------------------------------------------------------------------------------------------------------------
-%       Total energy conservation
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Total energy conservation}
-\label{subsec:C_KE+PE_flux}
-
-The discrete form of the total energy conservation, \autoref{eq:Tot_Energy}, is given by:
-\begin{flalign*}
-  \partial_t \left(  \sum\limits_{i,j,k} \biggl\{ \frac{u^2}{2} \,b_u + \frac{v^2}{2}\, b_v +  \rho \, g \, z_t \,b_t  \biggr\} \right) &=0  \\
-\end{flalign*}
-which in flux form, it leads to:
-\begin{flalign*}
-  \sum\limits_{i,j,k} \biggl\{  \frac{u    }{e_{3u}}\,\frac{\partial (e_{3u}u)}{\partial t} \,b_u
-  +  \frac{v    }{e_{3v}}\,\frac{\partial (e_{3v}v)}{\partial t} \,b_v  \biggr\}
-  &  -  \frac{1}{2} \sum\limits_{i,j,k} \biggl\{  \frac{u^2}{e_{3u}}\frac{\partial    e_{3u}    }{\partial t} \,b_u
-  +  \frac{v^2}{e_{3v}}\frac{\partial    e_{3v}    }{\partial t} \,b_v   \biggr\} \\
-  &= - \sum\limits_{i,j,k} \biggl\{ \frac{1}{e_3t}\frac{\partial e_{3t} \rho}{\partial t} \, g \, z_t \,b_t  \biggr\}
-  - \sum\limits_{i,j,k} \biggl\{ \rho \,g\,\frac{\partial z_t}{\partial t} \,b_t  \biggr\} \\
-\end{flalign*}
-
-Substituting the discrete expression of the time derivative of the velocity either in
-vector invariant or in flux form, leads to the discrete equivalent of the ????
-
-
-% -------------------------------------------------------------------------------------------------------------
-%       Coriolis and advection terms: flux form
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Coriolis and advection terms: flux form}
-\label{subsec:C.3.2}
-
-% -------------------------------------------------------------------------------------------------------------
-%       Coriolis plus ``metric'' Term
-% -------------------------------------------------------------------------------------------------------------
-\subsubsection{Coriolis plus ``metric'' term}
-\label{subsec:C.3.3} 
-
-In flux from the vorticity term reduces to a Coriolis term in which
-the Coriolis parameter has been modified to account for the ``metric'' term.
-This altered Coriolis parameter is discretised at an f-point.
-It is given by:
-\[
-  f+\frac{1} {e_1 e_2 } \left( v \frac{\partial e_2 } {\partial i} - u \frac{\partial e_1 } {\partial j}\right)\;
-  \equiv \;
-  f+\frac{1} {e_{1f}\,e_{2f}} \left( \overline v^{\,i+1/2} \delta_{i+1/2} \left[ e_{2u} \right]
-    -\overline u^{\,j+1/2} \delta_{j+1/2} \left[ e_{1u}  \right] \right)
-\]
-
-Either the ENE or EEN scheme is then applied to obtain the vorticity term in flux form.
-It therefore conserves the total KE.
-The derivation is the same as for the vorticity term in the vector invariant form (\autoref{subsec:C_vor}).
-
-% -------------------------------------------------------------------------------------------------------------
-%       Flux form advection
-% -------------------------------------------------------------------------------------------------------------
-\subsubsection{Flux form advection}
-\label{subsec:C.3.4} 
-
-The flux form operator of the momentum advection is evaluated using
-a centered second order finite difference scheme.
-Because of the flux form, the discrete operator does not contribute to the global budget of linear momentum.
-Because of the centered second order scheme, it conserves the horizontal kinetic energy, that is:
-
-\begin{equation}
-  \label{eq:C_ADV_KE_flux}
-  -  \int_D \textbf{U}_h \cdot     \left(                 {{
-        \begin{array} {*{20}c}
-          \nabla \cdot \left( \textbf{U}\,u \right) \hfill \\
-          \nabla \cdot \left( \textbf{U}\,v \right) \hfill \\
-        \end{array}
-      } }           \right)   \;dv
-  -   \frac{1}{2} \int_D {  {\textbf{U}_h}^2 \frac{1}{e_3} \frac{\partial  e_3 }{\partial t} \;dv } =\;0
-\end{equation}
-
-Let us first consider the first term of the scalar product
-(\ie just the the terms associated with the i-component of the advection):
-\begin{flalign*}
-  &  - \int_D u \cdot \nabla \cdot \left(   \textbf{U}\,u   \right) \; dv   \\
-  %
-  \equiv& - \sum\limits_{i,j,k} \biggl\{    \frac{1} {b_u}    \biggl(
-  \delta_{i+1/2}  \left[   \overline {U}^{\,i}      \;\overline u^{\,i}          \right]
-  + \delta_j           \left[   \overline {V}^{\,i+1/2}\;\overline u^{\,j+1/2}   \right]
-  + \delta_k          \left[   \overline {W}^{\,i+1/2}\;\overline u^{\,k+1/2} \right]  \biggr)   \;   \biggr\} \, b_u \;u &&&  \\
-  %
-  \equiv& - \sum\limits_{i,j,k}
-  \biggl\{
-  \delta_{i+1/2} \left[   \overline {U}^{\,i}\;  \overline u^{\,i}  \right]
-  + \delta_j          \left[   \overline {V}^{\,i+1/2}\;\overline u^{\,j+1/2}   \right]
-  + \delta_k         \left[   \overline {W}^{\,i+12}\;\overline u^{\,k+1/2}  \right]
-  \; \biggr\} \; u     \\
-  %
-  \equiv& + \sum\limits_{i,j,k}
-  \biggl\{
-  \overline {U}^{\,i}\;	\overline u^{\,i} 	\delta_i \left[ u \right]
-  + \overline {V}^{\,i+1/2}\;	\overline u^{\,j+1/2} 	\delta_{j+1/2} \left[ u \right]
-  + \overline {W}^{\,i+1/2}\;	\overline u^{\,k+1/2}	\delta_{k+1/2} 	\left[ u \right]     \biggr\}     && \\
-  %
-  \equiv& + \frac{1}{2} \sum\limits_{i,j,k}    \biggl\{
-  \overline{U}^{\,i} 		\delta_i 		\left[ u^2 \right]
-  + \overline{V}^{\,i+1/2} 	\delta_{j+/2} 	\left[ u^2 \right]
-  + \overline{W}^{\,i+1/2} 	\delta_{k+1/2} 	\left[ u^2 \right]      \biggr\} && \\
-  %
-  \equiv& -  \sum\limits_{i,j,k}    \frac{1}{2}   \bigg\{
-  U  \; \delta_{i+1/2}    \left[ \overline {u^2}^{\,i} \right]
-  + V  \; \delta_{j+1/2}    \left[ \overline {u^2}^{\,i} \right]
-  + W \; \delta_{k+1/2}   \left[ \overline {u^2}^{\,i} \right]     \biggr\}    &&& \\
-  %
-  \equiv& - \sum\limits_{i,j,k}  \frac{1}{2}  \overline {u^2}^{\,i}     \biggl\{
-  \delta_{i+1/2} 	\left[ U  \right]
-  + \delta_{j+1/2} 	\left[ V  \right]
-  + \delta_{k+1/2} 	\left[ W \right]     \biggr\}    &&& \\
-  %
-  \equiv& + \sum\limits_{i,j,k}  \frac{1}{2}  \overline {u^2}^{\,i}
-  \biggl\{     \left(   \frac{1}{e_{3t}} \frac{\partial e_{3t}}{\partial t}   \right) \; b_t     \biggr\}    &&& \\
-\end{flalign*}
-Applying similar manipulation applied to the second term of the scalar product leads to:
-\[
-  -  \int_D \textbf{U}_h \cdot     \left(                 {{
-        \begin{array} {*{20}c}
-          \nabla \cdot \left( \textbf{U}\,u \right) \hfill \\
-          \nabla \cdot \left( \textbf{U}\,v \right) \hfill \\
-        \end{array}
-      } }           \right)   \;dv
-  \equiv + \sum\limits_{i,j,k}  \frac{1}{2}  \left( \overline {u^2}^{\,i} + \overline {v^2}^{\,j} \right)
-  \biggl\{     \left(   \frac{1}{e_{3t}} \frac{\partial e_{3t}}{\partial t}   \right) \; b_t     \biggr\}
-\]
-which is the discrete form of $ \frac{1}{2} \int_D u \cdot \nabla \cdot \left(   \textbf{U}\,u   \right) \; dv $.
-\autoref{eq:C_ADV_KE_flux} is thus satisfied.
-
-When the UBS scheme is used to evaluate the flux form momentum advection,
-the discrete operator does not contribute to the global budget of linear momentum (flux form).
-The horizontal kinetic energy is not conserved, but forced to decay (\ie the scheme is diffusive). 
-
-% ================================================================
-% Discrete Enstrophy Conservation
-% ================================================================
-\section{Discrete enstrophy conservation}
-\label{sec:C.4}
-
-% -------------------------------------------------------------------------------------------------------------
-%       Vorticity Term with ENS scheme
-% -------------------------------------------------------------------------------------------------------------
-\subsubsection{Vorticity term with ENS scheme  (\protect\np{ln\_dynvor\_ens}\forcode{ = .true.})}
-\label{subsec:C_vorENS} 
-
-In the ENS scheme, the vorticity term is descretized as follows:
-\begin{equation}
-  \tag{\ref{eq:dynvor_ens}}
-  \left\{
-    \begin{aligned}
-      +\frac{1}{e_{1u}} & \overline{q}^{\,i}  & {\overline{ \overline{\left( e_{1v}\,e_{3v}\;  v \right) } } }^{\,i, j+1/2}    \\
-      - \frac{1}{e_{2v}} & \overline{q}^{\,j}  & {\overline{ \overline{\left( e_{2u}\,e_{3u}\; u \right) } } }^{\,i+1/2, j}
-    \end{aligned}
-  \right.
-\end{equation} 
-
-The scheme does not allow but the conservation of the total kinetic energy but the conservation of $q^2$,
-the potential enstrophy for a horizontally non-divergent flow (\ie when $\chi$=$0$).
-Indeed, using the symmetry or skew symmetry properties of the operators
-( \autoref{eq:DOM_mi_adj} and \autoref{eq:DOM_di_adj}),
-it can be shown that:
-\begin{equation}
-  \label{eq:C_1.1}
-  \int_D {q\,\;{\textbf{k}}\cdot \frac{1} {e_3} \nabla \times \left( {e_3 \, q \;{\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} \equiv 0
-\end{equation}
-where $dv=e_1\,e_2\,e_3 \; di\,dj\,dk$ is the volume element.
-Indeed, using \autoref{eq:dynvor_ens},
-the discrete form of the right hand side of \autoref{eq:C_1.1} can be transformed as follow:
-\begin{flalign*}
-  &\int_D q \,\; \textbf{k} \cdot \frac{1} {e_3 } \nabla \times
-  \left(  e_3 \, q \; \textbf{k} \times  \textbf{U}_h   \right)\;   dv \\
-  %
-  & \qquad
-  {
-    \begin{array}{*{20}l}
-      &\equiv \sum\limits_{i,j,k}
-        q \ \left\{  \delta_{i+1/2}  \left[ - \,\overline {q}^{\,i}\;  \overline{\overline  U }^{\,i,j+1/ 2} \right]
-        - \delta_{j+1/2} \left[	 \overline {q}^{\,j}\;  \overline{\overline  V }^{\,i+1/2, j} \right]     \right\}    \\
-      %
-      &\equiv \sum\limits_{i,j,k}
-        \left\{   \delta_i [q] \; \overline{q}^{\,i} \; \overline{  \overline U  }^{\,i,j+1/2}
-        + \delta_j [q] \; \overline{q}^{\,j} \; \overline{\overline V }^{\,i+1/2,j}        \right\}       &&  \\
-      %
-      &\equiv \,\frac{1} {2} \sum\limits_{i,j,k}
-        \left\{         \delta_i  \left[ q^2 \right] \; \overline{\overline U }^{\,i,j+1/2}
-        + \delta_j  \left[ q^2 \right] \; \overline{\overline V }^{\,i+1/2,j}      \right\}    &&  \\
-      %
-      &\equiv - \frac{1} {2} \sum\limits_{i,j,k} 	q^2 \;
-        \left\{    \delta_{i+1/2}   \left[   \overline{\overline{ U }}^{\,i,j+1/2}    \right]
-        + \delta_{j+1/2}  \left[   \overline{\overline{ V }}^{\,i+1/2,j}     \right]    \right\}    && \\
-    \end{array}
-  }
-  %
-  \allowdisplaybreaks
-  \intertext{ Since $\overline {\;\cdot \;} $ and $\delta $ operators commute: $\delta_{i+1/2}
-    \left[ {\overline a^{\,i}} \right] = \overline {\delta_i \left[ a \right]}^{\,i+1/2}$,
-    and introducing the horizontal divergence $\chi $, it becomes: }
-  \allowdisplaybreaks
-  %
-  & \qquad {
-    \begin{array}{*{20}l}
-      &\equiv \sum\limits_{i,j,k} - \frac{1} {2} q^2 \; \overline{\overline{ e_{1t}\,e_{2t}\,e_{3t}^{}\, \chi}}^{\,i+1/2,j+1/2}
-        \quad \equiv 0 &&
-    \end{array}
-  }
-\end{flalign*}
-The later equality is obtain only when the flow is horizontally non-divergent, \ie $\chi$=$0$. 
-
-% -------------------------------------------------------------------------------------------------------------
-%       Vorticity Term with EEN scheme
-% -------------------------------------------------------------------------------------------------------------
-\subsubsection{Vorticity Term with EEN scheme (\protect\np{ln\_dynvor\_een}\forcode{ = .true.})}
-\label{subsec:C_vorEEN} 
-
-With the EEN scheme, the vorticity terms are represented as: 
-\begin{equation}
-  \tag{\ref{eq:dynvor_een}}
-  \left\{ {
-      \begin{aligned}
-        +q\,e_3 \, v 	&\equiv +\frac{1}{e_{1u} }   \sum_{\substack{i_p,\,k_p}}
-        {^{i+1/2-i_p}_j}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{1v} e_{3v} \ v  \right)^{i+i_p-1/2}_{j+j_p}   \\
-        - q\,e_3 \, u     &\equiv -\frac{1}{e_{2v} }    \sum_{\substack{i_p,\,k_p}}
-        {^i_{j+1/2-j_p}}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{2u} e_{3u} \ u  \right)^{i+i_p}_{j+j_p-1/2}   \\
-      \end{aligned}
-    } \right.
-\end{equation} 
-where the indices $i_p$ and $k_p$ take the following values: 
-$i_p = -1/2$ or $1/2$ and $j_p = -1/2$ or $1/2$,
-and the vorticity triads, ${^i_j}\mathbb{Q}^{i_p}_{j_p}$, defined at $T$-point, are given by: 
-\begin{equation}
-  \tag{\ref{eq:Q_triads}}
-  _i^j \mathbb{Q}^{i_p}_{j_p}
-  = \frac{1}{12} \ \left(   q^{i-i_p}_{j+j_p} + q^{i+j_p}_{j+i_p} + q^{i+i_p}_{j-j_p}  \right)
-\end{equation}
-
-This formulation does conserve the potential enstrophy for a horizontally non-divergent flow (\ie $\chi=0$). 
-
-Let consider one of the vorticity triad, for example ${^{i}_j}\mathbb{Q}^{+1/2}_{+1/2} $,
-similar manipulation can be done for the 3 others.
-The discrete form of the right hand side of \autoref{eq:C_1.1} applied to
-this triad only can be transformed as follow:
-
-\begin{flalign*}
-  &\int_D {q\,\;{\textbf{k}}\cdot \frac{1} {e_3} \nabla \times \left( {e_3 \, q \;{\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} \\
-  %
-  \equiv& \sum\limits_{i,j,k}
-  {q} \    \biggl\{ \;\;
-  \delta_{i+1/2} \left[   -\, {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; U^{i+1/2}_{j}}    \right]
-  - \delta_{j+1/2} \left[       {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; V^{i}_{j+1/2}}    \right]
-  \;\;\biggr\}        &&  \\
-  %
-  \equiv& \sum\limits_{i,j,k}
-  \biggl\{   \delta_i [q] \  {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; U^{i+1/2}_{j}}
-  + \delta_j [q] \  {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; V^{i}_{j+1/2}}   \biggr\}
-  && \\
-  %
-  ... & &&\\
-  &Demonstation \ to \ be \ done... &&\\
-  ... & &&\\
-  %
-  \equiv& \frac{1} {2} \sum\limits_{i,j,k}
-  \biggl\{	\delta_i    \Bigl[    \left(  {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2   \Bigr]\;
-  \overline{\overline {U}}^{\,i,j+1/2}
-  + \delta_j 	\Bigl[    \left( {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2     \Bigr]\;
-  \overline{\overline {V}}^{\,i+1/2,j}
-  \biggr\}
-  &&  \\
-  %
-  \equiv& - \frac{1} {2} \sum\limits_{i,j,k} 	\left( {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2\;
-  \biggl\{    \delta_{i+1/2}
-  \left[   \overline{\overline {U}}^{\,i,j+1/2}    \right]
-  + \delta_{j+1/2}
-  \left[   \overline{\overline {V}}^{\,i+1/2,j}     \right]
-  \biggr\}    && \\
-  %
-  \equiv& \sum\limits_{i,j,k} - \frac{1} {2} \left( {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2
-  \; \overline{\overline{ b_t^{}\, \chi}}^{\,i+1/2,\,j+1/2}  &&\\
-  %
-  \ \ \equiv& \ 0     &&\\
-\end{flalign*}
-
-% ================================================================
-% Conservation Properties on Tracers
-% ================================================================
-\section{Conservation properties on tracers}
-\label{sec:C.5}
-
-All the numerical schemes used in NEMO are written such that the tracer content is conserved by
-the internal dynamics and physics (equations in flux form).
-For advection,
-only the CEN2 scheme (\ie $2^{nd}$ order finite different scheme) conserves the global variance of tracer.
-Nevertheless the other schemes ensure that the global variance decreases
-(\ie they are at least slightly diffusive).
-For diffusion, all the schemes ensure the decrease of the total tracer variance, except the iso-neutral operator.
-There is generally no strict conservation of mass,
-as the equation of state is non linear with respect to $T$ and $S$.
-In practice, the mass is conserved to a very high accuracy. 
-% -------------------------------------------------------------------------------------------------------------
-%       Advection Term
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Advection term}
-\label{subsec:C.5.1}
-
-conservation of a tracer, $T$:
-\[
-  \frac{\partial }{\partial t} \left(   \int_D {T\;dv}   \right)
-  =  \int_D { \frac{1}{e_3}\frac{\partial \left( e_3 \, T \right)}{\partial t} \;dv }=0
-\]
-
-conservation of its variance:
-\begin{flalign*}
-  \frac{\partial }{\partial t} \left( \int_D {\frac{1}{2} T^2\;dv} \right)
-  =&  \int_D { \frac{1}{e_3} Q      \frac{\partial \left( e_3 \, T \right) }{\partial t} \;dv }
-  -   \frac{1}{2} \int_D {  T^2 \frac{1}{e_3} \frac{\partial  e_3 }{\partial t} \;dv }
-\end{flalign*}
-
-Whatever the advection scheme considered it conserves of the tracer content as
-all the scheme are written in flux form.
-Indeed, let $T$ be the tracer and its $\tau_u$, $\tau_v$, and $\tau_w$ interpolated values at velocity point
-(whatever the interpolation is),
-the conservation of the tracer content due to the advection tendency is obtained as follows: 
-\begin{flalign*}
-  &\int_D { \frac{1}{e_3}\frac{\partial \left( e_3 \, T \right)}{\partial t} \;dv } = - \int_D \nabla \cdot \left( T \textbf{U} \right)\;dv    &&&\\
-  &\equiv - \sum\limits_{i,j,k}    \biggl\{
-  \frac{1} {b_t}  \left(  \delta_i    \left[   U \;\tau_u   \right]
-    + \delta_j    \left[   V  \;\tau_v   \right] \right)
-  + \frac{1} {e_{3t}} \delta_k \left[ w\;\tau_w \right]    \biggl\}  b_t   &&&\\
-  %
-  &\equiv - \sum\limits_{i,j,k}     \left\{
-    \delta_i  \left[   U \;\tau_u   \right]
-    + \delta_j  \left[   V  \;\tau_v   \right]
- 	 + \delta_k \left[ W \;\tau_w \right] \right\}   && \\
-  &\equiv 0 &&&
-\end{flalign*}
-
-The conservation of the variance of tracer due to the advection tendency can be achieved only with the CEN2 scheme,
-\ie when $\tau_u= \overline T^{\,i+1/2}$, $\tau_v= \overline T^{\,j+1/2}$, and $\tau_w= \overline T^{\,k+1/2}$. 
-It can be demonstarted as follows:
-\begin{flalign*}
-  &\int_D { \frac{1}{e_3} Q      \frac{\partial \left( e_3 \, T \right) }{\partial t} \;dv }
-  = - \int\limits_D \tau\;\nabla \cdot \left( T\; \textbf{U} \right)\;dv &&&\\
-  \equiv& - \sum\limits_{i,j,k} T\;
-  \left\{
-    \delta_i  \left[ U  \overline T^{\,i+1/2}  \right]
-    + \delta_j  \left[ V  \overline T^{\,j+1/2}  \right]
-    + \delta_k \left[ W \overline T^{\,k+1/2} \right]          \right\} && \\
-  \equiv& + \sum\limits_{i,j,k}
-  \left\{     U  \overline T^{\,i+1/2} \,\delta_{i+1/2}  \left[ T \right]
-    +  V  \overline T^{\,j+1/2} \;\delta_{j+1/2}  \left[ T \right]
-    +  W \overline T^{\,k+1/2}\;\delta_{k+1/2} \left[ T \right]     \right\}      &&\\
-  \equiv&  + \frac{1} {2}  \sum\limits_{i,j,k}
-  \Bigl\{   U  \;\delta_{i+1/2} \left[ T^2 \right]
-  + V  \;\delta_{j+1/2}  \left[ T^2 \right]
-  + W \;\delta_{k+1/2} \left[ T^2 \right]   \Bigr\}     && \\
-  \equiv& - \frac{1} {2}  \sum\limits_{i,j,k} T^2
-  \Bigl\{    \delta_i  \left[ U  \right]
-  + \delta_j  \left[ V  \right]
-  + \delta_k \left[ W \right]     \Bigr\}      &&&  \\
-  \equiv& + \frac{1} {2}  \sum\limits_{i,j,k} T^2
-  \Bigl\{   \frac{1}{e_{3t}} \frac{\partial e_{3t}\,T }{\partial t}     \Bigr\}      &&& \\
-\end{flalign*}
-which is the discrete form of $ \frac{1}{2} \int_D {  T^2 \frac{1}{e_3} \frac{\partial  e_3 }{\partial t} \;dv }$.
-
-% ================================================================
-% Conservation Properties on Lateral Momentum Physics
-% ================================================================
-\section{Conservation properties on lateral momentum physics}
-\label{sec:dynldf_properties}
-
-The discrete formulation of the horizontal diffusion of momentum ensures
-the conservation of potential vorticity and the horizontal divergence,
-and the dissipation of the square of these quantities
-(\ie enstrophy and the variance of the horizontal divergence) as well as
-the dissipation of the horizontal kinetic energy.
-In particular, when the eddy coefficients are horizontally uniform,
-it ensures a complete separation of vorticity and horizontal divergence fields,
-so that diffusion (dissipation) of vorticity (enstrophy) does not generate horizontal divergence
-(variance of the horizontal divergence) and \textit{vice versa}. 
-
-These properties of the horizontal diffusion operator are a direct consequence of
-properties \autoref{eq:DOM_curl_grad} and \autoref{eq:DOM_div_curl}.
-When the vertical curl of the horizontal diffusion of momentum (discrete sense) is taken,
-the term associated with the horizontal gradient of the divergence is locally zero. 
-
-% -------------------------------------------------------------------------------------------------------------
-%       Conservation of Potential Vorticity
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Conservation of potential vorticity}
-\label{subsec:C.6.1}
-
-The lateral momentum diffusion term conserves the potential vorticity:
-\begin{flalign*}
-  &\int \limits_D \frac{1} {e_3 } \textbf{k} \cdot \nabla \times
-  \Bigl[    \nabla_h  \left( A^{\,lm}\;\chi  \right)
-  - \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)    \Bigr]\;dv   \\
-  % \end{flalign*}
-  %%%%%%%%%% recheck here....  (gm)
-  % \begin{flalign*}
-  =& \int \limits_D  -\frac{1} {e_3 } \textbf{k} \cdot \nabla \times
-  \Bigl[ \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)  \Bigr]\;dv  \\
-  % \end{flalign*}
-  % \begin{flalign*}
-  \equiv& \sum\limits_{i,j}
-  \left\{
-    \delta_{i+1/2} \left[  \frac {e_{2v}} {e_{1v}\,e_{3v}}  \delta_i \left[ A_f^{\,lm} e_{3f} \zeta  \right]  \right]
-    + \delta_{j+1/2} \left[  \frac {e_{1u}} {e_{2u}\,e_{3u}}  \delta_j \left[ A_f^{\,lm} e_{3f} \zeta  \right]  \right]
-  \right\} 	 \\
-  %
-  \intertext{Using \autoref{eq:DOM_di_adj}, it follows:}
-  %
-  \equiv& \sum\limits_{i,j,k}
-  -\,\left\{
-    \frac{e_{2v}} {e_{1v}\,e_{3v}}  \delta_i	\left[ A_f^{\,lm} e_{3f} \zeta  \right]\;\delta_i \left[ 1\right]
-	 + \frac{e_{1u}} {e_{2u}\,e_{3u}}  \delta_j 	\left[ A_f^{\,lm} e_{3f} \zeta  \right]\;\delta_j \left[ 1\right]
-  \right\} \quad \equiv 0
-  \\
-\end{flalign*}
-
-% -------------------------------------------------------------------------------------------------------------
-%       Dissipation of Horizontal Kinetic Energy
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Dissipation of horizontal kinetic energy}
-\label{subsec:C.6.2}
-
-The lateral momentum diffusion term dissipates the horizontal kinetic energy:
-%\begin{flalign*}
-\[
-  \begin{split}
-    \int_D \textbf{U}_h \cdot
-    \left[ \nabla_h 		\right.   &     \left.       \left( A^{\,lm}\;\chi \right)
-      - \nabla_h \times  \left( A^{\,lm}\;\zeta \;\textbf{k} \right)     \right] \; dv    \\
-    \\  %%%
-    \equiv& \sum\limits_{i,j,k}
-    \left\{
-      \frac{1} {e_{1u}}               \delta_{i+1/2} \left[  A_T^{\,lm}          \chi     \right]
-      - \frac{1} {e_{2u}\,e_{3u}}  \delta_j           \left[ A_f^{\,lm} e_{3f} \zeta   \right]
-    \right\} \; e_{1u}\,e_{2u}\,e_{3u} \;u     \\
-    &\;\; + 	\left\{
-	   \frac{1} {e_{2u}}             \delta_{j+1/2}	\left[ A_T^{\,lm}          \chi    \right]
-      + \frac{1} {e_{1v}\,e_{3v}} \delta_i            \left[ A_f^{\,lm} e_{3f} \zeta  \right]
-    \right\} \; e_{1v}\,e_{2u}\,e_{3v} \;v     \qquad \\
-    \\  %%%
-    \equiv& \sum\limits_{i,j,k}
-    \Bigl\{
-    e_{2u}\,e_{3u} \;u\;  \delta_{i+1/2} \left[ A_T^{\,lm}           \chi    \right]
-    - e_{1u}             \;u\;  \delta_j           \left[ A_f^{\,lm} e_{3f} \zeta  \right]
-	 \Bigl\}
-	 \\
-    &\;\; + \Bigl\{
-    e_{1v}\,e_{3v} \;v\;  \delta_{j+1/2}  \left[ A_T^{\,lm}           \chi    \right]
-    + e_{2v}             \;v\;  \delta_i            \left[ A_f^{\,lm} e_{3f} \zeta  \right]
-    \Bigl\}      \\
-    \\  %%%
-    \equiv& \sum\limits_{i,j,k}
-    - \Bigl(
-    \delta_i   \left[  e_{2u}\,e_{3u} \;u  \right]
-    + \delta_j  \left[  e_{1v}\,e_{3v}  \;v  \right]
-    \Bigr) \;  A_T^{\,lm} \chi   \\
-    &\;\; - \Bigl(
-    \delta_{i+1/2}  \left[  e_{2v}  \;v  \right]
-    - \delta_{j+1/2}  \left[  e_{1u} \;u  \right]
-    \Bigr)\;  A_f^{\,lm} e_{3f} \zeta      \\
-    \\  %%%
-    \equiv& \sum\limits_{i,j,k}
-    - A_T^{\,lm}  \,\chi^2   \;e_{1t}\,e_{2t}\,e_{3t}
-    - A_f ^{\,lm}  \,\zeta^2 \;e_{1f }\,e_{2f }\,e_{3f}
-    \quad \leq 0       \\
-  \end{split}
-\]
-
-% -------------------------------------------------------------------------------------------------------------
-%       Dissipation of Enstrophy
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Dissipation of enstrophy}
-\label{subsec:C.6.3}
-
-The lateral momentum diffusion term dissipates the enstrophy when the eddy coefficients are horizontally uniform:
-\begin{flalign*}
-  &\int\limits_D  \zeta \; \textbf{k} \cdot \nabla \times
-  \left[   \nabla_h \left( A^{\,lm}\;\chi  \right)
-    - \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)   \right]\;dv &&&\\
-  &\quad = A^{\,lm} \int \limits_D \zeta \textbf{k} \cdot \nabla \times
-  \left[    \nabla_h \times \left( \zeta \; \textbf{k} \right)   \right]\;dv &&&\\
-  &\quad \equiv A^{\,lm} \sum\limits_{i,j,k}  \zeta \;e_{3f}
-  \left\{     \delta_{i+1/2} \left[  \frac{e_{2v}} {e_{1v}\,e_{3v}} \delta_i \left[ e_{3f} \zeta  \right]   \right]
-    + \delta_{j+1/2} \left[  \frac{e_{1u}} {e_{2u}\,e_{3u}} \delta_j \left[ e_{3f} \zeta  \right]   \right]      \right\}   &&&\\
-  %
-  \intertext{Using \autoref{eq:DOM_di_adj}, it follows:}
-  %
-  &\quad \equiv  - A^{\,lm} \sum\limits_{i,j,k}
-  \left\{    \left(  \frac{1} {e_{1v}\,e_{3v}}  \delta_i \left[ e_{3f} \zeta  \right]  \right)^2   b_v
-    + \left(  \frac{1} {e_{2u}\,e_{3u}}  \delta_j \left[ e_{3f} \zeta  \right] \right)^2   b_u  \right\}  \quad \leq \;0    &&&\\
-\end{flalign*}
-
-% -------------------------------------------------------------------------------------------------------------
-%       Conservation of Horizontal Divergence
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Conservation of horizontal divergence}
-\label{subsec:C.6.4}
-
-When the horizontal divergence of the horizontal diffusion of momentum (discrete sense) is taken,
-the term associated with the vertical curl of the vorticity is zero locally, due to \autoref{eq:DOM_div_curl}. 
-The resulting term conserves the $\chi$ and dissipates $\chi^2$ when the eddy coefficients are horizontally uniform.
-\begin{flalign*}
-  & \int\limits_D  \nabla_h \cdot
-  \Bigl[     \nabla_h \left( A^{\,lm}\;\chi \right)
-  - \nabla_h \times \left( A^{\,lm}\;\zeta \;\textbf{k} \right)    \Bigr]  dv
-  = \int\limits_D  \nabla_h \cdot \nabla_h \left( A^{\,lm}\;\chi  \right)   dv   \\
-  %
-  &\equiv \sum\limits_{i,j,k}
-  \left\{   \delta_i \left[ A_u^{\,lm} \frac{e_{2u}\,e_{3u}} {e_{1u}}  \delta_{i+1/2} \left[ \chi \right]  \right]
-    + \delta_j \left[ A_v^{\,lm} \frac{e_{1v}\,e_{3v}} {e_{2v}}  \delta_{j+1/2} \left[ \chi \right]  \right]    \right\}    \\
-  %
-  \intertext{Using \autoref{eq:DOM_di_adj}, it follows:}
-  %
-  &\equiv \sum\limits_{i,j,k}
-  - \left\{   \frac{e_{2u}\,e_{3u}} {e_{1u}}  A_u^{\,lm} \delta_{i+1/2} \left[ \chi \right] \delta_{i+1/2} \left[ 1 \right]
-    + \frac{e_{1v}\,e_{3v}} {e_{2v}}  A_v^{\,lm} \delta_{j+1/2} \left[ \chi \right] \delta_{j+1/2} \left[ 1 \right]    \right\}
-  \quad \equiv 0
-\end{flalign*}
-
-% -------------------------------------------------------------------------------------------------------------
-%       Dissipation of Horizontal Divergence Variance
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Dissipation of horizontal divergence variance}
-\label{subsec:C.6.5}
-
-\begin{flalign*}
-  &\int\limits_D \chi \;\nabla_h \cdot
-  \left[    \nabla_h              \left( A^{\,lm}\;\chi                    \right)
-    - \nabla_h   \times  \left( A^{\,lm}\;\zeta \;\textbf{k} \right)    \right]\;  dv
-  = A^{\,lm}   \int\limits_D \chi \;\nabla_h \cdot \nabla_h \left( \chi \right)\;  dv    \\
-  %
-  &\equiv A^{\,lm}  \sum\limits_{i,j,k}  \frac{1} {e_{1t}\,e_{2t}\,e_{3t}}  \chi
-  \left\{
-    \delta_i  \left[   \frac{e_{2u}\,e_{3u}} {e_{1u}}  \delta_{i+1/2} \left[ \chi \right]   \right]
-    + \delta_j  \left[   \frac{e_{1v}\,e_{3v}} {e_{2v}}   \delta_{j+1/2} \left[ \chi \right]   \right]
-  \right\} \;   e_{1t}\,e_{2t}\,e_{3t}    \\
-  %
-  \intertext{Using \autoref{eq:DOM_di_adj}, it turns out to be:}
-  %
-  &\equiv - A^{\,lm} \sum\limits_{i,j,k}
-  \left\{    \left(  \frac{1} {e_{1u}}  \delta_{i+1/2}  \left[ \chi \right]  \right)^2  b_u
-    + \left(  \frac{1} {e_{2v}}  \delta_{j+1/2}  \left[ \chi \right]  \right)^2  b_v    \right\}
-  \quad \leq 0
-\end{flalign*}
-
-% ================================================================
-% Conservation Properties on Vertical Momentum Physics
-% ================================================================
-\section{Conservation properties on vertical momentum physics}
-\label{sec:C.7}
-
-As for the lateral momentum physics,
-the continuous form of the vertical diffusion of momentum satisfies several integral constraints.
-The first two are associated with the conservation of momentum and the dissipation of horizontal kinetic energy:
-\begin{align*}
-  \int\limits_D   \frac{1} {e_3 }\; \frac{\partial } {\partial k}
-  \left(   \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}   \right)\;  dv
-  \qquad \quad &= \vec{\textbf{0}}
-  %
-  \intertext{and}
-  %
-                 \int\limits_D
-                 \textbf{U}_h \cdot   \frac{1} {e_3 }\; \frac{\partial } {\partial k}
-                 \left(   \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}   \right)\; dv    \quad &\leq 0
-\end{align*}
-
-The first property is obvious.
-The second results from:
-\begin{flalign*}
-  \int\limits_D
-  \textbf{U}_h \cdot   \frac{1} {e_3 }\; \frac{\partial } {\partial k}
-  \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}   \right)\;dv    &&&\\
-\end{flalign*}
-\begin{flalign*}
-  &\equiv \sum\limits_{i,j,k}
-  \left(
-    u\; \delta_k \left[ \frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2}  \left[ u \right]  \right]\;  e_{1u}\,e_{2u}
-    + v\; \delta_k \left[ \frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2}   \left[ v \right]  \right]\;  e_{1v}\,e_{2v} \right)   &&&
-  %
-  \intertext{since the horizontal scale factor does not depend on $k$, it follows:}
-  %
-  &\equiv - \sum\limits_{i,j,k}
-  \left(  \frac{A_u^{\,vm}} {e_{3uw}} \left( \delta_{k+1/2} \left[ u \right] \right)^2\; e_{1u}\,e_{2u}
-    + \frac{A_v^{\,vm}} {e_{3vw}}  \left( \delta_{k+1/2} \left[ v \right] \right)^2\; e_{1v}\,e_{2v}  \right)
-  \quad \leq 0   &&&
-\end{flalign*}
-
-The vorticity is also conserved.
-Indeed:
-\begin{flalign*}
-  \int \limits_D
-  \frac{1} {e_3 } \textbf{k} \cdot \nabla \times
-  \left( \frac{1} {e_3 }\; \frac{\partial } {\partial k}  \left(
-      \frac{A^{\,vm}} {e_3}\; \frac{\partial \textbf{U}_h } {\partial k}
-    \right)  \right)\; dv   &&&
-\end{flalign*}
-\begin{flalign*}
-  \equiv \sum\limits_{i,j,k}  \frac{1} {e_{3f}}\; \frac{1} {e_{1f}\,e_{2f}}
-  \bigg\{    \biggr.   \quad
-  \delta_{i+1/2}
-  &\left(   \frac{e_{2v}} {e_{3v}} \delta_k  \left[  \frac{1} {e_{3vw}} \delta_{k+1/2} \left[ v \right]  \right]  \right)   &&\\
-  \biggl.
-  - \delta_{j+1/2}
-  &\left(   \frac{e_{1u}} {e_{3u}} \delta_k \left[  \frac{1} {e_{3uw}}\delta_{k+1/2} \left[ u \right]  \right]   \right)
-  \biggr\} \;
-  e_{1f}\,e_{2f}\,e_{3f} \; \equiv 0   &&
-\end{flalign*}
-
-If the vertical diffusion coefficient is uniform over the whole domain, the enstrophy is dissipated, \ie
-\begin{flalign*}
-  \int\limits_D \zeta \, \textbf{k} \cdot \nabla \times
-  \left(   \frac{1} {e_3}\; \frac{\partial } {\partial k}
-    \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}   \right)   \right)\; dv = 0   &&&
-\end{flalign*}
-
-This property is only satisfied in $z$-coordinates:
-\begin{flalign*}
-  \int\limits_D \zeta \, \textbf{k} \cdot \nabla \times
-  \left(  \frac{1} {e_3}\; \frac{\partial } {\partial k}
-    \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}  \right)   \right)\; dv   &&&
-\end{flalign*}
-\begin{flalign*}
-  \equiv \sum\limits_{i,j,k} \zeta \;e_{3f} \;
-  \biggl\{ 	\biggr.	\quad
-  \delta_{i+1/2}
-  &\left(   \frac{e_{2v}} {e_{3v}} \delta_k \left[ \frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2}[v]  \right]   \right)   &&\\
-  - \delta_{j+1/2}
-  &\biggl.
-  \left(   \frac{e_{1u}} {e_{3u}} \delta_k \left[ \frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2} [u]  \right]    \right) \biggr\}   &&
-\end{flalign*}
-\begin{flalign*}
-  \equiv \sum\limits_{i,j,k} \zeta \;e_{3f}
-  \biggl\{		\biggr.	\quad
-  \frac{1} {e_{3v}} \delta_k
-  &\left[ \frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2} \left[ \delta_{i+1/2} \left[ e_{2v}\,v \right] \right]   \right]    &&\\
-  \biggl.
-  - \frac{1} {e_{3u}} \delta_k
-  &\left[  \frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2} \left[ \delta_{j+1/2} \left[ e_{1u}\,u \right] \right]  \right]  \biggr\}  &&
-\end{flalign*}
-Using the fact that the vertical diffusion coefficients are uniform,
-and that in $z$-coordinate, the vertical scale factors do not depend on $i$ and $j$ so that:
-$e_{3f} =e_{3u} =e_{3v} =e_{3t} $ and $e_{3w} =e_{3uw} =e_{3vw} $, it follows:
-\begin{flalign*}
-  \equiv A^{\,vm} \sum\limits_{i,j,k} \zeta \;\delta_k
-  \left[   \frac{1} {e_{3w}} \delta_{k+1/2} \Bigl[   \delta_{i+1/2} \left[ e_{2v}\,v \right]
-    - \delta_{j+1/ 2} \left[ e_{1u}\,u \right]   \Bigr]    \right]    &&&
-\end{flalign*}
-\begin{flalign*}
-  \equiv - A^{\,vm} \sum\limits_{i,j,k} \frac{1} {e_{3w}}
-  \left( \delta_{k+1/2} \left[ \zeta  \right] \right)^2 \; e_{1f}\,e_{2f}  \; \leq 0    &&&
-\end{flalign*}
-Similarly, the horizontal divergence is obviously conserved:
-
-\begin{flalign*}
-  \int\limits_D \nabla \cdot
-  \left( \frac{1} {e_3 }\; \frac{\partial } {\partial k}
-    \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k} \right) \right)\; dv = 0    &&&
-\end{flalign*}
-and the square of the horizontal divergence decreases (\ie the horizontal divergence is dissipated) if
-the vertical diffusion coefficient is uniform over the whole domain:
-
-\begin{flalign*}
-  \int\limits_D \chi \;\nabla \cdot
-  \left( \frac{1} {e_3 }\; \frac{\partial } {\partial k}
-    \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}  \right) \right)\;  dv = 0  &&&
-\end{flalign*}
-This property is only satisfied in the $z$-coordinate:
-\begin{flalign*}
-  \int\limits_D \chi \;\nabla \cdot
-  \left( \frac{1} {e_3 }\; \frac{\partial } {\partial k}
-    \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k} \right)  \right)\; dv    &&&
-\end{flalign*}
-\begin{flalign*}
-  \equiv \sum\limits_{i,j,k} \frac{\chi } {e_{1t}\,e_{2t}}
-  \biggl\{ 	\Biggr.	\quad
-  \delta_{i+1/2}
-  &\left(   \frac{e_{2u}} {e_{3u}} \delta_k
-    \left[ \frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2} [u] \right] \right)    &&\\
-  \Biggl.
-  + \delta_{j+1/2}
-  &\left( \frac{e_{1v}} {e_{3v}} \delta_k
-    \left[ \frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2} [v] \right]   \right)
-  \Biggr\} \;  e_{1t}\,e_{2t}\,e_{3t}   &&
-\end{flalign*}
-
-\begin{flalign*}
-  \equiv A^{\,vm} \sum\limits_{i,j,k}  \chi \,
-  \biggl\{	\biggr.	\quad
-  \delta_{i+1/2}
-  &\left(
-    \delta_k \left[
-      \frac{1} {e_{3uw}} \delta_{k+1/2} \left[ e_{2u}\,u \right] \right]   \right)    && \\
-  \biggl.
-  + \delta_{j+1/2}
-  &\left(    \delta_k \left[
-      \frac{1} {e_{3vw}} \delta_{k+1/2} \left[ e_{1v}\,v \right] \right]   \right)   \biggr\}    &&
-\end{flalign*}
-
-\begin{flalign*}
-  \equiv -A^{\,vm} \sum\limits_{i,j,k}
-  \frac{\delta_{k+1/2} \left[ \chi \right]} {e_{3w}}\; \biggl\{
-  \delta_{k+1/2} \Bigl[
-  \delta_{i+1/2} \left[ e_{2u}\,u \right]
-  + \delta_{j+1/2} \left[ e_{1v}\,v \right]  \Bigr]    \biggr\}    &&&
-\end{flalign*}
-
-\begin{flalign*}
-  \equiv -A^{\,vm} \sum\limits_{i,j,k}
-  \frac{1} {e_{3w}} \delta_{k+1/2} \left[ \chi \right]\; \delta_{k+1/2} \left[ e_{1t}\,e_{2t} \;\chi \right]   &&&
-\end{flalign*}
-
-\begin{flalign*}
-  \equiv -A^{\,vm} \sum\limits_{i,j,k}
-  \frac{e_{1t}\,e_{2t}} {e_{3w}}\; \left( \delta_{k+1/2} \left[ \chi \right]  \right)^2     \quad  \equiv 0    &&&
-\end{flalign*}
-
-% ================================================================
-% Conservation Properties on Tracer Physics
-% ================================================================
-\section{Conservation properties on tracer physics}
-\label{sec:C.8}
-
-The numerical schemes used for tracer subgridscale physics are written such that
-the heat and salt contents are conserved (equations in flux form).
-Since a flux form is used to compute the temperature and salinity,
-the quadratic form of these quantities (\ie their variance) globally tends to diminish.
-As for the advection term, there is conservation of mass only if the Equation Of Seawater is linear. 
-
-% -------------------------------------------------------------------------------------------------------------
-%       Conservation of Tracers
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Conservation of tracers}
-\label{subsec:C.8.1}
-
-constraint of conservation of tracers:
-\begin{flalign*}
-  &\int\limits_D  \nabla  \cdot \left( A\;\nabla T \right)\;dv  &&& \\ \\
-  &\equiv \sum\limits_{i,j,k}
-  \biggl\{ 	\biggr.
-  \delta_i
-  \left[
-    A_u^{\,lT} \frac{e_{2u}\,e_{3u}} {e_{1u}} \delta_{i+1/2}
-    \left[ T \right]
-  \right]
-  + \delta_j
-  \left[
-    A_v^{\,lT} \frac{e_{1v}\,e_{3v}} {e_{2v}} \delta_{j+1/2}
-    \left[ T \right]
-  \right] && \\
-  & \qquad \qquad \qquad \qquad \qquad \qquad \quad \;\;\;
-  + \delta_k
-  \left[
-    A_w^{\,vT} \frac{e_{1t}\,e_{2t}} {e_{3t}} \delta_{k+1/2}
-    \left[ T \right]
-  \right]
-  \biggr\}   \quad  \equiv 0
-  &&
-\end{flalign*}
-
-In fact, this property simply results from the flux form of the operator. 
-
-% -------------------------------------------------------------------------------------------------------------
-%       Dissipation of Tracer Variance
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Dissipation of tracer variance}
-\label{subsec:C.8.2}
-
-constraint on the dissipation of tracer variance:
-\begin{flalign*}
-  \int\limits_D T\;\nabla & \cdot \left( A\;\nabla T \right)\;dv	&&&\\
-  &\equiv   \sum\limits_{i,j,k} \; T
-  \biggl\{  \biggr.
-  \delta_i \left[ A_u^{\,lT} \frac{e_{2u}\,e_{3u}} {e_{1u}} \delta_{i+1/2} \left[T\right] \right]
-  & + \delta_j \left[ A_v^{\,lT} \frac{e_{1v} \,e_{3v}} {e_{2v}} \delta_{j+1/2} \left[T\right] \right]
-  \quad&& \\
-  \biggl.
-  &&+ \delta_k \left[A_w^{\,vT}\frac{e_{1t}\,e_{2t}} {e_{3t}}\delta_{k+1/2}\left[T\right]\right]
-  \biggr\} &&
-\end{flalign*}
-\begin{flalign*}
-  \equiv - \sum\limits_{i,j,k}
-  \biggl\{ 	\biggr.	\quad
-  &    A_u^{\,lT} \left( \frac{1} {e_{1u}} \delta_{i+1/2} \left[ T \right]  \right)^2   e_{1u}\,e_{2u}\,e_{3u}    && \\
-  & + A_v^{\,lT} \left( \frac{1} {e_{2v}} \delta_{j+1/2} \left[ T \right]  \right)^2   e_{1v}\,e_{2v}\,e_{3v}     && \\ \biggl.
-  & + A_w^{\,vT} \left( \frac{1} {e_{3w}} \delta_{k+1/2} \left[ T \right]   \right)^2    e_{1w}\,e_{2w}\,e_{3w}   \biggr\}
-  \quad      \leq 0      &&
-\end{flalign*}
-
-%%%%  end of appendix in gm comment
-%}
-\biblio
-
-\pindex
-
-\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/annex_E.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/annex_E.tex	(revision 12062)
+++ 	(revision )
@@ -1,848 +1,0 @@
-\documentclass[../main/NEMO_manual]{subfiles}
-
-\begin{document}
-% ================================================================
-% Appendix E : Note on some algorithms
-% ================================================================
-\chapter{Note on some algorithms}
-\label{apdx:E}
-
-\minitoc
-
-\newpage
-
-This appendix some on going consideration on algorithms used or planned to be used in \NEMO. 
-
-% -------------------------------------------------------------------------------------------------------------
-%        UBS scheme  
-% -------------------------------------------------------------------------------------------------------------
-\section{Upstream Biased Scheme (UBS) (\protect\np{ln\_traadv\_ubs}\forcode{ = .true.})}
-\label{sec:TRA_adv_ubs}
-
-The UBS advection scheme is an upstream biased third order scheme based on
-an upstream-biased parabolic interpolation.
-It is also known as Cell Averaged QUICK scheme (Quadratic Upstream Interpolation for Convective Kinematics).
-For example, in the $i$-direction:
-\begin{equation}
-  \label{eq:tra_adv_ubs2}
-  \tau_u^{ubs} = \left\{
-	 \begin{aligned}
-      & \tau_u^{cen4} + \frac{1}{12} \,\tau"_i	   & \quad \text{if }\ u_{i+1/2} \geqslant 0 \\
-      & \tau_u^{cen4} - \frac{1}{12} \,\tau"_{i+1} & \quad \text{if }\ u_{i+1/2}       <       0
-    \end{aligned}
-  \right.
-\end{equation}
-or equivalently, the advective flux is
-\begin{equation}
-  \label{eq:tra_adv_ubs2}
-  U_{i+1/2} \ \tau_u^{ubs}
-  =U_{i+1/2} \ \overline{ T_i - \frac{1}{6}\,\tau"_i }^{\,i+1/2}
-  - \frac{1}{2}\, |U|_{i+1/2} \;\frac{1}{6} \;\delta_{i+1/2}[\tau"_i]
-\end{equation}
-where $U_{i+1/2} = e_{1u}\,e_{3u}\,u_{i+1/2}$ and
-$\tau "_i =\delta_i \left[ {\delta_{i+1/2} \left[ \tau \right]} \right]$.
-By choosing this expression for $\tau "$ we consider a fourth order approximation of $\partial_i^2$ with
-a constant i-grid spacing ($\Delta i=1$).
-
-Alternative choice: introduce the scale factors:  
-$\tau "_i =\frac{e_{1T}}{e_{2T}\,e_{3T}}\delta_i \left[ \frac{e_{2u} e_{3u} }{e_{1u} }\delta_{i+1/2}[\tau] \right]$.
-
-This results in a dissipatively dominant (\ie hyper-diffusive) truncation error
-\citep{shchepetkin.mcwilliams_OM05}.
-The overall performance of the advection scheme is similar to that reported in \cite{farrow.stevens_JPO95}.
-It is a relatively good compromise between accuracy and smoothness.
-It is not a \emph{positive} scheme meaning false extrema are permitted but
-the amplitude of such are significantly reduced over the centred second order method.
-Nevertheless it is not recommended to apply it to a passive tracer that requires positivity. 
-
-The intrinsic diffusion of UBS makes its use risky in the vertical direction where
-the control of artificial diapycnal fluxes is of paramount importance.
-It has therefore been preferred to evaluate the vertical flux using the TVD scheme when
-\np{ln\_traadv\_ubs}\forcode{ = .true.}.
-
-For stability reasons, in \autoref{eq:tra_adv_ubs}, the first term which corresponds to
-a second order centred scheme is evaluated using the \textit{now} velocity (centred in time) while
-the second term which is the diffusive part of the scheme, is evaluated using the \textit{before} velocity
-(forward in time).
-This is discussed by \citet{webb.de-cuevas.ea_JAOT98} in the context of the Quick advection scheme.
-UBS and QUICK schemes only differ by one coefficient.
-Substituting 1/6 with 1/8 in (\autoref{eq:tra_adv_ubs}) leads to the QUICK advection scheme \citep{webb.de-cuevas.ea_JAOT98}.
-This option is not available through a namelist parameter, since the 1/6 coefficient is hard coded.
-Nevertheless it is quite easy to make the substitution in \mdl{traadv\_ubs} module and obtain a QUICK scheme.
-
-NB 1: When a high vertical resolution $O(1m)$ is used, the model stability can be controlled by vertical advection
-(not vertical diffusion which is usually solved using an implicit scheme).
-Computer time can be saved by using a time-splitting technique on vertical advection.
-This possibility have been implemented and validated in ORCA05-L301.
-It is not currently offered in the current reference version. 
-
-NB 2: In a forthcoming release four options will be proposed for the vertical component used in the UBS scheme.
-$\tau_w^{ubs}$ will be evaluated using either \textit{(a)} a centered $2^{nd}$ order scheme,
-or \textit{(b)} a TVD scheme, or \textit{(c)} an interpolation based on conservative parabolic splines following
-\citet{shchepetkin.mcwilliams_OM05} implementation of UBS in ROMS, or \textit{(d)} an UBS.
-The $3^{rd}$ case has dispersion properties similar to an eight-order accurate conventional scheme.
-
-NB 3: It is straight forward to rewrite \autoref{eq:tra_adv_ubs} as follows:
-\begin{equation}
-  \label{eq:tra_adv_ubs2}
-  \tau_u^{ubs} = \left\{
-	 \begin{aligned}
-      & \tau_u^{cen4} + \frac{1}{12} \tau"_i		& \quad \text{if }\ u_{i+1/2} \geqslant 0 \\
-      & \tau_u^{cen4} - \frac{1}{12} \tau"_{i+1}	& \quad \text{if }\ u_{i+1/2}       <       0
-    \end{aligned}
-  \right.
-\end{equation}
-or equivalently 
-\begin{equation}
-  \label{eq:tra_adv_ubs2}
-  \begin{split}
-    e_{2u} e_{3u}\,u_{i+1/2} \ \tau_u^{ubs}
-    &= e_{2u} e_{3u}\,u_{i+1/2} \ \overline{ T - \frac{1}{6}\,\tau"_i }^{\,i+1/2} \\
-    & - \frac{1}{2} e_{2u} e_{3u}\,|u|_{i+1/2} \;\frac{1}{6} \;\delta_{i+1/2}[\tau"_i]
-  \end{split}
-\end{equation}
-\autoref{eq:tra_adv_ubs2} has several advantages.
-First it clearly evidences that the UBS scheme is based on the fourth order scheme to which
-is added an upstream biased diffusive term.
-Second, this emphasises that the $4^{th}$ order part have to be evaluated at \emph{now} time step,
-not only the $2^{th}$ order part as stated above using \autoref{eq:tra_adv_ubs}.
-Third, the diffusive term is in fact a biharmonic operator with a eddy coefficient which
-is simply proportional to the velocity.
-
-laplacian diffusion:
-\begin{equation}
-  \label{eq:tra_ldf_lap}
-  \begin{split}
-    D_T^{lT} =\frac{1}{e_{1T} \; e_{2T}\;  e_{3T} } &\left[ {\quad \delta_i
-        \left[ {A_u^{lT} \frac{e_{2u} e_{3u} }{e_{1u} }\;\delta_{i+1/2}
-            \left[ T \right]} \right]} \right. \\
-    &\ \left. {+\; \delta_j \left[
-          {A_v^{lT} \left( {\frac{e_{1v} e_{3v} }{e_{2v} }\;\delta_{j+1/2} \left[ T
-                \right]} \right)} \right]\quad } \right]
-  \end{split}
-\end{equation}
-
-bilaplacian:
-\begin{equation}
-  \label{eq:tra_ldf_lap}
-  \begin{split}
-    D_T^{lT} =&-\frac{1}{e_{1T} \; e_{2T}\;  e_{3T}} \\
-    & \delta_i \left[  \sqrt{A_u^{lT}}\ \frac{e_{2u}\,e_{3u}}{e_{1u}}\;\delta_{i+1/2}
-      \left[ \frac{1}{e_{1T}\,e_{2T}\, e_{3T}}
-        \delta_i \left[ \sqrt{A_u^{lT}}\ \frac{e_{2u}\,e_{3u}}{e_{1u}}\;\delta_{i+1/2}
-          [T] \right] \right] \right]
-  \end{split}
-\end{equation}
-with ${A_u^{lT}}^2 = \frac{1}{12} {e_{1u}}^3\ |u|$, 
-\ie $A_u^{lT} = \frac{1}{\sqrt{12}} \,e_{1u}\ \sqrt{ e_{1u}\,|u|\,}$
-it comes:
-\begin{equation}
-  \label{eq:tra_ldf_lap}
-  \begin{split}
-    D_T^{lT} =&-\frac{1}{12}\,\frac{1}{e_{1T} \; e_{2T}\;  e_{3T}} \\
-    & \delta_i \left[ e_{2u}\,e_{3u}\,\sqrt{ e_{1u}\,|u|\,}\;\delta_{i+1/2}
-      \left[ \frac{1}{e_{1T}\,e_{2T}\, e_{3T}}
-        \delta_i \left[ e_{2u}\,e_{3u}\,\sqrt{ e_{1u}\,|u|\,}\;\delta_{i+1/2}
-          [T] \right] \right] \right]
-  \end{split}
-\end{equation}
-if the velocity is uniform (\ie $|u|=cst$) then the diffusive flux is
-\begin{equation}
-  \label{eq:tra_ldf_lap}
-  \begin{split}
-    F_u^{lT} = - \frac{1}{12}
-    e_{2u}\,e_{3u}\,|u| \;\sqrt{ e_{1u}}\,\delta_{i+1/2}
-    \left[ \frac{1}{e_{1T}\,e_{2T}\, e_{3T}}
-      \delta_i \left[ e_{2u}\,e_{3u}\,\sqrt{ e_{1u}}\:\delta_{i+1/2}
-        [T] \right] \right]
-  \end{split}
-\end{equation}
-beurk....  reverte the logic: starting from the diffusive part of the advective flux it comes:
-
-\begin{equation}
-  \label{eq:tra_adv_ubs2}
-  \begin{split}
-    F_u^{lT} &= - \frac{1}{2} e_{2u} e_{3u}\,|u|_{i+1/2} \;\frac{1}{6} \;\delta_{i+1/2}[\tau"_i]
-  \end{split}
-\end{equation}
-if the velocity is uniform (\ie $|u|=cst$) and
-choosing $\tau "_i =\frac{e_{1T}}{e_{2T}\,e_{3T}}\delta_i \left[ \frac{e_{2u} e_{3u} }{e_{1u} } \delta_{i+1/2}[\tau] \right]$
-
-sol 1 coefficient at T-point ( add $e_{1u}$ and $e_{1T}$ on both side of first $\delta$):
-\begin{equation}
-  \label{eq:tra_adv_ubs2}
-  \begin{split}
-    F_u^{lT} &= - \frac{1}{12} \frac{e_{2u} e_{3u}}{e_{1u}}\;\delta_{i+1/2}\left[ \frac{e_{1T}^3\,|u|}{e_{1T}e_{2T}\,e_{3T}}\,\delta_i \left[ \frac{e_{2u} e_{3u} }{e_{1u} } \delta_{i+1/2}[\tau] \right] \right]
-  \end{split}
-\end{equation}
-which leads to ${A_T^{lT}}^2 = \frac{1}{12} {e_{1T}}^3\ \overline{|u|}^{\,i+1/2}$
-
-sol 2 coefficient at u-point: split $|u|$ into $\sqrt{|u|}$ and $e_{1T}$ into $\sqrt{e_{1u}}$
-\begin{equation}
-  \label{eq:tra_adv_ubs2}
-  \begin{split}
-    F_u^{lT} &= - \frac{1}{12} {e_{1u}}^1 \sqrt{e_{1u}|u|} \frac{e_{2u} e_{3u}}{e_{1u}}\;\delta_{i+1/2}\left[ \frac{1}{e_{2T}\,e_{3T}}\,\delta_i \left[ \sqrt{e_{1u}|u|} \frac{e_{2u} e_{3u} }{e_{1u} } \delta_{i+1/2}[\tau] \right] \right] \\
-    &= - \frac{1}{12} e_{1u} \sqrt{e_{1u}|u|\,} \frac{e_{2u} e_{3u}}{e_{1u}}\;\delta_{i+1/2}\left[ \frac{1}{e_{1T}\,e_{2T}\,e_{3T}}\,\delta_i \left[ e_{1u} \sqrt{e_{1u}|u|\,} \frac{e_{2u} e_{3u} }{e_{1u}} \delta_{i+1/2}[\tau] \right] \right]
-  \end{split}
-\end{equation}
-which leads to ${A_u^{lT}} = \frac{1}{12} {e_{1u}}^3\ |u|$
-
-% -------------------------------------------------------------------------------------------------------------
-%        Leap-Frog energetic  
-% -------------------------------------------------------------------------------------------------------------
-\section{Leapfrog energetic}
-\label{sec:LF}
-
-We adopt the following semi-discrete notation for time derivative.
-Given the values of a variable $q$ at successive time step,
-the time derivation and averaging operators at the mid time step are:
-\[
-  % \label{eq:dt_mt}
-  \begin{split}
-    \delta_{t+\rdt/2} [q]     &=  \  \ \,   q^{t+\rdt}  - q^{t}		\\
-    \overline q^{\,t+\rdt/2} &= \left\{ q^{t+\rdt} + q^{t} \right\} \; / \; 2
-  \end{split}
-\]
-As for space operator,
-the adjoint of the derivation and averaging time operators are $\delta_t^*=\delta_{t+\rdt/2}$ and
-$\overline{\cdot}^{\,t\,*}= \overline{\cdot}^{\,t+\Delta/2}$, respectively.
-
-The Leap-frog time stepping given by \autoref{eq:DOM_nxt} can be defined as:
-\[
-  % \label{eq:LF}
-  \frac{\partial q}{\partial t}
-  \equiv \frac{1}{\rdt} \overline{ \delta_{t+\rdt/2}[q]}^{\,t}
-  =         \frac{q^{t+\rdt}-q^{t-\rdt}}{2\rdt}
-\] 
-Note that \autoref{chap:LF} shows that the leapfrog time step is $\rdt$,
-not $2\rdt$ as it can be found sometimes in literature.
-The leap-Frog time stepping is a second order centered scheme.
-As such it respects the quadratic invariant in integral forms, \ie the following continuous property,
-\[
-  % \label{eq:Energy}
-  \int_{t_0}^{t_1} {q\, \frac{\partial q}{\partial t} \;dt}
-  =\int_{t_0}^{t_1} {\frac{1}{2}\, \frac{\partial q^2}{\partial t} \;dt}
-  =  \frac{1}{2} \left( {q_{t_1}}^2 - {q_{t_0}}^2 \right) ,
-\]
-is satisfied in discrete form.
-Indeed, 
-\[
-  \begin{split}
-    \int_{t_0}^{t_1} {q\, \frac{\partial q}{\partial t} \;dt}
-    &\equiv \sum\limits_{0}^{N}
-    {\frac{1}{\rdt} q^t \ \overline{ \delta_{t+\rdt/2}[q]}^{\,t} \ \rdt}
-    \equiv \sum\limits_{0}^{N}  { q^t \ \overline{ \delta_{t+\rdt/2}[q]}^{\,t} } \\
-    &\equiv \sum\limits_{0}^{N}  { \overline{q}^{\,t+\Delta/2}{ \delta_{t+\rdt/2}[q]}}
-    \equiv \sum\limits_{0}^{N}  { \frac{1}{2} \delta_{t+\rdt/2}[q^2] }\\
-    &\equiv \sum\limits_{0}^{N}  { \frac{1}{2} \delta_{t+\rdt/2}[q^2] }
-    \equiv \frac{1}{2} \left( {q_{t_1}}^2 - {q_{t_0}}^2 \right)
-  \end{split}
-\]
-NB here pb of boundary condition when applying the adjoint!
-In space, setting to 0 the quantity in land area is sufficient to get rid of the boundary condition 
-(equivalently of the boundary value of the integration by part).
-In time this boundary condition is not physical and \textbf{add something here!!!}
-
-% ================================================================
-% Iso-neutral diffusion : 
-% ================================================================
-
-\section{Lateral diffusion operator}
-
-% ================================================================
-% Griffies' iso-neutral diffusion operator : 
-% ================================================================
-\subsection{Griffies iso-neutral diffusion operator}
-
-Let try to define a scheme that get its inspiration from the \citet{griffies.gnanadesikan.ea_JPO98} scheme,
-but is formulated within the \NEMO framework
-(\ie using scale factors rather than grid-size and having a position of $T$-points that
-is not necessary in the middle of vertical velocity points, see \autoref{fig:zgr_e3}).
-
-In the formulation \autoref{eq:tra_ldf_iso} introduced in 1995 in OPA, the ancestor of \NEMO,
-the off-diagonal terms of the small angle diffusion tensor contain several double spatial averages of a gradient,
-for example $\overline{\overline{\delta_k \cdot}}^{\,i,k}$.
-It is apparent that the combination of a $k$ average and a $k$ derivative of the tracer allows for
-the presence of grid point oscillation structures that will be invisible to the operator.
-These structures are \textit{computational modes}.
-They will not be damped by the iso-neutral operator, and even possibly amplified by it.
-In other word, the operator applied to a tracer does not warranties the decrease of its global average variance.
-To circumvent this, we have introduced a smoothing of the slopes of the iso-neutral surfaces
-(see \autoref{chap:LDF}).
-Nevertheless, this technique works fine for $T$ and $S$ as they are active tracers
-(\ie they enter the computation of density), but it does not work for a passive tracer.
-\citep{griffies.gnanadesikan.ea_JPO98} introduce a different way to discretise the off-diagonal terms that
-nicely solve the problem.
-The idea is to get rid of combinations of an averaged in one direction combined with
-a derivative in the same direction by considering triads.
-For example in the (\textbf{i},\textbf{k}) plane, the four triads are defined at the $(i,k)$ $T$-point as follows:
-\begin{equation}
-  \label{eq:Gf_triads}
-  _i^k \mathbb{T}_{i_p}^{k_p} (T)
-  = \frac{1}{4} \ {b_u}_{\,i+i_p}^{\,k}  \  A_i^k  	\left(
-    \frac{ \delta_{i + i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
-    -\ {_i^k \mathbb{R}_{i_p}^{k_p}} \ \frac{ \delta_{k+k_p} [T^i] }{ {e_{3w}}_{\,i}^{\,k+k_p} }
-  \right)
-\end{equation}
-where the indices $i_p$ and $k_p$ define the four triads and take the following value:
-$i_p = -1/2$ or $1/2$ and $k_p = -1/2$ or $1/2$,
-$b_u= e_{1u}\,e_{2u}\,e_{3u}$ is the volume of $u$-cells,
-$A_i^k$ is the lateral eddy diffusivity coefficient defined at $T$-point,
-and $_i^k \mathbb{R}_{i_p}^{k_p}$ is the slope associated with each triad:
-\begin{equation}
-  \label{eq:Gf_slopes}
-  _i^k \mathbb{R}_{i_p}^{k_p}
-  =\frac{ {e_{3w}}_{\,i}^{\,k+k_p}} { {e_{1u}}_{\,i+i_p}^{\,k}} \ \frac
-  {\left(\alpha / \beta \right)_i^k  \ \delta_{i + i_p}[T^k] - \delta_{i + i_p}[S^k] }
-  {\left(\alpha / \beta \right)_i^k  \ \delta_{k+k_p}[T^i ] - \delta_{k+k_p}[S^i ] }
-\end{equation}
-Note that in \autoref{eq:Gf_slopes} we use the ratio $\alpha / \beta$ instead of
-multiplying the temperature derivative by $\alpha$ and the salinity derivative by $\beta$.
-This is more efficient as the ratio $\alpha / \beta$ can to be evaluated directly.
-
-Note that in \autoref{eq:Gf_triads}, we chose to use ${b_u}_{\,i+i_p}^{\,k}$ instead of ${b_{uw}}_{\,i+i_p}^{\,k+k_p}$.
-This choice has been motivated by the decrease of tracer variance and
-the presence of partial cell at the ocean bottom (see \autoref{apdx:Gf_operator}).
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!ht]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_ISO_triad}
-    \caption{
-      \protect\label{fig:ISO_triad}
-      Triads used in the Griffies's like iso-neutral diffision scheme for
-      $u$-component (upper panel) and $w$-component (lower panel).
-    }
-  \end{center}
-\end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-The four iso-neutral fluxes associated with the triads are defined at $T$-point. 
-They take the following expression:
-\begin{flalign*}
-  % \label{eq:Gf_fluxes}
-  \begin{split}
-    {_i^k {\mathbb{F}_u}_{i_p}^{k_p} } (T)
-    &= \ \; \qquad  \quad    { _i^k \mathbb{T}_{i_p}^{k_p} }(T) \;\ / \ { {e_{1u}}_{\,i+i_p}^{\,k}}    \\
-    {_i^k {\mathbb{F}_w}_{i_p}^{k_p} } (T)
-    &=  -\; { _i^k \mathbb{R}_{i_p}^{k_p} }
-    \ \; { _i^k \mathbb{T}_{i_p}^{k_p} }(T) \;\ / \ { {e_{3w}}_{\,i}^{\,k+k_p}}
-  \end{split}
-\end{flalign*}
-
-The resulting iso-neutral fluxes at $u$- and $w$-points are then given by
-the sum of the fluxes that cross the $u$- and $w$-face (\autoref{fig:ISO_triad}):
-\begin{flalign}
-  \label{eq:iso_flux}
-  \textbf{F}_{iso}(T)
-  &\equiv  \sum_{\substack{i_p,\,k_p}}
-  \begin{pmatrix}
-    {_{i+1/2-i_p}^k {\mathbb{F}_u}_{i_p}^{k_p} } (T) \\ \\
-    {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p} } (T)
-  \end{pmatrix}
-  \notag \\
-  &  \notag \\
-  &\equiv  \sum_{\substack{i_p,\,k_p}}
-  \begin{pmatrix}
-    && { _{i+1/2-i_p}^k \mathbb{T}_{i_p}^{k_p} }(T) \;\ / \ { {e_{1u}}_{\,i+1/2}^{\,k} } \\ \\
-    & -\; { _i^{k+1/2-k_p} \mathbb{R}_{i_p}^{k_p} }
-    & {_i^{k+1/2-k_p} \mathbb{T}_{i_p}^{k_p} }(T) \;\ / \ { {e_{3w}}_{\,i}^{\,k+1/2} }
-  \end{pmatrix}      % \\
-  % &\\
-  % &\equiv  \sum_{\substack{i_p,\,k_p}}
-  % \begin{pmatrix}
-  %   \qquad  \qquad  \qquad
-  %   \frac{1}{ {e_{1u}}_{\,i+1/2}^{\,k} }  \ \;
-  %   { _{i+1/2-i_p}^k \mathbb{T}_{i_p}^{k_p} }(T)\\
-  %   \\
-  %   -\frac{1}{ {e_{3w}}_{\,i}^{\,k+1/2} }  \ \;
-  %   { _i^{k+1/2-k_p} \mathbb{R}_{i_p}^{k_p} } \ \;
-  %   {_i^{k+1/2-k_p} \mathbb{T}_{i_p}^{k_p} }(T)\\
-  % \end{pmatrix}
-\end{flalign}
-resulting in a iso-neutral diffusion tendency on temperature given by
-the divergence of the sum of all the four triad fluxes:
-\begin{equation}
-  \label{eq:Gf_operator}
-  D_l^T = \frac{1}{b_T}  \sum_{\substack{i_p,\,k_p}} \left\{
-    \delta_{i} \left[{_{i+1/2-i_p}^k {\mathbb{F}_u }_{i_p}^{k_p}} \right]
-    + \delta_{k} \left[ {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}} \right]   \right\}
-\end{equation}
-where $b_T= e_{1T}\,e_{2T}\,e_{3T}$ is the volume of $T$-cells. 
-
-This expression of the iso-neutral diffusion has been chosen in order to satisfy the following six properties:
-\begin{description}
-\item[$\bullet$ horizontal diffusion]
-  The discretization of the diffusion operator recovers the traditional five-point Laplacian in
-  the limit of flat iso-neutral direction:
-  \[
-    % \label{eq:Gf_property1a}
-    D_l^T = \frac{1}{b_T}  \ \delta_{i}
-    \left[ \frac{e_{2u}\,e_{3u}}{e_{1u}} \; \overline{A}^{\,i} \; \delta_{i+1/2}[T] \right]
-    \qquad  \text{when} \quad
-    { _i^k \mathbb{R}_{i_p}^{k_p} }=0
-  \]
-
-\item[$\bullet$ implicit treatment in the vertical]
-  In the diagonal term associated with the vertical divergence of the iso-neutral fluxes
-  \ie the term associated with a second order vertical derivative)
-  appears only tracer values associated with a single water column.
-  This is of paramount importance since it means that
-  the implicit in time algorithm for solving the vertical diffusion equation can be used to evaluate this term.
-  It is a necessity since the vertical eddy diffusivity associated with this term,
-  \[
-	 \sum_{\substack{i_p, \,k_p}} \left\{
-		A_i^k \; \left(_i^k \mathbb{R}_{i_p}^{k_p}\right)^2
-    \right\}
-  \]
-  can be quite large.
-
-\item[$\bullet$ pure iso-neutral operator]
-  The iso-neutral flux of locally referenced potential density is zero, \ie
-  \begin{align*}
-    % \label{eq:Gf_property2}
-    \begin{matrix}
-      &{_i^k {\mathbb{F}_u}_{i_p}^{k_p} (\rho)}
-      &=    &\alpha_i^k   &{_i^k {\mathbb{F}_u}_{i_p}^{k_p} } (T)
-      &- \ \;  \beta _i^k    &{_i^k {\mathbb{F}_u}_{i_p}^{k_p} } (S) & = \ 0   \\
-      &{_i^k {\mathbb{F}_w}_{i_p}^{k_p} (\rho)}
-      &=    &\alpha_i^k   &{_i^k {\mathbb{F}_w}_{i_p}^{k_p} } (T)
-      &- \  \; \beta _i^k    &{_i^k {\mathbb{F}_w}_{i_p}^{k_p} } (S)  &= \ 0
-    \end{matrix}
-  \end{align*}
-  This result is trivially obtained using the \autoref{eq:Gf_triads} applied to $T$ and $S$ and
-  the definition of the triads' slopes \autoref{eq:Gf_slopes}.
-
-\item[$\bullet$ conservation of tracer]
-  The iso-neutral diffusion term conserve the total tracer content, \ie
-  \[
-    % \label{eq:Gf_property1}
-    \sum_{i,j,k} \left\{ D_l^T \ b_T \right\} = 0
-  \]
-This property is trivially satisfied since the iso-neutral diffusive operator is written in flux form.
-
-\item[$\bullet$ decrease of tracer variance]
-  The iso-neutral diffusion term does not increase the total tracer variance, \ie
-  \[
-    % \label{eq:Gf_property1}
-    \sum_{i,j,k} \left\{ T \ D_l^T \ b_T \right\} \leq 0
-  \]
-The property is demonstrated in the \autoref{apdx:Gf_operator}.
-It is a key property for a diffusion term.
-It means that the operator is also a dissipation term,
-\ie it is a sink term for the square of the quantity on which it is applied.
-It therfore ensures that, when the diffusivity coefficient is large enough,
-the field on which it is applied become free of grid-point noise.
-
-\item[$\bullet$ self-adjoint operator]
-  The iso-neutral diffusion operator is self-adjoint, \ie
-  \[
-    % \label{eq:Gf_property1}
-    \sum_{i,j,k} \left\{ S \ D_l^T \ b_T \right\} = \sum_{i,j,k} \left\{ D_l^S \ T \ b_T \right\}
-  \]
-In other word, there is no needs to develop a specific routine from the adjoint of this operator.
-We just have to apply the same routine.
-This properties can be demonstrated quite easily in a similar way the "non increase of tracer variance" property
-has been proved (see \autoref{apdx:Gf_operator}).
-\end{description}
-
-% ================================================================
-% Skew flux formulation for Eddy Induced Velocity : 
-% ================================================================
-\subsection{Eddy induced velocity and skew flux formulation}
-
-When Gent and McWilliams [1990] diffusion is used (\key{traldf\_eiv} defined),
-an additional advection term is added.
-The associated velocity is the so called eddy induced velocity,
-the formulation of which depends on the slopes of iso-neutral surfaces.
-Contrary to the case of iso-neutral mixing, the slopes used here are referenced to the geopotential surfaces,
-\ie \autoref{eq:ldfslp_geo} is used in $z$-coordinate,
-and the sum \autoref{eq:ldfslp_geo} + \autoref{eq:ldfslp_iso} in $z^*$ or $s$-coordinates. 
-
-The eddy induced velocity is given by: 
-\begin{equation}
-  \label{eq:eiv_v}
-  \begin{split}
-    u^* & = - \frac{1}{e_2\,e_{3}}          \;\partial_k \left( e_2 \, A_e \; r_i  \right)
-    = - \frac{1}{e_3}                     \;\partial_k \left(           A_e \; r_i  \right)            \\
-    v^* & = - \frac{1}{e_1\,e_3}\;             \partial_k \left( e_1 \, A_e \; r_j  \right)
-    = - \frac{1}{e_3}                     \;\partial_k \left(           A_e \; r_j  \right)             \\
-    w^* & =    \frac{1}{e_1\,e_2}\; \left\{   \partial_i  \left( e_2 \, A_e \; r_i  \right)
-      + \partial_j  \left( e_1 \, A_e \;r_j   \right) \right\}
-  \end{split}
-\end{equation}
-where $A_{e}$ is the eddy induced velocity coefficient,
-and $r_i$ and $r_j$ the slopes between the iso-neutral and the geopotential surfaces.
-%%gm wrong: to be modified with 2 2D streamfunctions
-In other words, the eddy induced velocity can be derived from a vector streamfuntion, $\phi$,
-which is given by $\phi = A_e\,\textbf{r}$ as $\textbf{U}^*  = \textbf{k} \times \nabla \phi$.
-%%end gm
-
-A traditional way to implement this additional advection is to add it to the eulerian velocity prior to
-compute the tracer advection.
-This allows us to take advantage of all the advection schemes offered for the tracers
-(see \autoref{sec:TRA_adv}) and not just a $2^{nd}$ order advection scheme.
-This is particularly useful for passive tracers where
-\emph{positivity} of the advection scheme is of paramount importance. 
-% give here the expression using the triads. It is different from the one given in \autoref{eq:ldfeiv}
-% see just below a copy of this equation:
-%\begin{equation} \label{eq:ldfeiv}
-%\begin{split}
-% u^* & = \frac{1}{e_{2u}e_{3u}}\; \delta_k \left[e_{2u} \, A_{uw}^{eiv} \; \overline{r_{1w}}^{\,i+1/2} \right]\\
-% v^* & = \frac{1}{e_{1u}e_{3v}}\; \delta_k \left[e_{1v} \, A_{vw}^{eiv} \; \overline{r_{2w}}^{\,j+1/2} \right]\\
-%w^* & = \frac{1}{e_{1w}e_{2w}}\; \left\{ \delta_i \left[e_{2u} \, A_{uw}^{eiv} \; \overline{r_{1w}}^{\,i+1/2} \right] + %\delta_j \left[e_{1v} \, A_{vw}^{eiv} \; \overline{r_{2w}}^{\,j+1/2} \right] \right\} \\
-%\end{split}
-%\end{equation}
-\[
-  % \label{eq:eiv_vd}
-  \textbf{F}_{eiv}^T   \equiv   \left(
-    \begin{aligned}
-      \sum_{\substack{i_p,\,k_p}} &
-      +{e_{2u}}_{i+1/2-i_p}^{k}                                  \ \ {A_{e}}_{i+1/2-i_p}^{k}
-      \ \ \ { _{i+1/2-i_p}^k \mathbb{R}_{i_p}^{k_p} }    \ \ \delta_{k+k_p}[T_{i+1/2-i_p}] \\ \\
-      \sum_{\substack{i_p,\,k_p}} &
-      - {e_{2u}}_i^{k+1/2-k_p}                                      \ {A_{e}}_i^{k+1/2-k_p}
-      \ \ { _i^{k+1/2-k_p} \mathbb{R}_{i_p}^{k_p} }    \ \delta_{i+i_p}[T^{k+1/2-k_p}]
-    \end{aligned}
-  \right)
-\]
-
-\citep{griffies_JPO98} introduces another way to implement the eddy induced advection, the so-called skew form.
-It is based on a transformation of the advective fluxes using the non-divergent nature of the eddy induced velocity.
-For example in the (\textbf{i},\textbf{k}) plane, the tracer advective fluxes can be transformed as follows:
-\begin{flalign*}
-  \begin{split}
-    \textbf{F}_{eiv}^T =
-    \begin{pmatrix}
-      {e_{2}\,e_{3}\;  u^*} 	 	\\
- 		{e_{1}\,e_{2}\; w^*}
-    \end{pmatrix}
-    \;   T
-    &=
-    \begin{pmatrix}
-      { - \partial_k \left( e_{2} \, A_{e} \; r_i \right) \; T \;} 	 	\\
- 		{+ \partial_i  \left( e_{2} \, A_{e} \; r_i \right) \; T \;}
-    \end{pmatrix}
-    \\
-    &=
-    \begin{pmatrix}
-      { - \partial_k \left( e_{2} \, A_{e} \; r_i  \; T \right) \;}  \\
- 		{+ \partial_i  \left( e_{2} \, A_{e} \; r_i  \; T \right) \;}
-    \end{pmatrix}
-    +
-    \begin{pmatrix}
-      {+ e_{2} \, A_{e} \; r_i  \; \partial_k T}  \\
- 		{ - e_{2} \, A_{e} \; r_i  \; \partial_i  T}
-    \end{pmatrix}
-  \end{split}
-\end{flalign*}
-and since the eddy induces velocity field is no-divergent,
-we end up with the skew form of the eddy induced advective fluxes:
-\begin{equation}
-  \label{eq:eiv_skew_continuous}
-  \textbf{F}_{eiv}^T =
-  \begin{pmatrix}
-    {+ e_{2} \, A_{e} \; r_i  \; \partial_k T}   \\
-    { - e_{2} \, A_{e} \; r_i  \; \partial_i  T}
-  \end{pmatrix}
-\end{equation}
-The tendency associated with eddy induced velocity is then simply the divergence of
-the \autoref{eq:eiv_skew_continuous} fluxes.
-It naturally conserves the tracer content, as it is expressed in flux form and,
-as the advective form, it preserves the tracer variance.
-Another interesting property of \autoref{eq:eiv_skew_continuous} form is that when $A=A_e$,
-a simplification occurs in the sum of the iso-neutral diffusion and eddy induced velocity terms:
-\begin{flalign*}
-  % \label{eq:eiv_skew+eiv_continuous}
-  \textbf{F}_{iso}^T + \textbf{F}_{eiv}^T &=
-  \begin{pmatrix}
-    + \frac{e_2\,e_3\,}{e_1} A \;\partial_i T -  e_2 \, A \; r_i                              \;\partial_k T   \\
-    -  e_2 \, A_{e} \; r_i           \;\partial_i T + \frac{e_1\,e_2}{e_3} \, A \; r_i^2 \;\partial_k T
-  \end{pmatrix}
-  +
-  \begin{pmatrix}
-    {+ e_{2} \, A_{e} \; r_i  \; \partial_k T}   \\
-    { - e_{2} \, A_{e} \; r_i  \; \partial_i  T}
-  \end{pmatrix}
-  \\
-  &=
-  \begin{pmatrix}
-    + \frac{e_2\,e_3\,}{e_1} A \;\partial_i T    \\
-    -  2\; e_2 \, A_{e} \; r_i      \;\partial_i T + \frac{e_1\,e_2}{e_3} \, A \; r_i^2 \;\partial_k T
-  \end{pmatrix}
-\end{flalign*}
-The horizontal component reduces to the one use for an horizontal laplacian operator and
-the vertical one keeps the same complexity, but not more.
-This property has been used to reduce the computational time \citep{griffies_JPO98},
-but it is not of practical use as usually $A \neq A_e$.
-Nevertheless this property can be used to choose a discret form of \autoref{eq:eiv_skew_continuous} which
-is consistent with the iso-neutral operator \autoref{eq:Gf_operator}.
-Using the slopes \autoref{eq:Gf_slopes} and defining $A_e$ at $T$-point(\ie as $A$,
-the eddy diffusivity coefficient), the resulting discret form is given by:
-\begin{equation}
-  \label{eq:eiv_skew}
-  \textbf{F}_{eiv}^T   \equiv   \frac{1}{4} \left(
-    \begin{aligned}
-      \sum_{\substack{i_p,\,k_p}} &
-      +{e_{2u}}_{i+1/2-i_p}^{k}                                  \ \ {A_{e}}_{i+1/2-i_p}^{k}
-      \ \ \ { _{i+1/2-i_p}^k \mathbb{R}_{i_p}^{k_p} }    \ \ \delta_{k+k_p}[T_{i+1/2-i_p}] \\ \\
-      \sum_{\substack{i_p,\,k_p}} &
-      - {e_{2u}}_i^{k+1/2-k_p}                                      \ {A_{e}}_i^{k+1/2-k_p}
-      \ \ { _i^{k+1/2-k_p} \mathbb{R}_{i_p}^{k_p} }    \ \delta_{i+i_p}[T^{k+1/2-k_p}]
-    \end{aligned}
-  \right)
-\end{equation}
-Note that \autoref{eq:eiv_skew} is valid in $z$-coordinate with or without partial cells. 
-In $z^*$ or $s$-coordinate, the slope between the level and the geopotential surfaces must be added to
-$\mathbb{R}$ for the discret form to be exact. 
-
-Such a choice of discretisation is consistent with the iso-neutral operator as
-it uses the same definition for the slopes.
-It also ensures the conservation of the tracer variance (see Appendix \autoref{apdx:eiv_skew}),
-\ie it does not include a diffusive component but is a "pure" advection term.
-
-$\ $\newpage      %force an empty line
-% ================================================================
-% Discrete Invariants of the iso-neutral diffrusion 
-% ================================================================
-\subsection{Discrete invariants of the iso-neutral diffrusion}
-\label{subsec:Gf_operator}
-
-Demonstration of the decrease of the tracer variance in the (\textbf{i},\textbf{j}) plane. 
-
-This part will be moved in an Appendix.
-
-The continuous property to be demonstrated is:
-\[
-  \int_D  D_l^T \; T \;dv   \leq 0
-\]
-The discrete form of its left hand side is obtained using \autoref{eq:iso_flux}
-
-\begin{align*}
-  &\int_D  D_l^T \; T \;dv \equiv  \sum_{i,k} \left\{ T \ D_l^T \ b_T \right\}    \\
-  &\equiv + \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
-    \delta_{i} \left[{_{i+1/2-i_p}^k {\mathbb{F}_u }_{i_p}^{k_p}} \right]
-    + \delta_{k} \left[ {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}} \right]  \ T \right\}    \\
-  &\equiv  - \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
-    {_{i+1/2-i_p}^k {\mathbb{F}_u }_{i_p}^{k_p}} \ \delta_{i+1/2} [T]
-    + {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}}  \ \delta_{k+1/2} [T]   \right\}      \\
-  &\equiv -\sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
-    \frac{ _{i+1/2-i_p}^k \mathbb{T}_{i_p}^{k_p} (T) }{ {e_{1u}}_{\,i+1/2}^{\,k} }  \ \delta_{i+1/2} [T]
-    - { _i^{k+1/2-k_p} \mathbb{R}_{i_p}^{k_p} } \ \;
-    \frac{ _i^{k+1/2-k_p} \mathbb{T}_{i_p}^{k_p} (T) }{ {e_{3w}}_{\,i}^{\,k+1/2}  } \ \delta_{k+1/2} [T]
-    \right\}      \\
-    %
-  \allowdisplaybreaks
-  \intertext{ Expending the summation on $i_p$ and $k_p$, it becomes:}
-  %
-  &\equiv -\sum_{i,k}
-    \begin{Bmatrix}
-      &\ \ \Bigl(  { _{i+1}^{k} \mathbb{T}_{-1/2}^{-1/2} (T) }
-      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
-      & -\ \ {_{i}^{k+1} \mathbb{R}_{-1/2}^{-1/2}}
-      &      {_{i}^{k+1} \mathbb{T}_{-1/2}^{-1/2} (T) }
-      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)
-      & \\
-      &+\Bigl( \ \;\; { _i^k \mathbb{T}_{+1/2}^{-1/2} (T) }
-      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
-      & -\ \ {_i^{k+1} \mathbb{R}_{+1/2}^{-1/2}}
-      & { _i^{k+1} \mathbb{T}_{+1/2}^{-1/2} (T) }
-      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}      \Bigr)
-      & \\
-      &+\Bigl(  { _{i+1}^{k} \mathbb{T}_{-1/2}^{+1/2} (T) }
-      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
-      & -\ \ \ \;\;{_{i}^{k} \mathbb{R}_{-1/2}^{+1/2}}
-      &      \ \;\;{_{i}^{k} \mathbb{T}_{-1/2}^{+1/2} (T) }
-      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)
-      & \\
-      &+\Bigl( \ \;\; { _{i}^{k} \mathbb{T}_{+1/2}^{+1/2} (T) }
-      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
-      & -\ \ \ \;\;{_{i}^{k} \mathbb{R}_{+1/2}^{+1/2}}
-      &      \ \;\;{_{i}^{k} \mathbb{T}_{+1/2}^{+1/2} (T) }
-      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)   \\
-    \end{Bmatrix}
-    %
-  \allowdisplaybreaks
-  \intertext{
-  The summation is done over all $i$ and $k$ indices,
-  it is therefore possible to introduce a shift of $-1$ either in $i$ or $k$ direction in order to
-  regroup all the terms of the summation by triad at a ($i$,$k$) point.
-  In other words, we regroup all the terms in the neighbourhood that contain a triad at the same ($i$,$k$) indices.
-  It becomes:
-  }
-  %
-  &\equiv -\sum_{i,k}
-    \begin{Bmatrix}
-      &\ \ \Bigl(  {_i^k \mathbb{T}_{-1/2}^{-1/2} (T) }
-      &\frac{ \delta_{i -1/2} [T] }{{e_{1u} }_{\,i-1/2}^{\,k}}
-      & -\ \ {_i^k \mathbb{R}_{-1/2}^{-1/2}}
-      &      {_i^k \mathbb{T}_{-1/2}^{-1/2} (T) }
-      &\frac{ \delta_{k-1/2} [T] }{{e_{3w}}_{\,i}^{\,k-1/2}}     \Bigr)
-      & \\
-      &+\Bigl(  { _i^k \mathbb{T}_{+1/2}^{-1/2} (T) }
-      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
-      & -\ \ {_i^k \mathbb{R}_{+1/2}^{-1/2}}
-      &      { _i^k \mathbb{T}_{+1/2}^{-1/2} (T) }
-      &\frac{ \delta_{k-1/2} [T] }{{e_{3w}}_{\,i}^{\,k-1/2}}      \Bigr)
-      & \\
-      &+\Bigl(  {_i^k \mathbb{T}_{-1/2}^{+1/2} (T) }
-      &\frac{ \delta_{i -1/2} [T] }{{e_{1u} }_{\,i-1/2}^{\,k}}
-      & -\ \ {_i^k \mathbb{R}_{-1/2}^{+1/2}}
-      &      {_i^k \mathbb{T}_{-1/2}^{+1/2} (T) }
-      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)
-      & \\
-      &+\Bigl( { _i^k \mathbb{T}_{+1/2}^{+1/2} (T) }
-      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
-      & -\ \ {_i^k \mathbb{R}_{+1/2}^{+1/2}}
-      &      {_i^k \mathbb{T}_{+1/2}^{+1/2} (T) }
-      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)   \\
-    \end{Bmatrix}   \\
-    %
-  \allowdisplaybreaks
-  \intertext{
-  Then outing in factor the triad in each of the four terms of the summation and
-  substituting the triads by their expression given in \autoref{eq:Gf_triads}.
-  It becomes:
-  }
-  %
-  &\equiv -\sum_{i,k}
-    \begin{Bmatrix}
-      &\ \ \Bigl(  \frac{ \delta_{i -1/2} [T] }{{e_{1u} }_{\,i-1/2}^{\,k}}
-      & -\ \ {_i^k \mathbb{R}_{-1/2}^{-1/2}}
-      &\frac{ \delta_{k-1/2} [T] }{{e_{3w}}_{\,i}^{\,k-1/2}}     \Bigr)^2
-      & \frac{1}{4} \ {b_u}_{\,i-1/2}^{\,k}  \  A_i^k
-      & \\
-      &+\Bigl(  \frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
-      & -\ \ {_i^k \mathbb{R}_{+1/2}^{-1/2}}
-      &\frac{ \delta_{k-1/2} [T] }{{e_{3w}}_{\,i}^{\,k-1/2}}      \Bigr)^2
-      & \frac{1}{4} \ {b_u}_{\,i+1/2}^{\,k}  \  A_i^k
-      & \\
-      &+\Bigl(  \frac{ \delta_{i -1/2} [T] }{{e_{1u} }_{\,i-1/2}^{\,k}}
-      & -\ \ {_i^k \mathbb{R}_{-1/2}^{+1/2}}
-      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)^2
-      & \frac{1}{4} \ {b_u}_{\,i-1/2}^{\,k}  \  A_i^k
-      & \\
-      &+\Bigl( \frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
-      & -\ \ {_i^k \mathbb{R}_{+1/2}^{+1/2}}
-      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)^2
-      & \frac{1}{4} \ {b_u}_{\,i+1/2}^{\,k}  \  A_i^k      \\
-    \end{Bmatrix}
-  \\
-  & \\
-  %
-  &\equiv - \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
-    \begin{matrix}
-      &\Bigl( \frac{ \delta_{i +i_p} [T] }{{e_{1u} }_{\,i+i_p}^{\,k}}
-      & -\ \ {_i^k \mathbb{R}_{i_p}^{k_p}}
-      &\frac{ \delta_{k+k_p} [T] }{{e_{3w}}_{\,i}^{\,k+k_p}}     \Bigr)^2
-      & \frac{1}{4} \ {b_u}_{\,i+i_p}^{\,k}  \  A_i^k   \ \
-    \end{matrix}
-        \right\}
-        \quad   \leq 0
-\end{align*} 
-The last inequality is obviously obtained as we succeed in obtaining a negative summation of square quantities.
-
-Note that, if instead of multiplying $D_l^T$ by $T$, we were using another tracer field, let say $S$,
-then the previous demonstration would have let to:
-\begin{align*}
-  \int_D  S \; D_l^T  \;dv &\equiv  \sum_{i,k} \left\{ S \ D_l^T \ b_T \right\}    \\
-                           &\equiv - \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
-                             \left( \frac{ \delta_{i +i_p} [S] }{{e_{1u} }_{\,i+i_p}^{\,k}}
-                             - {_i^k \mathbb{R}_{i_p}^{k_p}}
-                             \frac{ \delta_{k+k_p} [S] }{{e_{3w}}_{\,i}^{\,k+k_p}}     \right)  \right. \\
-                           & \qquad \qquad \qquad \ \left.
-                             \left( \frac{ \delta_{i +i_p} [T] }{{e_{1u} }_{\,i+i_p}^{\,k}}
-                             - {_i^k \mathbb{R}_{i_p}^{k_p}}
-                             \frac{ \delta_{k+k_p} [T] }{{e_{3w}}_{\,i}^{\,k+k_p}}     \right)
-                             \frac{1}{4} \ {b_u}_{\,i+i_p}^{\,k}  \  A_i^k   \
-                             \right\}
-                             %
-                             \allowdisplaybreaks
-                             \intertext{
-                             which, by applying the same operation as before but in reverse order, leads to:
-                             }
-                             %
-                           &\equiv  \sum_{i,k} \left\{ D_l^S \ T \ b_T \right\}
-\end{align*} 
-This means that the iso-neutral operator is self-adjoint.
-There is no need to develop a specific to obtain it.
-
-\newpage
-
-% ================================================================
-% Discrete Invariants of the skew flux formulation
-% ================================================================
-\subsection{Discrete invariants of the skew flux formulation}
-\label{subsec:eiv_skew}
-
-Demonstration for the conservation of the tracer variance in the (\textbf{i},\textbf{j}) plane. 
-
-This have to be moved in an Appendix.
-
-The continuous property to be demonstrated is:
-\begin{align*}
-  \int_D \nabla \cdot \textbf{F}_{eiv}(T) \; T \;dv  \equiv 0
-\end{align*}
-The discrete form of its left hand side is obtained using \autoref{eq:eiv_skew}
-\begin{align*}
-  \sum\limits_{i,k} \sum_{\substack{i_p,\,k_p}}  \Biggl\{   \;\;
-  \delta_i  &\left[
-              {e_{2u}}_{i+i_p+1/2}^{k}                                  \;\ \ {A_{e}}_{i+i_p+1/2}^{k}
-              \ \ \ { _{i+i_p+1/2}^k \mathbb{R}_{-i_p}^{k_p} }   \quad \delta_{k+k_p}[T_{i+i_p+1/2}]
-              \right] \; T_i^k      \\
-  - \delta_k &\left[
-               {e_{2u}}_i^{k+k_p+1/2}                                     \ \ {A_{e}}_i^{k+k_p+1/2}
-               \ \ { _i^{k+k_p+1/2} \mathbb{R}_{i_p}^{-k_p} }   \ \ \delta_{i+i_p}[T^{k+k_p+1/2}]
-               \right] \; T_i^k      \         \Biggr\}
-\end{align*}
-apply the adjoint of delta operator, it becomes
-\begin{align*}
-  \sum\limits_{i,k} \sum_{\substack{i_p,\,k_p}}  \Biggl\{   \;\;
-  &\left(
-    {e_{2u}}_{i+i_p+1/2}^{k}                                  \;\ \ {A_{e}}_{i+i_p+1/2}^{k}
-    \ \ \ { _{i+i_p+1/2}^k \mathbb{R}_{-i_p}^{k_p} }   \quad \delta_{k+k_p}[T_{i+i_p+1/2}]
-    \right) \; \delta_{i+1/2}[T^{k}]      \\
-  - &\left(
-      {e_{2u}}_i^{k+k_p+1/2}                                     \ \ {A_{e}}_i^{k+k_p+1/2}
-      \ \ { _i^{k+k_p+1/2} \mathbb{R}_{i_p}^{-k_p} }   \ \ \delta_{i+i_p}[T^{k+k_p+1/2}]
-      \right) \; \delta_{k+1/2}[T_{i}]       \         \Biggr\}
-\end{align*}
-Expending the summation on $i_p$ and $k_p$, it becomes:
-\begin{align*}
-  \begin{matrix}
-    &\sum\limits_{i,k}   \Bigl\{
-    &+{e_{2u}}_{i+1}^{k}                             &{A_{e}}_{i+1    }^{k}
-    &\ {_{i+1}^k \mathbb{R}_{- 1/2}^{-1/2}} &\delta_{k-1/2}[T_{i+1}]    &\delta_{i+1/2}[T^{k}]   &\\
-    &&+{e_{2u}}_i^{k\ \ \ \:}                            &{A_{e}}_{i}^{k\ \ \ \:}
-    &\ {\ \ \;_i^k \mathbb{R}_{+1/2}^{-1/2}}  &\delta_{k-1/2}[T_{i\ \ \ \;}]  &\delta_{i+1/2}[T^{k}] &\\
-    &&+{e_{2u}}_{i+1}^{k}                             &{A_{e}}_{i+1    }^{k}
-    &\ {_{i+1}^k \mathbb{R}_{- 1/2}^{+1/2}} &\delta_{k+1/2}[T_{i+1}]     &\delta_{i+1/2}[T^{k}] &\\
-    &&+{e_{2u}}_i^{k\ \ \ \:}                            &{A_{e}}_{i}^{k\ \ \ \:}
-    &\ {\ \ \;_i^k \mathbb{R}_{+1/2}^{+1/2}} &\delta_{k+1/2}[T_{i\ \ \ \;}] &\delta_{i+1/2}[T^{k}] &\\
-    %
-    &&-{e_{2u}}_i^{k+1}                                &{A_{e}}_i^{k+1}
-    &{_i^{k+1} \mathbb{R}_{-1/2}^{- 1/2}}   &\delta_{i-1/2}[T^{k+1}]      &\delta_{k+1/2}[T_{i}] &\\
-    &&-{e_{2u}}_i^{k\ \ \ \:}                             &{A_{e}}_i^{k\ \ \ \:}
-    &{\ \ \;_i^k  \mathbb{R}_{-1/2}^{+1/2}}   &\delta_{i-1/2}[T^{k\ \ \ \:}]  &\delta_{k+1/2}[T_{i}] &\\
-    &&-{e_{2u}}_i^{k+1    }                             &{A_{e}}_i^{k+1}
-    &{_i^{k+1} \mathbb{R}_{+1/2}^{- 1/2}}   &\delta_{i+1/2}[T^{k+1}]      &\delta_{k+1/2}[T_{i}] &\\
-    &&-{e_{2u}}_i^{k\ \ \ \:}                             &{A_{e}}_i^{k\ \ \ \:}
-    &{\ \ \;_i^k  \mathbb{R}_{+1/2}^{+1/2}}   &\delta_{i+1/2}[T^{k\ \ \ \:}]  &\delta_{k+1/2}[T_{i}]
-    &\Bigr\}  \\
-  \end{matrix}   
-\end{align*}
-The two terms associated with the triad ${_i^k \mathbb{R}_{+1/2}^{+1/2}}$ are the same but of opposite signs,
-they cancel out. 
-Exactly the same thing occurs for the triad ${_i^k \mathbb{R}_{-1/2}^{-1/2}}$.
-The two terms associated with the triad ${_i^k \mathbb{R}_{+1/2}^{-1/2}}$ are the same but both of opposite signs and
-shifted by 1 in $k$ direction.
-When summing over $k$ they cancel out with the neighbouring grid points.
-Exactly the same thing occurs for the triad ${_i^k \mathbb{R}_{-1/2}^{+1/2}}$ in the $i$ direction.
-Therefore the sum over the domain is zero,
-\ie the variance of the tracer is preserved by the discretisation of the skew fluxes.
-
-\biblio
-
-\pindex
-
-\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/annex_iso.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/annex_iso.tex	(revision 12062)
+++ 	(revision )
@@ -1,1181 +1,0 @@
-\documentclass[../main/NEMO_manual]{subfiles}
-
-%% Local cmds
-\newcommand{\rML}[1][i]{\ensuremath{_{\mathrm{ML}\,#1}}}
-\newcommand{\rMLt}[1][i]{\tilde{r}_{\mathrm{ML}\,#1}}
-%% Move to ../../global/new_cmds.tex to avoid error with \listoffigures
-%\newcommand{\triad}[6][]{\ensuremath{{}_{#2}^{#3}{\mathbb{#4}_{#1}}_{#5}^{\,#6}}
-\newcommand{\triadd}[5]{\ensuremath{{}_{#1}^{#2}{\mathbb{#3}}_{#4}^{\,#5}}}
-\newcommand{\triadt}[5]{\ensuremath{{}_{#1}^{#2}{\tilde{\mathbb{#3}}}_{#4}^{\,#5}}}
-\newcommand{\rtriad}[2][]{\ensuremath{\triad[#1]{i}{k}{#2}{i_p}{k_p}}}
-\newcommand{\rtriadt}[1]{\ensuremath{\triadt{i}{k}{#1}{i_p}{k_p}}}
-
-\begin{document}
-% ================================================================
-% Iso-neutral diffusion :
-% ================================================================
-\chapter{Iso-Neutral Diffusion and Eddy Advection using Triads}
-\label{apdx:triad}
-
-\minitoc
-
-\newpage
-
-\section{Choice of \protect\ngn{namtra\_ldf} namelist parameters}
-%-----------------------------------------nam_traldf------------------------------------------------------
-
-\nlst{namtra_ldf}
-%---------------------------------------------------------------------------------------------------------
-
-Two scheme are available to perform the iso-neutral diffusion.
-If the namelist logical \np{ln\_traldf\_triad} is set true,
-\NEMO updates both active and passive tracers using the Griffies triad representation of iso-neutral diffusion and
-the eddy-induced advective skew (GM) fluxes.
-If the namelist logical \np{ln\_traldf\_iso} is set true,
-the filtered version of Cox's original scheme (the Standard scheme) is employed (\autoref{sec:LDF_slp}).
-In the present implementation of the Griffies scheme,
-the advective skew fluxes are implemented even if \np{ln\_traldf\_eiv} is false.
-
-Values of iso-neutral diffusivity and GM coefficient are set as described in \autoref{sec:LDF_coef}.
-Note that when GM fluxes are used, the eddy-advective (GM) velocities are output for diagnostic purposes using xIOS,
-even though the eddy advection is accomplished by means of the skew fluxes.
-
-The options specific to the Griffies scheme include:
-\begin{description}
-\item[\np{ln\_triad\_iso}]
-  See \autoref{sec:taper}.
-  If this is set false (the default),
-  then `iso-neutral' mixing is accomplished within the surface mixed-layer along slopes linearly decreasing with
-  depth from the value immediately below the mixed-layer to zero (flat) at the surface (\autoref{sec:lintaper}).
-  This is the same treatment as used in the default implementation
-  \autoref{subsec:LDF_slp_iso}; \autoref{fig:eiv_slp}.
-  Where \np{ln\_triad\_iso} is set true,
-  the vertical skew flux is further reduced to ensure no vertical buoyancy flux,
-  giving an almost pure horizontal diffusive tracer flux within the mixed layer.
-  This is similar to the tapering suggested by \citet{gerdes.koberle.ea_CD91}. See \autoref{subsec:Gerdes-taper}
-\item[\np{ln\_botmix\_triad}]
-  See \autoref{sec:iso_bdry}. 
-  If this is set false (the default) then the lateral diffusive fluxes
-  associated with triads partly masked by topography are neglected. 
-  If it is set true, however, then these lateral diffusive fluxes are applied, 
-  giving smoother bottom tracer fields at the cost of introducing diapycnal mixing.
-\item[\np{rn\_sw\_triad}]
-  blah blah to be added....
-\end{description}
-The options shared with the Standard scheme include:
-\begin{description}
-\item[\np{ln\_traldf\_msc}]   blah blah to be added
-\item[\np{rn\_slpmax}]  blah blah to be added
-\end{description}
-
-\section{Triad formulation of iso-neutral diffusion}
-\label{sec:iso}
-
-We have implemented into \NEMO a scheme inspired by \citet{griffies.gnanadesikan.ea_JPO98},
-but formulated within the \NEMO framework, using scale factors rather than grid-sizes.
-
-\subsection{Iso-neutral diffusion operator}
-
-The iso-neutral second order tracer diffusive operator for small angles between
-iso-neutral surfaces and geopotentials is given by \autoref{eq:iso_tensor_1}:
-\begin{subequations}
-  \label{eq:iso_tensor_1}
-  \begin{equation}
-    D^{lT}=-\nabla \cdot\vect{f}^{lT}\equiv
-    -\frac{1}{e_1e_2e_3}\left[\pd{i}\left (f_1^{lT}e_2e_3\right) +
-      \pd{j}\left (f_2^{lT}e_2e_3\right) + \pd{k}\left (f_3^{lT}e_1e_2\right)\right],
-  \end{equation}
-  where the diffusive flux per unit area of physical space
-  \begin{equation}
-    \vect{f}^{lT}=-{A^{lT}}\Re\cdot\nabla T,
-  \end{equation}
-  \begin{equation}
-    \label{eq:iso_tensor_2}
-    \mbox{with}\quad \;\;\Re =
-    \begin{pmatrix}
-      1   &  0   & -r_1           \rule[-.9 em]{0pt}{1.79 em} \\
-      0   &  1   & -r_2           \rule[-.9 em]{0pt}{1.79 em} \\
-      -r_1 & -r_2 &  r_1 ^2+r_2 ^2 \rule[-.9 em]{0pt}{1.79 em}
-    \end{pmatrix}
-    \quad \text{and} \quad\nabla T=
-    \begin{pmatrix}
-      \frac{1}{e_1} \pd[T]{i} \rule[-.9 em]{0pt}{1.79 em} \\
-      \frac{1}{e_2} \pd[T]{j} \rule[-.9 em]{0pt}{1.79 em} \\
-      \frac{1}{e_3} \pd[T]{k} \rule[-.9 em]{0pt}{1.79 em}
-    \end{pmatrix}
-    .
-  \end{equation}
-\end{subequations}
-% \left( {{\begin{array}{*{20}c}
-%  1 \hfill & 0 \hfill & {-r_1 } \hfill \\
-%  0 \hfill & 1 \hfill & {-r_2 } \hfill \\
-%  {-r_1 } \hfill & {-r_2 } \hfill & {r_1 ^2+r_2 ^2} \hfill \\
-% \end{array} }} \right)
-Here \autoref{eq:PE_iso_slopes} 
-\begin{align*}
-  r_1 &=-\frac{e_3 }{e_1 } \left( \frac{\partial \rho }{\partial i}
-        \right)
-        \left( {\frac{\partial \rho }{\partial k}} \right)^{-1} \\
-      &=-\frac{e_3 }{e_1 } \left( -\alpha\frac{\partial T }{\partial i} +
-        \beta\frac{\partial S }{\partial i} \right) \left(
-        -\alpha\frac{\partial T }{\partial k} + \beta\frac{\partial S
-        }{\partial k} \right)^{-1}
-\end{align*}
-is the $i$-component of the slope of the iso-neutral surface relative to the computational surface,
-and $r_2$ is the $j$-component.
-
-We will find it useful to consider the fluxes per unit area in $i,j,k$ space; we write
-\[
-  % \label{eq:Fijk}
-  \vect{F}_{\mathrm{iso}}=\left(f_1^{lT}e_2e_3, f_2^{lT}e_1e_3, f_3^{lT}e_1e_2\right).
-\]
-Additionally, we will sometimes write the contributions towards the fluxes $\vect{f}$ and
-$\vect{F}_{\mathrm{iso}}$ from the component $R_{ij}$ of $\Re$ as $f_{ij}$, $F_{\mathrm{iso}\: ij}$,
-with $f_{ij}=R_{ij}e_i^{-1}\partial T/\partial x_i$ (no summation) etc.
-
-The off-diagonal terms of the small angle diffusion tensor
-\autoref{eq:iso_tensor_1}, \autoref{eq:iso_tensor_2} produce skew-fluxes along
-the $i$- and $j$-directions resulting from the vertical tracer gradient:
-\begin{align}
-  \label{eq:i13c}
-  f_{13}=&+{A^{lT}} r_1\frac{1}{e_3}\frac{\partial T}{\partial k},\qquad f_{23}=+{A^{lT}} r_2\frac{1}{e_3}\frac{\partial T}{\partial k}\\
-  \intertext{and in the k-direction resulting from the lateral tracer gradients}
-  \label{eq:i31c}
-  f_{31}+f_{32}=& {A^{lT}} r_1\frac{1}{e_1}\frac{\partial T}{\partial i}+{A^{lT}} r_2\frac{1}{e_1}\frac{\partial T}{\partial i}
-\end{align}
-
-The vertical diffusive flux associated with the $_{33}$ component of the small angle diffusion tensor is
-\begin{equation}
-  \label{eq:i33c}
-  f_{33}=-{A^{lT}}(r_1^2 +r_2^2) \frac{1}{e_3}\frac{\partial T}{\partial k}.
-\end{equation}
-
-Since there are no cross terms involving $r_1$ and $r_2$ in the above,
-we can consider the iso-neutral diffusive fluxes separately in the $i$-$k$ and $j$-$k$ planes,
-just adding together the vertical components from each plane.
-The following description will describe the fluxes on the $i$-$k$ plane.
-
-There is no natural discretization for the $i$-component of the skew-flux, \autoref{eq:i13c},
-as although it must be evaluated at $u$-points,
-it involves vertical gradients (both for the tracer and the slope $r_1$), defined at $w$-points.
-Similarly, the vertical skew flux, \autoref{eq:i31c},
-is evaluated at $w$-points but involves horizontal gradients defined at $u$-points.
-
-\subsection{Standard discretization}
-
-The straightforward approach to discretize the lateral skew flux
-\autoref{eq:i13c} from tracer cell $i,k$ to $i+1,k$, introduced in 1995 into OPA,
-\autoref{eq:tra_ldf_iso}, is to calculate a mean vertical gradient at the $u$-point from
-the average of the four surrounding vertical tracer gradients, and multiply this by a mean slope at the $u$-point,
-calculated from the averaged surrounding vertical density gradients.
-The total area-integrated skew-flux (flux per unit area in $ijk$ space) from tracer cell $i,k$ to $i+1,k$,
-noting that the $e_{{3}_{i+1/2}^k}$ in the area $e{_{3}}_{i+1/2}^k{e_{2}}_{i+1/2}i^k$ at the $u$-point cancels out with
-the $1/{e_{3}}_{i+1/2}^k$ associated with the vertical tracer gradient, is then \autoref{eq:tra_ldf_iso}
-\[
-  \left(F_u^{13} \right)_{i+\frac{1}{2}}^k = {A}_{i+\frac{1}{2}}^k
-  {e_{2}}_{i+1/2}^k \overline{\overline
-    r_1} ^{\,i,k}\,\overline{\overline{\delta_k T}}^{\,i,k},
-\]
-where
-\[
-  \overline{\overline
-    r_1} ^{\,i,k} = -\frac{{e_{3u}}_{i+1/2}^k}{{e_{1u}}_{i+1/2}^k}
-  \frac{\delta_{i+1/2} [\rho]}{\overline{\overline{\delta_k \rho}}^{\,i,k}},
-\]
-and here and in the following we drop the $^{lT}$ superscript from ${A^{lT}}$ for simplicity.
-Unfortunately the resulting combination $\overline{\overline{\delta_k\bullet}}^{\,i,k}$ of a $k$ average and
-a $k$ difference of the tracer reduces to $\bullet_{k+1}-\bullet_{k-1}$,
-so two-grid-point oscillations are invisible to this discretization of the iso-neutral operator.
-These \emph{computational modes} will not be damped by this operator, and may even possibly be amplified by it.
-Consequently, applying this operator to a tracer does not guarantee the decrease of its global-average variance.
-To correct this, we introduced a smoothing of the slopes of the iso-neutral surfaces (see \autoref{chap:LDF}).
-This technique works for $T$ and $S$ in so far as they are active tracers
-(\ie they enter the computation of density), but it does not work for a passive tracer.
-
-\subsection{Expression of the skew-flux in terms of triad slopes}
-
-\citep{griffies.gnanadesikan.ea_JPO98} introduce a different discretization of the off-diagonal terms that
-nicely solves the problem.
-% Instead of multiplying the mean slope calculated at the $u$-point by
-% the mean vertical gradient at the $u$-point,
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[tb]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_GRIFF_triad_fluxes}
-    \caption{
-      \protect\label{fig:ISO_triad}
-      (a) Arrangement of triads $S_i$ and tracer gradients to
-      give lateral tracer flux from box $i,k$ to $i+1,k$
-      (b) Triads $S'_i$ and tracer gradients to give vertical tracer flux from
-      box $i,k$ to $i,k+1$.
-    }
-  \end{center}
-\end{figure}
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>
-They get the skew flux from the products of the vertical gradients at each $w$-point surrounding the $u$-point with
-the corresponding `triad' slope calculated from the lateral density gradient across the $u$-point divided by
-the vertical density gradient at the same $w$-point as the tracer gradient.
-See \autoref{fig:ISO_triad}a, where the thick lines denote the tracer gradients,
-and the thin lines the corresponding triads, with slopes $s_1, \dotsc s_4$.
-The total area-integrated skew-flux from tracer cell $i,k$ to $i+1,k$
-\begin{multline}
-  \label{eq:i13}
-  \left( F_u^{13}  \right)_{i+\frac{1}{2}}^k = {A}_{i+1}^k a_1 s_1
-  \delta_{k+\frac{1}{2}} \left[ T^{i+1}
-  \right]/e_{{3w}_{i+1}}^{k+\frac{1}{2}}  + {A} _i^k a_2 s_2 \delta
-  _{k+\frac{1}{2}} \left[ T^i
-  \right]/e_{{3w}_{i+1}}^{k+\frac{1}{2}} \\
-  +{A} _{i+1}^k a_3 s_3 \delta_{k-\frac{1}{2}} \left[ T^{i+1}
-  \right]/e_{{3w}_{i+1}}^{k+\frac{1}{2}}  +{A} _i^k a_4 s_4 \delta
-  _{k-\frac{1}{2}} \left[ T^i \right]/e_{{3w}_{i+1}}^{k+\frac{1}{2}},
-\end{multline}
-where the contributions of the triad fluxes are weighted by areas $a_1, \dotsc a_4$,
-and ${A}$ is now defined at the tracer points rather than the $u$-points.
-This discretization gives a much closer stencil, and disallows the two-point computational modes.
-
-The vertical skew flux \autoref{eq:i31c} from tracer cell $i,k$ to $i,k+1$ at
-the $w$-point $i,k+\frac{1}{2}$ is constructed similarly (\autoref{fig:ISO_triad}b) by
-multiplying lateral tracer gradients from each of the four surrounding $u$-points by the appropriate triad slope:
-\begin{multline}
-  \label{eq:i31}
-  \left( F_w^{31} \right) _i ^{k+\frac{1}{2}} =  {A}_i^{k+1} a_{1}'
-  s_{1}' \delta_{i-\frac{1}{2}} \left[ T^{k+1} \right]/{e_{3u}}_{i-\frac{1}{2}}^{k+1}
-  +{A}_i^{k+1} a_{2}' s_{2}' \delta_{i+\frac{1}{2}} \left[ T^{k+1} \right]/{e_{3u}}_{i+\frac{1}{2}}^{k+1} \\
-  + {A}_i^k a_{3}' s_{3}' \delta_{i-\frac{1}{2}} \left[ T^k\right]/{e_{3u}}_{i-\frac{1}{2}}^k
-  +{A}_i^k a_{4}' s_{4}' \delta_{i+\frac{1}{2}} \left[ T^k \right]/{e_{3u}}_{i+\frac{1}{2}}^k.
-\end{multline}
-
-We notate the triad slopes $s_i$ and $s'_i$ in terms of the `anchor point' $i,k$
-(appearing in both the vertical and lateral gradient),
-and the $u$- and $w$-points $(i+i_p,k)$, $(i,k+k_p)$ at the centres of the `arms' of the triad as follows
-(see also \autoref{fig:ISO_triad}):
-\begin{equation}
-  \label{eq:R}
-  _i^k \mathbb{R}_{i_p}^{k_p}
-  =-\frac{ {e_{3w}}_{\,i}^{\,k+k_p}} { {e_{1u}}_{\,i+i_p}^{\,k}}
-  \
-  \frac
-  { \alpha_i^k  \ \delta_{i+i_p}[T^k] - \beta_i^k \ \delta_{i+i_p}[S^k] }
-  { \alpha_i^k  \ \delta_{k+k_p}[T^i] - \beta_i^k \ \delta_{k+k_p}[S^i] }.
-\end{equation}
-In calculating the slopes of the local neutral surfaces,
-the expansion coefficients $\alpha$ and $\beta$ are evaluated at the anchor points of the triad,
-while the metrics are calculated at the $u$- and $w$-points on the arms.
-
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[tb]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_GRIFF_qcells}
-    \caption{
-      \protect\label{fig:qcells}
-      Triad notation for quarter cells. $T$-cells are inside boxes,
-      while the  $i+\fractext{1}{2},k$ $u$-cell is shaded in green and
-      the $i,k+\fractext{1}{2}$ $w$-cell is shaded in pink.
-    }
-  \end{center}
-\end{figure}
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-Each triad $\{_i^{k}\:_{i_p}^{k_p}\}$ is associated (\autoref{fig:qcells}) with the quarter cell that is
-the intersection of the $i,k$ $T$-cell, the $i+i_p,k$ $u$-cell and the $i,k+k_p$ $w$-cell.
-Expressing the slopes $s_i$ and $s'_i$ in \autoref{eq:i13} and \autoref{eq:i31} in this notation,
-we have \eg \ $s_1=s'_1={\:}_i^k \mathbb{R}_{1/2}^{1/2}$.
-Each triad slope $_i^k\mathbb{R}_{i_p}^{k_p}$ is used once (as an $s$) to
-calculate the lateral flux along its $u$-arm, at $(i+i_p,k)$,
-and then again as an $s'$ to calculate the vertical flux along its $w$-arm at $(i,k+k_p)$.
-Each vertical area $a_i$ used to calculate the lateral flux and horizontal area $a'_i$ used to
-calculate the vertical flux can also be identified as the area across the $u$- and $w$-arms of a unique triad,
-and we notate these areas, similarly to the triad slopes,
-as $_i^k{\mathbb{A}_u}_{i_p}^{k_p}$, $_i^k{\mathbb{A}_w}_{i_p}^{k_p}$,
-where \eg in \autoref{eq:i13} $a_{1}={\:}_i^k{\mathbb{A}_u}_{1/2}^{1/2}$,
-and in \autoref{eq:i31} $a'_{1}={\:}_i^k{\mathbb{A}_w}_{1/2}^{1/2}$.
-
-\subsection{Full triad fluxes}
-
-A key property of iso-neutral diffusion is that it should not affect the (locally referenced) density.
-In particular there should be no lateral or vertical density flux.
-The lateral density flux disappears so long as the area-integrated lateral diffusive flux from
-tracer cell $i,k$ to $i+1,k$ coming from the $_{11}$ term of the diffusion tensor takes the form
-\begin{equation}
-  \label{eq:i11}
-  \left( F_u^{11} \right) _{i+\frac{1}{2}} ^{k} =
-  - \left( {A}_i^{k+1} a_{1} + {A}_i^{k+1} a_{2} + {A}_i^k
-    a_{3} + {A}_i^k a_{4} \right)
-  \frac{\delta_{i+1/2} \left[ T^k\right]}{{e_{1u}}_{\,i+1/2}^{\,k}},
-\end{equation}
-where the areas $a_i$ are as in \autoref{eq:i13}.
-In this case, separating the total lateral flux, the sum of \autoref{eq:i13} and \autoref{eq:i11},
-into triad components, a lateral tracer flux
-\begin{equation}
-  \label{eq:latflux-triad}
-  _i^k {\mathbb{F}_u}_{i_p}^{k_p} (T) = - {A}_i^k{ \:}_i^k{\mathbb{A}_u}_{i_p}^{k_p}
-  \left(
-    \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
-    -\ {_i^k\mathbb{R}_{i_p}^{k_p}} \
-    \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
-  \right)
-\end{equation}
-can be identified with each triad.
-Then, because the same metric factors ${e_{3w}}_{\,i}^{\,k+k_p}$ and ${e_{1u}}_{\,i+i_p}^{\,k}$ are employed for both
-the density gradients in $ _i^k \mathbb{R}_{i_p}^{k_p}$ and the tracer gradients,
-the lateral density flux associated with each triad separately disappears.
-\begin{equation}
-  \label{eq:latflux-rho}
-  {\mathbb{F}_u}_{i_p}^{k_p} (\rho)=-\alpha _i^k {\:}_i^k {\mathbb{F}_u}_{i_p}^{k_p} (T) + \beta_i^k {\:}_i^k {\mathbb{F}_u}_{i_p}^{k_p} (S)=0
-\end{equation}
-Thus the total flux $\left( F_u^{31} \right) ^i _{i,k+\frac{1}{2}} + \left( F_u^{11} \right) ^i _{i,k+\frac{1}{2}}$ from
-tracer cell $i,k$ to $i+1,k$ must also vanish since it is a sum of four such triad fluxes.
-
-The squared slope $r_1^2$ in the expression \autoref{eq:i33c} for the $_{33}$ component is also expressed in
-terms of area-weighted squared triad slopes,
-so the area-integrated vertical flux from tracer cell $i,k$ to $i,k+1$ resulting from the $r_1^2$ term is
-\begin{equation}
-  \label{eq:i33}
-  \left( F_w^{33} \right) _i^{k+\frac{1}{2}} =
-  - \left( {A}_i^{k+1} a_{1}' s_{1}'^2
-    + {A}_i^{k+1} a_{2}' s_{2}'^2
-    + {A}_i^k a_{3}' s_{3}'^2
-    + {A}_i^k a_{4}' s_{4}'^2 \right)\delta_{k+\frac{1}{2}} \left[ T^{i+1} \right],
-\end{equation}
-where the areas $a'$ and slopes $s'$ are the same as in \autoref{eq:i31}.
-Then, separating the total vertical flux, the sum of \autoref{eq:i31} and \autoref{eq:i33},
-into triad components, a vertical flux
-\begin{align}
-  \label{eq:vertflux-triad}
-  _i^k {\mathbb{F}_w}_{i_p}^{k_p} (T)
-  &= {A}_i^k{\: }_i^k{\mathbb{A}_w}_{i_p}^{k_p}
-    \left(
-    {_i^k\mathbb{R}_{i_p}^{k_p}}\frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
-    -\ \left({_i^k\mathbb{R}_{i_p}^{k_p}}\right)^2 \
-    \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
-    \right) \\
-  &= - \left(\left.{ }_i^k{\mathbb{A}_w}_{i_p}^{k_p}\right/{ }_i^k{\mathbb{A}_u}_{i_p}^{k_p}\right)
-    {_i^k\mathbb{R}_{i_p}^{k_p}}{\: }_i^k{\mathbb{F}_u}_{i_p}^{k_p} (T) \label{eq:vertflux-triad2}
-\end{align}
-may be associated with each triad.
-Each vertical density flux $_i^k {\mathbb{F}_w}_{i_p}^{k_p} (\rho)$ associated with a triad then
-separately disappears (because the lateral flux $_i^k{\mathbb{F}_u}_{i_p}^{k_p} (\rho)$ disappears).
-Consequently the total vertical density flux
-$\left( F_w^{31} \right)_i ^{k+\frac{1}{2}} + \left( F_w^{33} \right)_i^{k+\frac{1}{2}}$ from
-tracer cell $i,k$ to $i,k+1$ must also vanish since it is a sum of four such triad fluxes.
-
-We can explicitly identify (\autoref{fig:qcells}) the triads associated with the $s_i$, $a_i$,
-and $s'_i$, $a'_i$ used in the definition of the $u$-fluxes and $w$-fluxes in \autoref{eq:i31},
-\autoref{eq:i13}, \autoref{eq:i11} \autoref{eq:i33} and \autoref{fig:ISO_triad} to write out
-the iso-neutral fluxes at $u$- and $w$-points as sums of the triad fluxes that cross the $u$- and $w$-faces:
-%(\autoref{fig:ISO_triad}):
-\begin{flalign}
-  \label{eq:iso_flux} \vect{F}_{\mathrm{iso}}(T) &\equiv
-  \sum_{\substack{i_p,\,k_p}}
-  \begin{pmatrix}
-    {_{i+1/2-i_p}^k {\mathbb{F}_u}_{i_p}^{k_p} } (T) \\ \\
-    {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p} } (T) \\
-  \end{pmatrix}.
-\end{flalign}
-
-\subsection{Ensuring the scheme does not increase tracer variance}
-\label{subsec:variance}
-
-We now require that this operator should not increase the globally-integrated tracer variance.
-%This changes according to
-% \begin{align*}
-% &\int_D  D_l^T \; T \;dv \equiv  \sum_{i,k} \left\{ T \ D_l^T \ b_T \right\}    \\
-% &\equiv + \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
-% 		\delta_{i} \left[{_{i+1/2-i_p}^k {\mathbb{F}_u }_{i_p}^{k_p}} \right]
-% 	     + \delta_{k} \left[ {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}} \right]  \ T \right\}    \\
-% &\equiv  - \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
-%                 {_{i+1/2-i_p}^k {\mathbb{F}_u }_{i_p}^{k_p}} \ \delta_{i+1/2} [T]
-%              + {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}}  \ \delta_{k+1/2} [T]   \right\}      \\
-% \end{align*}
-Each triad slope $_i^k\mathbb{R}_{i_p}^{k_p}$ drives a lateral flux $_i^k{\mathbb{F}_u}_{i_p}^{k_p} (T)$ across
-the $u$-point $i+i_p,k$ and a vertical flux $_i^k{\mathbb{F}_w}_{i_p}^{k_p} (T)$ across the $w$-point $i,k+k_p$.
-The lateral flux drives a net rate of change of variance,
-summed over the two $T$-points $i+i_p-\fractext{1}{2},k$ and $i+i_p+\fractext{1}{2},k$, of
-\begin{multline}
-  {b_T}_{i+i_p-1/2}^k\left(\frac{\partial T}{\partial t}T\right)_{i+i_p-1/2}^k+
-  \quad {b_T}_{i+i_p+1/2}^k\left(\frac{\partial T}{\partial
-      t}T\right)_{i+i_p+1/2}^k \\
-  \begin{aligned}
-    &= -T_{i+i_p-1/2}^k{\;} _i^k{\mathbb{F}_u}_{i_p}^{k_p} (T) \quad + \quad  T_{i+i_p+1/2}^k
-    {\;}_i^k{\mathbb{F}_u}_{i_p}^{k_p} (T) \\
-    &={\;} _i^k{\mathbb{F}_u}_{i_p}^{k_p} (T)\,\delta_{i+ i_p}[T^k], \label{eq:dvar_iso_i}
-  \end{aligned}
-\end{multline}
-while the vertical flux similarly drives a net rate of change of variance summed over
-the $T$-points $i,k+k_p-\fractext{1}{2}$ (above) and $i,k+k_p+\fractext{1}{2}$ (below) of
-\begin{equation}
-  \label{eq:dvar_iso_k}
-  _i^k{\mathbb{F}_w}_{i_p}^{k_p} (T) \,\delta_{k+ k_p}[T^i].
-\end{equation}
-The total variance tendency driven by the triad is the sum of these two.
-Expanding $_i^k{\mathbb{F}_u}_{i_p}^{k_p} (T)$ and $_i^k{\mathbb{F}_w}_{i_p}^{k_p} (T)$ with
-\autoref{eq:latflux-triad} and \autoref{eq:vertflux-triad}, it is
-\begin{multline*}
-  -{A}_i^k\left \{
-    { } _i^k{\mathbb{A}_u}_{i_p}^{k_p}
-    \left(
-      \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
-      - {_i^k\mathbb{R}_{i_p}^{k_p}} \
-      \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }\right)\,\delta_{i+ i_p}[T^k] \right.\\
-  - \left. { } _i^k{\mathbb{A}_w}_{i_p}^{k_p}
-    \left(
-      \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
-      -{\:}_i^k\mathbb{R}_{i_p}^{k_p}
-      \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
-    \right) {\,}_i^k\mathbb{R}_{i_p}^{k_p}\delta_{k+ k_p}[T^i]
-  \right \}.
-\end{multline*}
-The key point is then that if we require $_i^k{\mathbb{A}_u}_{i_p}^{k_p}$ and $_i^k{\mathbb{A}_w}_{i_p}^{k_p}$ to
-be related to a triad volume $_i^k\mathbb{V}_{i_p}^{k_p}$ by
-\begin{equation}
-  \label{eq:V-A}
-  _i^k\mathbb{V}_{i_p}^{k_p}
-  ={\;}_i^k{\mathbb{A}_u}_{i_p}^{k_p}\,{e_{1u}}_{\,i + i_p}^{\,k}
-  ={\;}_i^k{\mathbb{A}_w}_{i_p}^{k_p}\,{e_{3w}}_{\,i}^{\,k + k_p},
-\end{equation}
-the variance tendency reduces to the perfect square
-\begin{equation}
-  \label{eq:perfect-square}
-  -{A}_i^k{\:} _i^k\mathbb{V}_{i_p}^{k_p}
-  \left(
-    \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
-    -{\:}_i^k\mathbb{R}_{i_p}^{k_p}
-    \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
-  \right)^2\leq 0.
-\end{equation}
-Thus, the constraint \autoref{eq:V-A} ensures that the fluxes
-(\autoref{eq:latflux-triad}, \autoref{eq:vertflux-triad}) associated with
-a given slope triad $_i^k\mathbb{R}_{i_p}^{k_p}$ do not increase the net variance.
-Since the total fluxes are sums of such fluxes from the various triads, this constraint, applied to all triads,
-is sufficient to ensure that the globally integrated variance does not increase.
-
-The expression \autoref{eq:V-A} can be interpreted as a discretization of the global integral
-\begin{equation}
-  \label{eq:cts-var}
-  \frac{\partial}{\partial t}\int\!\fractext{1}{2} T^2\, dV =
-  \int\!\mathbf{F}\cdot\nabla T\, dV,
-\end{equation}
-where, within each triad volume $_i^k\mathbb{V}_{i_p}^{k_p}$, the lateral and vertical fluxes/unit area
-\[
-  \mathbf{F}=\left(
-    \left.{}_i^k{\mathbb{F}_u}_{i_p}^{k_p} (T)\right/{}_i^k{\mathbb{A}_u}_{i_p}^{k_p},
-    \left.{\:}_i^k{\mathbb{F}_w}_{i_p}^{k_p} (T)\right/{}_i^k{\mathbb{A}_w}_{i_p}^{k_p}
-  \right)
-\]
-and the gradient
-\[
-  \nabla T = \left(
-    \left.\delta_{i+ i_p}[T^k] \right/ {e_{1u}}_{\,i + i_p}^{\,k},
-    \left.\delta_{k+ k_p}[T^i] \right/ {e_{3w}}_{\,i}^{\,k + k_p}
-  \right)
-\]
-
-\subsection{Triad volumes in Griffes's scheme and in \NEMO}
-
-To complete the discretization we now need only specify the triad volumes $_i^k\mathbb{V}_{i_p}^{k_p}$.
-\citet{griffies.gnanadesikan.ea_JPO98} identifies these $_i^k\mathbb{V}_{i_p}^{k_p}$ as the volumes of the quarter cells,
-defined in terms of the distances between $T$, $u$,$f$ and $w$-points.
-This is the natural discretization of \autoref{eq:cts-var}.
-The \NEMO model, however, operates with scale factors instead of grid sizes,
-and scale factors for the quarter cells are not defined.
-Instead, therefore we simply choose
-\begin{equation}
-  \label{eq:V-NEMO}
-  _i^k\mathbb{V}_{i_p}^{k_p}=\fractext{1}{4} {b_u}_{i+i_p}^k,
-\end{equation}
-as a quarter of the volume of the $u$-cell inside which the triad quarter-cell lies.
-This has the nice property that when the slopes $\mathbb{R}$ vanish,
-the lateral flux from tracer cell $i,k$ to $i+1,k$ reduces to the classical form
-\begin{equation}
-  \label{eq:lat-normal}
-  -\overline{A}_{\,i+1/2}^k\;
-  \frac{{b_u}_{i+1/2}^k}{{e_{1u}}_{\,i + i_p}^{\,k}}
-  \;\frac{\delta_{i+ 1/2}[T^k] }{{e_{1u}}_{\,i + i_p}^{\,k}}
-  = -\overline{A}_{\,i+1/2}^k\;\frac{{e_{1w}}_{\,i + 1/2}^{\,k}\:{e_{1v}}_{\,i + 1/2}^{\,k}\;\delta_{i+ 1/2}[T^k]}{{e_{1u}}_{\,i + 1/2}^{\,k}}.
-\end{equation}
-In fact if the diffusive coefficient is defined at $u$-points,
-so that we employ ${A}_{i+i_p}^k$ instead of  ${A}_i^k$ in the definitions of the triad fluxes
-\autoref{eq:latflux-triad} and \autoref{eq:vertflux-triad},
-we can replace $\overline{A}_{\,i+1/2}^k$ by $A_{i+1/2}^k$ in the above.
-
-\subsection{Summary of the scheme}
-
-The iso-neutral fluxes at $u$- and $w$-points are the sums of the triad fluxes that
-cross the $u$- and $w$-faces \autoref{eq:iso_flux}:
-\begin{subequations}
-  % \label{eq:alltriadflux}
-  \begin{flalign*}
-    % \label{eq:vect_isoflux}
-    \vect{F}_{\mathrm{iso}}(T) &\equiv
-    \sum_{\substack{i_p,\,k_p}}
-    \begin{pmatrix}
-      {_{i+1/2-i_p}^k {\mathbb{F}_u}_{i_p}^{k_p} } (T) \\ \\
-      {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p} } (T)
-    \end{pmatrix},
-  \end{flalign*}
-  where \autoref{eq:latflux-triad}:
-  \begin{align}
-    \label{eq:triadfluxu}
-    _i^k {\mathbb{F}_u}_{i_p}^{k_p} (T) &= - {A}_i^k{
-                                          \:}\frac{{{}_i^k\mathbb{V}}_{i_p}^{k_p}}{{e_{1u}}_{\,i + i_p}^{\,k}}
-                                          \left(
-                                          \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
-                                          -\ {_i^k\mathbb{R}_{i_p}^{k_p}} \
-                                          \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
-                                          \right),\\
-    \intertext{and}
-    _i^k {\mathbb{F}_w}_{i_p}^{k_p} (T)
-                                        &= {A}_i^k{\: }\frac{{{}_i^k\mathbb{V}}_{i_p}^{k_p}}{{e_{3w}}_{\,i}^{\,k+k_p}}
-                                          \left(
-                                          {_i^k\mathbb{R}_{i_p}^{k_p}}\frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
-                                          -\ \left({_i^k\mathbb{R}_{i_p}^{k_p}}\right)^2 \
-                                          \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
-                                          \right),\label{eq:triadfluxw}
-  \end{align}
-  with \autoref{eq:V-NEMO}
-  \[
-    % \label{eq:V-NEMO2}
-    _i^k{\mathbb{V}}_{i_p}^{k_p}=\fractext{1}{4} {b_u}_{i+i_p}^k.
-  \]
-\end{subequations}
-
-The divergence of the expression \autoref{eq:iso_flux} for the fluxes gives the iso-neutral diffusion tendency at
-each tracer point:
-\[
-  % \label{eq:iso_operator}
-  D_l^T = \frac{1}{b_T}
-  \sum_{\substack{i_p,\,k_p}} \left\{ \delta_{i} \left[{_{i+1/2-i_p}^k
-        {\mathbb{F}_u }_{i_p}^{k_p}} \right] + \delta_{k} \left[
-      {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}} \right] \right\}
-\]
-where $b_T= e_{1T}\,e_{2T}\,e_{3T}$ is the volume of $T$-cells.
-The diffusion scheme satisfies the following six properties:
-\begin{description}
-\item[$\bullet$ horizontal diffusion]
-  The discretization of the diffusion operator recovers the traditional five-point Laplacian
-  \autoref{eq:lat-normal} in the limit of flat iso-neutral direction:
-  \[
-    % \label{eq:iso_property0}
-    D_l^T = \frac{1}{b_T} \
-    \delta_{i} \left[ \frac{e_{2u}\,e_{3u}}{e_{1u}} \;
-      \overline{A}^{\,i} \; \delta_{i+1/2}[T] \right] \qquad
-    \text{when} \quad { _i^k \mathbb{R}_{i_p}^{k_p} }=0
-  \]
-
-\item[$\bullet$ implicit treatment in the vertical]
-  Only tracer values associated with a single water column appear in the expression \autoref{eq:i33} for
-  the $_{33}$ fluxes, vertical fluxes driven by vertical gradients.
-  This is of paramount importance since it means that a time-implicit algorithm can be used to
-  solve the vertical diffusion equation.
-  This is necessary since the vertical eddy diffusivity associated with this term,
-  \[
-    \frac{1}{b_w}\sum_{\substack{i_p, \,k_p}} \left\{
-      {\:}_i^k\mathbb{V}_{i_p}^{k_p} \: {A}_i^k \: \left(_i^k \mathbb{R}_{i_p}^{k_p}\right)^2
-    \right\}  =
-    \frac{1}{4b_w}\sum_{\substack{i_p, \,k_p}} \left\{
-      {b_u}_{i+i_p}^k\: {A}_i^k \: \left(_i^k \mathbb{R}_{i_p}^{k_p}\right)^2
-    \right\},
-  \]
-  (where $b_w= e_{1w}\,e_{2w}\,e_{3w}$ is the volume of $w$-cells) can be quite large.
-
-\item[$\bullet$ pure iso-neutral operator]
-  The iso-neutral flux of locally referenced potential density is zero.
-  See \autoref{eq:latflux-rho} and \autoref{eq:vertflux-triad2}.
-
-\item[$\bullet$ conservation of tracer]
-  The iso-neutral diffusion conserves tracer content, \ie
-  \[
-    % \label{eq:iso_property1}
-    \sum_{i,j,k} \left\{ D_l^T \      b_T \right\} = 0
-  \]
-  This property is trivially satisfied since the iso-neutral diffusive operator is written in flux form.
-
-\item[$\bullet$ no increase of tracer variance]
-  The iso-neutral diffusion does not increase the tracer variance, \ie
-  \[
-    % \label{eq:iso_property2}
-    \sum_{i,j,k} \left\{ T \ D_l^T      \ b_T \right\} \leq 0
-  \]
-  The property is demonstrated in \autoref{subsec:variance} above.
-  It is a key property for a diffusion term.
-  It means that it is also a dissipation term,
-  \ie it dissipates the square of the quantity on which it is applied.
-  It therefore ensures that, when the diffusivity coefficient is large enough,
-  the field on which it is applied becomes free of grid-point noise.
-
-\item[$\bullet$ self-adjoint operator]
-  The iso-neutral diffusion operator is self-adjoint, \ie
-  \begin{equation}
-    \label{eq:iso_property3}
-    \sum_{i,j,k} \left\{ S \ D_l^T \ b_T \right\} = \sum_{i,j,k} \left\{ D_l^S \ T \ b_T \right\}
-  \end{equation}
-  In other word, there is no need to develop a specific routine from the adjoint of this operator.
-  We just have to apply the same routine.
-  This property can be demonstrated similarly to the proof of the `no increase of tracer variance' property.
-  The contribution by a single triad towards the left hand side of \autoref{eq:iso_property3},
-  can be found by replacing $\delta[T]$ by $\delta[S]$ in \autoref{eq:dvar_iso_i} and \autoref{eq:dvar_iso_k}.
-  This results in a term similar to \autoref{eq:perfect-square},
-  \[
-    % \label{eq:TScovar}
-    - {A}_i^k{\:} _i^k\mathbb{V}_{i_p}^{k_p}
-    \left(
-      \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
-      -{\:}_i^k\mathbb{R}_{i_p}^{k_p}
-      \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
-    \right)
-    \left(
-      \frac{ \delta_{i+ i_p}[S^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
-      -{\:}_i^k\mathbb{R}_{i_p}^{k_p}
-      \frac{ \delta_{k+k_p} [S^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
-    \right).
-  \]
-This is symmetrical in $T $ and $S$, so exactly the same term arises from
-the discretization of this triad's contribution towards the RHS of \autoref{eq:iso_property3}.
-\end{description}
-
-\subsection{Treatment of the triads at the boundaries}
-\label{sec:iso_bdry}
-
-The triad slope can only be defined where both the grid boxes centred at the end of the arms exist.
-Triads that would poke up through the upper ocean surface into the atmosphere,
-or down into the ocean floor, must be masked out.
-See \autoref{fig:bdry_triads}.
-Surface layer triads \triad{i}{1}{R}{1/2}{-1/2} (magenta) and \triad{i+1}{1}{R}{-1/2}{-1/2} (blue) that
-require density to be specified above the ocean surface are masked (\autoref{fig:bdry_triads}a):
-this ensures that lateral tracer gradients produce no flux through the ocean surface.
-However, to prevent surface noise, it is customary to retain the $_{11}$ contributions towards
-the lateral triad fluxes \triad[u]{i}{1}{F}{1/2}{-1/2} and \triad[u]{i+1}{1}{F}{-1/2}{-1/2};
-this drives diapycnal tracer fluxes.
-Similar comments apply to triads that would intersect the ocean floor (\autoref{fig:bdry_triads}b).
-Note that both near bottom triad slopes \triad{i}{k}{R}{1/2}{1/2} and \triad{i+1}{k}{R}{-1/2}{1/2} are masked when
-either of the $i,k+1$ or $i+1,k+1$ tracer points is masked, \ie the $i,k+1$ $u$-point is masked.
-The associated lateral fluxes (grey-black dashed line) are masked if \np{ln\_botmix\_triad}\forcode{ = .false.},
-but left unmasked, giving bottom mixing, if \np{ln\_botmix\_triad}\forcode{ = .true.}.
-
-The default option \np{ln\_botmix\_triad}\forcode{ = .false.} is suitable when the bbl mixing option is enabled
-(\key{trabbl}, with \np{nn\_bbl\_ldf}\forcode{ = 1}), or for simple idealized problems.
-For setups with topography without bbl mixing, \np{ln\_botmix\_triad}\forcode{ = .true.} may be necessary.
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[h]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_GRIFF_bdry_triads}
-    \caption{
-      \protect\label{fig:bdry_triads}
-      (a) Uppermost model layer $k=1$ with $i,1$ and $i+1,1$ tracer points (black dots),
-      and $i+1/2,1$ $u$-point (blue square).
-      Triad slopes \triad{i}{1}{R}{1/2}{-1/2} (magenta) and \triad{i+1}{1}{R}{-1/2}{-1/2} (blue) poking through
-      the ocean surface are masked (faded in figure).
-      However, the lateral $_{11}$ contributions towards \triad[u]{i}{1}{F}{1/2}{-1/2} and
-      \triad[u]{i+1}{1}{F}{-1/2}{-1/2} (yellow line) are still applied,
-      giving diapycnal diffusive fluxes.
-      \newline
-      (b) Both near bottom triad slopes \triad{i}{k}{R}{1/2}{1/2} and
-      \triad{i+1}{k}{R}{-1/2}{1/2} are masked when either of the $i,k+1$ or $i+1,k+1$ tracer points is masked,
-      \ie the $i,k+1$ $u$-point is masked.
-      The associated lateral fluxes (grey-black dashed line) are masked if
-      \protect\np{botmix\_triad}\forcode{ = .false.}, but left unmasked,
-      giving bottom mixing, if \protect\np{botmix\_triad}\forcode{ = .true.}
-    }
-  \end{center}
-\end{figure}
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-\subsection{ Limiting of the slopes within the interior}
-\label{sec:limit}
-
-As discussed in \autoref{subsec:LDF_slp_iso},
-iso-neutral slopes relative to geopotentials must be bounded everywhere,
-both for consistency with the small-slope approximation and for numerical stability \citep{cox_OM87, griffies_bk04}.
-The bound chosen in \NEMO is applied to each component of the slope separately and
-has a value of $1/100$ in the ocean interior.
-%, ramping linearly down above 70~m depth to zero at the surface
-It is of course relevant to the iso-neutral slopes $\tilde{r}_i=r_i+\sigma_i$ relative to geopotentials
-(here the $\sigma_i$ are the slopes of the coordinate surfaces relative to geopotentials)
-\autoref{eq:PE_slopes_eiv} rather than the slope $r_i$ relative to coordinate surfaces, so we require
-\[
-  |\tilde{r}_i|\leq \tilde{r}_\mathrm{max}=0.01.
-\]
-and then recalculate the slopes $r_i$ relative to coordinates.
-Each individual triad slope
-\begin{equation}
-  \label{eq:Rtilde}
-  _i^k\tilde{\mathbb{R}}_{i_p}^{k_p} = {}_i^k\mathbb{R}_{i_p}^{k_p}  + \frac{\delta_{i+i_p}[z_T^k]}{{e_{1u}}_{\,i + i_p}^{\,k}}
-\end{equation}
-is limited like this and then the corresponding $_i^k\mathbb{R}_{i_p}^{k_p} $ are recalculated and
-combined to form the fluxes.
-Note that where the slopes have been limited, there is now a non-zero iso-neutral density flux that
-drives dianeutral mixing.
-In particular this iso-neutral density flux is always downwards,
-and so acts to reduce gravitational potential energy.
-
-\subsection{Tapering within the surface mixed layer}
-\label{sec:taper}
-
-Additional tapering of the iso-neutral fluxes is necessary within the surface mixed layer.
-When the Griffies triads are used, we offer two options for this.
-
-\subsubsection{Linear slope tapering within the surface mixed layer}
-\label{sec:lintaper}
-
-This is the option activated by the default choice \np{ln\_triad\_iso}\forcode{ = .false.}.
-Slopes $\tilde{r}_i$ relative to geopotentials are tapered linearly from their value immediately below
-the mixed layer to zero at the surface, as described in option (c) of \autoref{fig:eiv_slp}, to values
-\begin{equation}
-  \label{eq:rmtilde}
-  \rMLt = -\frac{z}{h}\left.\tilde{r}_i\right|_{z=-h}\quad \text{ for  } z>-h,
-\end{equation}
-and then the $r_i$ relative to vertical coordinate surfaces are appropriately adjusted to
-\[
-  % \label{eq:rm}
-  \rML =\rMLt -\sigma_i \quad \text{ for  } z>-h.
-\]
-Thus the diffusion operator within the mixed layer is given by:
-\[
-  % \label{eq:iso_tensor_ML}
-  D^{lT}=\nabla {\mathrm {\mathbf .}}\left( {A^{lT}\;\Re \;\nabla T} \right) \qquad
-  \mbox{with}\quad \;\;\Re =\left( {{
-        \begin{array}{*{20}c}
-          1 \hfill & 0 \hfill & {-\rML[1]}\hfill \\
-          0 \hfill & 1 \hfill & {-\rML[2]} \hfill \\
-          {-\rML[1]}\hfill &   {-\rML[2]} \hfill & {\rML[1]^2+\rML[2]^2} \hfill
-        \end{array}
-      }} \right)
-\]
-
-This slope tapering gives a natural connection between tracer in the mixed-layer and
-in isopycnal layers immediately below, in the thermocline.
-It is consistent with the way the $\tilde{r}_i$ are tapered within the mixed layer
-(see \autoref{sec:taperskew} below) so as to ensure a uniform GM eddy-induced velocity throughout the mixed layer.
-However, it gives a downwards density flux and so acts so as to reduce potential energy in the same way as
-does the slope limiting discussed above in \autoref{sec:limit}.
- 
-As in \autoref{sec:limit} above, the tapering \autoref{eq:rmtilde} is applied separately to
-each triad $_i^k\tilde{\mathbb{R}}_{i_p}^{k_p}$, and the $_i^k\mathbb{R}_{i_p}^{k_p}$ adjusted.
-For clarity, we assume $z$-coordinates in the following;
-the conversion from $\mathbb{R}$ to $\tilde{\mathbb{R}}$ and back to $\mathbb{R}$ follows exactly as
-described above by \autoref{eq:Rtilde}.
-\begin{enumerate}
-\item
-  Mixed-layer depth is defined so as to avoid including regions of weak vertical stratification in
-  the slope definition.
-  At each $i,j$ (simplified to $i$ in \autoref{fig:MLB_triad}),
-  we define the mixed-layer by setting the vertical index of the tracer point immediately below the mixed layer,
-  $k_{\mathrm{ML}}$, as the maximum $k$ (shallowest tracer point) such that
-  the potential density ${\rho_0}_{i,k}>{\rho_0}_{i,k_{10}}+\Delta\rho_c$,
-  where $i,k_{10}$ is the tracer gridbox within which the depth reaches 10~m.
-  See the left side of \autoref{fig:MLB_triad}.
-  We use the $k_{10}$-gridbox instead of the surface gridbox to avoid problems \eg with thin daytime mixed-layers.
-  Currently we use the same $\Delta\rho_c=0.01\;\mathrm{kg\:m^{-3}}$ for ML triad tapering as is used to
-  output the diagnosed mixed-layer depth $h_{\mathrm{ML}}=|z_{W}|_{k_{\mathrm{ML}}+1/2}$,
-  the depth of the $w$-point above the $i,k_{\mathrm{ML}}$ tracer point.
-\item
-  We define `basal' triad slopes ${\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p}$ as
-  the slopes of those triads whose vertical `arms' go down from the $i,k_{\mathrm{ML}}$ tracer point to
-  the $i,k_{\mathrm{ML}}-1$ tracer point below.
-  This is to ensure that the vertical density gradients associated with
-  these basal triad slopes ${\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p}$ are representative of the thermocline.
-  The four basal triads defined in the bottom part of \autoref{fig:MLB_triad} are then
-  \begin{align*}
-    {\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p} &=
-                                                       {\:}^{k_{\mathrm{ML}}-k_p-1/2}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p},
-                                                       % \label{eq:Rbase}
-    \\
-    \intertext{with \eg the green triad}
-    {\:}_i{\mathbb{R}_{\mathrm{base}}}_{1/2}^{-1/2}&=
-                                                     {\:}^{k_{\mathrm{ML}}}_i{\mathbb{R}_{\mathrm{base}}}_{\,1/2}^{-1/2}.
-  \end{align*}
-The vertical flux associated with each of these triads passes through
-the $w$-point $i,k_{\mathrm{ML}}-1/2$ lying \emph{below} the $i,k_{\mathrm{ML}}$ tracer point, so it is this depth
-\[
-  % \label{eq:zbase}
-  {z_\mathrm{base}}_{\,i}={z_{w}}_{k_\mathrm{ML}-1/2}
-\]
-one gridbox deeper than the diagnosed ML depth $z_{\mathrm{ML}})$ that sets the $h$ used to taper the slopes in
-\autoref{eq:rmtilde}.
-\item
-  Finally, we calculate the adjusted triads ${\:}_i^k{\mathbb{R}_{\mathrm{ML}}}_{\,i_p}^{k_p}$ within
-  the mixed layer, by multiplying the appropriate ${\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p}$ by
-  the ratio of the depth of the $w$-point ${z_w}_{k+k_p}$ to ${z_{\mathrm{base}}}_{\,i}$.
-  For instance the green triad centred on $i,k$
-  \begin{align*}
-    {\:}_i^k{\mathbb{R}_{\mathrm{ML}}}_{\,1/2}^{-1/2} &=
-                                                        \frac{{z_w}_{k-1/2}}{{z_{\mathrm{base}}}_{\,i}}{\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,1/2}^{-1/2} \\
-    \intertext{and more generally}
-    {\:}_i^k{\mathbb{R}_{\mathrm{ML}}}_{\,i_p}^{k_p} &=
-                                                       \frac{{z_w}_{k+k_p}}{{z_{\mathrm{base}}}_{\,i}}{\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p}.
-                                                       % \label{eq:RML}
-  \end{align*}
-\end{enumerate}
-
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[h]
-%  \fcapside {
-  \caption{
-    \protect\label{fig:MLB_triad}
-    Definition of mixed-layer depth and calculation of linearly tapered triads.
-    The figure shows a water column at a given $i,j$ (simplified to $i$), with the ocean surface at the top.
-    Tracer points are denoted by bullets, and black lines the edges of the tracer cells;
-    $k$ increases upwards.
-    \newline
-    \hspace{5 em}
-    We define the mixed-layer by setting the vertical index of the tracer point immediately below the mixed layer,
-    $k_{\mathrm{ML}}$, as the maximum $k$ (shallowest tracer point) such that
-    ${\rho_0}_{i,k}>{\rho_0}_{i,k_{10}}+\Delta\rho_c$,
-    where $i,k_{10}$ is the tracer gridbox within which the depth reaches 10~m.
-    We calculate the triad slopes within the mixed layer by linearly tapering them from zero
-    (at the surface) to the `basal' slopes,
-    the slopes of the four triads passing through the $w$-point $i,k_{\mathrm{ML}}-1/2$ (blue square),
-    ${\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p}$.
-    Triads with different $i_p,k_p$, denoted by different colours,
-    (\eg the green triad $i_p=1/2,k_p=-1/2$) are tapered to the appropriate basal triad.}
-  % }
-  \includegraphics[width=\textwidth]{Fig_GRIFF_MLB_triads}
-\end{figure}
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-\subsubsection{Additional truncation of skew iso-neutral flux components}
-\label{subsec:Gerdes-taper}
-
-The alternative option is activated by setting \np{ln\_triad\_iso} = true.
-This retains the same tapered slope $\rML$  described above for the calculation of the $_{33}$ term of
-the iso-neutral diffusion tensor (the vertical tracer flux driven by vertical tracer gradients),
-but replaces the $\rML$ in the skew term by
-\begin{equation}
-  \label{eq:rm*}
-  \rML^*=\left.\rMLt^2\right/\tilde{r}_i-\sigma_i,
-\end{equation}
-giving a ML diffusive operator
-\[
-  % \label{eq:iso_tensor_ML2}
-  D^{lT}=\nabla {\mathrm {\mathbf .}}\left( {A^{lT}\;\Re \;\nabla T} \right) \qquad
-  \mbox{with}\quad \;\;\Re =\left( {{
-        \begin{array}{*{20}c}
-          1 \hfill & 0 \hfill & {-\rML[1]^*}\hfill \\
-          0 \hfill & 1 \hfill & {-\rML[2]^*} \hfill \\
-          {-\rML[1]^*}\hfill &   {-\rML[2]^*} \hfill & {\rML[1]^2+\rML[2]^2} \hfill \\
-        \end{array}
-      }} \right).
-\]
-This operator
-\footnote{
-  To ensure good behaviour where horizontal density gradients are weak,
-  we in fact follow \citet{gerdes.koberle.ea_CD91} and
-  set $\rML^*=\mathrm{sgn}(\tilde{r}_i)\min(|\rMLt^2/\tilde{r}_i|,|\tilde{r}_i|)-\sigma_i$.
-}
-then has the property it gives no vertical density flux, and so does not change the potential energy.
-This approach is similar to multiplying the iso-neutral diffusion coefficient by
-$\tilde{r}_{\mathrm{max}}^{-2}\tilde{r}_i^{-2}$ for steep slopes,
-as suggested by \citet{gerdes.koberle.ea_CD91} (see also \citet{griffies_bk04}).
-Again it is applied separately to each triad $_i^k\mathbb{R}_{i_p}^{k_p}$
-
-In practice, this approach gives weak vertical tracer fluxes through the mixed-layer,
-as well as vanishing density fluxes.
-While it is theoretically advantageous that it does not change the potential energy,
-it may give a discontinuity between the fluxes within the mixed-layer (purely horizontal) and
-just below (along iso-neutral surfaces).
-% This may give strange looking results,
-% particularly where the mixed-layer depth varies strongly laterally.
-% ================================================================
-% Skew flux formulation for Eddy Induced Velocity :
-% ================================================================
-\section{Eddy induced advection formulated as a skew flux}
-\label{sec:skew-flux}
-
-\subsection{Continuous skew flux formulation}
-\label{sec:continuous-skew-flux}
-
-When Gent and McWilliams's [1990] diffusion is used, an additional advection term is added.
-The associated velocity is the so called eddy induced velocity,
-the formulation of which depends on the slopes of iso-neutral surfaces.
-Contrary to the case of iso-neutral mixing, the slopes used here are referenced to the geopotential surfaces,
-\ie \autoref{eq:ldfslp_geo} is used in $z$-coordinate,
-and the sum \autoref{eq:ldfslp_geo} + \autoref{eq:ldfslp_iso} in $z^*$ or $s$-coordinates.
-
-The eddy induced velocity is given by:
-\begin{subequations}
-  % \label{eq:eiv}
-  \begin{equation}
-    \label{eq:eiv_v}
-    \begin{split}
-      u^* & = - \frac{1}{e_{3}}\;          \partial_i\psi_1,  \\
-      v^* & = - \frac{1}{e_{3}}\;          \partial_j\psi_2,    \\
-      w^* & =    \frac{1}{e_{1}e_{2}}\; \left\{ \partial_i  \left( e_{2} \, \psi_1\right)
-        + \partial_j  \left( e_{1} \, \psi_2\right) \right\},
-    \end{split}
-  \end{equation}
-  where the streamfunctions $\psi_i$ are given by
-  \begin{equation}
-    \label{eq:eiv_psi}
-    \begin{split}
-      \psi_1 & = A_{e} \; \tilde{r}_1,   \\
-      \psi_2 & = A_{e} \; \tilde{r}_2,
-    \end{split}
-  \end{equation}
-\end{subequations}
-with $A_{e}$ the eddy induced velocity coefficient,
-and $\tilde{r}_1$ and $\tilde{r}_2$ the slopes between the iso-neutral and the geopotential surfaces.
-
-The traditional way to implement this additional advection is to add it to the Eulerian velocity prior to
-computing the tracer advection.
-This is implemented if \key{traldf\_eiv} is set in the default implementation,
-where \np{ln\_traldf\_triad} is set false.
-This allows us to take advantage of all the advection schemes offered for the tracers
-(see \autoref{sec:TRA_adv}) and not just a $2^{nd}$ order advection scheme.
-This is particularly useful for passive tracers where
-\emph{positivity} of the advection scheme is of paramount importance.
-
-However, when \np{ln\_traldf\_triad} is set true,
-\NEMO instead implements eddy induced advection according to the so-called skew form \citep{griffies_JPO98}.
-It is based on a transformation of the advective fluxes using the non-divergent nature of the eddy induced velocity.
-For example in the (\textbf{i},\textbf{k}) plane,
-the tracer advective fluxes per unit area in $ijk$ space can be transformed as follows:
-\begin{flalign*}
-  \begin{split}
-    \textbf{F}_{\mathrm{eiv}}^T =
-    \begin{pmatrix}
-      {e_{2}\,e_{3}\;  u^*} \\
- 		{e_{1}\,e_{2}\; w^*}
-    \end{pmatrix}   \;   T
-    &=
-    \begin{pmatrix}
-      { - \partial_k \left( e_{2} \,\psi_1 \right) \; T \;} \\
- 		{+ \partial_i  \left( e_{2} \, \psi_1 \right) \; T \;}
-    \end{pmatrix} 			\\
-    &=
-    \begin{pmatrix}
-      { - \partial_k \left( e_{2} \, \psi_1  \; T \right) \;} \\
- 		{+ \partial_i  \left( e_{2} \,\psi_1 \; T \right) \;}
-    \end{pmatrix}
-    +
-    \begin{pmatrix}
-      {+ e_{2} \, \psi_1  \; \partial_k T} \\
- 		{ - e_{2} \, \psi_1  \; \partial_i  T}
-    \end{pmatrix}
-  \end{split}
-\end{flalign*}
-and since the eddy induced velocity field is non-divergent,
-we end up with the skew form of the eddy induced advective fluxes per unit area in $ijk$ space:
-\begin{equation}
-  \label{eq:eiv_skew_ijk}
-  \textbf{F}_\mathrm{eiv}^T =
-  \begin{pmatrix}
-    {+ e_{2} \, \psi_1  \; \partial_k T}   \\
-    { - e_{2} \, \psi_1  \; \partial_i  T}
-  \end{pmatrix}
-\end{equation}
-The total fluxes per unit physical area are then
-\begin{equation}
-  \label{eq:eiv_skew_physical}
-  \begin{split}
-    f^*_1 & = \frac{1}{e_{3}}\; \psi_1 \partial_k T   \\
-    f^*_2 & = \frac{1}{e_{3}}\; \psi_2 \partial_k T   \\
-    f^*_3 & =  -\frac{1}{e_{1}e_{2}}\; \left\{ e_{2} \psi_1 \partial_i T + e_{1} \psi_2 \partial_j T \right\}.
-\end{split}
-\end{equation}
-Note that \autoref{eq:eiv_skew_physical} takes the same form whatever the vertical coordinate,
-though of course the slopes $\tilde{r}_i$ which define the $\psi_i$ in \autoref{eq:eiv_psi} are relative to
-geopotentials.
-The tendency associated with eddy induced velocity is then simply the convergence of the fluxes
-(\autoref{eq:eiv_skew_ijk}, \autoref{eq:eiv_skew_physical}), so
-\[
-  % \label{eq:skew_eiv_conv}
-  \frac{\partial T}{\partial t}= -\frac{1}{e_1 \, e_2 \, e_3 }      \left[
-    \frac{\partial}{\partial i} \left( e_2 \psi_1 \partial_k T\right)
-    + \frac{\partial}{\partial j} \left( e_1  \;
-      \psi_2 \partial_k T\right)
-    -  \frac{\partial}{\partial k} \left( e_{2} \psi_1 \partial_i T
-      + e_{1} \psi_2 \partial_j T \right)  \right]
-\]
-It naturally conserves the tracer content, as it is expressed in flux form.
-Since it has the same divergence as the advective form it also preserves the tracer variance.
-
-\subsection{Discrete skew flux formulation}
-
-The skew fluxes in (\autoref{eq:eiv_skew_physical}, \autoref{eq:eiv_skew_ijk}),
-like the off-diagonal terms (\autoref{eq:i13c}, \autoref{eq:i31c}) of the small angle diffusion tensor,
-are best expressed in terms of the triad slopes, as in \autoref{fig:ISO_triad} and
-(\autoref{eq:i13}, \autoref{eq:i31});
-but now in terms of the triad slopes $\tilde{\mathbb{R}}$ relative to geopotentials instead of
-the $\mathbb{R}$ relative to coordinate surfaces.
-The discrete form of \autoref{eq:eiv_skew_ijk} using the slopes \autoref{eq:R} and
-defining $A_e$ at $T$-points is then given by:
-
-\begin{subequations}
-  % \label{eq:allskewflux}
-  \begin{flalign*}
-    % \label{eq:vect_skew_flux}
-    \vect{F}_{\mathrm{eiv}}(T) &\equiv    \sum_{\substack{i_p,\,k_p}}
-    \begin{pmatrix}
-      {_{i+1/2-i_p}^k {\mathbb{S}_u}_{i_p}^{k_p} } (T)      \\      \\
-      {_i^{k+1/2-k_p} {\mathbb{S}_w}_{i_p}^{k_p} } (T)      \\
-    \end{pmatrix},
-  \end{flalign*}
-  where the skew flux in the $i$-direction associated with a given triad is (\autoref{eq:latflux-triad},
-  \autoref{eq:triadfluxu}):
-  \begin{align}
-    \label{eq:skewfluxu}
-    _i^k {\mathbb{S}_u}_{i_p}^{k_p} (T) &= + \fractext{1}{4} {A_e}_i^k{
-                                          \:}\frac{{b_u}_{i+i_p}^k}{{e_{1u}}_{\,i + i_p}^{\,k}}
-                                          \ {_i^k\tilde{\mathbb{R}}_{i_p}^{k_p}} \
-                                          \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }, \\
-    \intertext{
-    and \autoref{eq:triadfluxw} in the $k$-direction, changing the sign
-    to be consistent with \autoref{eq:eiv_skew_ijk}:
-    }
-    _i^k {\mathbb{S}_w}_{i_p}^{k_p} (T)
-                                        &= -\fractext{1}{4} {A_e}_i^k{\: }\frac{{b_u}_{i+i_p}^k}{{e_{3w}}_{\,i}^{\,k+k_p}}
-                                          {_i^k\tilde{\mathbb{R}}_{i_p}^{k_p}}\frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }.\label{eq:skewfluxw}
-  \end{align}
-\end{subequations}
-
-Such a discretisation is consistent with the iso-neutral operator as it uses the same definition for the slopes.
-It also ensures the following two key properties.
-
-\subsubsection{No change in tracer variance}
-
-The discretization conserves tracer variance, \ie it does not include a diffusive component but is a `pure' advection term.
-This can be seen %either from Appendix \autoref{apdx:eiv_skew} or
-by considering the fluxes associated with a given triad slope $_i^k{\mathbb{R}}_{i_p}^{k_p} (T)$.
-For, following \autoref{subsec:variance} and \autoref{eq:dvar_iso_i},
-the associated horizontal skew-flux $_i^k{\mathbb{S}_u}_{i_p}^{k_p} (T)$ drives a net rate of change of variance,
-summed over the two $T$-points $i+i_p-\fractext{1}{2},k$ and $i+i_p+\fractext{1}{2},k$, of
-\begin{equation}
-  \label{eq:dvar_eiv_i}
-  _i^k{\mathbb{S}_u}_{i_p}^{k_p} (T)\,\delta_{i+ i_p}[T^k],
-\end{equation}
-while the associated vertical skew-flux gives a variance change summed over
-the $T$-points $i,k+k_p-\fractext{1}{2}$ (above) and $i,k+k_p+\fractext{1}{2}$ (below) of
-\begin{equation}
-  \label{eq:dvar_eiv_k}
-  _i^k{\mathbb{S}_w}_{i_p}^{k_p} (T) \,\delta_{k+ k_p}[T^i].
-\end{equation}
-Inspection of the definitions (\autoref{eq:skewfluxu}, \autoref{eq:skewfluxw}) shows that
-these two variance changes (\autoref{eq:dvar_eiv_i}, \autoref{eq:dvar_eiv_k}) sum to zero.
-Hence the two fluxes associated with each triad make no net contribution to the variance budget.
-
-\subsubsection{Reduction in gravitational PE}
-
-The vertical density flux associated with the vertical skew-flux always has the same sign as
-the vertical density gradient;
-thus, so long as the fluid is stable (the vertical density gradient is negative)
-the vertical density flux is negative (downward) and hence reduces the gravitational PE.
-
-For the change in gravitational PE driven by the $k$-flux is
-\begin{align}
-  \label{eq:vert_densityPE}
-  g {e_{3w}}_{\,i}^{\,k+k_p}{\mathbb{S}_w}_{i_p}^{k_p} (\rho)
-  &=g {e_{3w}}_{\,i}^{\,k+k_p}\left[-\alpha _i^k {\:}_i^k
-    {\mathbb{S}_w}_{i_p}^{k_p} (T) + \beta_i^k {\:}_i^k
-    {\mathbb{S}_w}_{i_p}^{k_p} (S) \right]. \notag \\
-  \intertext{Substituting  ${\:}_i^k {\mathbb{S}_w}_{i_p}^{k_p}$ from \autoref{eq:skewfluxw}, gives}
-  % and separating out
-  % $\rtriadt{R}=\rtriad{R} + \delta_{i+i_p}[z_T^k]$,
-  % gives two terms. The
-  % first $\rtriad{R}$ term (the only term for $z$-coordinates) is:
-  &=-\fractext{1}{4} g{A_e}_i^k{\: }{b_u}_{i+i_p}^k {_i^k\tilde{\mathbb{R}}_{i_p}^{k_p}}
-    \frac{ -\alpha _i^k\delta_{i+ i_p}[T^k]+ \beta_i^k\delta_{i+ i_p}[S^k]} { {e_{1u}}_{\,i + i_p}^{\,k} } \notag \\
-  &=+\fractext{1}{4} g{A_e}_i^k{\: }{b_u}_{i+i_p}^k
-    \left({_i^k\mathbb{R}_{i_p}^{k_p}}+\frac{\delta_{i+i_p}[z_T^k]}{{e_{1u}}_{\,i + i_p}^{\,k}}\right) {_i^k\mathbb{R}_{i_p}^{k_p}}
-    \frac{-\alpha_i^k \delta_{k+ k_p}[T^i]+ \beta_i^k\delta_{k+ k_p}[S^i]} {{e_{3w}}_{\,i}^{\,k+k_p}},
-\end{align}
-using the definition of the triad slope $\rtriad{R}$, \autoref{eq:R} to
-express $-\alpha _i^k\delta_{i+ i_p}[T^k]+\beta_i^k\delta_{i+ i_p}[S^k]$ in terms of
-$-\alpha_i^k \delta_{k+ k_p}[T^i]+ \beta_i^k\delta_{k+ k_p}[S^i]$.
-
-Where the coordinates slope, the $i$-flux gives a PE change
-\begin{multline}
-  \label{eq:lat_densityPE}
-  g \delta_{i+i_p}[z_T^k]
-  \left[
-    -\alpha _i^k {\:}_i^k {\mathbb{S}_u}_{i_p}^{k_p} (T) + \beta_i^k {\:}_i^k {\mathbb{S}_u}_{i_p}^{k_p} (S)
-  \right] \\
-  = +\fractext{1}{4} g{A_e}_i^k{\: }{b_u}_{i+i_p}^k
-  \frac{\delta_{i+i_p}[z_T^k]}{{e_{1u}}_{\,i + i_p}^{\,k}}
-  \left({_i^k\mathbb{R}_{i_p}^{k_p}}+\frac{\delta_{i+i_p}[z_T^k]}{{e_{1u}}_{\,i + i_p}^{\,k}}\right)
-  \frac{-\alpha_i^k \delta_{k+ k_p}[T^i]+ \beta_i^k\delta_{k+ k_p}[S^i]} {{e_{3w}}_{\,i}^{\,k+k_p}},
-\end{multline}
-(using \autoref{eq:skewfluxu}) and so the total PE change \autoref{eq:vert_densityPE} +
-\autoref{eq:lat_densityPE} associated with the triad fluxes is
-\begin{multline*}
-  % \label{eq:tot_densityPE}
-  g{e_{3w}}_{\,i}^{\,k+k_p}{\mathbb{S}_w}_{i_p}^{k_p} (\rho) +
-  g\delta_{i+i_p}[z_T^k] {\:}_i^k {\mathbb{S}_u}_{i_p}^{k_p} (\rho) \\
-  = +\fractext{1}{4} g{A_e}_i^k{\: }{b_u}_{i+i_p}^k
-  \left({_i^k\mathbb{R}_{i_p}^{k_p}}+\frac{\delta_{i+i_p}[z_T^k]}{{e_{1u}}_{\,i + i_p}^{\,k}}\right)^2
-  \frac{-\alpha_i^k \delta_{k+ k_p}[T^i]+ \beta_i^k\delta_{k+ k_p}[S^i]} {{e_{3w}}_{\,i}^{\,k+k_p}}.
-\end{multline*}
-Where the fluid is stable, with $-\alpha_i^k \delta_{k+ k_p}[T^i]+
-\beta_i^k\delta_{k+ k_p}[S^i]<0$, this PE change is negative.
-
-\subsection{Treatment of the triads at the boundaries}
-\label{sec:skew_bdry}
-
-Triad slopes \rtriadt{R} used for the calculation of the eddy-induced skew-fluxes are masked at the boundaries 
-in exactly the same way as are the triad slopes \rtriad{R} used for the iso-neutral diffusive fluxes, 
-as described in \autoref{sec:iso_bdry} and \autoref{fig:bdry_triads}. 
-Thus surface layer triads $\triadt{i}{1}{R}{1/2}{-1/2}$ and $\triadt{i+1}{1}{R}{-1/2}{-1/2}$ are masked, 
-and both near bottom triad slopes $\triadt{i}{k}{R}{1/2}{1/2}$ and $\triadt{i+1}{k}{R}{-1/2}{1/2}$ are masked when 
-either of the $i,k+1$ or $i+1,k+1$ tracer points is masked, \ie the $i,k+1$ $u$-point is masked. 
-The namelist parameter \np{ln\_botmix\_triad} has no effect on the eddy-induced skew-fluxes.
-
-\subsection{Limiting of the slopes within the interior}
-\label{sec:limitskew}
-
-Presently, the iso-neutral slopes $\tilde{r}_i$ relative to geopotentials are limited to be less than $1/100$, 
-exactly as in calculating the iso-neutral diffusion, \S \autoref{sec:limit}. 
-Each individual triad \rtriadt{R} is so limited.
-
-\subsection{Tapering within the surface mixed layer}
-\label{sec:taperskew}
-
-The slopes $\tilde{r}_i$ relative to geopotentials (and thus the individual triads \rtriadt{R}) 
-are always tapered linearly from their value immediately below the mixed layer to zero at the surface 
-\autoref{eq:rmtilde}, as described in \autoref{sec:lintaper}. 
-This is option (c) of \autoref{fig:eiv_slp}. 
-This linear tapering for the slopes used to calculate the eddy-induced fluxes is unaffected by 
-the value of \np{ln\_triad\_iso}.
-
-The justification for this linear slope tapering is that, for $A_e$ that is constant or varies only in
-the horizontal (the most commonly used options in \NEMO: see \autoref{sec:LDF_coef}),
-it is equivalent to a horizontal eiv (eddy-induced velocity) that is uniform within the mixed layer
-\autoref{eq:eiv_v}.
-This ensures that the eiv velocities do not restratify the mixed layer \citep{treguier.held.ea_JPO97,danabasoglu.ferrari.ea_JC08}.
-Equivantly, in terms of the skew-flux formulation we use here,
-the linear slope tapering within the mixed-layer gives a linearly varying vertical flux,
-and so a tracer convergence uniform in depth
-(the horizontal flux convergence is relatively insignificant within the mixed-layer).
-
-\subsection{Streamfunction diagnostics}
-\label{sec:sfdiag}
-
-Where the namelist parameter \np{ln\_traldf\_gdia}\forcode{ = .true.},
-diagnosed mean eddy-induced velocities are output.
-Each time step, streamfunctions are calculated in the $i$-$k$ and $j$-$k$ planes at
-$uw$ (integer +1/2 $i$, integer $j$, integer +1/2 $k$) and $vw$ (integer $i$, integer +1/2 $j$, integer +1/2 $k$)
-points (see Table \autoref{tab:cell}) respectively.
-We follow \citep{griffies_bk04} and calculate the streamfunction at a given $uw$-point from
-the surrounding four triads according to:
-\[
-  % \label{eq:sfdiagi}
-  {\psi_1}_{i+1/2}^{k+1/2}={\fractext{1}{4}}\sum_{\substack{i_p,\,k_p}}
-  {A_e}_{i+1/2-i_p}^{k+1/2-k_p}\:\triadd{i+1/2-i_p}{k+1/2-k_p}{R}{i_p}{k_p}.
-\]
-The streamfunction $\psi_1$ is calculated similarly at $vw$ points.
-The eddy-induced velocities are then calculated from the straightforward discretisation of \autoref{eq:eiv_v}:
-\[
-  % \label{eq:eiv_v_discrete}
-  \begin{split}
-    {u^*}_{i+1/2}^{k} & = - \frac{1}{{e_{3u}}_{i}^{k}}\left({\psi_1}_{i+1/2}^{k+1/2}-{\psi_1}_{i+1/2}^{k+1/2}\right),   \\
-    {v^*}_{j+1/2}^{k} & = - \frac{1}{{e_{3v}}_{j}^{k}}\left({\psi_2}_{j+1/2}^{k+1/2}-{\psi_2}_{j+1/2}^{k+1/2}\right),   \\
-    {w^*}_{i,j}^{k+1/2} & =    \frac{1}{e_{1t}e_{2t}}\; \left\{
-      {e_{2u}}_{i+1/2}^{k+1/2} \,{\psi_1}_{i+1/2}^{k+1/2} -
-      {e_{2u}}_{i-1/2}^{k+1/2} \,{\psi_1}_{i-1/2}^{k+1/2} \right. + \\
-    \phantom{=} & \qquad\qquad\left. {e_{2v}}_{j+1/2}^{k+1/2} \,{\psi_2}_{j+1/2}^{k+1/2} - {e_{2v}}_{j-1/2}^{k+1/2} \,{\psi_2}_{j-1/2}^{k+1/2} \right\},
-  \end{split}
-\]
-
-\biblio
-
-\pindex
-
-\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_DOMAINcfg.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_DOMAINcfg.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_DOMAINcfg.tex	(revision 12143)
@@ -0,0 +1,534 @@
+\documentclass[../main/NEMO_manual]{subfiles}
+
+\begin{document}
+
+\chapter{A brief guide to the DOMAINcfg tool}
+\label{apdx:DOMCFG}
+
+%    {\em 4.0} & {\em Andrew Coward} & {\em Created at v4.0 from materials removed from chap\_DOM that are still relevant to the \forcode{DOMAINcfg} tool and which illustrate and explain the choices to be made by the user when setting up new domains }  \\
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+This appendix briefly describes some of the options available in the
+\forcode{DOMAINcfg} tool mentioned in \autoref{chap:DOM}.
+
+This tool will evolve into an independent utility with its own documentation but its
+current manifestation is mostly a wrapper for \NEMO\ \forcode{DOM} modules more aligned to
+those in the previous versions of \NEMO. These versions allowed the user to define some
+horizontal and vertical grids through additional namelist parameters. Explanations of
+these parameters are retained here for reference pending better documentation for
+\forcode{DOMAINcfg}. Please note that the namelist blocks named in this appendix refer to
+those read by \forcode{DOMAINcfg} via its own \forcode{namelist_ref} and
+\forcode{namelist_cfg} files. Although, due to their origins, these namelists share names
+with those used by \NEMO, they are not interchangeable and should be considered independent
+of those described elsewhere in this manual.
+
+%% =================================================================================================
+\section{Choice of horizontal grid}
+\label{sec:DOMCFG_hor}
+
+\begin{listing}
+  \nlst{namdom_domcfg}
+  \caption{\forcode{&namdom_domcfg}}
+  \label{lst:namdom_domcfg}
+\end{listing}
+
+The user has three options available in defining a horizontal grid, which involve the
+namelist variable \np{jphgr_mesh}{jphgr\_mesh} of the \nam{dom}{dom} (\texttt{DOMAINcfg} variant only)
+namelist.
+
+\begin{description}
+ \item [{\np{jphgr_mesh}{jphgr\_mesh}=0}]  The most general curvilinear orthogonal grids.
+  The coordinates and their first derivatives with respect to $i$ and $j$ are provided
+  in a input file (\ifile{coordinates}), read in \rou{hgr\_read} subroutine of the domhgr module.
+  This is now the only option available within \NEMO\ itself from v4.0 onwards.
+\item [{\np{jphgr_mesh}{jphgr\_mesh}=1 to 5}] A few simple analytical grids are provided (see below).
+  For other analytical grids, the \mdl{domhgr} module (\texttt{DOMAINcfg} variant) must be
+  modified by the user. In most cases, modifying the \mdl{usrdef\_hgr} module of \NEMO\ is
+  a better alternative since this is designed to allow simple analytical domains to be
+  configured and used without the need for external data files.
+\end{description}
+
+There are two simple cases of geographical grids on the sphere. With
+\np{jphgr_mesh}{jphgr\_mesh}=1, the grid (expressed in degrees) is regular in space,
+with grid sizes specified by parameters \np{ppe1_deg}{ppe1\_deg} and \np{ppe2_deg}{ppe2\_deg},
+respectively. Such a geographical grid can be very anisotropic at high latitudes
+because of the convergence of meridians (the zonal scale factors $e_1$
+become much smaller than the meridional scale factors $e_2$). The Mercator
+grid (\np{jphgr_mesh}{jphgr\_mesh}=4) avoids this anisotropy by refining the meridional scale
+factors in the same way as the zonal ones. In this case, meridional scale factors
+and latitudes are calculated analytically using the formulae appropriate for
+a Mercator projection, based on \np{ppe1_deg}{ppe1\_deg} which is a reference grid spacing
+at the equator (this applies even when the geographical equator is situated outside
+the model domain).
+
+In these two cases (\np{jphgr_mesh}{jphgr\_mesh}=1 or 4), the grid position is defined by the
+longitude and latitude of the south-westernmost point (\np{ppglamt0}
+and \np{ppgphi0}{ppgphi0}). Note that for the Mercator grid the user need only provide
+an approximate starting latitude: the real latitude will be recalculated analytically,
+in order to ensure that the equator corresponds to line passing through $t$-
+and $u$-points.
+
+Rectangular grids ignoring the spherical geometry are defined with
+\np{jphgr_mesh}{jphgr\_mesh} = 2, 3, 5. The domain is either an $f$-plane (\np{jphgr_mesh}{jphgr\_mesh} = 2,
+Coriolis factor is constant) or a beta-plane (\np{jphgr_mesh}{jphgr\_mesh} = 3, the Coriolis factor
+is linear in the $j$-direction). The grid size is uniform in meter in each direction,
+and given by the parameters \np{ppe1_m}{ppe1\_m} and \np{ppe2_m}{ppe2\_m} respectively.
+The zonal grid coordinate (\textit{glam} arrays) is in kilometers, starting at zero
+with the first $t$-point. The meridional coordinate (gphi. arrays) is in kilometers,
+and the second $t$-point corresponds to coordinate $gphit=0$. The input
+variable \np{ppglam0}{ppglam0} is ignored. \np{ppgphi0}{ppgphi0} is used to set the reference
+latitude for computation of the Coriolis parameter. In the case of the beta plane,
+\np{ppgphi0}{ppgphi0} corresponds to the center of the domain. Finally, the special case
+\np{jphgr_mesh}{jphgr\_mesh}=5 corresponds to a beta plane in a rotated domain for the
+GYRE configuration, representing a classical mid-latitude double gyre system.
+The rotation allows us to maximize the jet length relative to the gyre areas
+(and the number of grid points).
+
+%% =================================================================================================
+\section{Vertical grid}
+\label{sec:DOMCFG_vert}
+
+%% =================================================================================================
+\subsection{Vertical reference coordinate}
+\label{sec:DOMCFG_zref}
+
+\begin{figure}[!tb]
+  \centering
+  \includegraphics[width=0.66\textwidth]{DOMCFG_zgr}
+  \caption[DOMAINcfg: default vertical mesh for ORCA2]{
+    Default vertical mesh for ORCA2: 30 ocean levels (L30).
+    Vertical level functions for (a) T-point depth and (b) the associated scale factor for
+    the $z$-coordinate case.}
+  \label{fig:DOMCFG_zgr}
+\end{figure}
+
+The reference coordinate transformation $z_0(k)$ defines the arrays $gdept_0$ and
+$gdepw_0$ for $t$- and $w$-points, respectively. See \autoref{sec:DOMCFG_sco} for the
+S-coordinate options.  As indicated on \autoref{fig:DOM_index_vert} \jp{jpk} is the number of
+$w$-levels.  $gdepw_0(1)$ is the ocean surface.  There are at most \jp{jpk}-1 $t$-points
+inside the ocean, the additional $t$-point at $jk = jpk$ is below the sea floor and is not
+used.  The vertical location of $w$- and $t$-levels is defined from the analytic
+expression of the depth $z_0(k)$ whose analytical derivative with respect to $k$ provides
+the vertical scale factors.  The user must provide the analytical expression of both $z_0$
+and its first derivative with respect to $k$.  This is done in routine \mdl{domzgr}
+through statement functions, using parameters provided in the \nam{dom}{dom} namelist
+(\texttt{DOMAINcfg} variant).
+
+It is possible to define a simple regular vertical grid by giving zero stretching
+(\np[=0]{ppacr}{ppacr}).  In that case, the parameters \jp{jpk} (number of $w$-levels)
+and \np{pphmax}{pphmax} (total ocean depth in meters) fully define the grid.
+
+For climate-related studies it is often desirable to concentrate the vertical resolution
+near the ocean surface.  The following function is proposed as a standard for a
+$z$-coordinate (with either full or partial steps):
+\begin{gather}
+  \label{eq:DOMCFG_zgr_ana_1}
+    z_0  (k) = h_{sur} - h_0 \; k - \; h_1 \; \log  \big[ \cosh ((k - h_{th}) / h_{cr}) \big] \\
+    e_3^0(k) = \lt|    - h_0      -    h_1 \; \tanh \big[        (k - h_{th}) / h_{cr}  \big] \rt|
+\end{gather}
+
+where $k = 1$ to \jp{jpk} for $w$-levels and $k = 1$ to $k = 1$ for $t-$levels.  Such an
+expression allows us to define a nearly uniform vertical location of levels at the ocean
+top and bottom with a smooth hyperbolic tangent transition in between (\autoref{fig:DOMCFG_zgr}).
+
+A double hyperbolic tangent version (\np[=.true.]{ldbletanh}{ldbletanh}) is also available
+which permits finer control and is used, typically, to obtain a well resolved upper ocean
+without compromising on resolution at depth using a moderate number of levels.
+
+\begin{gather}
+  \label{eq:DOMCFG_zgr_ana_1b}
+    \begin{split}
+    z_0  (k) = h_{sur} - h_0 \; k &- \; h_1 \; \log  \big[ \cosh ((k - h_{th}) / h_{cr}) \big] \\
+                             \;   &- \; h2_1 \; \log  \big[ \cosh ((k - h2_{th}) / h2_{cr}) \big]
+    \end{split}
+\end{gather}
+\begin{gather}
+    \begin{split}
+    e_3^0(k) = \big|    - h_0    &-   h_1 \; \tanh \big[       (k - h_{th})  / h_{cr}   \big]  \\
+                                 &-  h2_1 \; \tanh \big[       (k - h2_{th}) / h2_{cr}  \big] \big|
+    \end{split}
+\end{gather}
+
+If the ice shelf cavities are opened (\np[=.true.]{ln_isfcav}{ln\_isfcav}), the definition
+of $z_0$ is the same.  However, definition of $e_3^0$ at $t$- and $w$-points is
+respectively changed to:
+\begin{equation}
+  \label{eq:DOMCFG_zgr_ana_2}
+  \begin{split}
+    e_3^T(k) &= z_W (k + 1) - z_W (k    ) \\
+    e_3^W(k) &= z_T (k    ) - z_T (k - 1)
+  \end{split}
+\end{equation}
+
+This formulation decreases the self-generated circulation into the ice shelf cavity
+(which can, in extreme case, leads to numerical instability). This is now the recommended formulation for all configurations using v4.0 onwards. The analytical derivation of thicknesses is maintained for backwards compatibility.
+
+The most used vertical grid for ORCA2 has $10~m$ ($500~m$) resolution in the surface
+(bottom) layers and a depth which varies from 0 at the sea surface to a minimum of
+$-5000~m$.  This leads to the following conditions:
+
+\begin{equation}
+  \label{eq:DOMCFG_zgr_coef}
+  \begin{array}{ll}
+    e_3 (1   + 1/2) =  10. & z(1  ) =     0. \\
+    e_3 (jpk - 1/2) = 500. & z(jpk) = -5000.
+  \end{array}
+\end{equation}
+
+With the choice of the stretching $h_{cr} = 3$ and the number of levels \jp{jpk}~$= 31$,
+the four coefficients $h_{sur}$, $h_0$, $h_1$, and $h_{th}$ in
+\autoref{eq:DOMCFG_zgr_ana_2} have been determined such that \autoref{eq:DOMCFG_zgr_coef}
+is satisfied, through an optimisation procedure using a bisection method.
+For the first standard ORCA2 vertical grid this led to the following values:
+$h_{sur} = 4762.96$, $h_0 = 255.58, h_1 = 245.5813$, and $h_{th} = 21.43336$.
+The resulting depths and scale factors as a function of the model levels are shown in
+\autoref{fig:DOMCFG_zgr} and given in \autoref{tab:DOMCFG_orca_zgr}.
+Those values correspond to the parameters \np{ppsur}{ppsur}, \np{ppa0}{ppa0}, \np{ppa1}{ppa1}, \np{ppkth}{ppkth} in \nam{cfg}{cfg} namelist.
+
+Rather than entering parameters $h_{sur}$, $h_0$, and $h_1$ directly, it is possible to
+recalculate them.  In that case the user sets \np{ppsur}{ppsur}~$=$~\np{ppa0}{ppa0}~$=$~\np{ppa1}{ppa1}~$=
+999999$., in \nam{cfg}{cfg} namelist, and specifies instead the four following parameters:
+\begin{itemize}
+\item \np{ppacr}{ppacr}~$= h_{cr}$: stretching factor (nondimensional).
+  The larger \np{ppacr}{ppacr}, the smaller the stretching.
+  Values from $3$ to $10$ are usual.
+\item \np{ppkth}{ppkth}~$= h_{th}$: is approximately the model level at which maximum stretching occurs
+  (nondimensional, usually of order 1/2 or 2/3 of \jp{jpk})
+\item \np{ppdzmin}{ppdzmin}: minimum thickness for the top layer (in meters).
+\item \np{pphmax}{pphmax}: total depth of the ocean (meters).
+\end{itemize}
+
+As an example, for the $45$ layers used in the DRAKKAR configuration those parameters are:
+\jp{jpk}~$= 46$, \np{ppacr}{ppacr}~$= 9$, \np{ppkth}{ppkth}~$= 23.563$, \np{ppdzmin}{ppdzmin}~$= 6~m$,
+\np{pphmax}{pphmax}~$= 5750~m$.
+
+\begin{table}
+  \centering
+  \begin{tabular}{c||r|r|r|r}
+    \hline
+    \textbf{LEVEL} & \textbf{gdept\_1d} & \textbf{gdepw\_1d} & \textbf{e3t\_1d } & \textbf{e3w\_1d} \\
+    \hline
+    1              & \textbf{     5.00} &               0.00 & \textbf{   10.00} &            10.00 \\
+    \hline
+    2              & \textbf{    15.00} &              10.00 & \textbf{   10.00} &            10.00 \\
+    \hline
+    3              & \textbf{    25.00} &              20.00 & \textbf{   10.00} &            10.00 \\
+    \hline
+    4              & \textbf{    35.01} &              30.00 & \textbf{   10.01} &            10.00 \\
+    \hline
+    5              & \textbf{    45.01} &              40.01 & \textbf{   10.01} &            10.01 \\
+    \hline
+    6              & \textbf{    55.03} &              50.02 & \textbf{   10.02} &            10.02 \\
+    \hline
+    7              & \textbf{    65.06} &              60.04 & \textbf{   10.04} &            10.03 \\
+    \hline
+    8              & \textbf{    75.13} &              70.09 & \textbf{   10.09} &            10.06 \\
+    \hline
+    9              & \textbf{    85.25} &              80.18 & \textbf{   10.17} &            10.12 \\
+    \hline
+    10             & \textbf{    95.49} &              90.35 & \textbf{   10.33} &            10.24 \\
+    \hline
+    11             & \textbf{   105.97} &             100.69 & \textbf{   10.65} &            10.47 \\
+    \hline
+    12             & \textbf{   116.90} &             111.36 & \textbf{   11.27} &            10.91 \\
+    \hline
+    13             & \textbf{   128.70} &             122.65 & \textbf{   12.47} &            11.77 \\
+    \hline
+    14             & \textbf{   142.20} &             135.16 & \textbf{   14.78} &            13.43 \\
+    \hline
+    15             & \textbf{   158.96} &             150.03 & \textbf{   19.23} &            16.65 \\
+    \hline
+    16             & \textbf{   181.96} &             169.42 & \textbf{   27.66} &            22.78 \\
+    \hline
+    17             & \textbf{   216.65} &             197.37 & \textbf{   43.26} &            34.30 \\
+    \hline
+    18             & \textbf{   272.48} &             241.13 & \textbf{   70.88} &            55.21 \\
+    \hline
+    19             & \textbf{   364.30} &             312.74 & \textbf{  116.11} &            90.99 \\
+    \hline
+    20             & \textbf{   511.53} &             429.72 & \textbf{  181.55} &           146.43 \\
+    \hline
+    21             & \textbf{   732.20} &             611.89 & \textbf{  261.03} &           220.35 \\
+    \hline
+    22             & \textbf{  1033.22} &             872.87 & \textbf{  339.39} &           301.42 \\
+    \hline
+    23             & \textbf{  1405.70} &            1211.59 & \textbf{  402.26} &           373.31 \\
+    \hline
+    24             & \textbf{  1830.89} &            1612.98 & \textbf{  444.87} &           426.00 \\
+    \hline
+    25             & \textbf{  2289.77} &            2057.13 & \textbf{  470.55} &           459.47 \\
+    \hline
+    26             & \textbf{  2768.24} &            2527.22 & \textbf{  484.95} &           478.83 \\
+    \hline
+    27             & \textbf{  3257.48} &            3011.90 & \textbf{  492.70} &           489.44 \\
+    \hline
+    28             & \textbf{  3752.44} &            3504.46 & \textbf{  496.78} &           495.07 \\
+    \hline
+    29             & \textbf{  4250.40} &            4001.16 & \textbf{  498.90} &           498.02 \\
+    \hline
+    30             & \textbf{  4749.91} &            4500.02 & \textbf{  500.00} &           499.54 \\
+    \hline
+    31             & \textbf{  5250.23} &            5000.00 & \textbf{  500.56} &           500.33 \\
+    \hline
+  \end{tabular}
+  \caption[Default vertical mesh in $z$-coordinate for 30 layers ORCA2 configuration]{
+    Default vertical mesh in $z$-coordinate for 30 layers ORCA2 configuration as
+    computed from \autoref{eq:DOMCFG_zgr_ana_2} using
+    the coefficients given in \autoref{eq:DOMCFG_zgr_coef}}
+  \label{tab:DOMCFG_orca_zgr}
+\end{table}
+%%%YY
+%% % -------------------------------------------------------------------------------------------------------------
+%% %        Meter Bathymetry
+%% % -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
+\subsection{Model bathymetry}
+\label{subsec:DOMCFG_bathy}
+
+Three options are possible for defining the bathymetry, according to the namelist variable
+\np{nn_bathy}{nn\_bathy} (found in \nam{dom}{dom} namelist (\texttt{DOMAINCFG} variant) ):
+\begin{description}
+\item [{\np[=0]{nn_bathy}{nn\_bathy}}]: a flat-bottom domain is defined.
+  The total depth $z_w (jpk)$ is given by the coordinate transformation.
+  The domain can either be a closed basin or a periodic channel depending on the parameter \np{jperio}{jperio}.
+\item [{\np[=-1]{nn_bathy}{nn\_bathy}}]: a domain with a bump of topography one third of the domain width at the central latitude.
+  This is meant for the "EEL-R5" configuration, a periodic or open boundary channel with a seamount.
+\item [{\np[=1]{nn_bathy}{nn\_bathy}}]: read a bathymetry and ice shelf draft (if needed).
+  The \ifile{bathy\_meter} file (Netcdf format) provides the ocean depth (positive, in meters) at
+  each grid point of the model grid.
+  The bathymetry is usually built by interpolating a standard bathymetry product (\eg\ ETOPO2) onto
+  the horizontal ocean mesh.
+  Defining the bathymetry also defines the coastline: where the bathymetry is zero,
+  no wet levels are defined (all levels are masked).
+
+  The \ifile{isfdraft\_meter} file (Netcdf format) provides the ice shelf draft (positive, in meters) at
+  each grid point of the model grid.
+  This file is only needed if \np[=.true.]{ln_isfcav}{ln\_isfcav}.
+  Defining the ice shelf draft will also define the ice shelf edge and the grounding line position.
+\end{description}
+
+%% =================================================================================================
+\subsection{Choice of vertical grid}
+\label{sec:DOMCFG_vgrd}
+
+After reading the bathymetry, the algorithm for vertical grid definition differs between the different options:
+\begin{description}
+\item [\forcode{ln_zco = .true.}] set a reference coordinate transformation $z_0(k)$, and set $z(i,j,k,t) = z_0(k)$ where $z_0(k)$ is the closest match to the depth at $(i,j)$.
+\item [\forcode{ln_zps = .true.}] set a reference coordinate transformation $z_0(k)$, and calculate the thickness of the deepest level at
+  each $(i,j)$ point using the bathymetry, to obtain the final three-dimensional depth and scale factor arrays.
+\item [\forcode{ln_sco = .true.}] smooth the bathymetry to fulfill the hydrostatic consistency criteria and
+  set the three-dimensional transformation.
+\item [\forcode{s-z and s-zps}] smooth the bathymetry to fulfill the hydrostatic consistency criteria and
+  set the three-dimensional transformation $z(i,j,k)$,
+  and possibly introduce masking of extra land points to better fit the original bathymetry file.
+\end{description}
+
+%% =================================================================================================
+\subsubsection[$Z$-coordinate with uniform thickness levels (\forcode{ln_zco})]{$Z$-coordinate with uniform thickness levels (\protect\np{ln_zco}{ln\_zco})}
+\label{subsec:DOMCFG_zco}
+
+With this option the model topography can be fully described by the reference vertical
+coordinate and a 2D integer field giving the number of wet levels at each location
+(\forcode{bathy_level}). The resulting match to the real topography is likely to be poor
+though (especially with thick, deep levels) and slopes poorly represented. This option is
+rarely used in modern simulations but it can be useful for testing purposes.
+
+%% =================================================================================================
+\subsubsection[$Z$-coordinate with partial step (\forcode{ln_zps})]{$Z$-coordinate with partial step (\protect\np{ln_zps}{ln\_zps})}
+\label{subsec:DOMCFG_zps}
+
+In $z$-coordinate partial step, the depths of the model levels are defined by the
+reference analytical function $z_0(k)$ as described in \autoref{sec:DOMCFG_zref},
+\textit{except} in the bottom layer.  The thickness of the bottom layer is allowed to vary
+as a function of geographical location $(\lambda,\varphi)$ to allow a better
+representation of the bathymetry, especially in the case of small slopes (where the
+bathymetry varies by less than one level thickness from one grid point to the next).  The
+reference layer thicknesses $e_{3t}^0$ have been defined in the absence of bathymetry.
+With partial steps, layers from 1 to \jp{jpk}-2 can have a thickness smaller than
+$e_{3t}(jk)$.
+
+The model deepest layer (\jp{jpk}-1) is allowed to have either a smaller or larger
+thickness than $e_{3t}(jpk)$: the maximum thickness allowed is $2*e_{3t}(jpk - 1)$.
+
+This has to be kept in mind when specifying values in \nam{dom}{dom} namelist
+(\texttt{DOMAINCFG} variant), such as the maximum depth \np{pphmax}{pphmax} in partial steps.
+
+For example, with \np{pphmax}{pphmax}~$= 5750~m$ for the DRAKKAR 45 layer grid, the maximum ocean
+depth allowed is actually $6000~m$ (the default thickness $e_{3t}(jpk - 1)$ being
+$250~m$).  Two variables in the namdom namelist are used to define the partial step
+vertical grid.  The mimimum water thickness (in meters) allowed for a cell partially
+filled with bathymetry at level jk is the minimum of \np{rn_e3zps_min}{rn\_e3zps\_min} (thickness in
+meters, usually $20~m$) or $e_{3t}(jk)*$\np{rn_e3zps_rat}{rn\_e3zps\_rat} (a fraction, usually 10\%, of
+the default thickness $e_{3t}(jk)$).
+
+%% =================================================================================================
+\subsubsection[$S$-coordinate (\forcode{ln_sco})]{$S$-coordinate (\protect\np{ln_sco}{ln\_sco})}
+\label{sec:DOMCFG_sco}
+\begin{listing}
+  \nlst{namzgr_sco_domcfg}
+  \caption{\forcode{&namzgr_sco_domcfg}}
+  \label{lst:namzgr_sco_domcfg}
+\end{listing}
+Options are defined in \nam{zgr_sco}{zgr\_sco} (\texttt{DOMAINcfg} only).
+In $s$-coordinate (\np[=.true.]{ln_sco}{ln\_sco}), the depth and thickness of the model levels are defined from
+the product of a depth field and either a stretching function or its derivative, respectively:
+
+\begin{align*}
+  % \label{eq:DOMCFG_sco_ana}
+  z(k)   &= h(i,j) \; z_0 (k) \\
+  e_3(k) &= h(i,j) \; z_0'(k)
+\end{align*}
+
+where $h$ is the depth of the last $w$-level ($z_0(k)$) defined at the $t$-point location in the horizontal and
+$z_0(k)$ is a function which varies from $0$ at the sea surface to $1$ at the ocean bottom.
+The depth field $h$ is not necessary the ocean depth,
+since a mixed step-like and bottom-following representation of the topography can be used
+(\autoref{fig:DOM_z_zps_s_sps}) or an envelop bathymetry can be defined (\autoref{fig:DOM_z_zps_s_sps}).
+The namelist parameter \np{rn_rmax}{rn\_rmax} determines the slope at which
+the terrain-following coordinate intersects the sea bed and becomes a pseudo z-coordinate.
+The coordinate can also be hybridised by specifying \np{rn_sbot_min}{rn\_sbot\_min} and \np{rn_sbot_max}{rn\_sbot\_max} as
+the minimum and maximum depths at which the terrain-following vertical coordinate is calculated.
+
+Options for stretching the coordinate are provided as examples,
+but care must be taken to ensure that the vertical stretch used is appropriate for the application.
+
+The original default \NEMO\ s-coordinate stretching is available if neither of the other options are specified as true
+(\np[=.false.]{ln_s_SH94}{ln\_s\_SH94} and \np[=.false.]{ln_s_SF12}{ln\_s\_SF12}).
+This uses a depth independent $\tanh$ function for the stretching \citep{madec.delecluse.ea_JPO96}:
+
+\[
+  z = s_{min} + C (s) (H - s_{min})
+  % \label{eq:DOMCFG_SH94_1}
+\]
+
+where $s_{min}$ is the depth at which the $s$-coordinate stretching starts and
+allows a $z$-coordinate to placed on top of the stretched coordinate,
+and $z$ is the depth (negative down from the asea surface).
+\begin{gather*}
+  s = - \frac{k}{n - 1} \quad \text{and} \quad 0 \leq k \leq n - 1
+  % \label{eq:DOMCFG_s}
+ \\
+ \label{eq:DOMCFG_sco_function}
+  C(s) = \frac{[\tanh(\theta \, (s + b)) - \tanh(\theta \, b)]}{2 \; \sinh(\theta)}
+\end{gather*}
+
+A stretching function,
+modified from the commonly used \citet{song.haidvogel_JCP94} stretching (\np[=.true.]{ln_s_SH94}{ln\_s\_SH94}),
+is also available and is more commonly used for shelf seas modelling:
+
+\[
+  C(s) =   (1 - b) \frac{\sinh(\theta s)}{\sinh(\theta)}
+         + b       \frac{\tanh \lt[ \theta \lt(s + \frac{1}{2} \rt) \rt] -   \tanh \lt( \frac{\theta}{2} \rt)}
+                        {                                                  2 \tanh \lt( \frac{\theta}{2} \rt)}
+ \label{eq:DOMCFG_SH94_2}
+\]
+
+\begin{figure}[!ht]
+  \centering
+  \includegraphics[width=0.66\textwidth]{DOMCFG_sco_function}
+  \caption[DOMAINcfg: examples of the stretching function applied to a seamount]{
+    Examples of the stretching function applied to a seamount;
+    from left to right: surface, surface and bottom, and bottom intensified resolutions}
+  \label{fig:DOMCFG_sco_function}
+\end{figure}
+
+where $H_c$ is the critical depth (\np{rn_hc}{rn\_hc}) at which the coordinate transitions from pure $\sigma$ to
+the stretched coordinate, and $\theta$ (\np{rn_theta}{rn\_theta}) and $b$ (\np{rn_bb}{rn\_bb}) are the surface and
+bottom control parameters such that $0 \leqslant \theta \leqslant 20$, and $0 \leqslant b \leqslant 1$.
+$b$ has been designed to allow surface and/or bottom increase of the vertical resolution
+(\autoref{fig:DOMCFG_sco_function}).
+
+Another example has been provided at version 3.5 (\np{ln_s_SF12}{ln\_s\_SF12}) that allows a fixed surface resolution in
+an analytical terrain-following stretching \citet{siddorn.furner_OM13}.
+In this case the a stretching function $\gamma$ is defined such that:
+
+\begin{equation}
+  z = - \gamma h \quad \text{with} \quad 0 \leq \gamma \leq 1
+  % \label{eq:DOMCFG_z}
+\end{equation}
+
+The function is defined with respect to $\sigma$, the unstretched terrain-following coordinate:
+
+\begin{gather*}
+  % \label{eq:DOMCFG_gamma_deriv}
+  \gamma =   A \lt( \sigma   - \frac{1}{2} (\sigma^2     + f (\sigma)) \rt)
+           + B \lt( \sigma^3 - f           (\sigma) \rt) + f (\sigma)       \\
+  \intertext{Where:}
+ \label{eq:DOMCFG_gamma}
+  f(\sigma) = (\alpha + 2) \sigma^{\alpha + 1} - (\alpha + 1) \sigma^{\alpha + 2}
+  \quad \text{and} \quad \sigma = \frac{k}{n - 1}
+\end{gather*}
+
+This gives an analytical stretching of $\sigma$ that is solvable in $A$ and $B$ as a function of
+the user prescribed stretching parameter $\alpha$ (\np{rn_alpha}{rn\_alpha}) that stretches towards
+the surface ($\alpha > 1.0$) or the bottom ($\alpha < 1.0$) and
+user prescribed surface (\np{rn_zs}{rn\_zs}) and bottom depths.
+The bottom cell depth in this example is given as a function of water depth:
+
+\[
+  % \label{eq:DOMCFG_zb}
+  Z_b = h a + b
+\]
+
+where the namelist parameters \np{rn_zb_a}{rn\_zb\_a} and \np{rn_zb_b}{rn\_zb\_b} are $a$ and $b$ respectively.
+
+\begin{figure}[!ht]
+  \centering
+  \includegraphics[width=0.66\textwidth]{DOMCFG_compare_coordinates_surface}
+  \caption[DOMAINcfg: comparison of $s$- and $z$-coordinate]{
+    A comparison of the \citet{song.haidvogel_JCP94} $S$-coordinate (solid lines),
+    a 50 level $Z$-coordinate (contoured surfaces) and
+    the \citet{siddorn.furner_OM13} $S$-coordinate (dashed lines) in the surface $100~m$ for
+    a idealised bathymetry that goes from $50~m$ to $5500~m$ depth.
+    For clarity every third coordinate surface is shown.}
+  \label{fig:DOMCFG_fig_compare_coordinates_surface}
+\end{figure}
+ % >>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+This gives a smooth analytical stretching in computational space that is constrained to
+given specified surface and bottom grid cell thicknesses in real space.
+This is not to be confused with the hybrid schemes that
+superimpose geopotential coordinates on terrain following coordinates thus
+creating a non-analytical vertical coordinate that
+therefore may suffer from large gradients in the vertical resolutions.
+This stretching is less straightforward to implement than the \citet{song.haidvogel_JCP94} stretching,
+but has the advantage of resolving diurnal processes in deep water and has generally flatter slopes.
+
+As with the \citet{song.haidvogel_JCP94} stretching the stretch is only applied at depths greater than
+the critical depth $h_c$.
+In this example two options are available in depths shallower than $h_c$,
+with pure sigma being applied if the \np{ln_sigcrit}{ln\_sigcrit} is true and pure z-coordinates if it is false
+(the z-coordinate being equal to the depths of the stretched coordinate at $h_c$).
+
+Minimising the horizontal slope of the vertical coordinate is important in terrain-following systems as
+large slopes lead to hydrostatic consistency.
+A hydrostatic consistency parameter diagnostic following \citet{haney_JPO91} has been implemented,
+and is output as part of the model mesh file at the start of the run.
+
+%% =================================================================================================
+\subsubsection[\zstar- or \sstar-coordinate (\forcode{ln_linssh})]{\zstar- or \sstar-coordinate (\protect\np{ln_linssh}{ln\_linssh})}
+\label{subsec:DOMCFG_zgr_star}
+
+This option is described in the Report by Levier \textit{et al.} (2007), available on the \NEMO\ web site.
+
+\subinc{\input{../../global/epilogue}}
+
+\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_algos.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_algos.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_algos.tex	(revision 12143)
@@ -0,0 +1,825 @@
+\documentclass[../main/NEMO_manual]{subfiles}
+
+\begin{document}
+
+\chapter{Note on some algorithms}
+\label{apdx:ALGOS}
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+This appendix some on going consideration on algorithms used or planned to be used in \NEMO.
+
+%% =================================================================================================
+\section{Upstream Biased Scheme (UBS) (\protect\np[=.true.]{ln_traadv_ubs}{ln\_traadv\_ubs})}
+\label{sec:ALGOS_tra_adv_ubs}
+
+The UBS advection scheme is an upstream biased third order scheme based on
+an upstream-biased parabolic interpolation.
+It is also known as Cell Averaged QUICK scheme (Quadratic Upstream Interpolation for Convective Kinematics).
+For example, in the $i$-direction:
+\begin{equation}
+  \label{eq:ALGOS_tra_adv_ubs2}
+  \tau_u^{ubs} = \left\{
+	 \begin{aligned}
+      & \tau_u^{cen4} + \frac{1}{12} \,\tau"_i	   & \quad \text{if }\ u_{i+1/2} \geqslant 0 \\
+      & \tau_u^{cen4} - \frac{1}{12} \,\tau"_{i+1} & \quad \text{if }\ u_{i+1/2}       <       0
+    \end{aligned}
+  \right.
+\end{equation}
+or equivalently, the advective flux is
+\begin{equation}
+  \label{eq:ALGOS_tra_adv_ubs2}
+  U_{i+1/2} \ \tau_u^{ubs}
+  =U_{i+1/2} \ \overline{ T_i - \frac{1}{6}\,\tau"_i }^{\,i+1/2}
+  - \frac{1}{2}\, |U|_{i+1/2} \;\frac{1}{6} \;\delta_{i+1/2}[\tau"_i]
+\end{equation}
+where $U_{i+1/2} = e_{1u}\,e_{3u}\,u_{i+1/2}$ and
+$\tau "_i =\delta_i \left[ {\delta_{i+1/2} \left[ \tau \right]} \right]$.
+By choosing this expression for $\tau "$ we consider a fourth order approximation of $\partial_i^2$ with
+a constant i-grid spacing ($\Delta i=1$).
+
+Alternative choice: introduce the scale factors:
+$\tau "_i =\frac{e_{1T}}{e_{2T}\,e_{3T}}\delta_i \left[ \frac{e_{2u} e_{3u} }{e_{1u} }\delta_{i+1/2}[\tau] \right]$.
+
+This results in a dissipatively dominant (\ie\ hyper-diffusive) truncation error
+\citep{shchepetkin.mcwilliams_OM05}.
+The overall performance of the advection scheme is similar to that reported in \cite{farrow.stevens_JPO95}.
+It is a relatively good compromise between accuracy and smoothness.
+It is not a \emph{positive} scheme meaning false extrema are permitted but
+the amplitude of such are significantly reduced over the centred second order method.
+Nevertheless it is not recommended to apply it to a passive tracer that requires positivity.
+
+The intrinsic diffusion of UBS makes its use risky in the vertical direction where
+the control of artificial diapycnal fluxes is of paramount importance.
+It has therefore been preferred to evaluate the vertical flux using the TVD scheme when
+\np[=.true.]{ln_traadv_ubs}{ln\_traadv\_ubs}.
+
+For stability reasons, in \autoref{eq:TRA_adv_ubs}, the first term which corresponds to
+a second order centred scheme is evaluated using the \textit{now} velocity (centred in time) while
+the second term which is the diffusive part of the scheme, is evaluated using the \textit{before} velocity
+(forward in time).
+This is discussed by \citet{webb.de-cuevas.ea_JAOT98} in the context of the Quick advection scheme.
+UBS and QUICK schemes only differ by one coefficient.
+Substituting 1/6 with 1/8 in (\autoref{eq:TRA_adv_ubs}) leads to the QUICK advection scheme \citep{webb.de-cuevas.ea_JAOT98}.
+This option is not available through a namelist parameter, since the 1/6 coefficient is hard coded.
+Nevertheless it is quite easy to make the substitution in \mdl{traadv\_ubs} module and obtain a QUICK scheme.
+
+NB 1: When a high vertical resolution $O(1m)$ is used, the model stability can be controlled by vertical advection
+(not vertical diffusion which is usually solved using an implicit scheme).
+Computer time can be saved by using a time-splitting technique on vertical advection.
+This possibility have been implemented and validated in ORCA05-L301.
+It is not currently offered in the current reference version.
+
+NB 2: In a forthcoming release four options will be proposed for the vertical component used in the UBS scheme.
+$\tau_w^{ubs}$ will be evaluated using either \textit{(a)} a centered $2^{nd}$ order scheme,
+or \textit{(b)} a TVD scheme, or \textit{(c)} an interpolation based on conservative parabolic splines following
+\citet{shchepetkin.mcwilliams_OM05} implementation of UBS in ROMS, or \textit{(d)} an UBS.
+The $3^{rd}$ case has dispersion properties similar to an eight-order accurate conventional scheme.
+
+NB 3: It is straight forward to rewrite \autoref{eq:TRA_adv_ubs} as follows:
+\begin{equation}
+  \label{eq:ALGOS_tra_adv_ubs2}
+  \tau_u^{ubs} = \left\{
+	 \begin{aligned}
+      & \tau_u^{cen4} + \frac{1}{12} \tau"_i		& \quad \text{if }\ u_{i+1/2} \geqslant 0 \\
+      & \tau_u^{cen4} - \frac{1}{12} \tau"_{i+1}	& \quad \text{if }\ u_{i+1/2}       <       0
+    \end{aligned}
+  \right.
+\end{equation}
+or equivalently
+\begin{equation}
+  \label{eq:ALGOS_tra_adv_ubs2}
+  \begin{split}
+    e_{2u} e_{3u}\,u_{i+1/2} \ \tau_u^{ubs}
+    &= e_{2u} e_{3u}\,u_{i+1/2} \ \overline{ T - \frac{1}{6}\,\tau"_i }^{\,i+1/2} \\
+    & - \frac{1}{2} e_{2u} e_{3u}\,|u|_{i+1/2} \;\frac{1}{6} \;\delta_{i+1/2}[\tau"_i]
+  \end{split}
+\end{equation}
+\autoref{eq:TRA_adv_ubs2} has several advantages.
+First it clearly evidences that the UBS scheme is based on the fourth order scheme to which
+is added an upstream biased diffusive term.
+Second, this emphasises that the $4^{th}$ order part have to be evaluated at \emph{now} time step,
+not only the $2^{th}$ order part as stated above using \autoref{eq:TRA_adv_ubs}.
+Third, the diffusive term is in fact a biharmonic operator with a eddy coefficient which
+is simply proportional to the velocity.
+
+laplacian diffusion:
+\begin{equation}
+  \label{eq:ALGOS_tra_ldf_lap}
+  \begin{split}
+    D_T^{lT} =\frac{1}{e_{1T} \; e_{2T}\;  e_{3T} } &\left[ {\quad \delta_i
+        \left[ {A_u^{lT} \frac{e_{2u} e_{3u} }{e_{1u} }\;\delta_{i+1/2}
+            \left[ T \right]} \right]} \right. \\
+    &\ \left. {+\; \delta_j \left[
+          {A_v^{lT} \left( {\frac{e_{1v} e_{3v} }{e_{2v} }\;\delta_{j+1/2} \left[ T
+                \right]} \right)} \right]\quad } \right]
+  \end{split}
+\end{equation}
+
+bilaplacian:
+\begin{equation}
+  \label{eq:ALGOS_tra_ldf_lap}
+  \begin{split}
+    D_T^{lT} =&-\frac{1}{e_{1T} \; e_{2T}\;  e_{3T}} \\
+    & \delta_i \left[  \sqrt{A_u^{lT}}\ \frac{e_{2u}\,e_{3u}}{e_{1u}}\;\delta_{i+1/2}
+      \left[ \frac{1}{e_{1T}\,e_{2T}\, e_{3T}}
+        \delta_i \left[ \sqrt{A_u^{lT}}\ \frac{e_{2u}\,e_{3u}}{e_{1u}}\;\delta_{i+1/2}
+          [T] \right] \right] \right]
+  \end{split}
+\end{equation}
+with ${A_u^{lT}}^2 = \frac{1}{12} {e_{1u}}^3\ |u|$,
+\ie\ $A_u^{lT} = \frac{1}{\sqrt{12}} \,e_{1u}\ \sqrt{ e_{1u}\,|u|\,}$
+it comes:
+\begin{equation}
+  \label{eq:ALGOS_tra_ldf_lap}
+  \begin{split}
+    D_T^{lT} =&-\frac{1}{12}\,\frac{1}{e_{1T} \; e_{2T}\;  e_{3T}} \\
+    & \delta_i \left[ e_{2u}\,e_{3u}\,\sqrt{ e_{1u}\,|u|\,}\;\delta_{i+1/2}
+      \left[ \frac{1}{e_{1T}\,e_{2T}\, e_{3T}}
+        \delta_i \left[ e_{2u}\,e_{3u}\,\sqrt{ e_{1u}\,|u|\,}\;\delta_{i+1/2}
+          [T] \right] \right] \right]
+  \end{split}
+\end{equation}
+if the velocity is uniform (\ie\ $|u|=cst$) then the diffusive flux is
+\begin{equation}
+  \label{eq:ALGOS_tra_ldf_lap}
+  \begin{split}
+    F_u^{lT} = - \frac{1}{12}
+    e_{2u}\,e_{3u}\,|u| \;\sqrt{ e_{1u}}\,\delta_{i+1/2}
+    \left[ \frac{1}{e_{1T}\,e_{2T}\, e_{3T}}
+      \delta_i \left[ e_{2u}\,e_{3u}\,\sqrt{ e_{1u}}\:\delta_{i+1/2}
+        [T] \right] \right]
+  \end{split}
+\end{equation}
+beurk....  reverte the logic: starting from the diffusive part of the advective flux it comes:
+
+\begin{equation}
+  \label{eq:ALGOS_tra_adv_ubs2}
+  \begin{split}
+    F_u^{lT} &= - \frac{1}{2} e_{2u} e_{3u}\,|u|_{i+1/2} \;\frac{1}{6} \;\delta_{i+1/2}[\tau"_i]
+  \end{split}
+\end{equation}
+if the velocity is uniform (\ie\ $|u|=cst$) and
+choosing $\tau "_i =\frac{e_{1T}}{e_{2T}\,e_{3T}}\delta_i \left[ \frac{e_{2u} e_{3u} }{e_{1u} } \delta_{i+1/2}[\tau] \right]$
+
+sol 1 coefficient at T-point ( add $e_{1u}$ and $e_{1T}$ on both side of first $\delta$):
+\begin{equation}
+  \label{eq:ALGOS_tra_adv_ubs2}
+  \begin{split}
+    F_u^{lT} &= - \frac{1}{12} \frac{e_{2u} e_{3u}}{e_{1u}}\;\delta_{i+1/2}\left[ \frac{e_{1T}^3\,|u|}{e_{1T}e_{2T}\,e_{3T}}\,\delta_i \left[ \frac{e_{2u} e_{3u} }{e_{1u} } \delta_{i+1/2}[\tau] \right] \right]
+  \end{split}
+\end{equation}
+which leads to ${A_T^{lT}}^2 = \frac{1}{12} {e_{1T}}^3\ \overline{|u|}^{\,i+1/2}$
+
+sol 2 coefficient at u-point: split $|u|$ into $\sqrt{|u|}$ and $e_{1T}$ into $\sqrt{e_{1u}}$
+\begin{equation}
+  \label{eq:ALGOS_tra_adv_ubs2}
+  \begin{split}
+    F_u^{lT} &= - \frac{1}{12} {e_{1u}}^1 \sqrt{e_{1u}|u|} \frac{e_{2u} e_{3u}}{e_{1u}}\;\delta_{i+1/2}\left[ \frac{1}{e_{2T}\,e_{3T}}\,\delta_i \left[ \sqrt{e_{1u}|u|} \frac{e_{2u} e_{3u} }{e_{1u} } \delta_{i+1/2}[\tau] \right] \right] \\
+    &= - \frac{1}{12} e_{1u} \sqrt{e_{1u}|u|\,} \frac{e_{2u} e_{3u}}{e_{1u}}\;\delta_{i+1/2}\left[ \frac{1}{e_{1T}\,e_{2T}\,e_{3T}}\,\delta_i \left[ e_{1u} \sqrt{e_{1u}|u|\,} \frac{e_{2u} e_{3u} }{e_{1u}} \delta_{i+1/2}[\tau] \right] \right]
+  \end{split}
+\end{equation}
+which leads to ${A_u^{lT}} = \frac{1}{12} {e_{1u}}^3\ |u|$
+
+%% =================================================================================================
+\section{Leapfrog energetic}
+\label{sec:ALGOS_LF}
+
+We adopt the following semi-discrete notation for time derivative.
+Given the values of a variable $q$ at successive time step,
+the time derivation and averaging operators at the mid time step are:
+\[
+  % \label{eq:ALGOS_dt_mt}
+  \begin{split}
+    \delta_{t+\rdt/2} [q]     &=  \  \ \,   q^{t+\rdt}  - q^{t}		\\
+    \overline q^{\,t+\rdt/2} &= \left\{ q^{t+\rdt} + q^{t} \right\} \; / \; 2
+  \end{split}
+\]
+As for space operator,
+the adjoint of the derivation and averaging time operators are $\delta_t^*=\delta_{t+\rdt/2}$ and
+$\overline{\cdot}^{\,t\,*}= \overline{\cdot}^{\,t+\Delta/2}$, respectively.
+
+The Leap-frog time stepping given by \autoref{eq:DOM_nxt} can be defined as:
+\[
+  % \label{eq:ALGOS_LF}
+  \frac{\partial q}{\partial t}
+  \equiv \frac{1}{\rdt} \overline{ \delta_{t+\rdt/2}[q]}^{\,t}
+  =         \frac{q^{t+\rdt}-q^{t-\rdt}}{2\rdt}
+\]
+Note that \autoref{chap:LF} shows that the leapfrog time step is $\rdt$,
+not $2\rdt$ as it can be found sometimes in literature.
+The leap-Frog time stepping is a second order centered scheme.
+As such it respects the quadratic invariant in integral forms, \ie\ the following continuous property,
+\[
+  % \label{eq:ALGOS_Energy}
+  \int_{t_0}^{t_1} {q\, \frac{\partial q}{\partial t} \;dt}
+  =\int_{t_0}^{t_1} {\frac{1}{2}\, \frac{\partial q^2}{\partial t} \;dt}
+  =  \frac{1}{2} \left( {q_{t_1}}^2 - {q_{t_0}}^2 \right) ,
+\]
+is satisfied in discrete form.
+Indeed,
+\[
+  \begin{split}
+    \int_{t_0}^{t_1} {q\, \frac{\partial q}{\partial t} \;dt}
+    &\equiv \sum\limits_{0}^{N}
+    {\frac{1}{\rdt} q^t \ \overline{ \delta_{t+\rdt/2}[q]}^{\,t} \ \rdt}
+    \equiv \sum\limits_{0}^{N}  { q^t \ \overline{ \delta_{t+\rdt/2}[q]}^{\,t} } \\
+    &\equiv \sum\limits_{0}^{N}  { \overline{q}^{\,t+\Delta/2}{ \delta_{t+\rdt/2}[q]}}
+    \equiv \sum\limits_{0}^{N}  { \frac{1}{2} \delta_{t+\rdt/2}[q^2] }\\
+    &\equiv \sum\limits_{0}^{N}  { \frac{1}{2} \delta_{t+\rdt/2}[q^2] }
+    \equiv \frac{1}{2} \left( {q_{t_1}}^2 - {q_{t_0}}^2 \right)
+  \end{split}
+\]
+NB here pb of boundary condition when applying the adjoint!
+In space, setting to 0 the quantity in land area is sufficient to get rid of the boundary condition
+(equivalently of the boundary value of the integration by part).
+In time this boundary condition is not physical and \textbf{add something here!!!}
+
+%% =================================================================================================
+\section{Lateral diffusion operator}
+
+%% =================================================================================================
+\subsection{Griffies iso-neutral diffusion operator}
+
+Let try to define a scheme that get its inspiration from the \citet{griffies.gnanadesikan.ea_JPO98} scheme,
+but is formulated within the \NEMO\ framework
+(\ie\ using scale factors rather than grid-size and having a position of $T$-points that
+is not necessary in the middle of vertical velocity points, see \autoref{fig:DOM_zgr_e3}).
+
+In the formulation \autoref{eq:TRA_ldf_iso} introduced in 1995 in OPA, the ancestor of \NEMO,
+the off-diagonal terms of the small angle diffusion tensor contain several double spatial averages of a gradient,
+for example $\overline{\overline{\delta_k \cdot}}^{\,i,k}$.
+It is apparent that the combination of a $k$ average and a $k$ derivative of the tracer allows for
+the presence of grid point oscillation structures that will be invisible to the operator.
+These structures are \textit{computational modes}.
+They will not be damped by the iso-neutral operator, and even possibly amplified by it.
+In other word, the operator applied to a tracer does not warranties the decrease of its global average variance.
+To circumvent this, we have introduced a smoothing of the slopes of the iso-neutral surfaces
+(see \autoref{chap:LDF}).
+Nevertheless, this technique works fine for $T$ and $S$ as they are active tracers
+(\ie\ they enter the computation of density), but it does not work for a passive tracer.
+\citep{griffies.gnanadesikan.ea_JPO98} introduce a different way to discretise the off-diagonal terms that
+nicely solve the problem.
+The idea is to get rid of combinations of an averaged in one direction combined with
+a derivative in the same direction by considering triads.
+For example in the (\textbf{i},\textbf{k}) plane, the four triads are defined at the $(i,k)$ $T$-point as follows:
+\begin{equation}
+  \label{eq:ALGOS_Gf_triads}
+  _i^k \mathbb{T}_{i_p}^{k_p} (T)
+  = \frac{1}{4} \ {b_u}_{\,i+i_p}^{\,k}  \  A_i^k  	\left(
+    \frac{ \delta_{i + i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
+    -\ {_i^k \mathbb{R}_{i_p}^{k_p}} \ \frac{ \delta_{k+k_p} [T^i] }{ {e_{3w}}_{\,i}^{\,k+k_p} }
+  \right)
+\end{equation}
+where the indices $i_p$ and $k_p$ define the four triads and take the following value:
+$i_p = -1/2$ or $1/2$ and $k_p = -1/2$ or $1/2$,
+$b_u= e_{1u}\,e_{2u}\,e_{3u}$ is the volume of $u$-cells,
+$A_i^k$ is the lateral eddy diffusivity coefficient defined at $T$-point,
+and $_i^k \mathbb{R}_{i_p}^{k_p}$ is the slope associated with each triad:
+\begin{equation}
+  \label{eq:ALGOS_Gf_slopes}
+  _i^k \mathbb{R}_{i_p}^{k_p}
+  =\frac{ {e_{3w}}_{\,i}^{\,k+k_p}} { {e_{1u}}_{\,i+i_p}^{\,k}} \ \frac
+  {\left(\alpha / \beta \right)_i^k  \ \delta_{i + i_p}[T^k] - \delta_{i + i_p}[S^k] }
+  {\left(\alpha / \beta \right)_i^k  \ \delta_{k+k_p}[T^i ] - \delta_{k+k_p}[S^i ] }
+\end{equation}
+Note that in \autoref{eq:ALGOS_Gf_slopes} we use the ratio $\alpha / \beta$ instead of
+multiplying the temperature derivative by $\alpha$ and the salinity derivative by $\beta$.
+This is more efficient as the ratio $\alpha / \beta$ can to be evaluated directly.
+
+Note that in \autoref{eq:ALGOS_Gf_triads}, we chose to use ${b_u}_{\,i+i_p}^{\,k}$ instead of ${b_{uw}}_{\,i+i_p}^{\,k+k_p}$.
+This choice has been motivated by the decrease of tracer variance and
+the presence of partial cell at the ocean bottom (see \autoref{subsec:ALGOS_Gf_operator}).
+
+\begin{figure}[!ht]
+  \centering
+  %\includegraphics[width=0.66\textwidth]{ALGOS_ISO_triad}
+  \caption[Triads used in the Griffies's like iso-neutral diffision scheme for
+    $u$- and $w$-components)]{
+    Triads used in the Griffies's like iso-neutral diffision scheme for
+    $u$-component (upper panel) and $w$-component (lower panel).}
+  \label{fig:ALGOS_ISO_triad}
+\end{figure}
+
+The four iso-neutral fluxes associated with the triads are defined at $T$-point.
+They take the following expression:
+\begin{flalign*}
+  % \label{eq:ALGOS_Gf_fluxes}
+  \begin{split}
+    {_i^k {\mathbb{F}_u}_{i_p}^{k_p} } (T)
+    &= \ \; \qquad  \quad    { _i^k \mathbb{T}_{i_p}^{k_p} }(T) \;\ / \ { {e_{1u}}_{\,i+i_p}^{\,k}}    \\
+    {_i^k {\mathbb{F}_w}_{i_p}^{k_p} } (T)
+    &=  -\; { _i^k \mathbb{R}_{i_p}^{k_p} }
+    \ \; { _i^k \mathbb{T}_{i_p}^{k_p} }(T) \;\ / \ { {e_{3w}}_{\,i}^{\,k+k_p}}
+  \end{split}
+\end{flalign*}
+
+The resulting iso-neutral fluxes at $u$- and $w$-points are then given by
+the sum of the fluxes that cross the $u$- and $w$-face (\autoref{fig:TRIADS_ISO_triad}):
+\begin{flalign}
+  \label{eq:ALGOS_iso_flux}
+  \textbf{F}_{iso}(T)
+  &\equiv  \sum_{\substack{i_p,\,k_p}}
+  \begin{pmatrix}
+    {_{i+1/2-i_p}^k {\mathbb{F}_u}_{i_p}^{k_p} } (T) \\ \\
+    {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p} } (T)
+  \end{pmatrix}
+  \notag \\
+  &  \notag \\
+  &\equiv  \sum_{\substack{i_p,\,k_p}}
+  \begin{pmatrix}
+    && { _{i+1/2-i_p}^k \mathbb{T}_{i_p}^{k_p} }(T) \;\ / \ { {e_{1u}}_{\,i+1/2}^{\,k} } \\ \\
+    & -\; { _i^{k+1/2-k_p} \mathbb{R}_{i_p}^{k_p} }
+    & {_i^{k+1/2-k_p} \mathbb{T}_{i_p}^{k_p} }(T) \;\ / \ { {e_{3w}}_{\,i}^{\,k+1/2} }
+  \end{pmatrix}      % \\
+  % &\\
+  % &\equiv  \sum_{\substack{i_p,\,k_p}}
+  % \begin{pmatrix}
+  %   \qquad  \qquad  \qquad
+  %   \frac{1}{ {e_{1u}}_{\,i+1/2}^{\,k} }  \ \;
+  %   { _{i+1/2-i_p}^k \mathbb{T}_{i_p}^{k_p} }(T)\\
+  %   \\
+  %   -\frac{1}{ {e_{3w}}_{\,i}^{\,k+1/2} }  \ \;
+  %   { _i^{k+1/2-k_p} \mathbb{R}_{i_p}^{k_p} } \ \;
+  %   {_i^{k+1/2-k_p} \mathbb{T}_{i_p}^{k_p} }(T)\\
+  % \end{pmatrix}
+\end{flalign}
+resulting in a iso-neutral diffusion tendency on temperature given by
+the divergence of the sum of all the four triad fluxes:
+\begin{equation}
+  \label{eq:ALGOS_Gf_operator}
+  D_l^T = \frac{1}{b_T}  \sum_{\substack{i_p,\,k_p}} \left\{
+    \delta_{i} \left[{_{i+1/2-i_p}^k {\mathbb{F}_u }_{i_p}^{k_p}} \right]
+    + \delta_{k} \left[ {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}} \right]   \right\}
+\end{equation}
+where $b_T= e_{1T}\,e_{2T}\,e_{3T}$ is the volume of $T$-cells.
+
+This expression of the iso-neutral diffusion has been chosen in order to satisfy the following six properties:
+\begin{description}
+\item [Horizontal diffusion] The discretization of the diffusion operator recovers the traditional five-point Laplacian in the limit of flat iso-neutral direction:
+  \[
+    % \label{eq:ALGOS_Gf_property1a}
+    D_l^T = \frac{1}{b_T}  \ \delta_{i}
+    \left[ \frac{e_{2u}\,e_{3u}}{e_{1u}} \; \overline{A}^{\,i} \; \delta_{i+1/2}[T] \right]
+    \qquad  \text{when} \quad
+    { _i^k \mathbb{R}_{i_p}^{k_p} }=0
+  \]
+\item [Implicit treatment in the vertical] In the diagonal term associated with the vertical divergence of the iso-neutral fluxes
+  \ie\ the term associated with a second order vertical derivative)
+  appears only tracer values associated with a single water column.
+  This is of paramount importance since it means that
+  the implicit in time algorithm for solving the vertical diffusion equation can be used to evaluate this term.
+  It is a necessity since the vertical eddy diffusivity associated with this term,
+  \[
+	 \sum_{\substack{i_p, \,k_p}} \left\{
+		A_i^k \; \left(_i^k \mathbb{R}_{i_p}^{k_p}\right)^2
+    \right\}
+  \]
+  can be quite large.
+\item [Pure iso-neutral operator] The iso-neutral flux of locally referenced potential density is zero, \ie
+  \begin{align*}
+    % \label{eq:ALGOS_Gf_property2}
+    \begin{matrix}
+      &{_i^k {\mathbb{F}_u}_{i_p}^{k_p} (\rho)}
+      &=    &\alpha_i^k   &{_i^k {\mathbb{F}_u}_{i_p}^{k_p} } (T)
+      &- \ \;  \beta _i^k    &{_i^k {\mathbb{F}_u}_{i_p}^{k_p} } (S) & = \ 0   \\
+      &{_i^k {\mathbb{F}_w}_{i_p}^{k_p} (\rho)}
+      &=    &\alpha_i^k   &{_i^k {\mathbb{F}_w}_{i_p}^{k_p} } (T)
+      &- \  \; \beta _i^k    &{_i^k {\mathbb{F}_w}_{i_p}^{k_p} } (S)  &= \ 0
+    \end{matrix}
+  \end{align*}
+  This result is trivially obtained using the \autoref{eq:ALGOS_Gf_triads} applied to $T$ and $S$ and
+  the definition of the triads' slopes \autoref{eq:ALGOS_Gf_slopes}.
+\item [Conservation of tracer] The iso-neutral diffusion term conserve the total tracer content, \ie
+  \[
+    % \label{eq:ALGOS_Gf_property1}
+    \sum_{i,j,k} \left\{ D_l^T \ b_T \right\} = 0
+  \]
+This property is trivially satisfied since the iso-neutral diffusive operator is written in flux form.
+\item [Decrease of tracer variance] The iso-neutral diffusion term does not increase the total tracer variance, \ie
+  \[
+    % \label{eq:ALGOS_Gf_property1}
+    \sum_{i,j,k} \left\{ T \ D_l^T \ b_T \right\} \leq 0
+  \]
+The property is demonstrated in the \autoref{subsec:ALGOS_Gf_operator}.
+It is a key property for a diffusion term.
+It means that the operator is also a dissipation term,
+\ie\ it is a sink term for the square of the quantity on which it is applied.
+It therfore ensures that, when the diffusivity coefficient is large enough,
+the field on which it is applied become free of grid-point noise.
+\item [Self-adjoint operator] The iso-neutral diffusion operator is self-adjoint, \ie
+  \[
+    % \label{eq:ALGOS_Gf_property1}
+    \sum_{i,j,k} \left\{ S \ D_l^T \ b_T \right\} = \sum_{i,j,k} \left\{ D_l^S \ T \ b_T \right\}
+  \]
+In other word, there is no needs to develop a specific routine from the adjoint of this operator.
+We just have to apply the same routine.
+This properties can be demonstrated quite easily in a similar way the "non increase of tracer variance" property
+has been proved (see \autoref{apdx:ALGOS_Gf_operator}).
+\end{description}
+
+%% =================================================================================================
+\subsection{Eddy induced velocity and skew flux formulation}
+
+When Gent and McWilliams [1990] diffusion is used (\key{traldf\_eiv} defined),
+an additional advection term is added.
+The associated velocity is the so called eddy induced velocity,
+the formulation of which depends on the slopes of iso-neutral surfaces.
+Contrary to the case of iso-neutral mixing, the slopes used here are referenced to the geopotential surfaces,
+\ie\ \autoref{eq:LDF_slp_geo} is used in $z$-coordinate,
+and the sum \autoref{eq:LDF_slp_geo} + \autoref{eq:LDF_slp_iso} in $z^*$ or $s$-coordinates.
+
+The eddy induced velocity is given by:
+\begin{equation}
+  \label{eq:ALGOS_eiv_v}
+  \begin{split}
+    u^* & = - \frac{1}{e_2\,e_{3}}          \;\partial_k \left( e_2 \, A_e \; r_i  \right)
+    = - \frac{1}{e_3}                     \;\partial_k \left(           A_e \; r_i  \right)            \\
+    v^* & = - \frac{1}{e_1\,e_3}\;             \partial_k \left( e_1 \, A_e \; r_j  \right)
+    = - \frac{1}{e_3}                     \;\partial_k \left(           A_e \; r_j  \right)             \\
+    w^* & =    \frac{1}{e_1\,e_2}\; \left\{   \partial_i  \left( e_2 \, A_e \; r_i  \right)
+      + \partial_j  \left( e_1 \, A_e \;r_j   \right) \right\}
+  \end{split}
+\end{equation}
+where $A_{e}$ is the eddy induced velocity coefficient,
+and $r_i$ and $r_j$ the slopes between the iso-neutral and the geopotential surfaces.
+\cmtgm{Wrong: to be modified with 2 2D streamfunctions}
+In other words, the eddy induced velocity can be derived from a vector streamfuntion, $\phi$,
+which is given by $\phi = A_e\,\textbf{r}$ as $\textbf{U}^*  = \textbf{k} \times \nabla \phi$.
+
+A traditional way to implement this additional advection is to add it to the eulerian velocity prior to
+compute the tracer advection.
+This allows us to take advantage of all the advection schemes offered for the tracers
+(see \autoref{sec:TRA_adv}) and not just a $2^{nd}$ order advection scheme.
+This is particularly useful for passive tracers where
+\emph{positivity} of the advection scheme is of paramount importance.
+% give here the expression using the triads. It is different from the one given in \autoref{eq:LDF_eiv}
+% see just below a copy of this equation:
+%\begin{equation} \label{eq:ALGOS_ldfeiv}
+%\begin{split}
+% u^* & = \frac{1}{e_{2u}e_{3u}}\; \delta_k \left[e_{2u} \, A_{uw}^{eiv} \; \overline{r_{1w}}^{\,i+1/2} \right]\\
+% v^* & = \frac{1}{e_{1u}e_{3v}}\; \delta_k \left[e_{1v} \, A_{vw}^{eiv} \; \overline{r_{2w}}^{\,j+1/2} \right]\\
+%w^* & = \frac{1}{e_{1w}e_{2w}}\; \left\{ \delta_i \left[e_{2u} \, A_{uw}^{eiv} \; \overline{r_{1w}}^{\,i+1/2} \right] + %\delta_j \left[e_{1v} \, A_{vw}^{eiv} \; \overline{r_{2w}}^{\,j+1/2} \right] \right\} \\
+%\end{split}
+%\end{equation}
+\[
+  % \label{eq:ALGOS_eiv_vd}
+  \textbf{F}_{eiv}^T   \equiv   \left(
+    \begin{aligned}
+      \sum_{\substack{i_p,\,k_p}} &
+      +{e_{2u}}_{i+1/2-i_p}^{k}                                  \ \ {A_{e}}_{i+1/2-i_p}^{k}
+      \ \ \ { _{i+1/2-i_p}^k \mathbb{R}_{i_p}^{k_p} }    \ \ \delta_{k+k_p}[T_{i+1/2-i_p}] \\ \\
+      \sum_{\substack{i_p,\,k_p}} &
+      - {e_{2u}}_i^{k+1/2-k_p}                                      \ {A_{e}}_i^{k+1/2-k_p}
+      \ \ { _i^{k+1/2-k_p} \mathbb{R}_{i_p}^{k_p} }    \ \delta_{i+i_p}[T^{k+1/2-k_p}]
+    \end{aligned}
+  \right)
+\]
+
+\citep{griffies_JPO98} introduces another way to implement the eddy induced advection, the so-called skew form.
+It is based on a transformation of the advective fluxes using the non-divergent nature of the eddy induced velocity.
+For example in the (\textbf{i},\textbf{k}) plane, the tracer advective fluxes can be transformed as follows:
+\begin{flalign*}
+  \begin{split}
+    \textbf{F}_{eiv}^T =
+    \begin{pmatrix}
+      {e_{2}\,e_{3}\;  u^*} 	 	\\
+ 		{e_{1}\,e_{2}\; w^*}
+    \end{pmatrix}
+    \;   T
+    &=
+    \begin{pmatrix}
+      { - \partial_k \left( e_{2} \, A_{e} \; r_i \right) \; T \;} 	 	\\
+ 		{+ \partial_i  \left( e_{2} \, A_{e} \; r_i \right) \; T \;}
+    \end{pmatrix}
+    \\
+    &=
+    \begin{pmatrix}
+      { - \partial_k \left( e_{2} \, A_{e} \; r_i  \; T \right) \;}  \\
+ 		{+ \partial_i  \left( e_{2} \, A_{e} \; r_i  \; T \right) \;}
+    \end{pmatrix}
+    +
+    \begin{pmatrix}
+      {+ e_{2} \, A_{e} \; r_i  \; \partial_k T}  \\
+ 		{ - e_{2} \, A_{e} \; r_i  \; \partial_i  T}
+    \end{pmatrix}
+  \end{split}
+\end{flalign*}
+and since the eddy induces velocity field is no-divergent,
+we end up with the skew form of the eddy induced advective fluxes:
+\begin{equation}
+  \label{eq:ALGOS_eiv_skew_continuous}
+  \textbf{F}_{eiv}^T =
+  \begin{pmatrix}
+    {+ e_{2} \, A_{e} \; r_i  \; \partial_k T}   \\
+    { - e_{2} \, A_{e} \; r_i  \; \partial_i  T}
+  \end{pmatrix}
+\end{equation}
+The tendency associated with eddy induced velocity is then simply the divergence of
+the \autoref{eq:ALGOS_eiv_skew_continuous} fluxes.
+It naturally conserves the tracer content, as it is expressed in flux form and,
+as the advective form, it preserves the tracer variance.
+Another interesting property of \autoref{eq:ALGOS_eiv_skew_continuous} form is that when $A=A_e$,
+a simplification occurs in the sum of the iso-neutral diffusion and eddy induced velocity terms:
+\begin{flalign*}
+  % \label{eq:ALGOS_eiv_skew+eiv_continuous}
+  \textbf{F}_{iso}^T + \textbf{F}_{eiv}^T &=
+  \begin{pmatrix}
+    + \frac{e_2\,e_3\,}{e_1} A \;\partial_i T -  e_2 \, A \; r_i                              \;\partial_k T   \\
+    -  e_2 \, A_{e} \; r_i           \;\partial_i T + \frac{e_1\,e_2}{e_3} \, A \; r_i^2 \;\partial_k T
+  \end{pmatrix}
+  +
+  \begin{pmatrix}
+    {+ e_{2} \, A_{e} \; r_i  \; \partial_k T}   \\
+    { - e_{2} \, A_{e} \; r_i  \; \partial_i  T}
+  \end{pmatrix}
+  \\
+  &=
+  \begin{pmatrix}
+    + \frac{e_2\,e_3\,}{e_1} A \;\partial_i T    \\
+    -  2\; e_2 \, A_{e} \; r_i      \;\partial_i T + \frac{e_1\,e_2}{e_3} \, A \; r_i^2 \;\partial_k T
+  \end{pmatrix}
+\end{flalign*}
+The horizontal component reduces to the one use for an horizontal laplacian operator and
+the vertical one keeps the same complexity, but not more.
+This property has been used to reduce the computational time \citep{griffies_JPO98},
+but it is not of practical use as usually $A \neq A_e$.
+Nevertheless this property can be used to choose a discret form of \autoref{eq:ALGOS_eiv_skew_continuous} which
+is consistent with the iso-neutral operator \autoref{eq:ALGOS_Gf_operator}.
+Using the slopes \autoref{eq:ALGOS_Gf_slopes} and defining $A_e$ at $T$-point(\ie\ as $A$,
+the eddy diffusivity coefficient), the resulting discret form is given by:
+\begin{equation}
+  \label{eq:ALGOS_eiv_skew}
+  \textbf{F}_{eiv}^T   \equiv   \frac{1}{4} \left(
+    \begin{aligned}
+      \sum_{\substack{i_p,\,k_p}} &
+      +{e_{2u}}_{i+1/2-i_p}^{k}                                  \ \ {A_{e}}_{i+1/2-i_p}^{k}
+      \ \ \ { _{i+1/2-i_p}^k \mathbb{R}_{i_p}^{k_p} }    \ \ \delta_{k+k_p}[T_{i+1/2-i_p}] \\ \\
+      \sum_{\substack{i_p,\,k_p}} &
+      - {e_{2u}}_i^{k+1/2-k_p}                                      \ {A_{e}}_i^{k+1/2-k_p}
+      \ \ { _i^{k+1/2-k_p} \mathbb{R}_{i_p}^{k_p} }    \ \delta_{i+i_p}[T^{k+1/2-k_p}]
+    \end{aligned}
+  \right)
+\end{equation}
+Note that \autoref{eq:ALGOS_eiv_skew} is valid in $z$-coordinate with or without partial cells.
+In $z^*$ or $s$-coordinate, the slope between the level and the geopotential surfaces must be added to
+$\mathbb{R}$ for the discret form to be exact.
+
+Such a choice of discretisation is consistent with the iso-neutral operator as
+it uses the same definition for the slopes.
+It also ensures the conservation of the tracer variance (see \autoref{subsec:ALGOS_eiv_skew}),
+\ie\ it does not include a diffusive component but is a "pure" advection term.
+
+%% =================================================================================================
+\subsection{Discrete invariants of the iso-neutral diffrusion}
+\label{subsec:ALGOS_Gf_operator}
+
+Demonstration of the decrease of the tracer variance in the (\textbf{i},\textbf{j}) plane.
+
+This part will be moved in an Appendix.
+
+The continuous property to be demonstrated is:
+\[
+  \int_D  D_l^T \; T \;dv   \leq 0
+\]
+The discrete form of its left hand side is obtained using \autoref{eq:TRIADS_iso_flux}
+
+\begin{align*}
+  &\int_D  D_l^T \; T \;dv \equiv  \sum_{i,k} \left\{ T \ D_l^T \ b_T \right\}    \\
+  &\equiv + \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
+    \delta_{i} \left[{_{i+1/2-i_p}^k {\mathbb{F}_u }_{i_p}^{k_p}} \right]
+    + \delta_{k} \left[ {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}} \right]  \ T \right\}    \\
+  &\equiv  - \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
+    {_{i+1/2-i_p}^k {\mathbb{F}_u }_{i_p}^{k_p}} \ \delta_{i+1/2} [T]
+    + {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}}  \ \delta_{k+1/2} [T]   \right\}      \\
+  &\equiv -\sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
+    \frac{ _{i+1/2-i_p}^k \mathbb{T}_{i_p}^{k_p} (T) }{ {e_{1u}}_{\,i+1/2}^{\,k} }  \ \delta_{i+1/2} [T]
+    - { _i^{k+1/2-k_p} \mathbb{R}_{i_p}^{k_p} } \ \;
+    \frac{ _i^{k+1/2-k_p} \mathbb{T}_{i_p}^{k_p} (T) }{ {e_{3w}}_{\,i}^{\,k+1/2}  } \ \delta_{k+1/2} [T]
+    \right\}      \\
+    %
+  \allowdisplaybreaks
+  \intertext{ Expending the summation on $i_p$ and $k_p$, it becomes:}
+  %
+  &\equiv -\sum_{i,k}
+    \begin{Bmatrix}
+      &\ \ \Bigl(  { _{i+1}^{k} \mathbb{T}_{-1/2}^{-1/2} (T) }
+      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
+      & -\ \ {_{i}^{k+1} \mathbb{R}_{-1/2}^{-1/2}}
+      &      {_{i}^{k+1} \mathbb{T}_{-1/2}^{-1/2} (T) }
+      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)
+      & \\
+      &+\Bigl( \ \;\; { _i^k \mathbb{T}_{+1/2}^{-1/2} (T) }
+      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
+      & -\ \ {_i^{k+1} \mathbb{R}_{+1/2}^{-1/2}}
+      & { _i^{k+1} \mathbb{T}_{+1/2}^{-1/2} (T) }
+      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}      \Bigr)
+      & \\
+      &+\Bigl(  { _{i+1}^{k} \mathbb{T}_{-1/2}^{+1/2} (T) }
+      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
+      & -\ \ \ \;\;{_{i}^{k} \mathbb{R}_{-1/2}^{+1/2}}
+      &      \ \;\;{_{i}^{k} \mathbb{T}_{-1/2}^{+1/2} (T) }
+      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)
+      & \\
+      &+\Bigl( \ \;\; { _{i}^{k} \mathbb{T}_{+1/2}^{+1/2} (T) }
+      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
+      & -\ \ \ \;\;{_{i}^{k} \mathbb{R}_{+1/2}^{+1/2}}
+      &      \ \;\;{_{i}^{k} \mathbb{T}_{+1/2}^{+1/2} (T) }
+      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)   \\
+    \end{Bmatrix}
+    %
+  \allowdisplaybreaks
+  \intertext{
+  The summation is done over all $i$ and $k$ indices,
+  it is therefore possible to introduce a shift of $-1$ either in $i$ or $k$ direction in order to
+  regroup all the terms of the summation by triad at a ($i$,$k$) point.
+  In other words, we regroup all the terms in the neighbourhood that contain a triad at the same ($i$,$k$) indices.
+  It becomes:
+  }
+  %
+  &\equiv -\sum_{i,k}
+    \begin{Bmatrix}
+      &\ \ \Bigl(  {_i^k \mathbb{T}_{-1/2}^{-1/2} (T) }
+      &\frac{ \delta_{i -1/2} [T] }{{e_{1u} }_{\,i-1/2}^{\,k}}
+      & -\ \ {_i^k \mathbb{R}_{-1/2}^{-1/2}}
+      &      {_i^k \mathbb{T}_{-1/2}^{-1/2} (T) }
+      &\frac{ \delta_{k-1/2} [T] }{{e_{3w}}_{\,i}^{\,k-1/2}}     \Bigr)
+      & \\
+      &+\Bigl(  { _i^k \mathbb{T}_{+1/2}^{-1/2} (T) }
+      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
+      & -\ \ {_i^k \mathbb{R}_{+1/2}^{-1/2}}
+      &      { _i^k \mathbb{T}_{+1/2}^{-1/2} (T) }
+      &\frac{ \delta_{k-1/2} [T] }{{e_{3w}}_{\,i}^{\,k-1/2}}      \Bigr)
+      & \\
+      &+\Bigl(  {_i^k \mathbb{T}_{-1/2}^{+1/2} (T) }
+      &\frac{ \delta_{i -1/2} [T] }{{e_{1u} }_{\,i-1/2}^{\,k}}
+      & -\ \ {_i^k \mathbb{R}_{-1/2}^{+1/2}}
+      &      {_i^k \mathbb{T}_{-1/2}^{+1/2} (T) }
+      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)
+      & \\
+      &+\Bigl( { _i^k \mathbb{T}_{+1/2}^{+1/2} (T) }
+      &\frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
+      & -\ \ {_i^k \mathbb{R}_{+1/2}^{+1/2}}
+      &      {_i^k \mathbb{T}_{+1/2}^{+1/2} (T) }
+      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)   \\
+    \end{Bmatrix}   \\
+    %
+  \allowdisplaybreaks
+  \intertext{
+  Then outing in factor the triad in each of the four terms of the summation and
+  substituting the triads by their expression given in \autoref{eq:ALGOS_Gf_triads}.
+  It becomes:
+  }
+  %
+  &\equiv -\sum_{i,k}
+    \begin{Bmatrix}
+      &\ \ \Bigl(  \frac{ \delta_{i -1/2} [T] }{{e_{1u} }_{\,i-1/2}^{\,k}}
+      & -\ \ {_i^k \mathbb{R}_{-1/2}^{-1/2}}
+      &\frac{ \delta_{k-1/2} [T] }{{e_{3w}}_{\,i}^{\,k-1/2}}     \Bigr)^2
+      & \frac{1}{4} \ {b_u}_{\,i-1/2}^{\,k}  \  A_i^k
+      & \\
+      &+\Bigl(  \frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
+      & -\ \ {_i^k \mathbb{R}_{+1/2}^{-1/2}}
+      &\frac{ \delta_{k-1/2} [T] }{{e_{3w}}_{\,i}^{\,k-1/2}}      \Bigr)^2
+      & \frac{1}{4} \ {b_u}_{\,i+1/2}^{\,k}  \  A_i^k
+      & \\
+      &+\Bigl(  \frac{ \delta_{i -1/2} [T] }{{e_{1u} }_{\,i-1/2}^{\,k}}
+      & -\ \ {_i^k \mathbb{R}_{-1/2}^{+1/2}}
+      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)^2
+      & \frac{1}{4} \ {b_u}_{\,i-1/2}^{\,k}  \  A_i^k
+      & \\
+      &+\Bigl( \frac{ \delta_{i +1/2} [T] }{{e_{1u} }_{\,i+1/2}^{\,k}}
+      & -\ \ {_i^k \mathbb{R}_{+1/2}^{+1/2}}
+      &\frac{ \delta_{k+1/2} [T] }{{e_{3w}}_{\,i}^{\,k+1/2}}     \Bigr)^2
+      & \frac{1}{4} \ {b_u}_{\,i+1/2}^{\,k}  \  A_i^k      \\
+    \end{Bmatrix}
+  \\
+  & \\
+  %
+  &\equiv - \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
+    \begin{matrix}
+      &\Bigl( \frac{ \delta_{i +i_p} [T] }{{e_{1u} }_{\,i+i_p}^{\,k}}
+      & -\ \ {_i^k \mathbb{R}_{i_p}^{k_p}}
+      &\frac{ \delta_{k+k_p} [T] }{{e_{3w}}_{\,i}^{\,k+k_p}}     \Bigr)^2
+      & \frac{1}{4} \ {b_u}_{\,i+i_p}^{\,k}  \  A_i^k   \ \
+    \end{matrix}
+        \right\}
+        \quad   \leq 0
+\end{align*}
+The last inequality is obviously obtained as we succeed in obtaining a negative summation of square quantities.
+
+Note that, if instead of multiplying $D_l^T$ by $T$, we were using another tracer field, let say $S$,
+then the previous demonstration would have let to:
+\begin{align*}
+  \int_D  S \; D_l^T  \;dv &\equiv  \sum_{i,k} \left\{ S \ D_l^T \ b_T \right\}    \\
+                           &\equiv - \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
+                             \left( \frac{ \delta_{i +i_p} [S] }{{e_{1u} }_{\,i+i_p}^{\,k}}
+                             - {_i^k \mathbb{R}_{i_p}^{k_p}}
+                             \frac{ \delta_{k+k_p} [S] }{{e_{3w}}_{\,i}^{\,k+k_p}}     \right)  \right. \\
+                           & \qquad \qquad \qquad \ \left.
+                             \left( \frac{ \delta_{i +i_p} [T] }{{e_{1u} }_{\,i+i_p}^{\,k}}
+                             - {_i^k \mathbb{R}_{i_p}^{k_p}}
+                             \frac{ \delta_{k+k_p} [T] }{{e_{3w}}_{\,i}^{\,k+k_p}}     \right)
+                             \frac{1}{4} \ {b_u}_{\,i+i_p}^{\,k}  \  A_i^k   \
+                             \right\}
+                             %
+                             \allowdisplaybreaks
+                             \intertext{
+                             which, by applying the same operation as before but in reverse order, leads to:
+                             }
+                             %
+                           &\equiv  \sum_{i,k} \left\{ D_l^S \ T \ b_T \right\}
+\end{align*}
+This means that the iso-neutral operator is self-adjoint.
+There is no need to develop a specific to obtain it.
+
+%% =================================================================================================
+\subsection{Discrete invariants of the skew flux formulation}
+\label{subsec:ALGOS_eiv_skew}
+
+Demonstration for the conservation of the tracer variance in the (\textbf{i},\textbf{j}) plane.
+
+This have to be moved in an Appendix.
+
+The continuous property to be demonstrated is:
+\begin{align*}
+  \int_D \nabla \cdot \textbf{F}_{eiv}(T) \; T \;dv  \equiv 0
+\end{align*}
+The discrete form of its left hand side is obtained using \autoref{eq:ALGOS_eiv_skew}
+\begin{align*}
+  \sum\limits_{i,k} \sum_{\substack{i_p,\,k_p}}  \Biggl\{   \;\;
+  \delta_i  &\left[
+              {e_{2u}}_{i+i_p+1/2}^{k}                                  \;\ \ {A_{e}}_{i+i_p+1/2}^{k}
+              \ \ \ { _{i+i_p+1/2}^k \mathbb{R}_{-i_p}^{k_p} }   \quad \delta_{k+k_p}[T_{i+i_p+1/2}]
+              \right] \; T_i^k      \\
+  - \delta_k &\left[
+               {e_{2u}}_i^{k+k_p+1/2}                                     \ \ {A_{e}}_i^{k+k_p+1/2}
+               \ \ { _i^{k+k_p+1/2} \mathbb{R}_{i_p}^{-k_p} }   \ \ \delta_{i+i_p}[T^{k+k_p+1/2}]
+               \right] \; T_i^k      \         \Biggr\}
+\end{align*}
+apply the adjoint of delta operator, it becomes
+\begin{align*}
+  \sum\limits_{i,k} \sum_{\substack{i_p,\,k_p}}  \Biggl\{   \;\;
+  &\left(
+    {e_{2u}}_{i+i_p+1/2}^{k}                                  \;\ \ {A_{e}}_{i+i_p+1/2}^{k}
+    \ \ \ { _{i+i_p+1/2}^k \mathbb{R}_{-i_p}^{k_p} }   \quad \delta_{k+k_p}[T_{i+i_p+1/2}]
+    \right) \; \delta_{i+1/2}[T^{k}]      \\
+  - &\left(
+      {e_{2u}}_i^{k+k_p+1/2}                                     \ \ {A_{e}}_i^{k+k_p+1/2}
+      \ \ { _i^{k+k_p+1/2} \mathbb{R}_{i_p}^{-k_p} }   \ \ \delta_{i+i_p}[T^{k+k_p+1/2}]
+      \right) \; \delta_{k+1/2}[T_{i}]       \         \Biggr\}
+\end{align*}
+Expending the summation on $i_p$ and $k_p$, it becomes:
+\begin{align*}
+  \begin{matrix}
+    &\sum\limits_{i,k}   \Bigl\{
+    &+{e_{2u}}_{i+1}^{k}                             &{A_{e}}_{i+1    }^{k}
+    &\ {_{i+1}^k \mathbb{R}_{- 1/2}^{-1/2}} &\delta_{k-1/2}[T_{i+1}]    &\delta_{i+1/2}[T^{k}]   &\\
+    &&+{e_{2u}}_i^{k\ \ \ \:}                            &{A_{e}}_{i}^{k\ \ \ \:}
+    &\ {\ \ \;_i^k \mathbb{R}_{+1/2}^{-1/2}}  &\delta_{k-1/2}[T_{i\ \ \ \;}]  &\delta_{i+1/2}[T^{k}] &\\
+    &&+{e_{2u}}_{i+1}^{k}                             &{A_{e}}_{i+1    }^{k}
+    &\ {_{i+1}^k \mathbb{R}_{- 1/2}^{+1/2}} &\delta_{k+1/2}[T_{i+1}]     &\delta_{i+1/2}[T^{k}] &\\
+    &&+{e_{2u}}_i^{k\ \ \ \:}                            &{A_{e}}_{i}^{k\ \ \ \:}
+    &\ {\ \ \;_i^k \mathbb{R}_{+1/2}^{+1/2}} &\delta_{k+1/2}[T_{i\ \ \ \;}] &\delta_{i+1/2}[T^{k}] &\\
+    %
+    &&-{e_{2u}}_i^{k+1}                                &{A_{e}}_i^{k+1}
+    &{_i^{k+1} \mathbb{R}_{-1/2}^{- 1/2}}   &\delta_{i-1/2}[T^{k+1}]      &\delta_{k+1/2}[T_{i}] &\\
+    &&-{e_{2u}}_i^{k\ \ \ \:}                             &{A_{e}}_i^{k\ \ \ \:}
+    &{\ \ \;_i^k  \mathbb{R}_{-1/2}^{+1/2}}   &\delta_{i-1/2}[T^{k\ \ \ \:}]  &\delta_{k+1/2}[T_{i}] &\\
+    &&-{e_{2u}}_i^{k+1    }                             &{A_{e}}_i^{k+1}
+    &{_i^{k+1} \mathbb{R}_{+1/2}^{- 1/2}}   &\delta_{i+1/2}[T^{k+1}]      &\delta_{k+1/2}[T_{i}] &\\
+    &&-{e_{2u}}_i^{k\ \ \ \:}                             &{A_{e}}_i^{k\ \ \ \:}
+    &{\ \ \;_i^k  \mathbb{R}_{+1/2}^{+1/2}}   &\delta_{i+1/2}[T^{k\ \ \ \:}]  &\delta_{k+1/2}[T_{i}]
+    &\Bigr\}  \\
+  \end{matrix}
+\end{align*}
+The two terms associated with the triad ${_i^k \mathbb{R}_{+1/2}^{+1/2}}$ are the same but of opposite signs,
+they cancel out.
+Exactly the same thing occurs for the triad ${_i^k \mathbb{R}_{-1/2}^{-1/2}}$.
+The two terms associated with the triad ${_i^k \mathbb{R}_{+1/2}^{-1/2}}$ are the same but both of opposite signs and
+shifted by 1 in $k$ direction.
+When summing over $k$ they cancel out with the neighbouring grid points.
+Exactly the same thing occurs for the triad ${_i^k \mathbb{R}_{-1/2}^{+1/2}}$ in the $i$ direction.
+Therefore the sum over the domain is zero,
+\ie\ the variance of the tracer is preserved by the discretisation of the skew fluxes.
+
+\subinc{\input{../../global/epilogue}}
+
+\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_diff_opers.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_diff_opers.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_diff_opers.tex	(revision 12143)
@@ -0,0 +1,425 @@
+\documentclass[../main/NEMO_manual]{subfiles}
+
+\begin{document}
+
+\chapter{Diffusive Operators}
+\label{apdx:DIFFOPERS}
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+%% =================================================================================================
+\section{Horizontal/Vertical $2^{nd}$ order tracer diffusive operators}
+\label{sec:DIFFOPERS_1}
+
+%% =================================================================================================
+\subsubsection*{In z-coordinates}
+
+In $z$-coordinates, the horizontal/vertical second order tracer diffusion operator is given by:
+\begin{align}
+  \label{eq:DIFFOPERS_1}
+  &D^T = \frac{1}{e_1 \, e_2}      \left[
+    \left. \frac{\partial}{\partial i} \left( 	\frac{e_2}{e_1}A^{lT} \;\left. \frac{\partial T}{\partial i} \right|_z   \right)   \right|_z      \right.
+    \left.
+    + \left. \frac{\partial}{\partial j} \left(  \frac{e_1}{e_2}A^{lT} \;\left. \frac{\partial T}{\partial j} \right|_z   \right)   \right|_z      \right]
+    + \frac{\partial }{\partial z}\left( {A^{vT} \;\frac{\partial T}{\partial z}} \right)
+\end{align}
+
+%% =================================================================================================
+\subsubsection*{In generalized vertical coordinates}
+
+In $s$-coordinates, we defined the slopes of $s$-surfaces, $\sigma_1$ and $\sigma_2$ by \autoref{eq:SCOORD_s_slope} and
+the vertical/horizontal ratio of diffusion coefficient by $\epsilon = A^{vT} / A^{lT}$.
+The diffusion operator is given by:
+
+\begin{equation}
+  \label{eq:DIFFOPERS_2}
+  D^T = \left. \nabla \right|_s \cdot
+  \left[ A^{lT} \;\Re \cdot \left. \nabla \right|_s T  \right] \\
+  \;\;\text{where} \;\Re =\left( {{
+        \begin{array}{*{20}c}
+          1 \hfill & 0 \hfill & {-\sigma_1 } \hfill \\
+          0 \hfill & 1 \hfill & {-\sigma_2 } \hfill \\
+          {-\sigma_1 } \hfill & {-\sigma_2 } \hfill & {\varepsilon +\sigma_1
+                                                      ^2+\sigma_2 ^2} \hfill \\
+        \end{array}
+      }} \right)
+\end{equation}
+or in expanded form:
+\begin{align*}
+  {
+  \begin{array}{*{20}l}
+    D^T= \frac{1}{e_1\,e_2\,e_3 } & \left\{ \quad \quad \frac{\partial }{\partial i}  \left. \left[  e_2\,e_3 \, A^{lT}
+                               \left( \  \frac{1}{e_1}\; \left. \frac{\partial T}{\partial i} \right|_s
+                                       -\frac{\sigma_1 }{e_3 } \; \frac{\partial T}{\partial s} \right) \right]  \right|_s  \right. \\
+        &  \quad \  +   \            \left.   \frac{\partial }{\partial j}  \left. \left[  e_1\,e_3 \, A^{lT}
+                               \left( \ \frac{1}{e_2 }\; \left. \frac{\partial T}{\partial j} \right|_s
+                                       -\frac{\sigma_2 }{e_3 } \; \frac{\partial T}{\partial s} \right) \right]  \right|_s  \right. \\
+        &  \quad \  +   \           \left.  e_1\,e_2\, \frac{\partial }{\partial s}  \left[ A^{lT} \; \left(
+	                  -\frac{\sigma_1 }{e_1 } \; \left. \frac{\partial T}{\partial i} \right|_s
+	                  -\frac{\sigma_2 }{e_2 } \; \left. \frac{\partial T}{\partial j} \right|_s
+                          +\left( \varepsilon +\sigma_1^2+\sigma_2 ^2 \right) \; \frac{1}{e_3 } \; \frac{\partial T}{\partial s} \right) \; \right] \;  \right\} .
+  \end{array}
+          }
+\end{align*}
+
+\autoref{eq:DIFFOPERS_2} is obtained from \autoref{eq:DIFFOPERS_1} without any additional assumption.
+Indeed, for the special case $k=z$ and thus $e_3 =1$,
+we introduce an arbitrary vertical coordinate $s = s (i,j,z)$ as in \autoref{apdx:SCOORD} and
+use \autoref{eq:SCOORD_s_slope} and \autoref{eq:SCOORD_s_chain_rule1}.
+Since no cross horizontal derivative $\partial _i \partial _j $ appears in \autoref{eq:DIFFOPERS_1},
+the ($i$,$z$) and ($j$,$z$) planes are independent.
+The derivation can then be demonstrated for the ($i$,$z$)~$\to$~($j$,$s$) transformation without
+any loss of generality:
+
+\begin{align*}
+  {
+  \begin{array}{*{20}l}
+    D^T&=\frac{1}{e_1\,e_2} \left. {\frac{\partial }{\partial i}\left( {\frac{e_2}{e_1}A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_z } \right)} \right|_z
+         +\frac{\partial }{\partial z}\left( {A^{vT}\;\frac{\partial T}{\partial z}} \right) \\ \\
+         %
+       &=\frac{1}{e_1\,e_2 }\left[ {\left. {\;\frac{\partial }{\partial i}\left( {\frac{e_2}{e_1}A^{lT}\;\left( {\left. {\frac{\partial T}{\partial i}} \right|_s
+         -\frac{e_1\,\sigma_1 }{e_3 }\frac{\partial T}{\partial s}} \right)} \right)} \right|_s } \right. \\
+       & \qquad \qquad \left. { -\frac{e_1\,\sigma_1 }{e_3 }\frac{\partial }{\partial s}\left( {\frac{e_2 }{e_1 }A^{lT}\;\left. {\left( {\left. {\frac{\partial T}{\partial i}} \right|_s -\frac{e_1 \,\sigma_1 }{e_3 }\frac{\partial T}{\partial s}} \right)} \right|_s } \right)\;} \right]
+         \shoveright{ +\frac{1}{e_3 }\frac{\partial }{\partial s}\left[ {\frac{A^{vT}}{e_3 }\;\frac{\partial T}{\partial s}} \right]}  \qquad \qquad \qquad \\ \\
+         %
+       &=\frac{1}{e_1 \,e_2 \,e_3 }\left[ {\left. {\;\;\frac{\partial }{\partial i}\left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)} \right|_s -\left. {\frac{e_2 }{e_1}A^{lT}\;\frac{\partial e_3 }{\partial i}} \right|_s \left. {\frac{\partial T}{\partial i}} \right|_s } \right. \\
+       &  \qquad \qquad \quad \left. {-e_3 \frac{\partial }{\partial i}\left( {\frac{e_2 \,\sigma_1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s -e_1 \,\sigma_1 \frac{\partial }{\partial s}\left( {\frac{e_2 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right) \\
+       &  \qquad \qquad \quad \shoveright{ -e_1 \,\sigma_1 \frac{\partial }{\partial s}\left( {-\frac{e_2 \,\sigma_1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)\;\,\left. {+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 }{e_3 }A^{vT}\;\frac{\partial T}{\partial s}} \right)\quad} \right] }\\
+  \end{array}
+  } 		\\
+  %
+  {
+  \begin{array}{*{20}l}
+    \intertext{Noting that $\frac{1}{e_1} \left. \frac{\partial e_3 }{\partial i} \right|_s = \frac{\partial \sigma_1 }{\partial s}$, this becomes:}
+    %
+    D^T & =\frac{1}{e_1\,e_2\,e_3 }\left[ {\left. {\;\;\;\frac{\partial }{\partial i}\left( {\frac{e_2\,e_3 }{e_1}\,A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)} \right|_s \left. -\, {e_3 \frac{\partial }{\partial i}\left( {\frac{e_2 \,\sigma_1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right. \\
+    & \qquad \qquad \quad -e_2 A^{lT}\;\frac{\partial \sigma_1 }{\partial s}\left. {\frac{\partial T}{\partial i}} \right|_s -e_1 \,\sigma_1 \frac{\partial }{\partial s}\left( {\frac{e_2 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right) \\
+    & \qquad \qquad \quad\shoveright{ \left. { +e_1 \,\sigma_1 \frac{\partial }{\partial s}\left( {\frac{e_2 \,\sigma_1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right)+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 }{e_3 }A^{vT}\;\frac{\partial T}{\partial s}} \right)\;\;\;} \right] }\\
+    \\
+    &=\frac{1}{e_1 \,e_2 \,e_3 } \left[ {\left. {\;\;\;\frac{\partial }{\partial i} \left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)} \right|_s \left. {-\frac{\partial }{\partial i}\left( {e_2 \,\sigma_1 A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right. \\
+    & \qquad \qquad \quad \left. {+\frac{e_2 \,\sigma_1 }{e_3}A^{lT}\;\frac{\partial T}{\partial s} \;\frac{\partial e_3 }{\partial i}}  \right|_s -e_2 A^{lT}\;\frac{\partial \sigma_1 }{\partial s}\left. {\frac{\partial T}{\partial i}} \right|_s \\
+    & \qquad \qquad \quad-e_2 \,\sigma_1 \frac{\partial}{\partial s}\left( {A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 \,\sigma_1 ^2}{e_3 }A^{lT}\;\frac{\partial T}{\partial s}} \right) \\
+    & \qquad \qquad \quad\shoveright{ \left. {-\frac{\partial \left( {e_1 \,e_2 \,\sigma_1 } \right)}{\partial s} \left( {\frac{\sigma_1 }{e_3}A^{lT}\;\frac{\partial T}{\partial s}} \right) + \frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 }{e_3 }A^{vT}\;\frac{\partial T}{\partial s}} \right)\;\;\;} \right]} .
+  \end{array}
+      } \\
+  {
+  \begin{array}{*{20}l}
+    %
+    \intertext{Using the same remark as just above, $D^T$ becomes:}
+    %
+   D^T &= \frac{1}{e_1 \,e_2 \,e_3 } \left[ {\left. {\;\;\;\frac{\partial }{\partial i} \left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s -e_2 \,\sigma_1 A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right.\;\;\; \\
+    & \qquad \qquad \quad+\frac{e_1 \,e_2 \,\sigma_1 }{e_3 }A^{lT}\;\frac{\partial T}{\partial s}\;\frac{\partial \sigma_1 }{\partial s} - \frac {\sigma_1 }{e_3} A^{lT} \;\frac{\partial \left( {e_1 \,e_2 \,\sigma_1 } \right)}{\partial s}\;\frac{\partial T}{\partial s} \\
+    & \qquad \qquad \quad-e_2 \left( {A^{lT}\;\frac{\partial \sigma_1 }{\partial s}\left. {\frac{\partial T}{\partial i}} \right|_s +\frac{\partial }{\partial s}\left( {\sigma_1 A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right)-\frac{\partial \sigma_1 }{\partial s}\;A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s } \right) \\
+    & \qquad \qquad \quad\shoveright{\left. {+\frac{\partial }{\partial s}\left( {\frac{e_1 \,e_2 \,\sigma_1 ^2}{e_3 }A^{lT}\;\frac{\partial T}{\partial s}+\frac{e_1 \,e_2}{e_3 }A^{vT}\;\frac{\partial T}{\partial s}} \right)\;\;\;} \right] . }
+  \end{array}
+      } \\
+  {
+  \begin{array}{*{20}l}
+    %
+    \intertext{Since the horizontal scale factors do not depend on the vertical coordinate,
+    the two terms on the second line cancel, while
+    the third line reduces to a single vertical derivative, so it becomes:}
+  %
+    D^T & =\frac{1}{e_1 \,e_2 \,e_3 }\left[ {\left. {\;\;\;\frac{\partial }{\partial i}\left( {\frac{e_2 \,e_3 }{e_1 }A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s -e_2 \,\sigma_1 \,A^{lT}\;\frac{\partial T}{\partial s}} \right)} \right|_s } \right. \\
+    & \qquad \qquad \quad \shoveright{ \left. {+\frac{\partial }{\partial s}\left( {-e_2 \,\sigma_1 \,A^{lT}\;\left. {\frac{\partial T}{\partial i}} \right|_s +A^{lT}\frac{e_1 \,e_2 }{e_3 }\;\left( {\varepsilon +\sigma_1 ^2} \right)\frac{\partial T}{\partial s}} \right)\;\;\;} \right]} \\
+    %
+    \intertext{In other words, the horizontal/vertical Laplacian operator in the ($i$,$s$) plane takes the following form:}
+  \end{array}
+  } \\
+  %
+  {\frac{1}{e_1\,e_2\,e_3}}
+  \left( {{
+  \begin{array}{*{30}c}
+    {\left. {\frac{\partial \left( {e_2 e_3 \bullet } \right)}{\partial i}} \right|_s } \hfill \\
+    {\frac{\partial \left( {e_1 e_2 \bullet } \right)}{\partial s}} \hfill \\
+  \end{array}}}
+  \right)
+  \cdot \left[ {A^{lT}
+  \left( {{
+  \begin{array}{*{30}c}
+    {1} \hfill & {-\sigma_1 } \hfill \\
+    {-\sigma_1} \hfill & {\varepsilon + \sigma_1^2} \hfill \\
+  \end{array}
+  }} \right)
+  \cdot
+  \left( {{
+  \begin{array}{*{30}c}
+    {\frac{1}{e_1 }\;\left. {\frac{\partial \bullet }{\partial i}} \right|_s } \hfill \\
+    {\frac{1}{e_3 }\;\frac{\partial \bullet }{\partial s}} \hfill \\
+  \end{array}
+  }}       \right) \left( T \right)} \right]
+\end{align*}
+%\addtocounter{equation}{-2}
+
+%% =================================================================================================
+\section{Iso/Diapycnal $2^{nd}$ order tracer diffusive operators}
+\label{sec:DIFFOPERS_2}
+
+%% =================================================================================================
+\subsubsection*{In z-coordinates}
+
+The iso/diapycnal diffusive tensor $\textbf {A}_{\textbf I}$ expressed in
+the ($i$,$j$,$k$) curvilinear coordinate system in which
+the equations of the ocean circulation model are formulated,
+takes the following form \citep{redi_JPO82}:
+
+\begin{equation}
+  \label{eq:DIFFOPERS_3}
+  \textbf {A}_{\textbf I} = \frac{A^{lT}}{\left( {1+a_1 ^2+a_2 ^2} \right)}
+  \left[ {{
+        \begin{array}{*{20}c}
+          {1+a_2 ^2 +\varepsilon a_1 ^2} \hfill & {-a_1 a_2 (1-\varepsilon)} \hfill & {-a_1 (1-\varepsilon) } \hfill \\
+          {-a_1 a_2 (1-\varepsilon) } \hfill & {1+a_1 ^2 +\varepsilon a_2 ^2} \hfill & {-a_2 (1-\varepsilon)} \hfill \\
+          {-a_1 (1-\varepsilon)} \hfill & {-a_2 (1-\varepsilon)} \hfill & {\varepsilon +a_1 ^2+a_2 ^2} \hfill \\
+        \end{array}
+      }} \right]
+\end{equation}
+where ($a_1$, $a_2$) are $(-1) \times$ the isopycnal slopes in
+($\textbf{i}$, $\textbf{j}$) directions, relative to geopotentials (or
+equivalently the slopes of the geopotential surfaces in the isopycnal
+coordinate framework):
+\[
+  a_1 =\frac{e_3 }{e_1 }\left( {\frac{\partial \rho }{\partial i}} \right)\left( {\frac{\partial \rho }{\partial k}} \right)^{-1}
+  \qquad , \qquad
+  a_2 =\frac{e_3 }{e_2 }\left( {\frac{\partial \rho }{\partial j}}
+  \right)\left( {\frac{\partial \rho }{\partial k}} \right)^{-1}
+\]
+and, as before, $\epsilon = A^{vT} / A^{lT}$.
+
+In practice, $\epsilon$ is small and isopycnal slopes are generally less than $10^{-2}$ in the ocean,
+so $\textbf {A}_{\textbf I}$ can be simplified appreciably \citep{cox_OM87}. Keeping leading order terms\footnote{Apart from the (1,0)
+and (0,1) elements which are set to zero. See \citet{griffies_bk04}, section 14.1.4.1 for a discussion of this point.}:
+\begin{subequations}
+  \label{eq:DIFFOPERS_4}
+  \begin{equation}
+    \label{eq:DIFFOPERS_4a}
+    {\textbf{A}_{\textbf{I}}} \approx A^{lT}\;\Re\;\text{where} \;\Re =
+    \left[ {{
+          \begin{array}{*{20}c}
+            1 \hfill & 0 \hfill & {-a_1 } \hfill \\
+            0 \hfill & 1 \hfill & {-a_2 } \hfill \\
+            {-a_1 } \hfill & {-a_2 } \hfill & {\varepsilon +a_1 ^2+a_2 ^2} \hfill \\
+          \end{array}
+        }} \right],
+  \end{equation}
+  and the iso/dianeutral diffusive operator in $z$-coordinates is then
+  \begin{equation}
+    \label{eq:DIFFOPERS_4b}
+    D^T = \left. \nabla \right|_z \cdot
+    \left[ A^{lT} \;\Re \cdot \left. \nabla \right|_z T  \right]. \\
+  \end{equation}
+\end{subequations}
+
+Physically, the full tensor \autoref{eq:DIFFOPERS_3} represents strong isoneutral diffusion on a plane parallel to
+the isoneutral surface and weak dianeutral diffusion perpendicular to this plane.
+However,
+the approximate `weak-slope' tensor \autoref{eq:DIFFOPERS_4a} represents strong diffusion along the isoneutral surface,
+with weak \emph{vertical} diffusion -- the principal axes of the tensor are no longer orthogonal.
+This simplification also decouples the ($i$,$z$) and ($j$,$z$) planes of the tensor.
+The weak-slope operator therefore takes the same form, \autoref{eq:DIFFOPERS_4}, as \autoref{eq:DIFFOPERS_2},
+the diffusion operator for geopotential diffusion written in non-orthogonal $i,j,s$-coordinates.
+Written out explicitly,
+
+\begin{multline}
+  \label{eq:DIFFOPERS_ldfiso}
+  D^T=\frac{1}{e_1 e_2 }\left\{
+    {\;\frac{\partial }{\partial i}\left[ {A_h \left( {\frac{e_2}{e_1}\frac{\partial T}{\partial i}-a_1 \frac{e_2}{e_3}\frac{\partial T}{\partial k}} \right)} \right]}
+    {+\frac{\partial}{\partial j}\left[ {A_h \left( {\frac{e_1}{e_2}\frac{\partial T}{\partial j}-a_2 \frac{e_1}{e_3}\frac{\partial T}{\partial k}} \right)} \right]\;} \right\} \\
+  \shoveright{+\frac{1}{e_3 }\frac{\partial }{\partial k}\left[ {A_h \left( {-\frac{a_1 }{e_1 }\frac{\partial T}{\partial i}-\frac{a_2 }{e_2 }\frac{\partial T}{\partial j}+\frac{\left( {a_1 ^2+a_2 ^2+\varepsilon} \right)}{e_3 }\frac{\partial T}{\partial k}} \right)} \right]}. \\
+\end{multline}
+
+The isopycnal diffusion operator \autoref{eq:DIFFOPERS_4},
+\autoref{eq:DIFFOPERS_ldfiso} conserves tracer quantity and dissipates its square.
+As \autoref{eq:DIFFOPERS_4} is the divergence of a flux, the demonstration of the first property is trivial, providing that the flux normal to the boundary is zero
+(as it is when $A_h$ is zero at the boundary). Let us demonstrate the second one:
+\[
+  \iiint\limits_D T\;\nabla .\left( {\textbf{A}}_{\textbf{I}} \nabla T \right)\,dv
+  = -\iiint\limits_D \nabla T\;.\left( {\textbf{A}}_{\textbf{I}} \nabla T \right)\,dv,
+\]
+and since
+\begin{align*}
+  {
+  \begin{array}{*{20}l}
+    \nabla T\;.\left( {{\mathrm {\mathbf A}}_{\mathrm {\mathbf I}} \nabla T}
+    \right)&=A^{lT}\left[ {\left( {\frac{\partial T}{\partial i}} \right)^2-2a_1
+             \frac{\partial T}{\partial i}\frac{\partial T}{\partial k}+\left(
+             {\frac{\partial T}{\partial j}} \right)^2} \right. \\
+           &\qquad \qquad \qquad
+             { \left. -\,{2a_2 \frac{\partial T}{\partial j}\frac{\partial T}{\partial k}+\left( {a_1 ^2+a_2 ^2+\varepsilon} \right)\left( {\frac{\partial T}{\partial k}} \right)^2} \right]} \\
+           &=A_h \left[ {\left( {\frac{\partial T}{\partial i}-a_1 \frac{\partial
+             T}{\partial k}} \right)^2+\left( {\frac{\partial T}{\partial
+             j}-a_2 \frac{\partial T}{\partial k}} \right)^2}
+             +\varepsilon \left(\frac{\partial T}{\partial k}\right) ^2\right]      \\
+           & \geq 0 .
+  \end{array}
+             }
+\end{align*}
+%\addtocounter{equation}{-1}
+the property becomes obvious.
+
+%% =================================================================================================
+\subsubsection*{In generalized vertical coordinates}
+
+Because the weak-slope operator \autoref{eq:DIFFOPERS_4},
+\autoref{eq:DIFFOPERS_ldfiso} is decoupled in the ($i$,$z$) and ($j$,$z$) planes,
+it may be transformed into generalized $s$-coordinates in the same way as
+\autoref{sec:DIFFOPERS_1} was transformed into \autoref{sec:DIFFOPERS_2}.
+The resulting operator then takes the simple form
+
+\begin{equation}
+  \label{eq:DIFFOPERS_ldfiso_s}
+  D^T = \left. \nabla \right|_s \cdot
+  \left[ A^{lT} \;\Re \cdot \left. \nabla \right|_s T  \right] \\
+  \;\;\text{where} \;\Re =\left( {{
+        \begin{array}{*{20}c}
+          1 \hfill & 0 \hfill & {-r _1 } \hfill \\
+          0 \hfill & 1 \hfill & {-r _2 } \hfill \\
+          {-r _1 } \hfill & {-r _2 } \hfill & {\varepsilon +r _1
+                                              ^2+r _2 ^2} \hfill \\
+        \end{array}
+      }} \right),
+\end{equation}
+
+where ($r_1$, $r_2$) are $(-1)\times$ the isopycnal slopes in ($\textbf{i}$, $\textbf{j}$) directions,
+relative to $s$-coordinate surfaces (or equivalently the slopes of the
+$s$-coordinate surfaces in the isopycnal coordinate framework):
+\[
+  r_1 =\frac{e_3 }{e_1 }\left( {\frac{\partial \rho }{\partial i}} \right)\left( {\frac{\partial \rho }{\partial s}} \right)^{-1}
+  \qquad , \qquad
+  r_2 =\frac{e_3 }{e_2 }\left( {\frac{\partial \rho }{\partial j}}
+  \right)\left( {\frac{\partial \rho }{\partial s}} \right)^{-1}.
+\]
+
+To prove \autoref{eq:DIFFOPERS_ldfiso_s} by direct re-expression of \autoref{eq:DIFFOPERS_ldfiso} is straightforward, but laborious.
+An easier way is first to note (by reversing the derivation of \autoref{sec:DIFFOPERS_2} from \autoref{sec:DIFFOPERS_1} ) that
+the weak-slope operator may be \emph{exactly} reexpressed in non-orthogonal $i,j,\rho$-coordinates as
+
+\begin{equation}
+  \label{eq:DIFFOPERS_5}
+  D^T = \left. \nabla \right|_\rho \cdot
+  \left[ A^{lT} \;\Re \cdot \left. \nabla \right|_\rho T  \right] \\
+  \;\;\text{where} \;\Re =\left( {{
+        \begin{array}{*{20}c}
+          1 \hfill & 0 \hfill &0 \hfill \\
+          0 \hfill & 1 \hfill & 0 \hfill \\
+          0 \hfill & 0 \hfill & \varepsilon \hfill \\
+        \end{array}
+      }} \right).
+\end{equation}
+Then direct transformation from $i,j,\rho$-coordinates to $i,j,s$-coordinates gives
+\autoref{eq:DIFFOPERS_ldfiso_s} immediately.
+
+Note that the weak-slope approximation is only made in transforming from
+the (rotated,orthogonal) isoneutral axes to the non-orthogonal $i,j,\rho$-coordinates.
+The further transformation into $i,j,s$-coordinates is exact, whatever the steepness of the $s$-surfaces,
+in the same way as the transformation of horizontal/vertical Laplacian diffusion in $z$-coordinates in
+\autoref{sec:DIFFOPERS_1} onto $s$-coordinates is exact, however steep the $s$-surfaces.
+
+%% =================================================================================================
+\section{Lateral/Vertical momentum diffusive operators}
+\label{sec:DIFFOPERS_3}
+
+The second order momentum diffusion operator (Laplacian) in $z$-coordinates is found by
+applying \autoref{eq:MB_lap_vector}, the expression for the Laplacian of a vector,
+to the horizontal velocity vector:
+\begin{align*}
+  \Delta {\textbf{U}}_h
+  &=\nabla \left( {\nabla \cdot {\textbf{U}}_h } \right)-
+    \nabla \times \left( {\nabla \times {\textbf{U}}_h } \right) \\ \\
+  &=\left( {{
+    \begin{array}{*{20}c}
+      {\frac{1}{e_1 }\frac{\partial \chi }{\partial i}} \hfill \\
+      {\frac{1}{e_2 }\frac{\partial \chi }{\partial j}} \hfill \\
+      {\frac{1}{e_3 }\frac{\partial \chi }{\partial k}} \hfill \\
+    \end{array}
+  }} \right)
+  -\left( {{
+  \begin{array}{*{20}c}
+    {\frac{1}{e_2 }\frac{\partial \zeta }{\partial j}-\frac{1}{e_3
+    }\frac{\partial }{\partial k}\left( {\frac{1}{e_3 }\frac{\partial
+    u}{\partial k}} \right)} \hfill \\
+    {\frac{1}{e_3 }\frac{\partial }{\partial k}\left( {-\frac{1}{e_3
+    }\frac{\partial v}{\partial k}} \right)-\frac{1}{e_1 }\frac{\partial \zeta
+    }{\partial i}} \hfill \\
+    {\frac{1}{e_1 e_2 }\left[ {\frac{\partial }{\partial i}\left( {\frac{e_2
+    }{e_3 }\frac{\partial u}{\partial k}} \right)-\frac{\partial }{\partial
+    j}\left( {-\frac{e_1 }{e_3 }\frac{\partial v}{\partial k}} \right)} \right]}
+    \hfill \\
+  \end{array}
+  }} \right) \\ \\
+  &=\left( {{
+    \begin{array}{*{20}c}
+      {\frac{1}{e_1 }\frac{\partial \chi }{\partial i}-\frac{1}{e_2 }\frac{\partial \zeta }{\partial j}} \\
+      {\frac{1}{e_2 }\frac{\partial \chi }{\partial j}+\frac{1}{e_1 }\frac{\partial \zeta }{\partial i}} \\
+      0 \\
+    \end{array}
+  }} \right)
+  +\frac{1}{e_3 }
+  \left( {{
+  \begin{array}{*{20}c}
+    {\frac{\partial }{\partial k}\left( {\frac{1}{e_3 }\frac{\partial u}{\partial k}} \right)} \\
+    {\frac{\partial }{\partial k}\left( {\frac{1}{e_3 }\frac{\partial v}{\partial k}} \right)} \\
+    {\frac{\partial \chi }{\partial k}-\frac{1}{e_1 e_2 }\left( {\frac{\partial ^2\left( {e_2 \,u} \right)}{\partial i\partial k}+\frac{\partial ^2\left( {e_1 \,v} \right)}{\partial j\partial k}} \right)} \\
+  \end{array}
+  }} \right)
+\end{align*}
+Using \autoref{eq:MB_div}, the definition of the horizontal divergence,
+the third component of the second vector is obviously zero and thus :
+\[
+  \Delta {\textbf{U}}_h = \nabla _h \left( \chi \right) - \nabla _h \times \left( \zeta \textbf{k} \right) + \frac {1}{e_3 } \frac {\partial }{\partial k} \left( {\frac {1}{e_3 } \frac{\partial {\textbf{ U}}_h }{\partial k}} \right) .
+\]
+
+Note that this operator ensures a full separation between
+the vorticity and horizontal divergence fields (see \autoref{apdx:INVARIANTS}).
+It is only equal to a Laplacian applied to each component in Cartesian coordinates, not on the sphere.
+
+The horizontal/vertical second order (Laplacian type) operator used to diffuse horizontal momentum in
+the $z$-coordinate therefore takes the following form:
+\begin{equation}
+  \label{eq:DIFFOPERS_Lap_U}
+  {
+    \textbf{D}}^{\textbf{U}} =
+  \nabla _h \left( {A^{lm}\;\chi } \right)
+  - \nabla _h \times \left( {A^{lm}\;\zeta \;{\textbf{k}}} \right)
+  + \frac{1}{e_3 }\frac{\partial }{\partial k}\left( {\frac{A^{vm}\;}{e_3 }
+      \frac{\partial {\mathrm {\mathbf U}}_h }{\partial k}} \right) , \\
+\end{equation}
+that is, in expanded form:
+\begin{align*}
+  D^{\textbf{U}}_u
+  & = \frac{1}{e_1} \frac{\partial \left( {A^{lm}\chi   } \right)}{\partial i}
+    -\frac{1}{e_2} \frac{\partial \left( {A^{lm}\zeta } \right)}{\partial j}
+    +\frac{1}{e_3} \frac{\partial }{\partial k} \left( \frac{A^{vm}}{e_3} \frac{\partial u}{\partial k} \right)   ,   \\
+  D^{\textbf{U}}_v
+  & = \frac{1}{e_2 }\frac{\partial \left( {A^{lm}\chi   } \right)}{\partial j}
+    +\frac{1}{e_1 }\frac{\partial \left( {A^{lm}\zeta } \right)}{\partial i}
+    +\frac{1}{e_3} \frac{\partial }{\partial k} \left( \frac{A^{vm}}{e_3} \frac{\partial v}{\partial k} \right) .
+\end{align*}
+
+Note Bene: introducing a rotation in \autoref{eq:DIFFOPERS_Lap_U} does not lead to
+a useful expression for the iso/diapycnal Laplacian operator in the $z$-coordinate.
+Similarly, we did not found an expression of practical use for
+the geopotential horizontal/vertical Laplacian operator in the $s$-coordinate.
+Generally, \autoref{eq:DIFFOPERS_Lap_U} is used in both $z$- and $s$-coordinate systems,
+that is a Laplacian diffusion is applied on momentum along the coordinate directions.
+
+\subinc{\input{../../global/epilogue}}
+
+\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_invariants.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_invariants.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_invariants.tex	(revision 12143)
@@ -0,0 +1,1483 @@
+\documentclass[../main/NEMO_manual]{subfiles}
+
+\begin{document}
+
+\chapter{Discrete Invariants of the Equations}
+\label{apdx:INVARIANTS}
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+%%%  Appendix put in cmtgm as it has not been updated for \zstar and s coordinate
+%I'm writting this appendix. It will be available in a forthcoming release of the documentation
+
+%\cmtgm{
+
+%% =================================================================================================
+\section{Introduction / Notations}
+\label{sec:INVARIANTS_0}
+
+Notation used in this appendix in the demonstations:
+
+fluxes at the faces of a $T$-box:
+\[
+  U = e_{2u}\,e_{3u}\; u  \qquad  V = e_{1v}\,e_{3v}\; v  \qquad W = e_{1w}\,e_{2w}\; \omega
+\]
+
+volume of cells at $u$-, $v$-, and $T$-points:
+\[
+  b_u = e_{1u}\,e_{2u}\,e_{3u}  \qquad  b_v = e_{1v}\,e_{2v}\,e_{3v}  \qquad b_t = e_{1t}\,e_{2t}\,e_{3t}
+\]
+
+partial derivative notation: $\partial_\bullet = \frac{\partial}{\partial \bullet}$
+
+$dv=e_1\,e_2\,e_3 \,di\,dj\,dk$  is the volume element, with only $e_3$ that depends on time.
+$D$ and $S$ are the ocean domain volume and surface, respectively.
+No wetting/drying is allow (\ie\ $\frac{\partial S}{\partial t} = 0$).
+Let $k_s$ and $k_b$ be the ocean surface and bottom, resp.
+(\ie\ $s(k_s) = \eta$ and $s(k_b)=-H$, where $H$ is the bottom depth).
+\begin{flalign*}
+  z(k) = \eta - \int\limits_{\tilde{k}=k}^{\tilde{k}=k_s}  e_3(\tilde{k}) \;d\tilde{k}
+  = \eta - \int\limits_k^{k_s}  e_3 \;d\tilde{k}
+\end{flalign*}
+
+Continuity equation with the above notation:
+\[
+  \frac{1}{e_{3t}} \partial_t (e_{3t})+ \frac{1}{b_t}  \biggl\{  \delta_i [U] + \delta_j [V] + \delta_k [W] \biggr\} = 0
+\]
+
+A quantity, $Q$ is conserved when its domain averaged time change is zero, that is when:
+\[
+  \partial_t \left( \int_D{ Q\;dv } \right) =0
+\]
+Noting that the coordinate system used ....  blah blah
+\[
+  \partial_t \left( \int_D {Q\;dv} \right) =  \int_D { \partial_t \left( e_3 \, Q \right) e_1e_2\;di\,dj\,dk }
+  =  \int_D { \frac{1}{e_3} \partial_t \left( e_3 \, Q \right) dv } =0
+\]
+equation of evolution of $Q$ written as
+the time evolution of the vertical content of $Q$ like for tracers, or momentum in flux form,
+the quadratic quantity $\frac{1}{2}Q^2$ is conserved when:
+\begin{flalign*}
+  \partial_t \left(   \int_D{ \frac{1}{2} \,Q^2\;dv }   \right)
+  =&  \int_D{ \frac{1}{2} \partial_t \left( \frac{1}{e_3}\left( e_3 \, Q \right)^2 \right) e_1e_2\;di\,dj\,dk } \\
+  =&  \int_D {         Q   \;\partial_t\left( e_3 \, Q \right) e_1e_2\;di\,dj\,dk }
+  -  \int_D { \frac{1}{2} Q^2 \,\partial_t  (e_3) \;e_1e_2\;di\,dj\,dk } \\
+\end{flalign*}
+that is in a more compact form :
+\begin{flalign}
+  \label{eq:INVARIANTS_Q2_flux}
+  \partial_t \left( \int_D {\frac{1}{2} Q^2\;dv} \right)
+  =&                   \int_D { \frac{Q}{e_3}  \partial_t \left( e_3 \, Q \right) dv }
+  -   \frac{1}{2} \int_D {  \frac{Q^2}{e_3} \partial_t (e_3) \;dv }
+\end{flalign}
+equation of evolution of $Q$ written as the time evolution of $Q$ like for momentum in vector invariant form,
+the quadratic quantity $\frac{1}{2}Q^2$ is conserved when:
+\begin{flalign*}
+  \partial_t \left( \int_D {\frac{1}{2} Q^2\;dv} \right)
+  =&  \int_D { \frac{1}{2} \partial_t \left( e_3 \, Q^2 \right) \;e_1e_2\;di\,dj\,dk } \\
+  =& \int_D {         Q      \partial_t Q  \;e_1e_2e_3\;di\,dj\,dk }
+  +  \int_D { \frac{1}{2} Q^2 \, \partial_t e_3  \;e_1e_2\;di\,dj\,dk } \\
+\end{flalign*}
+that is in a more compact form:
+\begin{flalign}
+  \label{eq:INVARIANTS_Q2_vect}
+  \partial_t \left( \int_D {\frac{1}{2} Q^2\;dv} \right)
+  =& \int_D {         Q   \,\partial_t Q  \;dv }
+  +   \frac{1}{2} \int_D { \frac{1}{e_3} Q^2 \partial_t e_3 \;dv }
+\end{flalign}
+
+%% =================================================================================================
+\section{Continuous conservation}
+\label{sec:INVARIANTS_1}
+
+The discretization of pimitive equation in $s$-coordinate (\ie\ time and space varying vertical coordinate)
+must be chosen so that the discrete equation of the model satisfy integral constrains on energy and enstrophy.
+
+Let us first establish those constraint in the continuous world.
+The total energy (\ie\ kinetic plus potential energies) is conserved:
+\begin{flalign}
+  \label{eq:INVARIANTS_Tot_Energy}
+  \partial_t \left( \int_D \left( \frac{1}{2} {\textbf{U}_h}^2 +  \rho \, g \, z \right) \;dv \right)  = & 0
+\end{flalign}
+under the following assumptions: no dissipation, no forcing (wind, buoyancy flux, atmospheric pressure variations),
+mass conservation, and closed domain.
+
+This equation can be transformed to obtain several sub-equalities.
+The transformation for the advection term depends on whether the vector invariant form or
+the flux form is used for the momentum equation.
+Using \autoref{eq:INVARIANTS_Q2_vect} and introducing \autoref{eq:SCOORD_dyn_vect} in
+\autoref{eq:INVARIANTS_Tot_Energy} for the former form and
+using \autoref{eq:INVARIANTS_Q2_flux} and introducing \autoref{eq:SCOORD_dyn_flux} in
+\autoref{eq:INVARIANTS_Tot_Energy} for the latter form leads to:
+
+% \label{eq:INVARIANTS_E_tot}
+advection term (vector invariant form):
+\[
+  % \label{eq:INVARIANTS_E_tot_vect_vor_1}
+  \int\limits_D  \zeta \; \left( \textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv   = 0   \\
+\]
+\[
+  % \label{eq:INVARIANTS_E_tot_vect_adv_1}
+  \int\limits_D  \textbf{U}_h \cdot \nabla_h \left( \frac{{\textbf{U}_h}^2}{2} \right)     dv
+  + \int\limits_D  \textbf{U}_h \cdot \nabla_z \textbf{U}_h  \;dv
+  -  \int\limits_D { \frac{{\textbf{U}_h}^2}{2} \frac{1}{e_3} \partial_t e_3 \;dv }   = 0
+\]
+advection term (flux form):
+\[
+  % \label{eq:INVARIANTS_E_tot_flux_metric}
+  \int\limits_D  \frac{1} {e_1 e_2 } \left( v \,\partial_i e_2 - u \,\partial_j e_1  \right)\;
+  \left(  \textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv   = 0
+\]
+\[
+  % \label{eq:INVARIANTS_E_tot_flux_adv}
+  \int\limits_D \textbf{U}_h \cdot     \left(                 {{
+        \begin{array} {*{20}c}
+          \nabla \cdot \left( \textbf{U}\,u \right) \hfill \\
+          \nabla \cdot \left( \textbf{U}\,v \right) \hfill
+        \end{array}}
+    }           \right)   \;dv
+  +   \frac{1}{2} \int\limits_D {  {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t e_3 \;dv } =\;0
+\]
+coriolis term
+\[
+  % \label{eq:INVARIANTS_E_tot_cor}
+  \int\limits_D  f   \; \left( \textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv   = 0
+\]
+pressure gradient:
+\[
+  % \label{eq:INVARIANTS_E_tot_pg_1}
+  - \int\limits_D  \left. \nabla p \right|_z \cdot \textbf{U}_h \;dv
+  = - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
+  + \int\limits_D g\, \rho \; \partial_t z  \;dv
+\]
+
+where $\nabla_h = \left. \nabla \right|_k$ is the gradient along the $s$-surfaces.
+
+blah blah....
+
+The prognostic ocean dynamics equation can be summarized as follows:
+\[
+  \text{NXT} = \dbinom	{\text{VOR} + \text{KEG} + \text {ZAD} }
+  {\text{COR} + \text{ADV}                       }
+  + \text{HPG} + \text{SPG} + \text{LDF} + \text{ZDF}
+\]
+
+Vector invariant form:
+% \label{eq:INVARIANTS_E_tot_vect}
+\[
+  % \label{eq:INVARIANTS_E_tot_vect_vor_2}
+  \int\limits_D   \textbf{U}_h \cdot \text{VOR} \;dv   = 0
+\]
+\[
+  % \label{eq:INVARIANTS_E_tot_vect_adv_2}
+  \int\limits_D  \textbf{U}_h \cdot \text{KEG}  \;dv
+  + \int\limits_D  \textbf{U}_h \cdot \text{ZAD}  \;dv
+  -  \int\limits_D { \frac{{\textbf{U}_h}^2}{2} \frac{1}{e_3} \partial_t e_3 \;dv }   = 0
+\]
+\[
+  % \label{eq:INVARIANTS_E_tot_pg_2}
+  - \int\limits_D  \textbf{U}_h \cdot (\text{HPG}+ \text{SPG}) \;dv
+  = - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
+  + \int\limits_D g\, \rho \; \partial_t z  \;dv
+\]
+
+Flux form:
+\begin{subequations}
+  \label{eq:INVARIANTS_E_tot_flux}
+  \[
+    % \label{eq:INVARIANTS_E_tot_flux_metric_2}
+    \int\limits_D  \textbf{U}_h \cdot \text {COR} \;  dv   = 0
+  \]
+  \[
+    % \label{eq:INVARIANTS_E_tot_flux_adv_2}
+    \int\limits_D \textbf{U}_h \cdot \text{ADV}   \;dv
+    +   \frac{1}{2} \int\limits_D {  {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t e_3  \;dv } =\;0
+  \]
+  \begin{equation}
+    \label{eq:INVARIANTS_E_tot_pg_3}
+    - \int\limits_D  \textbf{U}_h \cdot (\text{HPG}+ \text{SPG}) \;dv
+    = - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
+    + \int\limits_D g\, \rho \; \partial_t  z  \;dv
+  \end{equation}
+\end{subequations}
+
+\autoref{eq:INVARIANTS_E_tot_pg_3} is the balance between the conversion KE to PE and PE to KE.
+Indeed the left hand side of \autoref{eq:INVARIANTS_E_tot_pg_3} can be transformed as follows:
+\begin{flalign*}
+  \partial_t  \left( \int\limits_D { \rho \, g \, z  \;dv} \right)
+  &= + \int\limits_D \frac{1}{e_3} \partial_t (e_3\,\rho) \;g\;z\;\;dv
+  +  \int\limits_D g\, \rho \; \partial_t z  \;dv   &&&\\
+  &= - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
+  + \int\limits_D g\, \rho \; \partial_t z \;dv   &&&\\
+  &= + \int\limits_D  \rho \,g \left( \textbf {U}_h \cdot \nabla_h z + \omega \frac{1}{e_3} \partial_k z \right)  \;dv
+  + \int\limits_D g\, \rho \; \partial_t z \;dv   &&&\\
+  &= + \int\limits_D  \rho \,g \left( \omega + \partial_t z + \textbf {U}_h \cdot \nabla_h z  \right)  \;dv  &&&\\
+  &=+  \int\limits_D g\, \rho \; w \; dv   &&&\\
+\end{flalign*}
+where the last equality is obtained by noting that the brackets is exactly the expression of $w$,
+the vertical velocity referenced to the fixe $z$-coordinate system (see \autoref{eq:SCOORD_w_s}).
+
+The left hand side of \autoref{eq:INVARIANTS_E_tot_pg_3} can be transformed as follows:
+\begin{flalign*}
+  - \int\limits_D  \left. \nabla p \right|_z & \cdot \textbf{U}_h \;dv
+  = - \int\limits_D  \left( \nabla_h p + \rho \, g \nabla_h z \right) \cdot \textbf{U}_h \;dv   &&&\\
+  \allowdisplaybreaks
+  &= - \int\limits_D  \nabla_h  p \cdot \textbf{U}_h \;dv   - \int\limits_D  \rho \, g \, \nabla_h z \cdot \textbf{U}_h \;dv   &&&\\
+  \allowdisplaybreaks
+  &= +\int\limits_D p \,\nabla_h \cdot \textbf{U}_h \;dv   + \int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
+  \allowdisplaybreaks
+  &= -\int\limits_D p \left( \frac{1}{e_3} \partial_t e_3 + \frac{1}{e_3} \partial_k \omega  \right) \;dv
+  +\int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
+  \allowdisplaybreaks
+  &= -\int\limits_D \frac{p}{e_3} \partial_t e_3  \;dv
+  +\int\limits_D \frac{1}{e_3} \partial_k p\; \omega \;dv
+  +\int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
+  &= -\int\limits_D \frac{p}{e_3} \partial_t e_3  \;dv
+  -\int\limits_D \rho \, g \, \omega \;dv
+  +\int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
+  &= - \int\limits_D \frac{p}{e_3} \partial_t e_3 \; \;dv
+  - \int\limits_D  \rho \, g \, w \;dv
+  + \int\limits_D   \rho \, g \, \partial_t z \;dv   &&&\\
+  \allowdisplaybreaks
+  \intertext{introducing the hydrostatic balance $\partial_k p=-\rho \,g\,e_3$ in the last term,
+    it becomes:}
+  &= - \int\limits_D \frac{p}{e_3} \partial_t e_3 \;dv
+  - \int\limits_D  \rho \, g \, w \;dv
+  - \int\limits_D  \frac{1}{e_3} \partial_k p\, \partial_t z \;dv   &&&\\
+  &= - \int\limits_D \frac{p}{e_3} \partial_t e_3 \;dv
+  - \int\limits_D  \rho \, g \, w \;dv
+  + \int\limits_D \,\frac{p}{e_3}\partial_t ( \partial_k z )  dv   &&&\\
+  %
+  &= - \int\limits_D  \rho \, g \, w \;dv   &&&\\
+\end{flalign*}
+
+%gm comment
+\cmtgm{
+The last equality comes from the following equation,
+\begin{flalign*}
+  \int\limits_D p \frac{1}{e_3} \frac{\partial e_3}{\partial t}\; \;dv
+  = \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv \quad,
+\end{flalign*}
+that can be demonstrated as follows:
+
+\begin{flalign*}
+  \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv
+  &= \int\limits_D    \rho \, g \, \frac{\partial \eta}{\partial t} \;dv
+  -  \int\limits_D    \rho \, g \, \frac{\partial}{\partial t} \left(  \int\limits_k^{k_s}  e_3 \;d\tilde{k} \right) \;dv   &&&\\
+  &= \int\limits_D    \rho \, g \, \frac{\partial \eta}{\partial t} \;dv
+  -  \int\limits_D    \rho \, g    \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right) \;dv   &&&\\
+  %
+  \allowdisplaybreaks
+  \intertext{The second term of the right hand side can be transformed by applying the integration by part rule:
+    $\left[ a\,b \right]_{k_b}^{k_s} = \int_{k_b}^{k_s}  a\,\frac{\partial b}{\partial k}       \;dk
+    + \int_{k_b}^{k_s}      \frac{\partial a}{\partial k} \,b \;dk $
+    to the following function: $a=  \int_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k}$
+    and $b=  \int_k^{k_s}  \rho \, e_3 \;d\tilde{k}$
+    (note that $\frac{\partial}{\partial k} \left(  \int_k^{k_s}  a \;d\tilde{k}  \right) = - a$ as $k$ is the lower bound of the integral).
+    This leads to:  }
+\end{flalign*}
+\begin{flalign*}
+  &\left[ \int\limits_{k}^{k_s}  \frac{\partial e_3}{\partial t} \,dk \cdot \int\limits_{k}^{k_s}  \rho \, e_3 \,dk   \right]_{k_b}^{k_s}
+  =-\int\limits_{k_b}^{k_s} \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right)  \rho \,e_3 \;dk
+  -\int\limits_{k_b}^{k_s}  \frac{\partial e_3}{\partial t}  \left(  \int\limits_k^{k_s}  \rho \, e_3 \;d\tilde{k} \right)   dk  &&&\\
+  \allowdisplaybreaks
+  \intertext{Noting that $\frac{\partial \eta}{\partial t}
+    = \frac{\partial}{\partial t}  \left( \int_{k_b}^{k_s}   e_3  \;d\tilde{k}  \right)
+    = \int_{k_b}^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k}$
+    and
+    $p(k) = \int_k^{k_s}  \rho \,g \, e_3 \;d\tilde{k} $,
+    but also that $\frac{\partial \eta}{\partial t}$ does not depends on $k$, it comes:
+  }
+  & - \int\limits_{k_b}^{k_s}  \rho \, \frac{\partial \eta}{\partial t} \, e_3 \;dk
+  = - \int\limits_{k_b}^{k_s} \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right)   \, \rho \, g   e_3\;dk
+  - \int\limits_{k_b}^{k_s}  \frac{\partial e_3}{\partial t} \frac{p}{g}         \;dk       &&&\\
+\end{flalign*}
+Mutliplying by $g$ and integrating over the $(i,j)$ domain it becomes:
+\begin{flalign*}
+  \int\limits_D  \rho \, g \, \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right)    \;dv
+  =  \int\limits_D  \rho \, g \, \frac{\partial \eta}{\partial t} dv
+  - \int\limits_D  \frac{p}{e_3}\frac{\partial e_3}{\partial t}         \;dv
+\end{flalign*}
+Using this property, we therefore have:
+\begin{flalign*}
+  \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv
+  &= \int\limits_D    \rho \, g \, \frac{\partial \eta}{\partial t}   \;dv
+  - \left(  \int\limits_D  \rho \, g \, \frac{\partial \eta}{\partial t} dv
+    - \int\limits_D  \frac{p}{e_3}\frac{\partial e_3}{\partial t}   \;dv  \right)    &&&\\
+  %
+  &=\int\limits_D \frac{p}{e_3} \frac{\partial (e_3\,\rho)}{\partial t}\; \;dv
+\end{flalign*}
+% end gm comment
+}
+
+%% =================================================================================================
+\section{Discrete total energy conservation: vector invariant form}
+\label{sec:INVARIANTS_2}
+
+%% =================================================================================================
+\subsection{Total energy conservation}
+\label{subsec:INVARIANTS_KE+PE_vect}
+
+The discrete form of the total energy conservation, \autoref{eq:INVARIANTS_Tot_Energy}, is given by:
+\begin{flalign*}
+  \partial_t  \left(  \sum\limits_{i,j,k} \biggl\{ \frac{u^2}{2} \,b_u + \frac{v^2}{2}\, b_v +  \rho \, g \, z_t \,b_t  \biggr\} \right) &=0
+\end{flalign*}
+which in vector invariant forms, it leads to:
+\begin{equation}
+  \label{eq:INVARIANTS_KE+PE_vect_discrete}
+  \begin{split}
+    \sum\limits_{i,j,k} \biggl\{   u\,                        \partial_t u         \;b_u
+    + v\,                        \partial_t v          \;b_v  \biggr\}
+    + \frac{1}{2} \sum\limits_{i,j,k} \biggl\{  \frac{u^2}{e_{3u}}\partial_t e_{3u} \;b_u
+    +  \frac{v^2}{e_{3v}}\partial_t e_{3v} \;b_v   \biggr\}      \\
+    = - \sum\limits_{i,j,k} \biggl\{ \frac{1}{e_{3t}}\partial_t (e_{3t} \rho) \, g \, z_t \;b_t  \biggr\}
+    - \sum\limits_{i,j,k} \biggl\{ \rho \,g\,\partial_t (z_t) \,b_t  \biggr\}
+  \end{split}
+\end{equation}
+
+Substituting the discrete expression of the time derivative of the velocity either in vector invariant,
+leads to the discrete equivalent of the four equations \autoref{eq:INVARIANTS_E_tot_flux}.
+
+%% =================================================================================================
+\subsection{Vorticity term (coriolis + vorticity part of the advection)}
+\label{subsec:INVARIANTS_vor}
+
+Let $q$, located at $f$-points, be either the relative ($q=\zeta / e_{3f}$),
+or the planetary ($q=f/e_{3f}$), or the total potential vorticity ($q=(\zeta +f) /e_{3f}$).
+Two discretisation of the vorticity term (ENE and EEN) allows the conservation of the kinetic energy.
+%% =================================================================================================
+\subsubsection{Vorticity term with ENE scheme (\protect\np[=.true.]{ln_dynvor_ene}{ln\_dynvor\_ene})}
+\label{subsec:INVARIANTS_vorENE}
+
+For the ENE scheme, the two components of the vorticity term are given by:
+\[
+  - e_3 \, q \;{\textbf{k}}\times {\textbf {U}}_h    \equiv
+  \left( {{
+        \begin{array} {*{20}c}
+          + \frac{1} {e_{1u}} \;
+          \overline {\, q \ \overline {\left( e_{1v}\,e_{3v}\,v \right)}^{\,i+1/2}} ^{\,j}        \hfill \\
+          - \frac{1} {e_{2v}} \;
+          \overline {\, q \ \overline {\left( e_{2u}\,e_{3u}\,u \right)}^{\,j+1/2}} ^{\,i}       \hfill
+        \end{array}
+      } }    \right)
+\]
+
+This formulation does not conserve the enstrophy but it does conserve the total kinetic energy.
+Indeed, the kinetic energy tendency associated to the vorticity term and
+averaged over the ocean domain can be transformed as follows:
+\begin{flalign*}
+  &\int\limits_D -  \left(  e_3 \, q \;\textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv &&  \\
+  & \qquad \qquad
+  {
+    \begin{array}{*{20}l}
+      &\equiv \sum\limits_{i,j,k} 	\biggl\{
+        \frac{1} {e_{1u}} \overline { \,q\ \overline{ V }^{\,i+1/2}} ^{\,j} \, u \; b_u
+        - \frac{1} {e_{2v}}\overline { \, q\ \overline{ U }^{\,j+1/2}} ^{\,i} \, v \; b_v \; \biggr\}    \\
+      &\equiv  \sum\limits_{i,j,k} 	\biggl\{
+        \overline { \,q\ \overline{ V }^{\,i+1/2}}^{\,j} \; U
+        - \overline { \,q\ \overline{ U }^{\,j+1/2}}^{\,i} \; V  \; \biggr\}     \\
+      &\equiv \sum\limits_{i,j,k} q \  \biggl\{  \overline{ V }^{\,i+1/2}\; \overline{ U }^{\,j+1/2}
+        - \overline{ U }^{\,j+1/2}\; \overline{ V }^{\,i+1/2}         \biggr\}  \quad  \equiv 0
+    \end{array}
+  }
+\end{flalign*}
+In other words, the domain averaged kinetic energy does not change due to the vorticity term.
+
+%% =================================================================================================
+\subsubsection{Vorticity term with EEN scheme (\protect\np[=.true.]{ln_dynvor_een}{ln\_dynvor\_een})}
+\label{subsec:INVARIANTS_vorEEN_vect}
+
+With the EEN scheme, the vorticity terms are represented as:
+\begin{equation}
+  \label{eq:INVARIANTS_dynvor_een1}
+  \left\{ {
+      \begin{aligned}
+        +q\,e_3 \, v 	&\equiv +\frac{1}{e_{1u} }   \sum_{\substack{i_p,\,k_p}}
+        {^{i+1/2-i_p}_j}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{1v} e_{3v} \ v  \right)^{i+i_p-1/2}_{j+j_p}   \\
+        - q\,e_3 \, u     &\equiv -\frac{1}{e_{2v} }    \sum_{\substack{i_p,\,k_p}}
+        {^i_{j+1/2-j_p}}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{2u} e_{3u} \ u  \right)^{i+i_p}_{j+j_p-1/2}
+      \end{aligned}
+    } \right.
+\end{equation}
+where the indices $i_p$ and $j_p$ take the following value: $i_p = -1/2$ or $1/2$ and $j_p = -1/2$ or $1/2$,
+and the vorticity triads, ${^i_j}\mathbb{Q}^{i_p}_{j_p}$, defined at $T$-point, are given by:
+\begin{equation}
+  \label{eq:INVARIANTS_Q_triads}
+  _i^j \mathbb{Q}^{i_p}_{j_p}
+  = \frac{1}{12} \ \left(   q^{i-i_p}_{j+j_p} + q^{i+j_p}_{j+i_p} + q^{i+i_p}_{j-j_p}  \right)
+\end{equation}
+
+This formulation does conserve the total kinetic energy.
+Indeed,
+\begin{flalign*}
+  &\int\limits_D - \textbf{U}_h \cdot   \left(  \zeta \;\textbf{k} \times \textbf{U}_h  \right)  \;  dv &&  \\
+  \equiv \sum\limits_{i,j,k} &	\biggl\{
+  \left[  \sum_{\substack{i_p,\,k_p}}
+    {^{i+1/2-i_p}_j}\mathbb{Q}^{i_p}_{j_p} \; V^{i+1/2-i_p}_{j+j_p} \right] U^{i+1/2}_{j}    %   &&\\
+  - \left[  \sum_{\substack{i_p,\,k_p}}
+    {^i_{j+1/2-j_p}}\mathbb{Q}^{i_p}_{j_p} \; U^{i+i_p}_{j+1/2-j_p}  \right] V^{i}_{j+1/2}    \biggr\}     && \\ \\
+  \equiv \sum\limits_{i,j,k} &  \sum_{\substack{i_p,\,k_p}} \biggl\{  \ \
+  {^{i+1/2-i_p}_j}\mathbb{Q}^{i_p}_{j_p} \; V^{i+1/2-i_p}_{j+j_p}  \, U^{i+1/2}_{j}     %  &&\\
+  - {^i_{j+1/2-j_p}}\mathbb{Q}^{i_p}_{j_p} \; U^{i+i_p}_{j+1/2-j_p} \, V^{i}_{j+1/2}     \ \;     \biggr\}     &&  \\
+  %
+  \allowdisplaybreaks
+  \intertext{ Expending the summation on $i_p$ and $k_p$, it becomes:}
+  %
+  \equiv \sum\limits_{i,j,k} & \biggl\{  \ \
+  {^{i+1}_j     }\mathbb{Q}^{-1/2}_{+1/2} \;V^{i+1}_{j+1/2} \; U^{\,i+1/2}_{j}
+  -  {^i_{j}\quad}\mathbb{Q}^{-1/2}_{+1/2} \; U^{i-1/2}_{j}    \; V^{\,i}_{j+1/2}         &&  \\
+  &       + {^{i+1}_j     }\mathbb{Q}^{-1/2}_{-1/2} \; V^{i+1}_{j-1/2} \; U^{\,i+1/2}_{j}
+  - {^i_{j+1}     }\mathbb{Q}^{-1/2}_{-1/2} \; U^{i-1/2}_{j+1} \; V^{\,i}_{j+1/2}        \biggr.     &&  \\
+  &       + {^{i}_j\quad}\mathbb{Q}^{+1/2}_{+1/2} \; V^{i}_{j+1/2}   \; U^{\,i+1/2}_{j}
+  - {^i_{j}\quad}\mathbb{Q}^{+1/2}_{+1/2} \; U^{i+1/2}_{j}   \; V^{\,i}_{j+1/2}          \biggr.        &&  \\
+  &       + {^{i}_j\quad}\mathbb{Q}^{+1/2}_{-1/2} \; V^{i}_{j-1/2}     \; U^{\,i+1/2}_{j}
+  -  {^i_{j+1}     }\mathbb{Q}^{+1/2}_{-1/2} \; U^{i+1/2}_{j+1}\; V^{\,i}_{j+1/2}  \ \;     \biggr\}     &&  \\
+  %
+  \allowdisplaybreaks
+  \intertext{The summation is done over all $i$ and $j$ indices, it is therefore possible to introduce
+    a shift of $-1$ either in $i$ or $j$ direction in some of the term of the summation (first term of the
+    first and second lines, second term of the second and fourth lines). By doning so, we can regroup
+    all the terms of the summation by triad at a ($i$,$j$) point. In other words, we regroup all the terms
+    in the neighbourhood  that contain a triad at the same ($i$,$j$) indices. It becomes: }
+  \allowdisplaybreaks
+  %
+  \equiv \sum\limits_{i,j,k} & \biggl\{  \ \
+  {^{i}_j}\mathbb{Q}^{-1/2}_{+1/2}  \left[  V^{i}_{j+1/2}\, U^{\,i-1/2}_{j}
+    -  U^{i-1/2}_{j} \, V^{\,i}_{j+1/2}      \right]    &&  \\
+  &       + {^{i}_j}\mathbb{Q}^{-1/2}_{-1/2}  \left[  V^{i}_{j-1/2} \, U^{\,i-1/2}_{j}
+    -    U^{i-1/2}_{j} \, V^{\,i}_{j-1/2}      \right]    \biggr.   &&  \\
+  &      + {^{i}_j}\mathbb{Q}^{+1/2}_{+1/2}  \left[  V^{i}_{j+1/2} \, U^{\,i+1/2}_{j}
+    -    U^{i+1/2}_{j} \, V^{\,i}_{j+1/2}     \right]  \biggr.  &&  \\
+  &     + {^{i}_j}\mathbb{Q}^{+1/2}_{-1/2}  \left[   V^{i}_{j-1/2} \, U^{\,i+1/2}_{j}
+    -    U^{i+1/2}_{j-1} \, V^{\,i}_{j-1/2}  \right]  \ \;   \biggr\}   \qquad
+  \equiv \ 0   &&
+\end{flalign*}
+
+%% =================================================================================================
+\subsubsection{Gradient of kinetic energy / Vertical advection}
+\label{subsec:INVARIANTS_zad}
+
+The change of Kinetic Energy (KE) due to the vertical advection is exactly balanced by the change of KE due to the horizontal gradient of KE~:
+\[
+  \int_D \textbf{U}_h \cdot \frac{1}{e_3 } \omega \partial_k \textbf{U}_h \;dv
+  =  -   \int_D \textbf{U}_h \cdot \nabla_h \left( \frac{1}{2}\;{\textbf{U}_h}^2 \right)\;dv
+  +   \frac{1}{2} \int_D {  \frac{{\textbf{U}_h}^2}{e_3} \partial_t ( e_3) \;dv }
+\]
+Indeed, using successively \autoref{eq:DOM_di_adj} (\ie\ the skew symmetry property of the $\delta$ operator)
+and the continuity equation, then \autoref{eq:DOM_di_adj} again,
+then the commutativity of operators $\overline {\,\cdot \,}$ and $\delta$, and finally \autoref{eq:DOM_mi_adj}
+(\ie\ the symmetry property of the $\overline {\,\cdot \,}$ operator)
+applied in the horizontal and vertical directions, it becomes:
+\begin{flalign*}
+  & - \int_D \textbf{U}_h \cdot \text{KEG}\;dv
+  = - \int_D \textbf{U}_h \cdot \nabla_h \left( \frac{1}{2}\;{\textbf{U}_h}^2 \right)\;dv    &&&\\
+  %
+  \equiv  & -  \sum\limits_{i,j,k} \frac{1}{2}  \biggl\{
+  \frac{1} {e_{1u}}  \delta_{i+1/2}   \left[   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right]  u \ b_u
+  + \frac{1} {e_{2v}}  \delta_{j+1/2}   \left[   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right]  v \ b_v   \biggr\}  	&&&  \\
+  %
+  \equiv & + \sum\limits_{i,j,k} \frac{1}{2}  \left(   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right)\;
+  \biggl\{ \delta_{i} \left[  U   \right] +  \delta_{j} \left[  V  \right]    \biggr\}       &&&  \\
+  \allowdisplaybreaks
+  %
+  \equiv   & - \sum\limits_{i,j,k}  \frac{1}{2}
+  \left(       \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right)  \;
+  \biggl\{   \frac{b_t}{e_{3t}} \partial_t (e_{3t})  +  \delta_k \left[  W   \right]    \biggr\}    &&&\\
+  \allowdisplaybreaks
+  %
+  \equiv & +  \sum\limits_{i,j,k} \frac{1}{2} \delta_{k+1/2}   \left[ \overline{ u^2}^{\,i} + \overline{ v^2}^{\,j}   \right] \;  W
+  -  \sum\limits_{i,j,k} \frac{1}{2} \left(   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right) \;\partial_t b_t   &&& \\
+  \allowdisplaybreaks
+  %
+  \equiv   & + \sum\limits_{i,j,k} \frac{1} {2} \left(    \overline{\delta_{k+1/2} \left[ u^2 \right]}^{\,i}
+    + \overline{\delta_{k+1/2} \left[ v^2 \right]}^{\,j}    \right) \; W
+  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t \overline{b_t}^{\,{i+1/2}}
+    + \frac{v^2}{2}\,\partial_t \overline{b_t}^{\,{j+1/2}}   \right)    &&& \\
+  \allowdisplaybreaks
+  \intertext{Assuming that $b_u= \overline{b_t}^{\,i+1/2}$ and $b_v= \overline{b_t}^{\,j+1/2}$, or at least that the time
+    derivative of these two equations is satisfied, it becomes:}
+  %
+  \equiv &     \sum\limits_{i,j,k} \frac{1} {2}
+  \biggl\{ \; \overline{W}^{\,i+1/2}\;\delta_{k+1/2} \left[ u^2 \right]
+  + \overline{W}^{\,j+1/2}\;\delta_{k+1/2} \left[ v^2 \right]  \;  \biggr\}
+  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t b_u
+    + \frac{v^2}{2}\,\partial_t b_v   \right)    &&& \\
+  \allowdisplaybreaks
+  %
+  \equiv &     \sum\limits_{i,j,k}
+  \biggl\{ \; \overline{W}^{\,i+1/2}\; \overline {u}^{\,k+1/2}\; \delta_{k+1/2}[ u ]
+  + \overline{W}^{\,j+1/2}\; \overline {v}^{\,k+1/2}\; \delta_{k+1/2}[ v ]  \;  \biggr\}
+  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t b_u
+    + \frac{v^2}{2}\,\partial_t b_v   \right)    &&& \\
+  %
+  \allowdisplaybreaks
+  \equiv  &  \sum\limits_{i,j,k}
+  \biggl\{ \; \frac{1} {b_u } \; \overline { \overline{W}^{\,i+1/2}\,\delta_{k+1/2}  \left[ u \right] }^{\,k} \;u\;b_u
+  + \frac{1} {b_v } \; \overline { \overline{W}^{\,j+1/2} \delta_{k+1/2}  \left[ v \right]  }^{\,k} \;v\;b_v  \; \biggr\}
+  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t b_u
+    + \frac{v^2}{2}\,\partial_t b_v   \right)    &&& \\
+  %
+  \intertext{The first term provides the discrete expression for the vertical advection of momentum (ZAD),
+    while the second term corresponds exactly to \autoref{eq:INVARIANTS_KE+PE_vect_discrete}, therefore:}
+  \equiv&                   \int\limits_D \textbf{U}_h \cdot \text{ZAD} \;dv
+  + \frac{1}{2} \int_D { {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t  (e_3)  \;dv }    &&&\\
+  \equiv&                   \int\limits_D \textbf{U}_h \cdot w \partial_k \textbf{U}_h \;dv
+  + \frac{1}{2} \int_D { {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t  (e_3)  \;dv }    &&&\\
+\end{flalign*}
+
+There is two main points here.
+First, the satisfaction of this property links the choice of the discrete formulation of the vertical advection and
+of the horizontal gradient of KE.
+Choosing one imposes the other.
+For example KE can also be discretized as $1/2\,({\overline u^{\,i}}^2 + {\overline v^{\,j}}^2)$.
+This leads to the following expression for the vertical advection:
+\[
+  \frac{1} {e_3 }\; \omega\; \partial_k \textbf{U}_h
+  \equiv \left( {{
+        \begin{array} {*{20}c}
+          \frac{1} {e_{1u}\,e_{2u}\,e_{3u}} \;  \overline{\overline {e_{1t}\,e_{2t} \,\omega\;\delta_{k+1/2}
+          \left[ \overline u^{\,i+1/2} \right]}}^{\,i+1/2,k}  \hfill \\
+          \frac{1} {e_{1v}\,e_{2v}\,e_{3v}} \;   \overline{\overline {e_{1t}\,e_{2t} \,\omega \;\delta_{k+1/2}
+          \left[ \overline v^{\,j+1/2} \right]}}^{\,j+1/2,k} \hfill
+        \end{array}
+      } } \right)
+\]
+a formulation that requires an additional horizontal mean in contrast with the one used in \NEMO.
+Nine velocity points have to be used instead of 3.
+This is the reason why it has not been chosen.
+
+Second, as soon as the chosen $s$-coordinate depends on time,
+an extra constraint arises on the time derivative of the volume at $u$- and $v$-points:
+\begin{flalign*}
+  e_{1u}\,e_{2u}\,\partial_t (e_{3u}) =\overline{ e_{1t}\,e_{2t}\;\partial_t (e_{3t}) }^{\,i+1/2}    \\
+  e_{1v}\,e_{2v}\,\partial_t (e_{3v})  =\overline{ e_{1t}\,e_{2t}\;\partial_t (e_{3t}) }^{\,j+1/2}
+\end{flalign*}
+which is (over-)satified by defining the vertical scale factor as follows:
+\begin{flalign*}
+  % \label{eq:INVARIANTS_e3u-e3v}
+  e_{3u} = \frac{1}{e_{1u}\,e_{2u}}\;\overline{ e_{1t}^{ }\,e_{2t}^{ }\,e_{3t}^{ } }^{\,i+1/2}    \\
+  e_{3v} = \frac{1}{e_{1v}\,e_{2v}}\;\overline{ e_{1t}^{ }\,e_{2t}^{ }\,e_{3t}^{ } }^{\,j+1/2}
+\end{flalign*}
+
+Blah blah required on the the step representation of bottom topography.....
+
+%% =================================================================================================
+\subsection{Pressure gradient term}
+\label{subsec:INVARIANTS_2.6}
+
+\cmtgm{
+  A pressure gradient has no contribution to the evolution of the vorticity as the curl of a gradient is zero.
+  In the $z$-coordinate, this property is satisfied locally on a C-grid with 2nd order finite differences
+  (property \autoref{eq:DOM_curl_grad}).
+}
+
+When the equation of state is linear
+(\ie\ when an advection-diffusion equation for density can be derived from those of temperature and salinity)
+the change of KE due to the work of pressure forces is balanced by
+the change of potential energy due to buoyancy forces:
+\[
+  - \int_D  \left. \nabla p \right|_z \cdot \textbf{U}_h \;dv
+  = - \int_D \nabla \cdot \left( \rho \,\textbf {U} \right) \,g\,z \;dv
+  + \int_D g\, \rho \; \partial_t (z)  \;dv
+\]
+
+This property can be satisfied in a discrete sense for both $z$- and $s$-coordinates.
+Indeed, defining the depth of a $T$-point, $z_t$,
+as the sum of the vertical scale factors at $w$-points starting from the surface,
+the work of pressure forces can be written as:
+\begin{flalign*}
+  &- \int_D  \left. \nabla p \right|_z \cdot \textbf{U}_h \;dv
+  \equiv \sum\limits_{i,j,k} \biggl\{ \;  - \frac{1} {e_{1u}}   \Bigl(
+  \delta_{i+1/2} [p_t] - g\;\overline \rho^{\,i+1/2}\;\delta_{i+1/2} [z_t]     \Bigr)  \; u\;b_u && \\
+  & \qquad \qquad  \qquad \qquad  \qquad \quad \ \,
+  - \frac{1} {e_{2v}}    \Bigl(
+  \delta_{j+1/2} [p_t] - g\;\overline \rho^{\,j+1/2}\delta_{j+1/2} [z_t]      \Bigr)  \; v\;b_v \;  \biggr\}   && \\
+  %
+  \allowdisplaybreaks
+  \intertext{Using successively \autoref{eq:DOM_di_adj}, \ie\ the skew symmetry property of
+    the $\delta$ operator, \autoref{eq:DYN_wzv}, the continuity equation, \autoref{eq:DYN_hpg_sco},
+    the hydrostatic equation in the $s$-coordinate, and $\delta_{k+1/2} \left[ z_t \right] \equiv e_{3w} $,
+    which comes from the definition of $z_t$, it becomes: }
+  \allowdisplaybreaks
+  %
+  \equiv& +  \sum\limits_{i,j,k}   g  \biggl\{
+  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
+  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
+  +\Bigl(  \delta_i[U] + \delta_j [V]  \Bigr)\;\frac{p_t}{g} \biggr\}  &&\\
+  %
+  \equiv& +  \sum\limits_{i,j,k}   g   \biggl\{
+  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
+  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
+  -       \left(   \frac{b_t}{e_{3t}} \partial_t (e_{3t})  +  \delta_k \left[ W \right]    \right) \frac{p_t}{g}    \biggr\}   &&&\\
+  %
+  \equiv& +  \sum\limits_{i,j,k}  g   \biggl\{
+  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
+  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
+  +	\frac{W}{g}\;\delta_{k+1/2} [p_t]
+  -        \frac{p_t}{g}\,\partial_t b_t    \biggr\}    &&&\\
+  %
+  \equiv& +  \sum\limits_{i,j,k}  g   \biggl\{
+  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
+  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
+  - 	W\;e_{3w} \overline \rho^{\,k+1/2}
+  -        \frac{p_t}{g}\,\partial_t b_t    \biggr\}    &&&\\
+  %
+  \equiv& +  \sum\limits_{i,j,k}    g   \biggl\{
+  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
+  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
+  + 	W\; \overline \rho^{\,k+1/2}\;\delta_{k+1/2} [z_t]
+  -        \frac{p_t}{g}\,\partial_t b_t    \biggr\}    &&&\\
+  %
+  \allowdisplaybreaks
+  %
+  \equiv& - \sum\limits_{i,j,k}   g \; z_t      \biggl\{
+  \delta_i 	\left[ U\;	\overline \rho^{\,i+1/2} 	\right]
+  + 	\delta_j 	\left[ V\;	\overline \rho^{\,j+1/2} 	\right]
+  + 	\delta_k 	\left[ W\;	\overline \rho^{\,k+1/2} 	\right]       \biggr\}
+  - \sum\limits_{i,j,k}       \biggl\{ p_t\;\partial_t b_t    \biggr\}   &&&\\
+  %
+  \equiv& + \sum\limits_{i,j,k}   g \; z_t    \biggl\{      \partial_t ( e_{3t} \,\rho)    \biggr\}  \; b_t
+  -  \sum\limits_{i,j,k}                 \biggl\{  p_t\;\partial_t b_t                     \biggr\}              &&&\\
+  %
+\end{flalign*}
+The first term is exactly the first term of the right-hand-side of \autoref{eq:INVARIANTS_KE+PE_vect_discrete}.
+It remains to demonstrate that the last term,
+which is obviously a discrete analogue of $\int_D \frac{p}{e_3} \partial_t (e_3)\;dv$ is equal to
+the last term of \autoref{eq:INVARIANTS_KE+PE_vect_discrete}.
+In other words, the following property must be satisfied:
+\begin{flalign*}
+  \sum\limits_{i,j,k}  \biggl\{  p_t\;\partial_t b_t                  \biggr\}
+  \equiv  \sum\limits_{i,j,k}  \biggl\{ \rho \,g\,\partial_t (z_t) \,b_t  \biggr\}
+\end{flalign*}
+
+Let introduce $p_w$ the pressure at $w$-point such that $\delta_k [p_w] = - \rho \,g\,e_{3t}$.
+The right-hand-side of the above equation can be transformed as follows:
+
+\begin{flalign*}
+  \sum\limits_{i,j,k}  \biggl\{ \rho \,g\,\partial_t (z_t) \,b_t  \biggr\}
+  &\equiv   - \sum\limits_{i,j,k}  \biggl\{ \delta_k [p_w]\,\partial_t (z_t) \,e_{1t}\,e_{2t}  \biggr\}        &&&\\
+  %
+  &\equiv  + \sum\limits_{i,j,k}  \biggl\{  p_w\, \delta_{k+1/2} [\partial_t (z_t)] \,e_{1t}\,e_{2t}  \biggr\}
+  \equiv  + \sum\limits_{i,j,k}  \biggl\{  p_w\, \partial_t (e_{3w}) \,e_{1t}\,e_{2t}  \biggr\}        &&&\\
+  &\equiv  + \sum\limits_{i,j,k}  \biggl\{  p_w\, \partial_t (b_w) \biggr\}
+  %
+  % & \equiv     \sum\limits_{i,j,k} \biggl\{  \frac{1}{e_{3t}} \delta_k [p_w]\;\partial_t (z_t) \,b_w   \right)   \biggr\}           &&&\\
+  % & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t \left(    \delta_k [z_t]   \right)  e_{1w}\,e_{2w}   \biggr\}           &&&\\
+  % & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t b_w   \biggr\}
+\end{flalign*}
+therefore, the balance to be satisfied is:
+\begin{flalign*}
+  \sum\limits_{i,j,k}  \biggl\{  p_t\;\partial_t (b_t) \biggr\}  \equiv  \sum\limits_{i,j,k}  \biggl\{  p_w\, \partial_t (b_w) \biggr\}
+\end{flalign*}
+which is a purely vertical balance:
+\begin{flalign*}
+  \sum\limits_{k}  \biggl\{  p_t\;\partial_t (e_{3t}) \biggr\}  \equiv  \sum\limits_{k}  \biggl\{  p_w\, \partial_t (e_{3w}) \biggr\}
+\end{flalign*}
+Defining $p_w = \overline{p_t}^{\,k+1/2}$
+
+%gm comment
+\cmtgm{
+  \begin{flalign*}
+    \sum\limits_{i,j,k} \biggl\{   p_t\;\partial_t b_t   \biggr\}                                &&&\\
+    %
+    & \equiv     \sum\limits_{i,j,k} \biggl\{  \frac{1}{e_{3t}} \delta_k [p_w]\;\partial_t (z_t) \,b_w    \biggr\}           &&&\\
+    & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t \left(    \delta_{k+1/2} [z_t]   \right)  e_{1w}\,e_{2w}   \biggr\}           &&&\\
+    & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t b_w   \biggr\}
+  \end{flalign*}
+
+  \begin{flalign*}
+    \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv
+    \equiv&  \sum\limits_{i,j,k}   \biggl\{  \frac{1}{e_{3t}} \frac{\partial e_{3t}}{\partial t} p   \biggr\} \; b_t   &&&\\
+    \equiv&  \sum\limits_{i,j,k}   \biggl\{      \biggr\} \; b_t   &&&\\
+  \end{flalign*}
+
+  %
+  \begin{flalign*}
+    \equiv& - \int_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
+    + \int\limits_D g\, \rho \; \frac{\partial z}{\partial t}  \;dv     &&& \\
+  \end{flalign*}
+  %
+}
+%end gm comment
+
+Note that this property strongly constrains the discrete expression of both the depth of $T-$points and
+of the term added to the pressure gradient in the $s$-coordinate.
+Nevertheless, it is almost never satisfied since a linear equation of state is rarely used.
+
+%% =================================================================================================
+\section{Discrete total energy conservation: flux form}
+\label{sec:INVARIANTS_3}
+
+%% =================================================================================================
+\subsection{Total energy conservation}
+\label{subsec:INVARIANTS_KE+PE_flux}
+
+The discrete form of the total energy conservation, \autoref{eq:INVARIANTS_Tot_Energy}, is given by:
+\begin{flalign*}
+  \partial_t \left(  \sum\limits_{i,j,k} \biggl\{ \frac{u^2}{2} \,b_u + \frac{v^2}{2}\, b_v +  \rho \, g \, z_t \,b_t  \biggr\} \right) &=0  \\
+\end{flalign*}
+which in flux form, it leads to:
+\begin{flalign*}
+  \sum\limits_{i,j,k} \biggl\{  \frac{u    }{e_{3u}}\,\frac{\partial (e_{3u}u)}{\partial t} \,b_u
+  +  \frac{v    }{e_{3v}}\,\frac{\partial (e_{3v}v)}{\partial t} \,b_v  \biggr\}
+  &  -  \frac{1}{2} \sum\limits_{i,j,k} \biggl\{  \frac{u^2}{e_{3u}}\frac{\partial    e_{3u}    }{\partial t} \,b_u
+  +  \frac{v^2}{e_{3v}}\frac{\partial    e_{3v}    }{\partial t} \,b_v   \biggr\} \\
+  &= - \sum\limits_{i,j,k} \biggl\{ \frac{1}{e_3t}\frac{\partial e_{3t} \rho}{\partial t} \, g \, z_t \,b_t  \biggr\}
+  - \sum\limits_{i,j,k} \biggl\{ \rho \,g\,\frac{\partial z_t}{\partial t} \,b_t  \biggr\} \\
+\end{flalign*}
+
+Substituting the discrete expression of the time derivative of the velocity either in
+vector invariant or in flux form, leads to the discrete equivalent of the ????
+
+%% =================================================================================================
+\subsection{Coriolis and advection terms: flux form}
+\label{subsec:INVARIANTS_3.2}
+
+%% =================================================================================================
+\subsubsection{Coriolis plus ``metric'' term}
+\label{subsec:INVARIANTS_3.3}
+
+In flux from the vorticity term reduces to a Coriolis term in which
+the Coriolis parameter has been modified to account for the ``metric'' term.
+This altered Coriolis parameter is discretised at an f-point.
+It is given by:
+\[
+  f+\frac{1} {e_1 e_2 } \left( v \frac{\partial e_2 } {\partial i} - u \frac{\partial e_1 } {\partial j}\right)\;
+  \equiv \;
+  f+\frac{1} {e_{1f}\,e_{2f}} \left( \overline v^{\,i+1/2} \delta_{i+1/2} \left[ e_{2u} \right]
+    -\overline u^{\,j+1/2} \delta_{j+1/2} \left[ e_{1u}  \right] \right)
+\]
+
+Either the ENE or EEN scheme is then applied to obtain the vorticity term in flux form.
+It therefore conserves the total KE.
+The derivation is the same as for the vorticity term in the vector invariant form (\autoref{subsec:INVARIANTS_vor}).
+
+%% =================================================================================================
+\subsubsection{Flux form advection}
+\label{subsec:INVARIANTS_3.4}
+
+The flux form operator of the momentum advection is evaluated using
+a centered second order finite difference scheme.
+Because of the flux form, the discrete operator does not contribute to the global budget of linear momentum.
+Because of the centered second order scheme, it conserves the horizontal kinetic energy, that is:
+
+\begin{equation}
+  \label{eq:INVARIANTS_ADV_KE_flux}
+  -  \int_D \textbf{U}_h \cdot     \left(                 {{
+        \begin{array} {*{20}c}
+          \nabla \cdot \left( \textbf{U}\,u \right) \hfill \\
+          \nabla \cdot \left( \textbf{U}\,v \right) \hfill \\
+        \end{array}
+      } }           \right)   \;dv
+  -   \frac{1}{2} \int_D {  {\textbf{U}_h}^2 \frac{1}{e_3} \frac{\partial  e_3 }{\partial t} \;dv } =\;0
+\end{equation}
+
+Let us first consider the first term of the scalar product
+(\ie\ just the the terms associated with the i-component of the advection):
+\begin{flalign*}
+  &  - \int_D u \cdot \nabla \cdot \left(   \textbf{U}\,u   \right) \; dv   \\
+  %
+  \equiv& - \sum\limits_{i,j,k} \biggl\{    \frac{1} {b_u}    \biggl(
+  \delta_{i+1/2}  \left[   \overline {U}^{\,i}      \;\overline u^{\,i}          \right]
+  + \delta_j           \left[   \overline {V}^{\,i+1/2}\;\overline u^{\,j+1/2}   \right]
+  + \delta_k          \left[   \overline {W}^{\,i+1/2}\;\overline u^{\,k+1/2} \right]  \biggr)   \;   \biggr\} \, b_u \;u &&&  \\
+  %
+  \equiv& - \sum\limits_{i,j,k}
+  \biggl\{
+  \delta_{i+1/2} \left[   \overline {U}^{\,i}\;  \overline u^{\,i}  \right]
+  + \delta_j          \left[   \overline {V}^{\,i+1/2}\;\overline u^{\,j+1/2}   \right]
+  + \delta_k         \left[   \overline {W}^{\,i+12}\;\overline u^{\,k+1/2}  \right]
+  \; \biggr\} \; u     \\
+  %
+  \equiv& + \sum\limits_{i,j,k}
+  \biggl\{
+  \overline {U}^{\,i}\;	\overline u^{\,i} 	\delta_i \left[ u \right]
+  + \overline {V}^{\,i+1/2}\;	\overline u^{\,j+1/2} 	\delta_{j+1/2} \left[ u \right]
+  + \overline {W}^{\,i+1/2}\;	\overline u^{\,k+1/2}	\delta_{k+1/2} 	\left[ u \right]     \biggr\}     && \\
+  %
+  \equiv& + \frac{1}{2} \sum\limits_{i,j,k}    \biggl\{
+  \overline{U}^{\,i} 		\delta_i 		\left[ u^2 \right]
+  + \overline{V}^{\,i+1/2} 	\delta_{j+/2} 	\left[ u^2 \right]
+  + \overline{W}^{\,i+1/2} 	\delta_{k+1/2} 	\left[ u^2 \right]      \biggr\} && \\
+  %
+  \equiv& -  \sum\limits_{i,j,k}    \frac{1}{2}   \bigg\{
+  U  \; \delta_{i+1/2}    \left[ \overline {u^2}^{\,i} \right]
+  + V  \; \delta_{j+1/2}    \left[ \overline {u^2}^{\,i} \right]
+  + W \; \delta_{k+1/2}   \left[ \overline {u^2}^{\,i} \right]     \biggr\}    &&& \\
+  %
+  \equiv& - \sum\limits_{i,j,k}  \frac{1}{2}  \overline {u^2}^{\,i}     \biggl\{
+  \delta_{i+1/2} 	\left[ U  \right]
+  + \delta_{j+1/2} 	\left[ V  \right]
+  + \delta_{k+1/2} 	\left[ W \right]     \biggr\}    &&& \\
+  %
+  \equiv& + \sum\limits_{i,j,k}  \frac{1}{2}  \overline {u^2}^{\,i}
+  \biggl\{     \left(   \frac{1}{e_{3t}} \frac{\partial e_{3t}}{\partial t}   \right) \; b_t     \biggr\}    &&& \\
+\end{flalign*}
+Applying similar manipulation applied to the second term of the scalar product leads to:
+\[
+  -  \int_D \textbf{U}_h \cdot     \left(                 {{
+        \begin{array} {*{20}c}
+          \nabla \cdot \left( \textbf{U}\,u \right) \hfill \\
+          \nabla \cdot \left( \textbf{U}\,v \right) \hfill \\
+        \end{array}
+      } }           \right)   \;dv
+  \equiv + \sum\limits_{i,j,k}  \frac{1}{2}  \left( \overline {u^2}^{\,i} + \overline {v^2}^{\,j} \right)
+  \biggl\{     \left(   \frac{1}{e_{3t}} \frac{\partial e_{3t}}{\partial t}   \right) \; b_t     \biggr\}
+\]
+which is the discrete form of $ \frac{1}{2} \int_D u \cdot \nabla \cdot \left(   \textbf{U}\,u   \right) \; dv $.
+\autoref{eq:INVARIANTS_ADV_KE_flux} is thus satisfied.
+
+When the UBS scheme is used to evaluate the flux form momentum advection,
+the discrete operator does not contribute to the global budget of linear momentum (flux form).
+The horizontal kinetic energy is not conserved, but forced to decay (\ie\ the scheme is diffusive).
+
+%% =================================================================================================
+\section{Discrete enstrophy conservation}
+\label{sec:INVARIANTS_4}
+
+%% =================================================================================================
+\subsubsection{Vorticity term with ENS scheme  (\protect\np[=.true.]{ln_dynvor_ens}{ln\_dynvor\_ens})}
+\label{subsec:INVARIANTS_vorENS}
+
+In the ENS scheme, the vorticity term is descretized as follows:
+\begin{equation}
+  \label{eq:INVARIANTS_dynvor_ens}
+  \left\{
+    \begin{aligned}
+      +\frac{1}{e_{1u}} & \overline{q}^{\,i}  & {\overline{ \overline{\left( e_{1v}\,e_{3v}\;  v \right) } } }^{\,i, j+1/2}    \\
+      - \frac{1}{e_{2v}} & \overline{q}^{\,j}  & {\overline{ \overline{\left( e_{2u}\,e_{3u}\; u \right) } } }^{\,i+1/2, j}
+    \end{aligned}
+  \right.
+\end{equation}
+
+The scheme does not allow but the conservation of the total kinetic energy but the conservation of $q^2$,
+the potential enstrophy for a horizontally non-divergent flow (\ie\ when $\chi$=$0$).
+Indeed, using the symmetry or skew symmetry properties of the operators
+( \autoref{eq:DOM_mi_adj} and \autoref{eq:DOM_di_adj}),
+it can be shown that:
+\begin{equation}
+  \label{eq:INVARIANTS_1.1}
+  \int_D {q\,\;{\textbf{k}}\cdot \frac{1} {e_3} \nabla \times \left( {e_3 \, q \;{\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} \equiv 0
+\end{equation}
+where $dv=e_1\,e_2\,e_3 \; di\,dj\,dk$ is the volume element.
+Indeed, using \autoref{eq:DYN_vor_ens},
+the discrete form of the right hand side of \autoref{eq:INVARIANTS_1.1} can be transformed as follow:
+\begin{flalign*}
+  &\int_D q \,\; \textbf{k} \cdot \frac{1} {e_3 } \nabla \times
+  \left(  e_3 \, q \; \textbf{k} \times  \textbf{U}_h   \right)\;   dv \\
+  %
+  & \qquad
+  {
+    \begin{array}{*{20}l}
+      &\equiv \sum\limits_{i,j,k}
+        q \ \left\{  \delta_{i+1/2}  \left[ - \,\overline {q}^{\,i}\;  \overline{\overline  U }^{\,i,j+1/ 2} \right]
+        - \delta_{j+1/2} \left[	 \overline {q}^{\,j}\;  \overline{\overline  V }^{\,i+1/2, j} \right]     \right\}    \\
+      %
+      &\equiv \sum\limits_{i,j,k}
+        \left\{   \delta_i [q] \; \overline{q}^{\,i} \; \overline{  \overline U  }^{\,i,j+1/2}
+        + \delta_j [q] \; \overline{q}^{\,j} \; \overline{\overline V }^{\,i+1/2,j}        \right\}       &&  \\
+      %
+      &\equiv \,\frac{1} {2} \sum\limits_{i,j,k}
+        \left\{         \delta_i  \left[ q^2 \right] \; \overline{\overline U }^{\,i,j+1/2}
+        + \delta_j  \left[ q^2 \right] \; \overline{\overline V }^{\,i+1/2,j}      \right\}    &&  \\
+      %
+      &\equiv - \frac{1} {2} \sum\limits_{i,j,k} 	q^2 \;
+        \left\{    \delta_{i+1/2}   \left[   \overline{\overline{ U }}^{\,i,j+1/2}    \right]
+        + \delta_{j+1/2}  \left[   \overline{\overline{ V }}^{\,i+1/2,j}     \right]    \right\}    && \\
+    \end{array}
+  }
+  %
+  \allowdisplaybreaks
+  \intertext{ Since $\overline {\;\cdot \;} $ and $\delta $ operators commute: $\delta_{i+1/2}
+    \left[ {\overline a^{\,i}} \right] = \overline {\delta_i \left[ a \right]}^{\,i+1/2}$,
+    and introducing the horizontal divergence $\chi $, it becomes: }
+  \allowdisplaybreaks
+  %
+  & \qquad {
+    \begin{array}{*{20}l}
+      &\equiv \sum\limits_{i,j,k} - \frac{1} {2} q^2 \; \overline{\overline{ e_{1t}\,e_{2t}\,e_{3t}^{}\, \chi}}^{\,i+1/2,j+1/2}
+        \quad \equiv 0 &&
+    \end{array}
+  }
+\end{flalign*}
+The later equality is obtain only when the flow is horizontally non-divergent, \ie\ $\chi$=$0$.
+
+%% =================================================================================================
+\subsubsection{Vorticity Term with EEN scheme (\protect\np[=.true.]{ln_dynvor_een}{ln\_dynvor\_een})}
+\label{subsec:INVARIANTS_vorEEN}
+
+With the EEN scheme, the vorticity terms are represented as:
+\begin{equation}
+  \label{eq:INVARIANTS_dynvor_een2}
+  \left\{ {
+      \begin{aligned}
+        +q\,e_3 \, v 	&\equiv +\frac{1}{e_{1u} }   \sum_{\substack{i_p,\,k_p}}
+        {^{i+1/2-i_p}_j}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{1v} e_{3v} \ v  \right)^{i+i_p-1/2}_{j+j_p}   \\
+        - q\,e_3 \, u     &\equiv -\frac{1}{e_{2v} }    \sum_{\substack{i_p,\,k_p}}
+        {^i_{j+1/2-j_p}}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{2u} e_{3u} \ u  \right)^{i+i_p}_{j+j_p-1/2}   \\
+      \end{aligned}
+    } \right.
+\end{equation}
+where the indices $i_p$ and $k_p$ take the following values:
+$i_p = -1/2$ or $1/2$ and $j_p = -1/2$ or $1/2$,
+and the vorticity triads, ${^i_j}\mathbb{Q}^{i_p}_{j_p}$, defined at $T$-point, are given by:
+\begin{equation}
+  \tag{\ref{eq:INVARIANTS_Q_triads}}
+  _i^j \mathbb{Q}^{i_p}_{j_p}
+  = \frac{1}{12} \ \left(   q^{i-i_p}_{j+j_p} + q^{i+j_p}_{j+i_p} + q^{i+i_p}_{j-j_p}  \right)
+\end{equation}
+
+This formulation does conserve the potential enstrophy for a horizontally non-divergent flow (\ie\ $\chi=0$).
+
+Let consider one of the vorticity triad, for example ${^{i}_j}\mathbb{Q}^{+1/2}_{+1/2} $,
+similar manipulation can be done for the 3 others.
+The discrete form of the right hand side of \autoref{eq:INVARIANTS_1.1} applied to
+this triad only can be transformed as follow:
+
+\begin{flalign*}
+  &\int_D {q\,\;{\textbf{k}}\cdot \frac{1} {e_3} \nabla \times \left( {e_3 \, q \;{\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} \\
+  %
+  \equiv& \sum\limits_{i,j,k}
+  {q} \    \biggl\{ \;\;
+  \delta_{i+1/2} \left[   -\, {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; U^{i+1/2}_{j}}    \right]
+  - \delta_{j+1/2} \left[       {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; V^{i}_{j+1/2}}    \right]
+  \;\;\biggr\}        &&  \\
+  %
+  \equiv& \sum\limits_{i,j,k}
+  \biggl\{   \delta_i [q] \  {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; U^{i+1/2}_{j}}
+  + \delta_j [q] \  {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; V^{i}_{j+1/2}}   \biggr\}
+  && \\
+  %
+  ... & &&\\
+  &Demonstation \ to \ be \ done... &&\\
+  ... & &&\\
+  %
+  \equiv& \frac{1} {2} \sum\limits_{i,j,k}
+  \biggl\{	\delta_i    \Bigl[    \left(  {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2   \Bigr]\;
+  \overline{\overline {U}}^{\,i,j+1/2}
+  + \delta_j 	\Bigl[    \left( {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2     \Bigr]\;
+  \overline{\overline {V}}^{\,i+1/2,j}
+  \biggr\}
+  &&  \\
+  %
+  \equiv& - \frac{1} {2} \sum\limits_{i,j,k} 	\left( {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2\;
+  \biggl\{    \delta_{i+1/2}
+  \left[   \overline{\overline {U}}^{\,i,j+1/2}    \right]
+  + \delta_{j+1/2}
+  \left[   \overline{\overline {V}}^{\,i+1/2,j}     \right]
+  \biggr\}    && \\
+  %
+  \equiv& \sum\limits_{i,j,k} - \frac{1} {2} \left( {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2
+  \; \overline{\overline{ b_t^{}\, \chi}}^{\,i+1/2,\,j+1/2}  &&\\
+  %
+  \ \ \equiv& \ 0     &&\\
+\end{flalign*}
+
+%% =================================================================================================
+\section{Conservation properties on tracers}
+\label{sec:INVARIANTS_5}
+
+All the numerical schemes used in \NEMO\ are written such that the tracer content is conserved by
+the internal dynamics and physics (equations in flux form).
+For advection,
+only the CEN2 scheme (\ie\ $2^{nd}$ order finite different scheme) conserves the global variance of tracer.
+Nevertheless the other schemes ensure that the global variance decreases
+(\ie\ they are at least slightly diffusive).
+For diffusion, all the schemes ensure the decrease of the total tracer variance, except the iso-neutral operator.
+There is generally no strict conservation of mass,
+as the equation of state is non linear with respect to $T$ and $S$.
+In practice, the mass is conserved to a very high accuracy.
+%% =================================================================================================
+\subsection{Advection term}
+\label{subsec:INVARIANTS_5.1}
+
+conservation of a tracer, $T$:
+\[
+  \frac{\partial }{\partial t} \left(   \int_D {T\;dv}   \right)
+  =  \int_D { \frac{1}{e_3}\frac{\partial \left( e_3 \, T \right)}{\partial t} \;dv }=0
+\]
+
+conservation of its variance:
+\begin{flalign*}
+  \frac{\partial }{\partial t} \left( \int_D {\frac{1}{2} T^2\;dv} \right)
+  =&  \int_D { \frac{1}{e_3} Q      \frac{\partial \left( e_3 \, T \right) }{\partial t} \;dv }
+  -   \frac{1}{2} \int_D {  T^2 \frac{1}{e_3} \frac{\partial  e_3 }{\partial t} \;dv }
+\end{flalign*}
+
+Whatever the advection scheme considered it conserves of the tracer content as
+all the scheme are written in flux form.
+Indeed, let $T$ be the tracer and its $\tau_u$, $\tau_v$, and $\tau_w$ interpolated values at velocity point
+(whatever the interpolation is),
+the conservation of the tracer content due to the advection tendency is obtained as follows:
+\begin{flalign*}
+  &\int_D { \frac{1}{e_3}\frac{\partial \left( e_3 \, T \right)}{\partial t} \;dv } = - \int_D \nabla \cdot \left( T \textbf{U} \right)\;dv    &&&\\
+  &\equiv - \sum\limits_{i,j,k}    \biggl\{
+  \frac{1} {b_t}  \left(  \delta_i    \left[   U \;\tau_u   \right]
+    + \delta_j    \left[   V  \;\tau_v   \right] \right)
+  + \frac{1} {e_{3t}} \delta_k \left[ w\;\tau_w \right]    \biggl\}  b_t   &&&\\
+  %
+  &\equiv - \sum\limits_{i,j,k}     \left\{
+    \delta_i  \left[   U \;\tau_u   \right]
+    + \delta_j  \left[   V  \;\tau_v   \right]
+ 	 + \delta_k \left[ W \;\tau_w \right] \right\}   && \\
+  &\equiv 0 &&&
+\end{flalign*}
+
+The conservation of the variance of tracer due to the advection tendency can be achieved only with the CEN2 scheme,
+\ie\ when $\tau_u= \overline T^{\,i+1/2}$, $\tau_v= \overline T^{\,j+1/2}$, and $\tau_w= \overline T^{\,k+1/2}$.
+It can be demonstarted as follows:
+\begin{flalign*}
+  &\int_D { \frac{1}{e_3} Q      \frac{\partial \left( e_3 \, T \right) }{\partial t} \;dv }
+  = - \int\limits_D \tau\;\nabla \cdot \left( T\; \textbf{U} \right)\;dv &&&\\
+  \equiv& - \sum\limits_{i,j,k} T\;
+  \left\{
+    \delta_i  \left[ U  \overline T^{\,i+1/2}  \right]
+    + \delta_j  \left[ V  \overline T^{\,j+1/2}  \right]
+    + \delta_k \left[ W \overline T^{\,k+1/2} \right]          \right\} && \\
+  \equiv& + \sum\limits_{i,j,k}
+  \left\{     U  \overline T^{\,i+1/2} \,\delta_{i+1/2}  \left[ T \right]
+    +  V  \overline T^{\,j+1/2} \;\delta_{j+1/2}  \left[ T \right]
+    +  W \overline T^{\,k+1/2}\;\delta_{k+1/2} \left[ T \right]     \right\}      &&\\
+  \equiv&  + \frac{1} {2}  \sum\limits_{i,j,k}
+  \Bigl\{   U  \;\delta_{i+1/2} \left[ T^2 \right]
+  + V  \;\delta_{j+1/2}  \left[ T^2 \right]
+  + W \;\delta_{k+1/2} \left[ T^2 \right]   \Bigr\}     && \\
+  \equiv& - \frac{1} {2}  \sum\limits_{i,j,k} T^2
+  \Bigl\{    \delta_i  \left[ U  \right]
+  + \delta_j  \left[ V  \right]
+  + \delta_k \left[ W \right]     \Bigr\}      &&&  \\
+  \equiv& + \frac{1} {2}  \sum\limits_{i,j,k} T^2
+  \Bigl\{   \frac{1}{e_{3t}} \frac{\partial e_{3t}\,T }{\partial t}     \Bigr\}      &&& \\
+\end{flalign*}
+which is the discrete form of $ \frac{1}{2} \int_D {  T^2 \frac{1}{e_3} \frac{\partial  e_3 }{\partial t} \;dv }$.
+
+%% =================================================================================================
+\section{Conservation properties on lateral momentum physics}
+\label{sec:INVARIANTS_dynldf_properties}
+
+The discrete formulation of the horizontal diffusion of momentum ensures
+the conservation of potential vorticity and the horizontal divergence,
+and the dissipation of the square of these quantities
+(\ie\ enstrophy and the variance of the horizontal divergence) as well as
+the dissipation of the horizontal kinetic energy.
+In particular, when the eddy coefficients are horizontally uniform,
+it ensures a complete separation of vorticity and horizontal divergence fields,
+so that diffusion (dissipation) of vorticity (enstrophy) does not generate horizontal divergence
+(variance of the horizontal divergence) and \textit{vice versa}.
+
+These properties of the horizontal diffusion operator are a direct consequence of
+properties \autoref{eq:DOM_curl_grad} and \autoref{eq:DOM_div_curl}.
+When the vertical curl of the horizontal diffusion of momentum (discrete sense) is taken,
+the term associated with the horizontal gradient of the divergence is locally zero.
+
+%% =================================================================================================
+\subsection{Conservation of potential vorticity}
+\label{subsec:INVARIANTS_6.1}
+
+The lateral momentum diffusion term conserves the potential vorticity:
+\begin{flalign*}
+  &\int \limits_D \frac{1} {e_3 } \textbf{k} \cdot \nabla \times
+  \Bigl[    \nabla_h  \left( A^{\,lm}\;\chi  \right)
+  - \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)    \Bigr]\;dv   \\
+  % \end{flalign*}
+  %%%%%%%%%% recheck here....  (gm)
+  % \begin{flalign*}
+  =& \int \limits_D  -\frac{1} {e_3 } \textbf{k} \cdot \nabla \times
+  \Bigl[ \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)  \Bigr]\;dv  \\
+  % \end{flalign*}
+  % \begin{flalign*}
+  \equiv& \sum\limits_{i,j}
+  \left\{
+    \delta_{i+1/2} \left[  \frac {e_{2v}} {e_{1v}\,e_{3v}}  \delta_i \left[ A_f^{\,lm} e_{3f} \zeta  \right]  \right]
+    + \delta_{j+1/2} \left[  \frac {e_{1u}} {e_{2u}\,e_{3u}}  \delta_j \left[ A_f^{\,lm} e_{3f} \zeta  \right]  \right]
+  \right\} 	 \\
+  %
+  \intertext{Using \autoref{eq:DOM_di_adj}, it follows:}
+  %
+  \equiv& \sum\limits_{i,j,k}
+  -\,\left\{
+    \frac{e_{2v}} {e_{1v}\,e_{3v}}  \delta_i	\left[ A_f^{\,lm} e_{3f} \zeta  \right]\;\delta_i \left[ 1\right]
+	 + \frac{e_{1u}} {e_{2u}\,e_{3u}}  \delta_j 	\left[ A_f^{\,lm} e_{3f} \zeta  \right]\;\delta_j \left[ 1\right]
+  \right\} \quad \equiv 0
+  \\
+\end{flalign*}
+
+%% =================================================================================================
+\subsection{Dissipation of horizontal kinetic energy}
+\label{subsec:INVARIANTS_6.2}
+
+The lateral momentum diffusion term dissipates the horizontal kinetic energy:
+%\begin{flalign*}
+\[
+  \begin{split}
+    \int_D \textbf{U}_h \cdot
+    \left[ \nabla_h 		\right.   &     \left.       \left( A^{\,lm}\;\chi \right)
+      - \nabla_h \times  \left( A^{\,lm}\;\zeta \;\textbf{k} \right)     \right] \; dv    \\
+    \\  %%%
+    \equiv& \sum\limits_{i,j,k}
+    \left\{
+      \frac{1} {e_{1u}}               \delta_{i+1/2} \left[  A_T^{\,lm}          \chi     \right]
+      - \frac{1} {e_{2u}\,e_{3u}}  \delta_j           \left[ A_f^{\,lm} e_{3f} \zeta   \right]
+    \right\} \; e_{1u}\,e_{2u}\,e_{3u} \;u     \\
+    &\;\; + 	\left\{
+	   \frac{1} {e_{2u}}             \delta_{j+1/2}	\left[ A_T^{\,lm}          \chi    \right]
+      + \frac{1} {e_{1v}\,e_{3v}} \delta_i            \left[ A_f^{\,lm} e_{3f} \zeta  \right]
+    \right\} \; e_{1v}\,e_{2u}\,e_{3v} \;v     \qquad \\
+    \\  %%%
+    \equiv& \sum\limits_{i,j,k}
+    \Bigl\{
+    e_{2u}\,e_{3u} \;u\;  \delta_{i+1/2} \left[ A_T^{\,lm}           \chi    \right]
+    - e_{1u}             \;u\;  \delta_j           \left[ A_f^{\,lm} e_{3f} \zeta  \right]
+	 \Bigl\}
+	 \\
+    &\;\; + \Bigl\{
+    e_{1v}\,e_{3v} \;v\;  \delta_{j+1/2}  \left[ A_T^{\,lm}           \chi    \right]
+    + e_{2v}             \;v\;  \delta_i            \left[ A_f^{\,lm} e_{3f} \zeta  \right]
+    \Bigl\}      \\
+    \\  %%%
+    \equiv& \sum\limits_{i,j,k}
+    - \Bigl(
+    \delta_i   \left[  e_{2u}\,e_{3u} \;u  \right]
+    + \delta_j  \left[  e_{1v}\,e_{3v}  \;v  \right]
+    \Bigr) \;  A_T^{\,lm} \chi   \\
+    &\;\; - \Bigl(
+    \delta_{i+1/2}  \left[  e_{2v}  \;v  \right]
+    - \delta_{j+1/2}  \left[  e_{1u} \;u  \right]
+    \Bigr)\;  A_f^{\,lm} e_{3f} \zeta      \\
+    \\  %%%
+    \equiv& \sum\limits_{i,j,k}
+    - A_T^{\,lm}  \,\chi^2   \;e_{1t}\,e_{2t}\,e_{3t}
+    - A_f ^{\,lm}  \,\zeta^2 \;e_{1f }\,e_{2f }\,e_{3f}
+    \quad \leq 0       \\
+  \end{split}
+\]
+
+%% =================================================================================================
+\subsection{Dissipation of enstrophy}
+\label{subsec:INVARIANTS_6.3}
+
+The lateral momentum diffusion term dissipates the enstrophy when the eddy coefficients are horizontally uniform:
+\begin{flalign*}
+  &\int\limits_D  \zeta \; \textbf{k} \cdot \nabla \times
+  \left[   \nabla_h \left( A^{\,lm}\;\chi  \right)
+    - \nabla_h \times \left( A^{\,lm}\;\zeta \; \textbf{k} \right)   \right]\;dv &&&\\
+  &\quad = A^{\,lm} \int \limits_D \zeta \textbf{k} \cdot \nabla \times
+  \left[    \nabla_h \times \left( \zeta \; \textbf{k} \right)   \right]\;dv &&&\\
+  &\quad \equiv A^{\,lm} \sum\limits_{i,j,k}  \zeta \;e_{3f}
+  \left\{     \delta_{i+1/2} \left[  \frac{e_{2v}} {e_{1v}\,e_{3v}} \delta_i \left[ e_{3f} \zeta  \right]   \right]
+    + \delta_{j+1/2} \left[  \frac{e_{1u}} {e_{2u}\,e_{3u}} \delta_j \left[ e_{3f} \zeta  \right]   \right]      \right\}   &&&\\
+  %
+  \intertext{Using \autoref{eq:DOM_di_adj}, it follows:}
+  %
+  &\quad \equiv  - A^{\,lm} \sum\limits_{i,j,k}
+  \left\{    \left(  \frac{1} {e_{1v}\,e_{3v}}  \delta_i \left[ e_{3f} \zeta  \right]  \right)^2   b_v
+    + \left(  \frac{1} {e_{2u}\,e_{3u}}  \delta_j \left[ e_{3f} \zeta  \right] \right)^2   b_u  \right\}  \quad \leq \;0    &&&\\
+\end{flalign*}
+
+%% =================================================================================================
+\subsection{Conservation of horizontal divergence}
+\label{subsec:INVARIANTS_6.4}
+
+When the horizontal divergence of the horizontal diffusion of momentum (discrete sense) is taken,
+the term associated with the vertical curl of the vorticity is zero locally, due to \autoref{eq:DOM_div_curl}.
+The resulting term conserves the $\chi$ and dissipates $\chi^2$ when the eddy coefficients are horizontally uniform.
+\begin{flalign*}
+  & \int\limits_D  \nabla_h \cdot
+  \Bigl[     \nabla_h \left( A^{\,lm}\;\chi \right)
+  - \nabla_h \times \left( A^{\,lm}\;\zeta \;\textbf{k} \right)    \Bigr]  dv
+  = \int\limits_D  \nabla_h \cdot \nabla_h \left( A^{\,lm}\;\chi  \right)   dv   \\
+  %
+  &\equiv \sum\limits_{i,j,k}
+  \left\{   \delta_i \left[ A_u^{\,lm} \frac{e_{2u}\,e_{3u}} {e_{1u}}  \delta_{i+1/2} \left[ \chi \right]  \right]
+    + \delta_j \left[ A_v^{\,lm} \frac{e_{1v}\,e_{3v}} {e_{2v}}  \delta_{j+1/2} \left[ \chi \right]  \right]    \right\}    \\
+  %
+  \intertext{Using \autoref{eq:DOM_di_adj}, it follows:}
+  %
+  &\equiv \sum\limits_{i,j,k}
+  - \left\{   \frac{e_{2u}\,e_{3u}} {e_{1u}}  A_u^{\,lm} \delta_{i+1/2} \left[ \chi \right] \delta_{i+1/2} \left[ 1 \right]
+    + \frac{e_{1v}\,e_{3v}} {e_{2v}}  A_v^{\,lm} \delta_{j+1/2} \left[ \chi \right] \delta_{j+1/2} \left[ 1 \right]    \right\}
+  \quad \equiv 0
+\end{flalign*}
+
+%% =================================================================================================
+\subsection{Dissipation of horizontal divergence variance}
+\label{subsec:INVARIANTS_6.5}
+
+\begin{flalign*}
+  &\int\limits_D \chi \;\nabla_h \cdot
+  \left[    \nabla_h              \left( A^{\,lm}\;\chi                    \right)
+    - \nabla_h   \times  \left( A^{\,lm}\;\zeta \;\textbf{k} \right)    \right]\;  dv
+  = A^{\,lm}   \int\limits_D \chi \;\nabla_h \cdot \nabla_h \left( \chi \right)\;  dv    \\
+  %
+  &\equiv A^{\,lm}  \sum\limits_{i,j,k}  \frac{1} {e_{1t}\,e_{2t}\,e_{3t}}  \chi
+  \left\{
+    \delta_i  \left[   \frac{e_{2u}\,e_{3u}} {e_{1u}}  \delta_{i+1/2} \left[ \chi \right]   \right]
+    + \delta_j  \left[   \frac{e_{1v}\,e_{3v}} {e_{2v}}   \delta_{j+1/2} \left[ \chi \right]   \right]
+  \right\} \;   e_{1t}\,e_{2t}\,e_{3t}    \\
+  %
+  \intertext{Using \autoref{eq:DOM_di_adj}, it turns out to be:}
+  %
+  &\equiv - A^{\,lm} \sum\limits_{i,j,k}
+  \left\{    \left(  \frac{1} {e_{1u}}  \delta_{i+1/2}  \left[ \chi \right]  \right)^2  b_u
+    + \left(  \frac{1} {e_{2v}}  \delta_{j+1/2}  \left[ \chi \right]  \right)^2  b_v    \right\}
+  \quad \leq 0
+\end{flalign*}
+
+%% =================================================================================================
+\section{Conservation properties on vertical momentum physics}
+\label{sec:INVARIANTS_7}
+
+As for the lateral momentum physics,
+the continuous form of the vertical diffusion of momentum satisfies several integral constraints.
+The first two are associated with the conservation of momentum and the dissipation of horizontal kinetic energy:
+\begin{align*}
+  \int\limits_D   \frac{1} {e_3 }\; \frac{\partial } {\partial k}
+  \left(   \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}   \right)\;  dv
+  \qquad \quad &= \vec{\textbf{0}}
+  %
+  \intertext{and}
+  %
+                 \int\limits_D
+                 \textbf{U}_h \cdot   \frac{1} {e_3 }\; \frac{\partial } {\partial k}
+                 \left(   \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}   \right)\; dv    \quad &\leq 0
+\end{align*}
+
+The first property is obvious.
+The second results from:
+\begin{flalign*}
+  \int\limits_D
+  \textbf{U}_h \cdot   \frac{1} {e_3 }\; \frac{\partial } {\partial k}
+  \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}   \right)\;dv    &&&\\
+\end{flalign*}
+\begin{flalign*}
+  &\equiv \sum\limits_{i,j,k}
+  \left(
+    u\; \delta_k \left[ \frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2}  \left[ u \right]  \right]\;  e_{1u}\,e_{2u}
+    + v\; \delta_k \left[ \frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2}   \left[ v \right]  \right]\;  e_{1v}\,e_{2v} \right)   &&&
+  %
+  \intertext{since the horizontal scale factor does not depend on $k$, it follows:}
+  %
+  &\equiv - \sum\limits_{i,j,k}
+  \left(  \frac{A_u^{\,vm}} {e_{3uw}} \left( \delta_{k+1/2} \left[ u \right] \right)^2\; e_{1u}\,e_{2u}
+    + \frac{A_v^{\,vm}} {e_{3vw}}  \left( \delta_{k+1/2} \left[ v \right] \right)^2\; e_{1v}\,e_{2v}  \right)
+  \quad \leq 0   &&&
+\end{flalign*}
+
+The vorticity is also conserved.
+Indeed:
+\begin{flalign*}
+  \int \limits_D
+  \frac{1} {e_3 } \textbf{k} \cdot \nabla \times
+  \left( \frac{1} {e_3 }\; \frac{\partial } {\partial k}  \left(
+      \frac{A^{\,vm}} {e_3}\; \frac{\partial \textbf{U}_h } {\partial k}
+    \right)  \right)\; dv   &&&
+\end{flalign*}
+\begin{flalign*}
+  \equiv \sum\limits_{i,j,k}  \frac{1} {e_{3f}}\; \frac{1} {e_{1f}\,e_{2f}}
+  \bigg\{    \biggr.   \quad
+  \delta_{i+1/2}
+  &\left(   \frac{e_{2v}} {e_{3v}} \delta_k  \left[  \frac{1} {e_{3vw}} \delta_{k+1/2} \left[ v \right]  \right]  \right)   &&\\
+  \biggl.
+  - \delta_{j+1/2}
+  &\left(   \frac{e_{1u}} {e_{3u}} \delta_k \left[  \frac{1} {e_{3uw}}\delta_{k+1/2} \left[ u \right]  \right]   \right)
+  \biggr\} \;
+  e_{1f}\,e_{2f}\,e_{3f} \; \equiv 0   &&
+\end{flalign*}
+
+If the vertical diffusion coefficient is uniform over the whole domain, the enstrophy is dissipated, \ie
+\begin{flalign*}
+  \int\limits_D \zeta \, \textbf{k} \cdot \nabla \times
+  \left(   \frac{1} {e_3}\; \frac{\partial } {\partial k}
+    \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}   \right)   \right)\; dv = 0   &&&
+\end{flalign*}
+
+This property is only satisfied in $z$-coordinates:
+\begin{flalign*}
+  \int\limits_D \zeta \, \textbf{k} \cdot \nabla \times
+  \left(  \frac{1} {e_3}\; \frac{\partial } {\partial k}
+    \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}  \right)   \right)\; dv   &&&
+\end{flalign*}
+\begin{flalign*}
+  \equiv \sum\limits_{i,j,k} \zeta \;e_{3f} \;
+  \biggl\{ 	\biggr.	\quad
+  \delta_{i+1/2}
+  &\left(   \frac{e_{2v}} {e_{3v}} \delta_k \left[ \frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2}[v]  \right]   \right)   &&\\
+  - \delta_{j+1/2}
+  &\biggl.
+  \left(   \frac{e_{1u}} {e_{3u}} \delta_k \left[ \frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2} [u]  \right]    \right) \biggr\}   &&
+\end{flalign*}
+\begin{flalign*}
+  \equiv \sum\limits_{i,j,k} \zeta \;e_{3f}
+  \biggl\{		\biggr.	\quad
+  \frac{1} {e_{3v}} \delta_k
+  &\left[ \frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2} \left[ \delta_{i+1/2} \left[ e_{2v}\,v \right] \right]   \right]    &&\\
+  \biggl.
+  - \frac{1} {e_{3u}} \delta_k
+  &\left[  \frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2} \left[ \delta_{j+1/2} \left[ e_{1u}\,u \right] \right]  \right]  \biggr\}  &&
+\end{flalign*}
+Using the fact that the vertical diffusion coefficients are uniform,
+and that in $z$-coordinate, the vertical scale factors do not depend on $i$ and $j$ so that:
+$e_{3f} =e_{3u} =e_{3v} =e_{3t} $ and $e_{3w} =e_{3uw} =e_{3vw} $, it follows:
+\begin{flalign*}
+  \equiv A^{\,vm} \sum\limits_{i,j,k} \zeta \;\delta_k
+  \left[   \frac{1} {e_{3w}} \delta_{k+1/2} \Bigl[   \delta_{i+1/2} \left[ e_{2v}\,v \right]
+    - \delta_{j+1/ 2} \left[ e_{1u}\,u \right]   \Bigr]    \right]    &&&
+\end{flalign*}
+\begin{flalign*}
+  \equiv - A^{\,vm} \sum\limits_{i,j,k} \frac{1} {e_{3w}}
+  \left( \delta_{k+1/2} \left[ \zeta  \right] \right)^2 \; e_{1f}\,e_{2f}  \; \leq 0    &&&
+\end{flalign*}
+Similarly, the horizontal divergence is obviously conserved:
+
+\begin{flalign*}
+  \int\limits_D \nabla \cdot
+  \left( \frac{1} {e_3 }\; \frac{\partial } {\partial k}
+    \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k} \right) \right)\; dv = 0    &&&
+\end{flalign*}
+and the square of the horizontal divergence decreases (\ie\ the horizontal divergence is dissipated) if
+the vertical diffusion coefficient is uniform over the whole domain:
+
+\begin{flalign*}
+  \int\limits_D \chi \;\nabla \cdot
+  \left( \frac{1} {e_3 }\; \frac{\partial } {\partial k}
+    \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k}  \right) \right)\;  dv = 0  &&&
+\end{flalign*}
+This property is only satisfied in the $z$-coordinate:
+\begin{flalign*}
+  \int\limits_D \chi \;\nabla \cdot
+  \left( \frac{1} {e_3 }\; \frac{\partial } {\partial k}
+    \left( \frac{A^{\,vm}} {e_3 }\; \frac{\partial \textbf{U}_h } {\partial k} \right)  \right)\; dv    &&&
+\end{flalign*}
+\begin{flalign*}
+  \equiv \sum\limits_{i,j,k} \frac{\chi } {e_{1t}\,e_{2t}}
+  \biggl\{ 	\Biggr.	\quad
+  \delta_{i+1/2}
+  &\left(   \frac{e_{2u}} {e_{3u}} \delta_k
+    \left[ \frac{A_u^{\,vm}} {e_{3uw}} \delta_{k+1/2} [u] \right] \right)    &&\\
+  \Biggl.
+  + \delta_{j+1/2}
+  &\left( \frac{e_{1v}} {e_{3v}} \delta_k
+    \left[ \frac{A_v^{\,vm}} {e_{3vw}} \delta_{k+1/2} [v] \right]   \right)
+  \Biggr\} \;  e_{1t}\,e_{2t}\,e_{3t}   &&
+\end{flalign*}
+
+\begin{flalign*}
+  \equiv A^{\,vm} \sum\limits_{i,j,k}  \chi \,
+  \biggl\{	\biggr.	\quad
+  \delta_{i+1/2}
+  &\left(
+    \delta_k \left[
+      \frac{1} {e_{3uw}} \delta_{k+1/2} \left[ e_{2u}\,u \right] \right]   \right)    && \\
+  \biggl.
+  + \delta_{j+1/2}
+  &\left(    \delta_k \left[
+      \frac{1} {e_{3vw}} \delta_{k+1/2} \left[ e_{1v}\,v \right] \right]   \right)   \biggr\}    &&
+\end{flalign*}
+
+\begin{flalign*}
+  \equiv -A^{\,vm} \sum\limits_{i,j,k}
+  \frac{\delta_{k+1/2} \left[ \chi \right]} {e_{3w}}\; \biggl\{
+  \delta_{k+1/2} \Bigl[
+  \delta_{i+1/2} \left[ e_{2u}\,u \right]
+  + \delta_{j+1/2} \left[ e_{1v}\,v \right]  \Bigr]    \biggr\}    &&&
+\end{flalign*}
+
+\begin{flalign*}
+  \equiv -A^{\,vm} \sum\limits_{i,j,k}
+  \frac{1} {e_{3w}} \delta_{k+1/2} \left[ \chi \right]\; \delta_{k+1/2} \left[ e_{1t}\,e_{2t} \;\chi \right]   &&&
+\end{flalign*}
+
+\begin{flalign*}
+  \equiv -A^{\,vm} \sum\limits_{i,j,k}
+  \frac{e_{1t}\,e_{2t}} {e_{3w}}\; \left( \delta_{k+1/2} \left[ \chi \right]  \right)^2     \quad  \equiv 0    &&&
+\end{flalign*}
+
+%% =================================================================================================
+\section{Conservation properties on tracer physics}
+\label{sec:INVARIANTS_8}
+
+The numerical schemes used for tracer subgridscale physics are written such that
+the heat and salt contents are conserved (equations in flux form).
+Since a flux form is used to compute the temperature and salinity,
+the quadratic form of these quantities (\ie\ their variance) globally tends to diminish.
+As for the advection term, there is conservation of mass only if the Equation Of Seawater is linear.
+
+%% =================================================================================================
+\subsection{Conservation of tracers}
+\label{subsec:INVARIANTS_8.1}
+
+constraint of conservation of tracers:
+\begin{flalign*}
+  &\int\limits_D  \nabla  \cdot \left( A\;\nabla T \right)\;dv  &&& \\ \\
+  &\equiv \sum\limits_{i,j,k}
+  \biggl\{ 	\biggr.
+  \delta_i
+  \left[
+    A_u^{\,lT} \frac{e_{2u}\,e_{3u}} {e_{1u}} \delta_{i+1/2}
+    \left[ T \right]
+  \right]
+  + \delta_j
+  \left[
+    A_v^{\,lT} \frac{e_{1v}\,e_{3v}} {e_{2v}} \delta_{j+1/2}
+    \left[ T \right]
+  \right] && \\
+  & \qquad \qquad \qquad \qquad \qquad \qquad \quad \;\;\;
+  + \delta_k
+  \left[
+    A_w^{\,vT} \frac{e_{1t}\,e_{2t}} {e_{3t}} \delta_{k+1/2}
+    \left[ T \right]
+  \right]
+  \biggr\}   \quad  \equiv 0
+  &&
+\end{flalign*}
+
+In fact, this property simply results from the flux form of the operator.
+
+%% =================================================================================================
+\subsection{Dissipation of tracer variance}
+\label{subsec:INVARIANTS_8.2}
+
+constraint on the dissipation of tracer variance:
+\begin{flalign*}
+  \int\limits_D T\;\nabla & \cdot \left( A\;\nabla T \right)\;dv	&&&\\
+  &\equiv   \sum\limits_{i,j,k} \; T
+  \biggl\{  \biggr.
+  \delta_i \left[ A_u^{\,lT} \frac{e_{2u}\,e_{3u}} {e_{1u}} \delta_{i+1/2} \left[T\right] \right]
+  & + \delta_j \left[ A_v^{\,lT} \frac{e_{1v} \,e_{3v}} {e_{2v}} \delta_{j+1/2} \left[T\right] \right]
+  \quad&& \\
+  \biggl.
+  &&+ \delta_k \left[A_w^{\,vT}\frac{e_{1t}\,e_{2t}} {e_{3t}}\delta_{k+1/2}\left[T\right]\right]
+  \biggr\} &&
+\end{flalign*}
+\begin{flalign*}
+  \equiv - \sum\limits_{i,j,k}
+  \biggl\{ 	\biggr.	\quad
+  &    A_u^{\,lT} \left( \frac{1} {e_{1u}} \delta_{i+1/2} \left[ T \right]  \right)^2   e_{1u}\,e_{2u}\,e_{3u}    && \\
+  & + A_v^{\,lT} \left( \frac{1} {e_{2v}} \delta_{j+1/2} \left[ T \right]  \right)^2   e_{1v}\,e_{2v}\,e_{3v}     && \\ \biggl.
+  & + A_w^{\,vT} \left( \frac{1} {e_{3w}} \delta_{k+1/2} \left[ T \right]   \right)^2    e_{1w}\,e_{2w}\,e_{3w}   \biggr\}
+  \quad      \leq 0      &&
+\end{flalign*}
+
+%%%%  end of appendix in gm comment
+%}
+
+\subinc{\input{../../global/epilogue}}
+
+\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_s_coord.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_s_coord.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_s_coord.tex	(revision 12143)
@@ -0,0 +1,588 @@
+\documentclass[../main/NEMO_manual]{subfiles}
+
+\begin{document}
+
+\chapter{Curvilinear $s-$Coordinate Equations}
+\label{apdx:SCOORD}
+
+%    {\em 4.0} & {\em Mike Bell} & {\em review}  \\
+%    {\em 3.x} & {\em Gurvan Madec} & {\em original}  \\
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+\section{Chain rule for $s-$coordinates}
+\label{sec:SCOORD_chain}
+
+In order to establish the set of Primitive Equation in curvilinear $s$-coordinates
+(\ie\ an orthogonal curvilinear coordinate in the horizontal and
+an Arbitrary Lagrangian Eulerian (ALE) coordinate in the vertical),
+we start from the set of equations established in \autoref{subsec:MB_zco_Eq} for
+the special case $k = z$ and thus $e_3 = 1$,
+and we introduce an arbitrary vertical coordinate $a = a(i,j,z,t)$.
+Let us define a new vertical scale factor by $e_3 = \partial z / \partial s$ (which now depends on $(i,j,z,t)$) and
+the horizontal slope of $s-$surfaces by:
+\begin{equation}
+  \label{eq:SCOORD_s_slope}
+  \sigma_1 =\frac{1}{e_1 } \; \left. {\frac{\partial z}{\partial i}} \right|_s
+  \quad \text{and} \quad
+  \sigma_2 =\frac{1}{e_2 } \; \left. {\frac{\partial z}{\partial j}} \right|_s .
+\end{equation}
+
+The model fields (e.g. pressure $p$) can be viewed as functions of $(i,j,z,t)$ (e.g. $p(i,j,z,t)$) or as
+functions of $(i,j,s,t)$ (e.g. $p(i,j,s,t)$). The symbol $\bullet$ will be used to represent any one of
+these fields.  Any ``infinitesimal'' change in $\bullet$ can be written in two forms:
+\begin{equation}
+  \label{eq:SCOORD_s_infin_changes}
+  \begin{aligned}
+    & \delta \bullet =  \delta i \left. \frac{ \partial \bullet }{\partial i} \right|_{j,s,t}
+                + \delta j \left. \frac{ \partial \bullet }{\partial i} \right|_{i,s,t}
+                + \delta s \left. \frac{ \partial \bullet }{\partial s} \right|_{i,j,t}
+                + \delta t \left. \frac{ \partial \bullet }{\partial t} \right|_{i,j,s} , \\
+    & \delta \bullet =  \delta i \left. \frac{ \partial \bullet }{\partial i} \right|_{j,z,t}
+                + \delta j \left. \frac{ \partial \bullet }{\partial i} \right|_{i,z,t}
+                + \delta z \left. \frac{ \partial \bullet }{\partial z} \right|_{i,j,t}
+                + \delta t \left. \frac{ \partial \bullet }{\partial t} \right|_{i,j,z} .
+  \end{aligned}
+\end{equation}
+Using the first form and considering a change $\delta i$ with $j, z$ and $t$ held constant, shows that
+\begin{equation}
+  \label{eq:SCOORD_s_chain_rule1}
+      \left. {\frac{\partial \bullet }{\partial i}} \right|_{j,z,t}  =
+      \left. {\frac{\partial \bullet }{\partial i}} \right|_{j,s,t}
+    + \left. {\frac{\partial s       }{\partial i}} \right|_{j,z,t} \;
+      \left. {\frac{\partial \bullet }{\partial s}} \right|_{i,j,t} .
+\end{equation}
+The term $\left. \partial s / \partial i \right|_{j,z,t}$ can be related to the slope of constant $s$ surfaces,
+(\autoref{eq:SCOORD_s_slope}), by applying the second of (\autoref{eq:SCOORD_s_infin_changes}) with $\bullet$ set to
+$s$ and $j, t$ held constant
+\begin{equation}
+\label{eq:SCOORD_delta_s}
+\delta s|_{j,t} =
+         \delta i \left. \frac{ \partial s }{\partial i} \right|_{j,z,t}
+       + \delta z \left. \frac{ \partial s }{\partial z} \right|_{i,j,t} .
+\end{equation}
+Choosing to look at a direction in the $(i,z)$ plane in which $\delta s = 0$ and using
+(\autoref{eq:SCOORD_s_slope}) we obtain
+\begin{equation}
+\left. \frac{ \partial s }{\partial i} \right|_{j,z,t} =
+         -  \left. \frac{ \partial z }{\partial i} \right|_{j,s,t} \;
+            \left. \frac{ \partial s }{\partial z} \right|_{i,j,t}
+	 = - \frac{e_1 }{e_3 }\sigma_1  .
+\label{eq:SCOORD_ds_di_z}
+\end{equation}
+Another identity, similar in form to (\autoref{eq:SCOORD_ds_di_z}), can be derived
+by choosing $\bullet$ to be $s$ and using the second form of (\autoref{eq:SCOORD_s_infin_changes}) to consider
+changes in which $i , j$ and $s$ are constant. This shows that
+\begin{equation}
+\label{eq:SCOORD_w_in_s}
+w_s = \left. \frac{ \partial z }{\partial t} \right|_{i,j,s} =
+- \left. \frac{ \partial z }{\partial s} \right|_{i,j,t}
+  \left. \frac{ \partial s }{\partial t} \right|_{i,j,z}
+  = - e_3 \left. \frac{ \partial s }{\partial t} \right|_{i,j,z} .
+\end{equation}
+
+In what follows, for brevity, indication of the constancy of the $i, j$ and $t$ indices is
+usually omitted. Using the arguments outlined above one can show that the chain rules needed to establish
+the model equations in the curvilinear $s-$coordinate system are:
+\begin{equation}
+  \label{eq:SCOORD_s_chain_rule2}
+  \begin{aligned}
+    &\left. {\frac{\partial \bullet }{\partial t}} \right|_z  =
+    \left. {\frac{\partial \bullet }{\partial t}} \right|_s
+	 + \frac{\partial \bullet }{\partial s}\; \frac{\partial s}{\partial t} , \\
+    &\left. {\frac{\partial \bullet }{\partial i}} \right|_z  =
+    \left. {\frac{\partial \bullet }{\partial i}} \right|_s
+    +\frac{\partial \bullet }{\partial s}\; \frac{\partial s}{\partial i}=
+    \left. {\frac{\partial \bullet }{\partial i}} \right|_s
+    -\frac{e_1 }{e_3 }\sigma_1 \frac{\partial \bullet }{\partial s} , \\
+    &\left. {\frac{\partial \bullet }{\partial j}} \right|_z  =
+    \left. {\frac{\partial \bullet }{\partial j}} \right|_s
+    + \frac{\partial \bullet }{\partial s}\;\frac{\partial s}{\partial j}=
+    \left. {\frac{\partial \bullet }{\partial j}} \right|_s
+    - \frac{e_2 }{e_3 }\sigma_2 \frac{\partial \bullet }{\partial s} , \\
+    &\;\frac{\partial \bullet }{\partial z}  \;\; = \frac{1}{e_3 }\frac{\partial \bullet }{\partial s} .
+  \end{aligned}
+\end{equation}
+
+%% =================================================================================================
+\section{Continuity equation in $s-$coordinates}
+\label{sec:SCOORD_continuity}
+
+Using (\autoref{eq:SCOORD_s_chain_rule1}) and
+the fact that the horizontal scale factors $e_1$ and $e_2$ do not depend on the vertical coordinate,
+the divergence of the velocity relative to the ($i$,$j$,$z$) coordinate system is transformed as follows in order to
+obtain its expression in the curvilinear $s-$coordinate system:
+
+\begin{subequations}
+  \begin{align*}
+    {
+    \begin{array}{*{20}l}
+      \nabla \cdot {\mathrm {\mathbf U}}
+      &= \frac{1}{e_1 \,e_2 }  \left[ \left. {\frac{\partial (e_2 \,u)}{\partial i}} \right|_z
+        +\left. {\frac{\partial(e_1 \,v)}{\partial j}} \right|_z  \right]
+        + \frac{\partial w}{\partial z} \\ \\
+      &     = \frac{1}{e_1 \,e_2 }  \left[
+		  \left.   \frac{\partial (e_2 \,u)}{\partial i}    \right|_s
+		  - \frac{e_1 }{e_3 } \sigma_1 \frac{\partial (e_2 \,u)}{\partial s}
+        + \left.   \frac{\partial (e_1 \,v)}{\partial j}    \right|_s
+		  - \frac{e_2 }{e_3 } \sigma_2 \frac{\partial (e_1 \,v)}{\partial s}	\right]
+        + \frac{\partial w}{\partial s} \; \frac{\partial s}{\partial z} \\ \\
+      &     = \frac{1}{e_1 \,e_2 }   \left[
+		  \left.   \frac{\partial (e_2 \,u)}{\partial i}    \right|_s
+        + \left.   \frac{\partial (e_1 \,v)}{\partial j}    \right|_s       	\right]
+        + \frac{1}{e_3 }\left[        \frac{\partial w}{\partial s}
+        -  \sigma_1 \frac{\partial u}{\partial s}
+        -  \sigma_2 \frac{\partial v}{\partial s}      \right] \\ \\
+      &     = \frac{1}{e_1 \,e_2 \,e_3 }   \left[
+		  \left.   \frac{\partial (e_2 \,e_3 \,u)}{\partial i}    \right|_s
+		  -\left.    e_2 \,u    \frac{\partial e_3 }{\partial i}     \right|_s
+        + \left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j}    \right|_s
+		  - \left.    e_1 v      \frac{\partial e_3 }{\partial j}    \right|_s   \right] \\
+      & \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad
+        + \frac{1}{e_3 } \left[        \frac{\partial w}{\partial s}
+        -  \sigma_1 \frac{\partial u}{\partial s}
+        -  \sigma_2 \frac{\partial v}{\partial s}      \right]      \\
+      %
+      \intertext{Noting that $
+      \frac{1}{e_1} \left.{ \frac{\partial e_3}{\partial i}} \right|_s
+      =\frac{1}{e_1} \left.{ \frac{\partial^2 z}{\partial i\,\partial s}} \right|_s
+      =\frac{\partial}{\partial s} \left( {\frac{1}{e_1 } \left.{ \frac{\partial z}{\partial i} }\right|_s } \right)
+      =\frac{\partial \sigma_1}{\partial s}
+      $ and $
+      \frac{1}{e_2 }\left. {\frac{\partial e_3 }{\partial j}} \right|_s
+      =\frac{\partial \sigma_2}{\partial s}
+      $, it becomes:}
+    %
+      \nabla \cdot {\mathrm {\mathbf U}}
+      & = \frac{1}{e_1 \,e_2 \,e_3 }  \left[
+		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s
+        +\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right] \\
+      & \qquad \qquad \qquad \qquad \quad
+        +\frac{1}{e_3 }\left[ {\frac{\partial w}{\partial s}-u\frac{\partial \sigma_1 }{\partial s}-v\frac{\partial \sigma_2 }{\partial s}-\sigma_1 \frac{\partial u}{\partial s}-\sigma_2 \frac{\partial v}{\partial s}} \right] \\
+      \\
+      & = \frac{1}{e_1 \,e_2 \,e_3 }  \left[
+		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s
+        +\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]
+        + \frac{1}{e_3 } \; \frac{\partial}{\partial s}   \left[  w -  u\;\sigma_1  - v\;\sigma_2  \right]
+    \end{array}
+        }
+  \end{align*}
+\end{subequations}
+
+Here, $w$ is the vertical velocity relative to the $z-$coordinate system.
+Using the first form of (\autoref{eq:SCOORD_s_infin_changes})
+and the definitions (\autoref{eq:SCOORD_s_slope}) and (\autoref{eq:SCOORD_w_in_s}) for $\sigma_1$, $\sigma_2$ and  $w_s$,
+one can show that the vertical velocity, $w_p$ of a point
+moving with the horizontal velocity of the fluid along an $s$ surface is given by
+\begin{equation}
+\label{eq:SCOORD_w_p}
+\begin{split}
+w_p  = & \left. \frac{ \partial z }{\partial t} \right|_s
+     + \frac{u}{e_1} \left. \frac{ \partial z }{\partial i} \right|_s
+     + \frac{v}{e_2} \left. \frac{ \partial z }{\partial j} \right|_s \\
+     = & w_s + u \sigma_1 + v \sigma_2 .
+\end{split}
+\end{equation}
+ The vertical velocity across this surface is denoted by
+\begin{equation}
+  \label{eq:SCOORD_w_s}
+  \omega  = w - w_p = w - ( w_s + \sigma_1 \,u + \sigma_2 \,v )  .
+\end{equation}
+Hence
+\begin{equation}
+\frac{1}{e_3 } \frac{\partial}{\partial s}   \left[  w -  u\;\sigma_1  - v\;\sigma_2  \right] =
+\frac{1}{e_3 } \frac{\partial}{\partial s} \left[  \omega + w_s \right] =
+   \frac{1}{e_3 } \left[ \frac{\partial \omega}{\partial s}
+ + \left. \frac{ \partial }{\partial t} \right|_s \frac{\partial z}{\partial s} \right] =
+   \frac{1}{e_3 } \frac{\partial \omega}{\partial s} + \frac{1}{e_3 } \left. \frac{ \partial e_3}{\partial t} . \right|_s
+\end{equation}
+
+Using (\autoref{eq:SCOORD_w_s}) in our expression for $\nabla \cdot {\mathrm {\mathbf U}}$ we obtain
+our final expression for the divergence of the velocity in the curvilinear $s-$coordinate system:
+\begin{equation}
+      \nabla \cdot {\mathrm {\mathbf U}} =
+         \frac{1}{e_1 \,e_2 \,e_3 }    \left[
+		  \left.  \frac{\partial (e_2 \,e_3 \,u)}{\partial i} \right|_s
+        +\left.  \frac{\partial (e_1 \,e_3 \,v)}{\partial j} \right|_s        \right]
+        + \frac{1}{e_3 } \frac{\partial \omega }{\partial s}
+        + \frac{1}{e_3 } \left. \frac{\partial e_3}{\partial t} \right|_s .
+\end{equation}
+
+As a result, the continuity equation \autoref{eq:MB_PE_continuity} in the $s-$coordinates is:
+\begin{equation}
+  \label{eq:SCOORD_sco_Continuity}
+  \frac{1}{e_3 } \frac{\partial e_3}{\partial t}
+  + \frac{1}{e_1 \,e_2 \,e_3 }\left[
+    {\left. {\frac{\partial (e_2 \,e_3 \,u)}{\partial i}} \right|_s
+      +  \left. {\frac{\partial (e_1 \,e_3 \,v)}{\partial j}} \right|_s } \right]
+  +\frac{1}{e_3 }\frac{\partial \omega }{\partial s} = 0 .
+\end{equation}
+An additional term has appeared that takes into account
+the contribution of the time variation of the vertical coordinate to the volume budget.
+
+%% =================================================================================================
+\section{Momentum equation in $s-$coordinate}
+\label{sec:SCOORD_momentum}
+
+Here we only consider the first component of the momentum equation,
+the generalization to the second one being straightforward.
+
+$\bullet$ \textbf{Total derivative in vector invariant form}
+
+Let us consider \autoref{eq:MB_dyn_vect}, the first component of the momentum equation in the vector invariant form.
+Its total $z-$coordinate time derivative,
+$\left. \frac{D u}{D t} \right|_z$ can be transformed as follows in order to obtain
+its expression in the curvilinear $s-$coordinate system:
+
+\begin{subequations}
+  \begin{align*}
+    {
+    \begin{array}{*{20}l}
+      \left. \frac{D u}{D t} \right|_z
+      &= \left. {\frac{\partial u }{\partial t}} \right|_z
+        - \left. \zeta \right|_z v
+        + \frac{1}{2e_1} \left.{ \frac{\partial (u^2+v^2)}{\partial i}} \right|_z
+        + w \;\frac{\partial u}{\partial z} \\ \\
+      &= \left. {\frac{\partial u }{\partial t}} \right|_z
+        -  \frac{1}{e_1 \,e_2 }\left[ { \left.{ \frac{\partial (e_2 \,v)}{\partial i} }\right|_z
+        -\left.{ \frac{\partial (e_1 \,u)}{\partial j} }\right|_z } \right] \; v
+        +  \frac{1}{2e_1} \left.{ \frac{\partial (u^2+v^2)}{\partial i} } \right|_z
+        +  w \;\frac{\partial u}{\partial z}      \\
+        %
+      \intertext{introducing the chain rule (\autoref{eq:SCOORD_s_chain_rule1}) }
+      %
+      &= \left. {\frac{\partial u }{\partial t}} \right|_z
+        - \frac{1}{e_1\,e_2}\left[ { \left.{ \frac{\partial (e_2 \,v)}{\partial i} } \right|_s
+        -\left.{ \frac{\partial (e_1 \,u)}{\partial j} } \right|_s } \right.
+        \left. {-\frac{e_1}{e_3}\sigma_1 \frac{\partial (e_2 \,v)}{\partial s}
+        +\frac{e_2}{e_3}\sigma_2 \frac{\partial (e_1 \,u)}{\partial s}} \right] \; v  \\
+      & \qquad \qquad \qquad \qquad
+        {
+        + \frac{1}{2e_1} \left(                                  \left.  \frac{\partial (u^2+v^2)}{\partial i} \right|_s
+        - \frac{e_1}{e_3}\sigma_1 \frac{\partial (u^2+v^2)}{\partial s}               \right)
+        + \frac{w}{e_3 } \;\frac{\partial u}{\partial s}
+        } \\ \\
+      &= \left. {\frac{\partial u }{\partial t}} \right|_z
+        - \left. \zeta \right|_s \;v
+        + \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s \\
+      &\qquad \qquad \qquad \quad
+        + \frac{w}{e_3 } \;\frac{\partial u}{\partial s}
+        + \left[   {\frac{\sigma_1 }{e_3 }\frac{\partial v}{\partial s}
+        - \frac{\sigma_2 }{e_3 }\frac{\partial u}{\partial s}}   \right]\;v
+        - \frac{\sigma_1 }{2e_3 }\frac{\partial (u^2+v^2)}{\partial s} \\ \\
+      &= \left. {\frac{\partial u }{\partial t}} \right|_z
+        - \left. \zeta \right|_s \;v
+        + \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s \\
+      &\qquad \qquad \qquad \quad
+        + \frac{1}{e_3} \left[    {w\frac{\partial u}{\partial s}
+        +\sigma_1 v\frac{\partial v}{\partial s} - \sigma_2 v\frac{\partial u}{\partial s}
+        - \sigma_1 u\frac{\partial u}{\partial s} - \sigma_1 v\frac{\partial v}{\partial s}} \right] \\ \\
+      &= \left. {\frac{\partial u }{\partial t}} \right|_z
+        - \left. \zeta \right|_s \;v
+        + \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s
+        + \frac{1}{e_3} \left[  w - \sigma_2 v - \sigma_1 u  \right]
+        \; \frac{\partial u}{\partial s} .  \\
+        %
+      \intertext{Introducing $\omega$, the dia-s-surface velocity given by (\autoref{eq:SCOORD_w_s}) }
+      %
+      &= \left. {\frac{\partial u }{\partial t}} \right|_z
+        - \left. \zeta \right|_s \;v
+        + \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s
+        + \frac{1}{e_3 } \left( \omega + w_s \right) \frac{\partial u}{\partial s}   \\
+    \end{array}
+    }
+  \end{align*}
+\end{subequations}
+Applying the time derivative chain rule (first equation of (\autoref{eq:SCOORD_s_chain_rule1})) to $u$ and
+using (\autoref{eq:SCOORD_w_in_s}) provides the expression of the last term of the right hand side,
+\[
+  {
+    \begin{array}{*{20}l}
+      \frac{w_s}{e_3}  \;\frac{\partial u}{\partial s}
+      = - \left. \frac{\partial s}{\partial t} \right|_z \;  \frac{\partial u }{\partial s}
+      = \left. {\frac{\partial u }{\partial t}} \right|_s  - \left. {\frac{\partial u }{\partial t}} \right|_z \ .
+    \end{array}
+  }
+\]
+This leads to the $s-$coordinate formulation of the total $z-$coordinate time derivative,
+\ie\ the total $s-$coordinate time derivative :
+\begin{align}
+  \label{eq:SCOORD_sco_Dt_vect}
+  \left. \frac{D u}{D t} \right|_s
+  = \left. {\frac{\partial u }{\partial t}} \right|_s
+  - \left. \zeta \right|_s \;v
+  + \frac{1}{2\,e_1}\left. {\frac{\partial (u^2+v^2)}{\partial i}} \right|_s
+  + \frac{1}{e_3 } \omega \;\frac{\partial u}{\partial s} .
+\end{align}
+Therefore, the vector invariant form of the total time derivative has exactly the same mathematical form in
+$z-$ and $s-$coordinates.
+This is not the case for the flux form as shown in next paragraph.
+
+$\bullet$ \textbf{Total derivative in flux form}
+
+Let us start from the total time derivative in the curvilinear $s-$coordinate system we have just establish.
+Following the procedure used to establish (\autoref{eq:MB_flux_form}), it can be transformed into :
+% \begin{subequations}
+\begin{align*}
+  {
+  \begin{array}{*{20}l}
+    \left. \frac{D u}{D t} \right|_s  &= \left. {\frac{\partial u }{\partial t}} \right|_s
+    & -  \zeta \;v
+      + \frac{1}{2\;e_1 } \frac{\partial \left( {u^2+v^2} \right)}{\partial i}
+      + \frac{1}{e_3} \omega \;\frac{\partial u}{\partial s} \\ \\
+                                      &= \left. {\frac{\partial u }{\partial t}} \right|_s
+    &+\frac{1}{e_1\;e_2}  \left(    \frac{\partial \left( {e_2 \,u\,u } \right)}{\partial i}
+      + \frac{\partial \left( {e_1 \,u\,v } \right)}{\partial j}     \right)
+      + \frac{1}{e_3 } \frac{\partial \left( {\omega\,u} \right)}{\partial s} \\ \\
+                                      &&- \,u \left[     \frac{1}{e_1 e_2 } \left(    \frac{\partial(e_2 u)}{\partial i}
+                                         + \frac{\partial(e_1 v)}{\partial j}    \right)
+                                         + \frac{1}{e_3}        \frac{\partial \omega}{\partial s}                       \right] \\ \\
+                                      &&- \frac{v}{e_1 e_2 }\left(    v	\;\frac{\partial e_2 }{\partial i}
+                                         -u	\;\frac{\partial e_1 }{\partial j} 	\right) . \\
+  \end{array}
+  }
+\end{align*}
+Introducing the vertical scale factor inside the horizontal derivative of the first two terms
+(\ie\ the horizontal divergence), it becomes :
+\begin{align*}
+  {
+  \begin{array}{*{20}l}
+    % \begin{align*} {\begin{array}{*{20}l}
+    %     {\begin{array}{*{20}l} \left. \frac{D u}{D t} \right|_s
+    &= \left. {\frac{\partial u }{\partial t}} \right|_s
+    &+ \frac{1}{e_1\,e_2\,e_3}  \left(  \frac{\partial( e_2 e_3 \,u^2 )}{\partial i}
+      + \frac{\partial( e_1 e_3 \,u v )}{\partial j}
+      -  e_2 u u \frac{\partial e_3}{\partial i}
+      -  e_1 u v \frac{\partial e_3 }{\partial j}    \right)
+      + \frac{1}{e_3} \frac{\partial \left( {\omega\,u} \right)}{\partial s} \\ \\
+    && - \,u \left[  \frac{1}{e_1 e_2 e_3} \left(   \frac{\partial(e_2 e_3 \, u)}{\partial i}
+       + \frac{\partial(e_1 e_3 \, v)}{\partial j}
+       -  e_2 u \;\frac{\partial e_3 }{\partial i}
+       -  e_1 v \;\frac{\partial e_3 }{\partial j}   \right)
+       + \frac{1}{e_3}        \frac{\partial \omega}{\partial s}                       \right] \\ \\
+    && - \frac{v}{e_1 e_2 }\left( 	v  \;\frac{\partial e_2 }{\partial i}
+       -u  \;\frac{\partial e_1 }{\partial j} 	\right) \\ \\
+    &= \left. {\frac{\partial u }{\partial t}} \right|_s
+    &+ \frac{1}{e_1\,e_2\,e_3}  \left(  \frac{\partial( e_2 e_3 \,u\,u )}{\partial i}
+      + \frac{\partial( e_1 e_3 \,u\,v )}{\partial j}    \right)
+      + \frac{1}{e_3 } \frac{\partial \left( {\omega\,u} \right)}{\partial s} \\ \\
+    && - \,u \left[  \frac{1}{e_1 e_2 e_3} \left(   \frac{\partial(e_2 e_3 \, u)}{\partial i}
+       + \frac{\partial(e_1 e_3 \, v)}{\partial j}  \right)
+       + \frac{1}{e_3}        \frac{\partial \omega}{\partial s}                       \right]
+       - \frac{v}{e_1 e_2 }\left( 	v   \;\frac{\partial e_2 }{\partial i}
+       -u   \;\frac{\partial e_1 }{\partial j} 	\right)     .             \\
+     %
+    \intertext {Introducing a more compact form for the divergence of the momentum fluxes,
+    and using (\autoref{eq:SCOORD_sco_Continuity}), the $s-$coordinate continuity equation,
+    it becomes : }
+  %
+    &= \left. {\frac{\partial u }{\partial t}} \right|_s
+    &+ \left.  \nabla \cdot \left(   {{\mathrm {\mathbf U}}\,u}   \right)    \right|_s
+      + \,u \frac{1}{e_3 } \frac{\partial e_3}{\partial t}
+      - \frac{v}{e_1 e_2 }\left(    v  \;\frac{\partial e_2 }{\partial i}
+      -u  \;\frac{\partial e_1 }{\partial j} 	\right)
+    \\
+  \end{array}
+  }
+\end{align*}
+which leads to the $s-$coordinate flux formulation of the total $s-$coordinate time derivative,
+\ie\ the total $s-$coordinate time derivative in flux form:
+\begin{flalign}
+  \label{eq:SCOORD_sco_Dt_flux}
+  \left. \frac{D u}{D t} \right|_s   = \frac{1}{e_3}  \left. \frac{\partial ( e_3\,u)}{\partial t} \right|_s
+  + \left.  \nabla \cdot \left(   {{\mathrm {\mathbf U}}\,u}   \right)    \right|_s
+  - \frac{v}{e_1 e_2 }\left(    v  \;\frac{\partial e_2 }{\partial i}
+    -u  \;\frac{\partial e_1 }{\partial j}            \right).
+\end{flalign}
+which is the total time derivative expressed in the curvilinear $s-$coordinate system.
+It has the same form as in the $z-$coordinate but for
+the vertical scale factor that has appeared inside the time derivative which
+comes from the modification of (\autoref{eq:SCOORD_sco_Continuity}),
+the continuity equation.
+
+$\bullet$ \textbf{horizontal pressure gradient}
+
+The horizontal pressure gradient term can be transformed as follows:
+\[
+  \begin{split}
+    -\frac{1}{\rho_o \, e_1 }\left. {\frac{\partial p}{\partial i}} \right|_z
+    & =-\frac{1}{\rho_o e_1 }\left[ {\left. {\frac{\partial p}{\partial i}} \right|_s -\frac{e_1 }{e_3 }\sigma_1 \frac{\partial p}{\partial s}} \right] \\
+    & =-\frac{1}{\rho_o \,e_1 }\left. {\frac{\partial p}{\partial i}} \right|_s +\frac{\sigma_1 }{\rho_o \,e_3 }\left( {-g\;\rho \;e_3 } \right) \\
+    &=-\frac{1}{\rho_o \,e_1 }\left. {\frac{\partial p}{\partial i}} \right|_s -\frac{g\;\rho }{\rho_o }\sigma_1 .
+  \end{split}
+\]
+Applying similar manipulation to the second component and
+replacing $\sigma_1$ and $\sigma_2$ by their expression \autoref{eq:SCOORD_s_slope}, it becomes:
+\begin{equation}
+  \label{eq:SCOORD_grad_p_1}
+  \begin{split}
+    -\frac{1}{\rho_o \, e_1 } \left. {\frac{\partial p}{\partial i}} \right|_z
+    &=-\frac{1}{\rho_o \,e_1 } \left(     \left.              {\frac{\partial p}{\partial i}} \right|_s
+      + g\;\rho  \;\left. {\frac{\partial z}{\partial i}} \right|_s    \right) \\
+             %
+    -\frac{1}{\rho_o \, e_2 }\left. {\frac{\partial p}{\partial j}} \right|_z
+    &=-\frac{1}{\rho_o \,e_2 } \left(    \left.               {\frac{\partial p}{\partial j}} \right|_s
+      + g\;\rho \;\left. {\frac{\partial z}{\partial j}} \right|_s   \right) . \\
+  \end{split}
+\end{equation}
+
+An additional term appears in (\autoref{eq:SCOORD_grad_p_1}) which accounts for
+the tilt of $s-$surfaces with respect to geopotential $z-$surfaces.
+
+As in $z$-coordinate,
+the horizontal pressure gradient can be split in two parts following \citet{marsaleix.auclair.ea_OM08}.
+Let defined a density anomaly, $d$, by $d=(\rho - \rho_o)/ \rho_o$,
+and a hydrostatic pressure anomaly, $p_h'$, by $p_h'= g \; \int_z^\eta d \; e_3 \; dk$.
+The pressure is then given by:
+\[
+  \begin{split}
+    p &= g\; \int_z^\eta \rho \; e_3 \; dk = g\; \int_z^\eta \rho_o \left( d + 1 \right) \; e_3 \; dk   \\
+    &= g \, \rho_o \; \int_z^\eta d \; e_3 \; dk + \rho_o g \, \int_z^\eta e_3 \; dk .
+  \end{split}
+\]
+Therefore, $p$ and $p_h'$ are linked through:
+\begin{equation}
+  \label{eq:SCOORD_pressure}
+  p = \rho_o \; p_h' + \rho_o \, g \, ( \eta - z )
+\end{equation}
+and the hydrostatic pressure balance expressed in terms of $p_h'$ and $d$ is:
+\[
+  \frac{\partial p_h'}{\partial k} = - d \, g \, e_3 .
+\]
+
+Substituing \autoref{eq:SCOORD_pressure} in \autoref{eq:SCOORD_grad_p_1} and
+using the definition of the density anomaly it becomes an expression in two parts:
+\begin{equation}
+  \label{eq:SCOORD_grad_p_2}
+  \begin{split}
+    -\frac{1}{\rho_o \, e_1 } \left. {\frac{\partial p}{\partial i}} \right|_z
+    &=-\frac{1}{e_1 } \left(     \left.              {\frac{\partial p_h'}{\partial i}} \right|_s
+      + g\; d  \;\left. {\frac{\partial z}{\partial i}} \right|_s    \right)  - \frac{g}{e_1 } \frac{\partial \eta}{\partial i} ,  \\
+             %
+    -\frac{1}{\rho_o \, e_2 }\left. {\frac{\partial p}{\partial j}} \right|_z
+    &=-\frac{1}{e_2 } \left(    \left.               {\frac{\partial p_h'}{\partial j}} \right|_s
+      + g\; d \;\left. {\frac{\partial z}{\partial j}} \right|_s   \right)  - \frac{g}{e_2 } \frac{\partial \eta}{\partial j} . \\
+  \end{split}
+\end{equation}
+This formulation of the pressure gradient is characterised by the appearance of
+a term depending on the sea surface height only
+(last term on the right hand side of expression \autoref{eq:SCOORD_grad_p_2}).
+This term will be loosely termed \textit{surface pressure gradient} whereas
+the first term will be termed the \textit{hydrostatic pressure gradient} by analogy to
+the $z$-coordinate formulation.
+In fact, the true surface pressure gradient is $1/\rho_o \nabla (\rho \eta)$,
+and $\eta$ is implicitly included in the computation of $p_h'$ through the upper bound of the vertical integration.
+
+$\bullet$ \textbf{The other terms of the momentum equation}
+
+The coriolis and forcing terms as well as the the vertical physics remain unchanged as
+they involve neither time nor space derivatives.
+The form of the lateral physics is discussed in \autoref{apdx:DIFFOPERS}.
+
+$\bullet$ \textbf{Full momentum equation}
+
+To sum up, in a curvilinear $s$-coordinate system,
+the vector invariant momentum equation solved by the model has the same mathematical expression as
+the one in a curvilinear $z-$coordinate, except for the pressure gradient term:
+\begin{subequations}
+  \label{eq:SCOORD_dyn_vect}
+  \begin{multline}
+    \label{eq:SCOORD_PE_dyn_vect_u}
+    \frac{\partial u}{\partial t}=
+    +   \left( {\zeta +f} \right)\,v
+    -   \frac{1}{2\,e_1} \frac{\partial}{\partial i} \left(  u^2+v^2   \right)
+    -   \frac{1}{e_3} \omega \frac{\partial u}{\partial k}       \\
+    -   \frac{1}{e_1 } \left(    \frac{\partial p_h'}{\partial i} + g\; d  \; \frac{\partial z}{\partial i}    \right)
+    -   \frac{g}{e_1 } \frac{\partial \eta}{\partial i}
+    +   D_u^{\vect{U}}  +   F_u^{\vect{U}} ,
+  \end{multline}
+  \begin{multline}
+    \label{eq:SCOORD_dyn_vect_v}
+    \frac{\partial v}{\partial t}=
+    -   \left( {\zeta +f} \right)\,u
+    -   \frac{1}{2\,e_2 }\frac{\partial }{\partial j}\left(  u^2+v^2  \right)
+    -   \frac{1}{e_3 } \omega \frac{\partial v}{\partial k}         \\
+    -   \frac{1}{e_2 } \left(    \frac{\partial p_h'}{\partial j} + g\; d  \; \frac{\partial z}{\partial j}    \right)
+    -   \frac{g}{e_2 } \frac{\partial \eta}{\partial j}
+    +  D_v^{\vect{U}}  +   F_v^{\vect{U}} .
+  \end{multline}
+\end{subequations}
+whereas the flux form momentum equation differs from it by
+the formulation of both the time derivative and the pressure gradient term:
+\begin{subequations}
+  \label{eq:SCOORD_dyn_flux}
+  \begin{multline}
+    \label{eq:SCOORD_PE_dyn_flux_u}
+    \frac{1}{e_3} \frac{\partial \left(  e_3\,u  \right) }{\partial t} =
+    - \nabla \cdot \left(   {{\mathrm {\mathbf U}}\,u}   \right)
+    +   \left\{ {f + \frac{1}{e_1 e_2 }\left(    v  \;\frac{\partial e_2 }{\partial i}
+          -u  \;\frac{\partial e_1 }{\partial j}            \right)} \right\} \,v     \\
+    -   \frac{1}{e_1 } \left(    \frac{\partial p_h'}{\partial i} + g\; d  \; \frac{\partial z}{\partial i}    \right)
+    -   \frac{g}{e_1 } \frac{\partial \eta}{\partial i}
+    +   D_u^{\vect{U}}  +   F_u^{\vect{U}} ,
+  \end{multline}
+  \begin{multline}
+    \label{eq:SCOORD_dyn_flux_v}
+    \frac{1}{e_3}\frac{\partial \left(  e_3\,v  \right) }{\partial t}=
+    -  \nabla \cdot \left(   {{\mathrm {\mathbf U}}\,v}   \right)
+    -   \left\{ {f + \frac{1}{e_1 e_2 }\left(    v  \;\frac{\partial e_2 }{\partial i}
+          -u  \;\frac{\partial e_1 }{\partial j}            \right)} \right\} \,u     \\
+    -   \frac{1}{e_2 } \left(    \frac{\partial p_h'}{\partial j} + g\; d  \; \frac{\partial z}{\partial j}    \right)
+    -   \frac{g}{e_2 } \frac{\partial \eta}{\partial j}
+    +  D_v^{\vect{U}}  +   F_v^{\vect{U}} .
+  \end{multline}
+\end{subequations}
+Both formulation share the same hydrostatic pressure balance expressed in terms of
+hydrostatic pressure and density anomalies, $p_h'$ and $d=( \frac{\rho}{\rho_o}-1 )$:
+\begin{equation}
+  \label{eq:SCOORD_dyn_zph}
+  \frac{\partial p_h'}{\partial k} = - d \, g \, e_3 .
+\end{equation}
+
+It is important to realize that the change in coordinate system has only concerned the position on the vertical.
+It has not affected (\textbf{i},\textbf{j},\textbf{k}), the orthogonal curvilinear set of unit vectors.
+($u$,$v$) are always horizontal velocities so that their evolution is driven by \emph{horizontal} forces,
+in particular the pressure gradient.
+By contrast, $\omega$ is not $w$, the third component of the velocity, but the dia-surface velocity component,
+\ie\ the volume flux across the moving $s$-surfaces per unit horizontal area.
+
+%% =================================================================================================
+\section{Tracer equation}
+\label{sec:SCOORD_tracer}
+
+The tracer equation is obtained using the same calculation as for the continuity equation and then
+regrouping the time derivative terms in the left hand side :
+
+\begin{multline}
+  \label{eq:SCOORD_tracer}
+  \frac{1}{e_3} \frac{\partial \left(  e_3 T  \right)}{\partial t}
+  = -\frac{1}{e_1 \,e_2 \,e_3}
+  \left[           \frac{\partial }{\partial i} \left( {e_2 \,e_3 \;Tu} \right)
+    +   \frac{\partial }{\partial j} \left( {e_1 \,e_3 \;Tv} \right)               \right]       \\
+  -  \frac{1}{e_3}  \frac{\partial }{\partial k} \left(                   Tw  \right)
+  +  D^{T} +F^{T}
+\end{multline}
+
+The expression for the advection term is a straight consequence of (\autoref{eq:SCOORD_sco_Continuity}),
+the expression of the 3D divergence in the $s-$coordinates established above.
+
+\subinc{\input{../../global/epilogue}}
+
+\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_triads.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_triads.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/apdx_triads.tex	(revision 12143)
@@ -0,0 +1,1181 @@
+\documentclass[../main/NEMO_manual]{subfiles}
+
+%% Local cmds
+\newcommand{\rML}[1][i]{\ensuremath{_{\mathrm{ML}\,#1}}}
+\newcommand{\rMLt}[1][i]{\tilde{r}_{\mathrm{ML}\,#1}}
+%% Move to ../../global/new_cmds.tex to avoid error with \listoffigures
+%\newcommand{\triad}[6][]{\ensuremath{{}_{#2}^{#3}{\mathbb{#4}_{#1}}_{#5}^{\,#6}}
+\newcommand{\triadd}[5]{\ensuremath{{}_{#1}^{#2}{\mathbb{#3}}_{#4}^{\,#5}}}
+\newcommand{\triadt}[5]{\ensuremath{{}_{#1}^{#2}{\tilde{\mathbb{#3}}}_{#4}^{\,#5}}}
+\newcommand{\rtriad}[2][]{\ensuremath{\triad[#1]{i}{k}{#2}{i_p}{k_p}}}
+\newcommand{\rtriadt}[1]{\ensuremath{\triadt{i}{k}{#1}{i_p}{k_p}}}
+
+\begin{document}
+
+\chapter{Iso-Neutral Diffusion and Eddy Advection using Triads}
+\label{apdx:TRIADS}
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+%% =================================================================================================
+\section[Choice of \forcode{namtra\_ldf} namelist parameters]{Choice of \protect\nam{tra_ldf}{tra\_ldf} namelist parameters}
+
+Two scheme are available to perform the iso-neutral diffusion.
+If the namelist logical \np{ln_traldf_triad}{ln\_traldf\_triad} is set true,
+\NEMO\ updates both active and passive tracers using the Griffies triad representation of iso-neutral diffusion and
+the eddy-induced advective skew (GM) fluxes.
+If the namelist logical \np{ln_traldf_iso}{ln\_traldf\_iso} is set true,
+the filtered version of Cox's original scheme (the Standard scheme) is employed (\autoref{sec:LDF_slp}).
+In the present implementation of the Griffies scheme,
+the advective skew fluxes are implemented even if \np{ln_traldf_eiv}{ln\_traldf\_eiv} is false.
+
+Values of iso-neutral diffusivity and GM coefficient are set as described in \autoref{sec:LDF_coef}.
+Note that when GM fluxes are used, the eddy-advective (GM) velocities are output for diagnostic purposes using XIOS,
+even though the eddy advection is accomplished by means of the skew fluxes.
+
+The options specific to the Griffies scheme include:
+\begin{description}
+\item [{\np{ln_triad_iso}{ln\_triad\_iso}}] See \autoref{sec:TRIADS_taper}.
+  If this is set false (the default),
+  then `iso-neutral' mixing is accomplished within the surface mixed-layer along slopes linearly decreasing with
+  depth from the value immediately below the mixed-layer to zero (flat) at the surface (\autoref{sec:TRIADS_lintaper}).
+  This is the same treatment as used in the default implementation
+  \autoref{subsec:LDF_slp_iso}; \autoref{fig:LDF_eiv_slp}.
+  Where \np{ln_triad_iso}{ln\_triad\_iso} is set true,
+  the vertical skew flux is further reduced to ensure no vertical buoyancy flux,
+  giving an almost pure horizontal diffusive tracer flux within the mixed layer.
+  This is similar to the tapering suggested by \citet{gerdes.koberle.ea_CD91}. See \autoref{subsec:TRIADS_Gerdes-taper}
+\item [{\np{ln_botmix_triad}{ln\_botmix\_triad}}] See \autoref{sec:TRIADS_iso_bdry}.
+  If this is set false (the default) then the lateral diffusive fluxes
+  associated with triads partly masked by topography are neglected.
+  If it is set true, however, then these lateral diffusive fluxes are applied,
+  giving smoother bottom tracer fields at the cost of introducing diapycnal mixing.
+\item [{\np{rn_sw_triad}{rn\_sw\_triad}}] blah blah to be added....
+\end{description}
+The options shared with the Standard scheme include:
+\begin{description}
+\item [{\np{ln_traldf_msc}{ln\_traldf\_msc}}] blah blah to be added
+\item [{\np{rn_slpmax}{rn\_slpmax}}]          blah blah to be added
+\end{description}
+
+%% =================================================================================================
+\section{Triad formulation of iso-neutral diffusion}
+\label{sec:TRIADS_iso}
+
+We have implemented into \NEMO\ a scheme inspired by \citet{griffies.gnanadesikan.ea_JPO98},
+but formulated within the \NEMO\ framework, using scale factors rather than grid-sizes.
+
+%% =================================================================================================
+\subsection{Iso-neutral diffusion operator}
+
+The iso-neutral second order tracer diffusive operator for small angles between
+iso-neutral surfaces and geopotentials is given by \autoref{eq:TRIADS_iso_tensor_1}:
+\begin{subequations}
+  \label{eq:TRIADS_iso_tensor_1}
+  \begin{equation}
+    D^{lT}=-\nabla \cdot\vect{f}^{lT}\equiv
+    -\frac{1}{e_1e_2e_3}\left[\pd{i}\left (f_1^{lT}e_2e_3\right) +
+      \pd{j}\left (f_2^{lT}e_2e_3\right) + \pd{k}\left (f_3^{lT}e_1e_2\right)\right],
+  \end{equation}
+  where the diffusive flux per unit area of physical space
+  \begin{equation}
+    \vect{f}^{lT}=-{A^{lT}}\Re\cdot\nabla T,
+  \end{equation}
+  \begin{equation}
+    \label{eq:TRIADS_iso_tensor_2}
+    \mbox{with}\quad \;\;\Re =
+    \begin{pmatrix}
+      1   &  0   & -r_1           \rule[-.9 em]{0pt}{1.79 em} \\
+      0   &  1   & -r_2           \rule[-.9 em]{0pt}{1.79 em} \\
+      -r_1 & -r_2 &  r_1 ^2+r_2 ^2 \rule[-.9 em]{0pt}{1.79 em}
+    \end{pmatrix}
+    \quad \text{and} \quad\nabla T=
+    \begin{pmatrix}
+      \frac{1}{e_1} \pd[T]{i} \rule[-.9 em]{0pt}{1.79 em} \\
+      \frac{1}{e_2} \pd[T]{j} \rule[-.9 em]{0pt}{1.79 em} \\
+      \frac{1}{e_3} \pd[T]{k} \rule[-.9 em]{0pt}{1.79 em}
+    \end{pmatrix}
+    .
+  \end{equation}
+\end{subequations}
+% \left( {{\begin{array}{*{20}c}
+%  1 \hfill & 0 \hfill & {-r_1 } \hfill \\
+%  0 \hfill & 1 \hfill & {-r_2 } \hfill \\
+%  {-r_1 } \hfill & {-r_2 } \hfill & {r_1 ^2+r_2 ^2} \hfill \\
+% \end{array} }} \right)
+Here \autoref{eq:MB_iso_slopes}
+\begin{align*}
+  r_1 &=-\frac{e_3 }{e_1 } \left( \frac{\partial \rho }{\partial i}
+        \right)
+        \left( {\frac{\partial \rho }{\partial k}} \right)^{-1} \\
+      &=-\frac{e_3 }{e_1 } \left( -\alpha\frac{\partial T }{\partial i} +
+        \beta\frac{\partial S }{\partial i} \right) \left(
+        -\alpha\frac{\partial T }{\partial k} + \beta\frac{\partial S
+        }{\partial k} \right)^{-1}
+\end{align*}
+is the $i$-component of the slope of the iso-neutral surface relative to the computational surface,
+and $r_2$ is the $j$-component.
+
+We will find it useful to consider the fluxes per unit area in $i,j,k$ space; we write
+\[
+  % \label{eq:TRIADS_Fijk}
+  \vect{F}_{\mathrm{iso}}=\left(f_1^{lT}e_2e_3, f_2^{lT}e_1e_3, f_3^{lT}e_1e_2\right).
+\]
+Additionally, we will sometimes write the contributions towards the fluxes $\vect{f}$ and
+$\vect{F}_{\mathrm{iso}}$ from the component $R_{ij}$ of $\Re$ as $f_{ij}$, $F_{\mathrm{iso}\: ij}$,
+with $f_{ij}=R_{ij}e_i^{-1}\partial T/\partial x_i$ (no summation) etc.
+
+The off-diagonal terms of the small angle diffusion tensor
+\autoref{eq:TRIADS_iso_tensor_1}, \autoref{eq:TRIADS_iso_tensor_2} produce skew-fluxes along
+the $i$- and $j$-directions resulting from the vertical tracer gradient:
+\begin{align}
+  \label{eq:TRIADS_i13c}
+  f_{13}=&+{A^{lT}} r_1\frac{1}{e_3}\frac{\partial T}{\partial k},\qquad f_{23}=+{A^{lT}} r_2\frac{1}{e_3}\frac{\partial T}{\partial k}\\
+  \intertext{and in the k-direction resulting from the lateral tracer gradients}
+  \label{eq:TRIADS_i31c}
+  f_{31}+f_{32}=& {A^{lT}} r_1\frac{1}{e_1}\frac{\partial T}{\partial i}+{A^{lT}} r_2\frac{1}{e_1}\frac{\partial T}{\partial i}
+\end{align}
+
+The vertical diffusive flux associated with the $_{33}$ component of the small angle diffusion tensor is
+\begin{equation}
+  \label{eq:TRIADS_i33c}
+  f_{33}=-{A^{lT}}(r_1^2 +r_2^2) \frac{1}{e_3}\frac{\partial T}{\partial k}.
+\end{equation}
+
+Since there are no cross terms involving $r_1$ and $r_2$ in the above,
+we can consider the iso-neutral diffusive fluxes separately in the $i$-$k$ and $j$-$k$ planes,
+just adding together the vertical components from each plane.
+The following description will describe the fluxes on the $i$-$k$ plane.
+
+There is no natural discretization for the $i$-component of the skew-flux, \autoref{eq:TRIADS_i13c},
+as although it must be evaluated at $u$-points,
+it involves vertical gradients (both for the tracer and the slope $r_1$), defined at $w$-points.
+Similarly, the vertical skew flux, \autoref{eq:TRIADS_i31c},
+is evaluated at $w$-points but involves horizontal gradients defined at $u$-points.
+
+%% =================================================================================================
+\subsection{Standard discretization}
+
+The straightforward approach to discretize the lateral skew flux
+\autoref{eq:TRIADS_i13c} from tracer cell $i,k$ to $i+1,k$, introduced in 1995 into OPA,
+\autoref{eq:TRA_ldf_iso}, is to calculate a mean vertical gradient at the $u$-point from
+the average of the four surrounding vertical tracer gradients, and multiply this by a mean slope at the $u$-point,
+calculated from the averaged surrounding vertical density gradients.
+The total area-integrated skew-flux (flux per unit area in $ijk$ space) from tracer cell $i,k$ to $i+1,k$,
+noting that the $e_{{3}_{i+1/2}^k}$ in the area $e{_{3}}_{i+1/2}^k{e_{2}}_{i+1/2}i^k$ at the $u$-point cancels out with
+the $1/{e_{3}}_{i+1/2}^k$ associated with the vertical tracer gradient, is then \autoref{eq:TRA_ldf_iso}
+\[
+  \left(F_u^{13} \right)_{i+\frac{1}{2}}^k = {A}_{i+\frac{1}{2}}^k
+  {e_{2}}_{i+1/2}^k \overline{\overline
+    r_1} ^{\,i,k}\,\overline{\overline{\delta_k T}}^{\,i,k},
+\]
+where
+\[
+  \overline{\overline
+    r_1} ^{\,i,k} = -\frac{{e_{3u}}_{i+1/2}^k}{{e_{1u}}_{i+1/2}^k}
+  \frac{\delta_{i+1/2} [\rho]}{\overline{\overline{\delta_k \rho}}^{\,i,k}},
+\]
+and here and in the following we drop the $^{lT}$ superscript from ${A^{lT}}$ for simplicity.
+Unfortunately the resulting combination $\overline{\overline{\delta_k\bullet}}^{\,i,k}$ of a $k$ average and
+a $k$ difference of the tracer reduces to $\bullet_{k+1}-\bullet_{k-1}$,
+so two-grid-point oscillations are invisible to this discretization of the iso-neutral operator.
+These \emph{computational modes} will not be damped by this operator, and may even possibly be amplified by it.
+Consequently, applying this operator to a tracer does not guarantee the decrease of its global-average variance.
+To correct this, we introduced a smoothing of the slopes of the iso-neutral surfaces (see \autoref{chap:LDF}).
+This technique works for $T$ and $S$ in so far as they are active tracers
+(\ie\ they enter the computation of density), but it does not work for a passive tracer.
+
+%% =================================================================================================
+\subsection{Expression of the skew-flux in terms of triad slopes}
+
+\citep{griffies.gnanadesikan.ea_JPO98} introduce a different discretization of the off-diagonal terms that
+nicely solves the problem.
+% Instead of multiplying the mean slope calculated at the $u$-point by
+% the mean vertical gradient at the $u$-point,
+\begin{figure}[tb]
+  \centering
+  \includegraphics[width=0.66\textwidth]{TRIADS_GRIFF_triad_fluxes}
+  \caption[Triads arrangement and tracer gradients to give lateral and vertical tracer fluxes]{
+    (a) Arrangement of triads $S_i$ and tracer gradients to
+    give lateral tracer flux from box $i,k$ to $i+1,k$
+    (b) Triads $S'_i$ and tracer gradients to give vertical tracer flux from
+    box $i,k$ to $i,k+1$.}
+  \label{fig:TRIADS_ISO_triad}
+\end{figure}
+They get the skew flux from the products of the vertical gradients at each $w$-point surrounding the $u$-point with
+the corresponding `triad' slope calculated from the lateral density gradient across the $u$-point divided by
+the vertical density gradient at the same $w$-point as the tracer gradient.
+See \autoref{fig:TRIADS_ISO_triad}a, where the thick lines denote the tracer gradients,
+and the thin lines the corresponding triads, with slopes $s_1, \dotsc s_4$.
+The total area-integrated skew-flux from tracer cell $i,k$ to $i+1,k$
+\begin{multline}
+  \label{eq:TRIADS_i13}
+  \left( F_u^{13}  \right)_{i+\frac{1}{2}}^k = {A}_{i+1}^k a_1 s_1
+  \delta_{k+\frac{1}{2}} \left[ T^{i+1}
+  \right]/e_{{3w}_{i+1}}^{k+\frac{1}{2}}  + {A} _i^k a_2 s_2 \delta
+  _{k+\frac{1}{2}} \left[ T^i
+  \right]/e_{{3w}_{i+1}}^{k+\frac{1}{2}} \\
+  +{A} _{i+1}^k a_3 s_3 \delta_{k-\frac{1}{2}} \left[ T^{i+1}
+  \right]/e_{{3w}_{i+1}}^{k+\frac{1}{2}}  +{A} _i^k a_4 s_4 \delta
+  _{k-\frac{1}{2}} \left[ T^i \right]/e_{{3w}_{i+1}}^{k+\frac{1}{2}},
+\end{multline}
+where the contributions of the triad fluxes are weighted by areas $a_1, \dotsc a_4$,
+and ${A}$ is now defined at the tracer points rather than the $u$-points.
+This discretization gives a much closer stencil, and disallows the two-point computational modes.
+
+The vertical skew flux \autoref{eq:TRIADS_i31c} from tracer cell $i,k$ to $i,k+1$ at
+the $w$-point $i,k+\frac{1}{2}$ is constructed similarly (\autoref{fig:TRIADS_ISO_triad}b) by
+multiplying lateral tracer gradients from each of the four surrounding $u$-points by the appropriate triad slope:
+\begin{multline}
+  \label{eq:TRIADS_i31}
+  \left( F_w^{31} \right) _i ^{k+\frac{1}{2}} =  {A}_i^{k+1} a_{1}'
+  s_{1}' \delta_{i-\frac{1}{2}} \left[ T^{k+1} \right]/{e_{3u}}_{i-\frac{1}{2}}^{k+1}
+  +{A}_i^{k+1} a_{2}' s_{2}' \delta_{i+\frac{1}{2}} \left[ T^{k+1} \right]/{e_{3u}}_{i+\frac{1}{2}}^{k+1} \\
+  + {A}_i^k a_{3}' s_{3}' \delta_{i-\frac{1}{2}} \left[ T^k\right]/{e_{3u}}_{i-\frac{1}{2}}^k
+  +{A}_i^k a_{4}' s_{4}' \delta_{i+\frac{1}{2}} \left[ T^k \right]/{e_{3u}}_{i+\frac{1}{2}}^k.
+\end{multline}
+
+We notate the triad slopes $s_i$ and $s'_i$ in terms of the `anchor point' $i,k$
+(appearing in both the vertical and lateral gradient),
+and the $u$- and $w$-points $(i+i_p,k)$, $(i,k+k_p)$ at the centres of the `arms' of the triad as follows
+(see also \autoref{fig:TRIADS_ISO_triad}):
+\begin{equation}
+  \label{eq:TRIADS_R}
+  _i^k \mathbb{R}_{i_p}^{k_p}
+  =-\frac{ {e_{3w}}_{\,i}^{\,k+k_p}} { {e_{1u}}_{\,i+i_p}^{\,k}}
+  \
+  \frac
+  { \alpha_i^k  \ \delta_{i+i_p}[T^k] - \beta_i^k \ \delta_{i+i_p}[S^k] }
+  { \alpha_i^k  \ \delta_{k+k_p}[T^i] - \beta_i^k \ \delta_{k+k_p}[S^i] }.
+\end{equation}
+In calculating the slopes of the local neutral surfaces,
+the expansion coefficients $\alpha$ and $\beta$ are evaluated at the anchor points of the triad,
+while the metrics are calculated at the $u$- and $w$-points on the arms.
+
+\begin{figure}[tb]
+  \centering
+  \includegraphics[width=0.66\textwidth]{TRIADS_GRIFF_qcells}
+  \caption[Triad notation for quarter cells]{
+    Triad notation for quarter cells.
+    $T$-cells are inside boxes,
+    while the $i+\fractext{1}{2},k$ $u$-cell is shaded in green and
+    the $i,k+\fractext{1}{2}$ $w$-cell is shaded in pink.}
+  \label{fig:TRIADS_qcells}
+\end{figure}
+
+Each triad $\{_i^{k}\:_{i_p}^{k_p}\}$ is associated (\autoref{fig:TRIADS_qcells}) with the quarter cell that is
+the intersection of the $i,k$ $T$-cell, the $i+i_p,k$ $u$-cell and the $i,k+k_p$ $w$-cell.
+Expressing the slopes $s_i$ and $s'_i$ in \autoref{eq:TRIADS_i13} and \autoref{eq:TRIADS_i31} in this notation,
+we have \eg\ \ $s_1=s'_1={\:}_i^k \mathbb{R}_{1/2}^{1/2}$.
+Each triad slope $_i^k\mathbb{R}_{i_p}^{k_p}$ is used once (as an $s$) to
+calculate the lateral flux along its $u$-arm, at $(i+i_p,k)$,
+and then again as an $s'$ to calculate the vertical flux along its $w$-arm at $(i,k+k_p)$.
+Each vertical area $a_i$ used to calculate the lateral flux and horizontal area $a'_i$ used to
+calculate the vertical flux can also be identified as the area across the $u$- and $w$-arms of a unique triad,
+and we notate these areas, similarly to the triad slopes,
+as $_i^k{\mathbb{A}_u}_{i_p}^{k_p}$, $_i^k{\mathbb{A}_w}_{i_p}^{k_p}$,
+where \eg\ in \autoref{eq:TRIADS_i13} $a_{1}={\:}_i^k{\mathbb{A}_u}_{1/2}^{1/2}$,
+and in \autoref{eq:TRIADS_i31} $a'_{1}={\:}_i^k{\mathbb{A}_w}_{1/2}^{1/2}$.
+
+%% =================================================================================================
+\subsection{Full triad fluxes}
+
+A key property of iso-neutral diffusion is that it should not affect the (locally referenced) density.
+In particular there should be no lateral or vertical density flux.
+The lateral density flux disappears so long as the area-integrated lateral diffusive flux from
+tracer cell $i,k$ to $i+1,k$ coming from the $_{11}$ term of the diffusion tensor takes the form
+\begin{equation}
+  \label{eq:TRIADS_i11}
+  \left( F_u^{11} \right) _{i+\frac{1}{2}} ^{k} =
+  - \left( {A}_i^{k+1} a_{1} + {A}_i^{k+1} a_{2} + {A}_i^k
+    a_{3} + {A}_i^k a_{4} \right)
+  \frac{\delta_{i+1/2} \left[ T^k\right]}{{e_{1u}}_{\,i+1/2}^{\,k}},
+\end{equation}
+where the areas $a_i$ are as in \autoref{eq:TRIADS_i13}.
+In this case, separating the total lateral flux, the sum of \autoref{eq:TRIADS_i13} and \autoref{eq:TRIADS_i11},
+into triad components, a lateral tracer flux
+\begin{equation}
+  \label{eq:TRIADS_latflux-triad}
+  _i^k {\mathbb{F}_u}_{i_p}^{k_p} (T) = - {A}_i^k{ \:}_i^k{\mathbb{A}_u}_{i_p}^{k_p}
+  \left(
+    \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
+    -\ {_i^k\mathbb{R}_{i_p}^{k_p}} \
+    \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
+  \right)
+\end{equation}
+can be identified with each triad.
+Then, because the same metric factors ${e_{3w}}_{\,i}^{\,k+k_p}$ and ${e_{1u}}_{\,i+i_p}^{\,k}$ are employed for both
+the density gradients in $ _i^k \mathbb{R}_{i_p}^{k_p}$ and the tracer gradients,
+the lateral density flux associated with each triad separately disappears.
+\begin{equation}
+  \label{eq:TRIADS_latflux-rho}
+  {\mathbb{F}_u}_{i_p}^{k_p} (\rho)=-\alpha _i^k {\:}_i^k {\mathbb{F}_u}_{i_p}^{k_p} (T) + \beta_i^k {\:}_i^k {\mathbb{F}_u}_{i_p}^{k_p} (S)=0
+\end{equation}
+Thus the total flux $\left( F_u^{31} \right) ^i _{i,k+\frac{1}{2}} + \left( F_u^{11} \right) ^i _{i,k+\frac{1}{2}}$ from
+tracer cell $i,k$ to $i+1,k$ must also vanish since it is a sum of four such triad fluxes.
+
+The squared slope $r_1^2$ in the expression \autoref{eq:TRIADS_i33c} for the $_{33}$ component is also expressed in
+terms of area-weighted squared triad slopes,
+so the area-integrated vertical flux from tracer cell $i,k$ to $i,k+1$ resulting from the $r_1^2$ term is
+\begin{equation}
+  \label{eq:TRIADS_i33}
+  \left( F_w^{33} \right) _i^{k+\frac{1}{2}} =
+  - \left( {A}_i^{k+1} a_{1}' s_{1}'^2
+    + {A}_i^{k+1} a_{2}' s_{2}'^2
+    + {A}_i^k a_{3}' s_{3}'^2
+    + {A}_i^k a_{4}' s_{4}'^2 \right)\delta_{k+\frac{1}{2}} \left[ T^{i+1} \right],
+\end{equation}
+where the areas $a'$ and slopes $s'$ are the same as in \autoref{eq:TRIADS_i31}.
+Then, separating the total vertical flux, the sum of \autoref{eq:TRIADS_i31} and \autoref{eq:TRIADS_i33},
+into triad components, a vertical flux
+\begin{align}
+  \label{eq:TRIADS_vertflux-triad}
+  _i^k {\mathbb{F}_w}_{i_p}^{k_p} (T)
+  &= {A}_i^k{\: }_i^k{\mathbb{A}_w}_{i_p}^{k_p}
+    \left(
+    {_i^k\mathbb{R}_{i_p}^{k_p}}\frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
+    -\ \left({_i^k\mathbb{R}_{i_p}^{k_p}}\right)^2 \
+    \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
+    \right) \\
+  &= - \left(\left.{ }_i^k{\mathbb{A}_w}_{i_p}^{k_p}\right/{ }_i^k{\mathbb{A}_u}_{i_p}^{k_p}\right)
+    {_i^k\mathbb{R}_{i_p}^{k_p}}{\: }_i^k{\mathbb{F}_u}_{i_p}^{k_p} (T) \label{eq:TRIADS_vertflux-triad2}
+\end{align}
+may be associated with each triad.
+Each vertical density flux $_i^k {\mathbb{F}_w}_{i_p}^{k_p} (\rho)$ associated with a triad then
+separately disappears (because the lateral flux $_i^k{\mathbb{F}_u}_{i_p}^{k_p} (\rho)$ disappears).
+Consequently the total vertical density flux
+$\left( F_w^{31} \right)_i ^{k+\frac{1}{2}} + \left( F_w^{33} \right)_i^{k+\frac{1}{2}}$ from
+tracer cell $i,k$ to $i,k+1$ must also vanish since it is a sum of four such triad fluxes.
+
+We can explicitly identify (\autoref{fig:TRIADS_qcells}) the triads associated with the $s_i$, $a_i$,
+and $s'_i$, $a'_i$ used in the definition of the $u$-fluxes and $w$-fluxes in \autoref{eq:TRIADS_i31},
+\autoref{eq:TRIADS_i13}, \autoref{eq:TRIADS_i11} \autoref{eq:TRIADS_i33} and \autoref{fig:TRIADS_ISO_triad} to write out
+the iso-neutral fluxes at $u$- and $w$-points as sums of the triad fluxes that cross the $u$- and $w$-faces:
+%(\autoref{fig:TRIADS_ISO_triad}):
+\begin{flalign}
+  \label{eq:TRIADS_iso_flux} \vect{F}_{\mathrm{iso}}(T) &\equiv
+  \sum_{\substack{i_p,\,k_p}}
+  \begin{pmatrix}
+    {_{i+1/2-i_p}^k {\mathbb{F}_u}_{i_p}^{k_p} } (T) \\ \\
+    {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p} } (T) \\
+  \end{pmatrix}.
+\end{flalign}
+
+%% =================================================================================================
+\subsection{Ensuring the scheme does not increase tracer variance}
+\label{subsec:TRIADS_variance}
+
+We now require that this operator should not increase the globally-integrated tracer variance.
+%This changes according to
+% \begin{align*}
+% &\int_D  D_l^T \; T \;dv \equiv  \sum_{i,k} \left\{ T \ D_l^T \ b_T \right\}    \\
+% &\equiv + \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
+% 		\delta_{i} \left[{_{i+1/2-i_p}^k {\mathbb{F}_u }_{i_p}^{k_p}} \right]
+% 	     + \delta_{k} \left[ {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}} \right]  \ T \right\}    \\
+% &\equiv  - \sum_{i,k} \sum_{\substack{i_p,\,k_p}} \left\{
+%                 {_{i+1/2-i_p}^k {\mathbb{F}_u }_{i_p}^{k_p}} \ \delta_{i+1/2} [T]
+%              + {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}}  \ \delta_{k+1/2} [T]   \right\}      \\
+% \end{align*}
+Each triad slope $_i^k\mathbb{R}_{i_p}^{k_p}$ drives a lateral flux $_i^k{\mathbb{F}_u}_{i_p}^{k_p} (T)$ across
+the $u$-point $i+i_p,k$ and a vertical flux $_i^k{\mathbb{F}_w}_{i_p}^{k_p} (T)$ across the $w$-point $i,k+k_p$.
+The lateral flux drives a net rate of change of variance,
+summed over the two $T$-points $i+i_p-\fractext{1}{2},k$ and $i+i_p+\fractext{1}{2},k$, of
+\begin{multline}
+  {b_T}_{i+i_p-1/2}^k\left(\frac{\partial T}{\partial t}T\right)_{i+i_p-1/2}^k+
+  \quad {b_T}_{i+i_p+1/2}^k\left(\frac{\partial T}{\partial
+      t}T\right)_{i+i_p+1/2}^k \\
+  \begin{aligned}
+    &= -T_{i+i_p-1/2}^k{\;} _i^k{\mathbb{F}_u}_{i_p}^{k_p} (T) \quad + \quad  T_{i+i_p+1/2}^k
+    {\;}_i^k{\mathbb{F}_u}_{i_p}^{k_p} (T) \\
+    &={\;} _i^k{\mathbb{F}_u}_{i_p}^{k_p} (T)\,\delta_{i+ i_p}[T^k], \label{eq:TRIADS_dvar_iso_i}
+  \end{aligned}
+\end{multline}
+while the vertical flux similarly drives a net rate of change of variance summed over
+the $T$-points $i,k+k_p-\fractext{1}{2}$ (above) and $i,k+k_p+\fractext{1}{2}$ (below) of
+\begin{equation}
+  \label{eq:TRIADS_dvar_iso_k}
+  _i^k{\mathbb{F}_w}_{i_p}^{k_p} (T) \,\delta_{k+ k_p}[T^i].
+\end{equation}
+The total variance tendency driven by the triad is the sum of these two.
+Expanding $_i^k{\mathbb{F}_u}_{i_p}^{k_p} (T)$ and $_i^k{\mathbb{F}_w}_{i_p}^{k_p} (T)$ with
+\autoref{eq:TRIADS_latflux-triad} and \autoref{eq:TRIADS_vertflux-triad}, it is
+\begin{multline*}
+  -{A}_i^k\left \{
+    { } _i^k{\mathbb{A}_u}_{i_p}^{k_p}
+    \left(
+      \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
+      - {_i^k\mathbb{R}_{i_p}^{k_p}} \
+      \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }\right)\,\delta_{i+ i_p}[T^k] \right.\\
+  - \left. { } _i^k{\mathbb{A}_w}_{i_p}^{k_p}
+    \left(
+      \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
+      -{\:}_i^k\mathbb{R}_{i_p}^{k_p}
+      \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
+    \right) {\,}_i^k\mathbb{R}_{i_p}^{k_p}\delta_{k+ k_p}[T^i]
+  \right \}.
+\end{multline*}
+The key point is then that if we require $_i^k{\mathbb{A}_u}_{i_p}^{k_p}$ and $_i^k{\mathbb{A}_w}_{i_p}^{k_p}$ to
+be related to a triad volume $_i^k\mathbb{V}_{i_p}^{k_p}$ by
+\begin{equation}
+  \label{eq:TRIADS_V-A}
+  _i^k\mathbb{V}_{i_p}^{k_p}
+  ={\;}_i^k{\mathbb{A}_u}_{i_p}^{k_p}\,{e_{1u}}_{\,i + i_p}^{\,k}
+  ={\;}_i^k{\mathbb{A}_w}_{i_p}^{k_p}\,{e_{3w}}_{\,i}^{\,k + k_p},
+\end{equation}
+the variance tendency reduces to the perfect square
+\begin{equation}
+  \label{eq:TRIADS_perfect-square}
+  -{A}_i^k{\:} _i^k\mathbb{V}_{i_p}^{k_p}
+  \left(
+    \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
+    -{\:}_i^k\mathbb{R}_{i_p}^{k_p}
+    \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
+  \right)^2\leq 0.
+\end{equation}
+Thus, the constraint \autoref{eq:TRIADS_V-A} ensures that the fluxes
+(\autoref{eq:TRIADS_latflux-triad}, \autoref{eq:TRIADS_vertflux-triad}) associated with
+a given slope triad $_i^k\mathbb{R}_{i_p}^{k_p}$ do not increase the net variance.
+Since the total fluxes are sums of such fluxes from the various triads, this constraint, applied to all triads,
+is sufficient to ensure that the globally integrated variance does not increase.
+
+The expression \autoref{eq:TRIADS_V-A} can be interpreted as a discretization of the global integral
+\begin{equation}
+  \label{eq:TRIADS_cts-var}
+  \frac{\partial}{\partial t}\int\!\fractext{1}{2} T^2\, dV =
+  \int\!\mathbf{F}\cdot\nabla T\, dV,
+\end{equation}
+where, within each triad volume $_i^k\mathbb{V}_{i_p}^{k_p}$, the lateral and vertical fluxes/unit area
+\[
+  \mathbf{F}=\left(
+    \left.{}_i^k{\mathbb{F}_u}_{i_p}^{k_p} (T)\right/{}_i^k{\mathbb{A}_u}_{i_p}^{k_p},
+    \left.{\:}_i^k{\mathbb{F}_w}_{i_p}^{k_p} (T)\right/{}_i^k{\mathbb{A}_w}_{i_p}^{k_p}
+  \right)
+\]
+and the gradient
+\[
+  \nabla T = \left(
+    \left.\delta_{i+ i_p}[T^k] \right/ {e_{1u}}_{\,i + i_p}^{\,k},
+    \left.\delta_{k+ k_p}[T^i] \right/ {e_{3w}}_{\,i}^{\,k + k_p}
+  \right)
+\]
+
+%% =================================================================================================
+\subsection{Triad volumes in Griffes's scheme and in \NEMO}
+
+To complete the discretization we now need only specify the triad volumes $_i^k\mathbb{V}_{i_p}^{k_p}$.
+\citet{griffies.gnanadesikan.ea_JPO98} identifies these $_i^k\mathbb{V}_{i_p}^{k_p}$ as the volumes of the quarter cells,
+defined in terms of the distances between $T$, $u$,$f$ and $w$-points.
+This is the natural discretization of \autoref{eq:TRIADS_cts-var}.
+The \NEMO\ model, however, operates with scale factors instead of grid sizes,
+and scale factors for the quarter cells are not defined.
+Instead, therefore we simply choose
+\begin{equation}
+  \label{eq:TRIADS_V-NEMO}
+  _i^k\mathbb{V}_{i_p}^{k_p}=\fractext{1}{4} {b_u}_{i+i_p}^k,
+\end{equation}
+as a quarter of the volume of the $u$-cell inside which the triad quarter-cell lies.
+This has the nice property that when the slopes $\mathbb{R}$ vanish,
+the lateral flux from tracer cell $i,k$ to $i+1,k$ reduces to the classical form
+\begin{equation}
+  \label{eq:TRIADS_lat-normal}
+  -\overline{A}_{\,i+1/2}^k\;
+  \frac{{b_u}_{i+1/2}^k}{{e_{1u}}_{\,i + i_p}^{\,k}}
+  \;\frac{\delta_{i+ 1/2}[T^k] }{{e_{1u}}_{\,i + i_p}^{\,k}}
+  = -\overline{A}_{\,i+1/2}^k\;\frac{{e_{1w}}_{\,i + 1/2}^{\,k}\:{e_{1v}}_{\,i + 1/2}^{\,k}\;\delta_{i+ 1/2}[T^k]}{{e_{1u}}_{\,i + 1/2}^{\,k}}.
+\end{equation}
+In fact if the diffusive coefficient is defined at $u$-points,
+so that we employ ${A}_{i+i_p}^k$ instead of  ${A}_i^k$ in the definitions of the triad fluxes
+\autoref{eq:TRIADS_latflux-triad} and \autoref{eq:TRIADS_vertflux-triad},
+we can replace $\overline{A}_{\,i+1/2}^k$ by $A_{i+1/2}^k$ in the above.
+
+%% =================================================================================================
+\subsection{Summary of the scheme}
+
+The iso-neutral fluxes at $u$- and $w$-points are the sums of the triad fluxes that
+cross the $u$- and $w$-faces \autoref{eq:TRIADS_iso_flux}:
+\begin{subequations}
+  % \label{eq:TRIADS_alltriadflux}
+  \begin{flalign*}
+    % \label{eq:TRIADS_vect_isoflux}
+    \vect{F}_{\mathrm{iso}}(T) &\equiv
+    \sum_{\substack{i_p,\,k_p}}
+    \begin{pmatrix}
+      {_{i+1/2-i_p}^k {\mathbb{F}_u}_{i_p}^{k_p} } (T) \\ \\
+      {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p} } (T)
+    \end{pmatrix},
+  \end{flalign*}
+  where \autoref{eq:TRIADS_latflux-triad}:
+  \begin{align}
+    \label{eq:TRIADS_triadfluxu}
+    _i^k {\mathbb{F}_u}_{i_p}^{k_p} (T) &= - {A}_i^k{
+                                          \:}\frac{{{}_i^k\mathbb{V}}_{i_p}^{k_p}}{{e_{1u}}_{\,i + i_p}^{\,k}}
+                                          \left(
+                                          \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
+                                          -\ {_i^k\mathbb{R}_{i_p}^{k_p}} \
+                                          \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
+                                          \right),\\
+    \intertext{and}
+    _i^k {\mathbb{F}_w}_{i_p}^{k_p} (T)
+                                        &= {A}_i^k{\: }\frac{{{}_i^k\mathbb{V}}_{i_p}^{k_p}}{{e_{3w}}_{\,i}^{\,k+k_p}}
+                                          \left(
+                                          {_i^k\mathbb{R}_{i_p}^{k_p}}\frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
+                                          -\ \left({_i^k\mathbb{R}_{i_p}^{k_p}}\right)^2 \
+                                          \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
+                                          \right),\label{eq:TRIADS_triadfluxw}
+  \end{align}
+  with \autoref{eq:TRIADS_V-NEMO}
+  \[
+    % \label{eq:TRIADS_V-NEMO2}
+    _i^k{\mathbb{V}}_{i_p}^{k_p}=\fractext{1}{4} {b_u}_{i+i_p}^k.
+  \]
+\end{subequations}
+
+The divergence of the expression \autoref{eq:TRIADS_iso_flux} for the fluxes gives the iso-neutral diffusion tendency at
+each tracer point:
+\[
+  % \label{eq:TRIADS_iso_operator}
+  D_l^T = \frac{1}{b_T}
+  \sum_{\substack{i_p,\,k_p}} \left\{ \delta_{i} \left[{_{i+1/2-i_p}^k
+        {\mathbb{F}_u }_{i_p}^{k_p}} \right] + \delta_{k} \left[
+      {_i^{k+1/2-k_p} {\mathbb{F}_w}_{i_p}^{k_p}} \right] \right\}
+\]
+where $b_T= e_{1T}\,e_{2T}\,e_{3T}$ is the volume of $T$-cells.
+The diffusion scheme satisfies the following six properties:
+
+\begin{description}
+\item [Horizontal diffusion] The discretization of the diffusion operator recovers the traditional five-point Laplacian
+  \autoref{eq:TRIADS_lat-normal} in the limit of flat iso-neutral direction:
+  \[
+    % \label{eq:TRIADS_iso_property0}
+    D_l^T = \frac{1}{b_T} \
+    \delta_{i} \left[ \frac{e_{2u}\,e_{3u}}{e_{1u}} \;
+      \overline{A}^{\,i} \; \delta_{i+1/2}[T] \right] \qquad
+    \text{when} \quad { _i^k \mathbb{R}_{i_p}^{k_p} }=0
+  \]
+\item [Implicit treatment in the vertical] Only tracer values associated with a single water column appear in the expression \autoref{eq:TRIADS_i33} for
+  the $_{33}$ fluxes, vertical fluxes driven by vertical gradients.
+  This is of paramount importance since it means that a time-implicit algorithm can be used to
+  solve the vertical diffusion equation.
+  This is necessary since the vertical eddy diffusivity associated with this term,
+  \[
+    \frac{1}{b_w}\sum_{\substack{i_p, \,k_p}} \left\{
+      {\:}_i^k\mathbb{V}_{i_p}^{k_p} \: {A}_i^k \: \left(_i^k \mathbb{R}_{i_p}^{k_p}\right)^2
+    \right\}  =
+    \frac{1}{4b_w}\sum_{\substack{i_p, \,k_p}} \left\{
+      {b_u}_{i+i_p}^k\: {A}_i^k \: \left(_i^k \mathbb{R}_{i_p}^{k_p}\right)^2
+    \right\},
+  \]
+  (where $b_w= e_{1w}\,e_{2w}\,e_{3w}$ is the volume of $w$-cells) can be quite large.
+\item [Pure iso-neutral operator] The iso-neutral flux of locally referenced potential density is zero.
+  See \autoref{eq:TRIADS_latflux-rho} and \autoref{eq:TRIADS_vertflux-triad2}.
+\item [Conservation of tracer] The iso-neutral diffusion conserves tracer content, \ie
+  \[
+    % \label{eq:TRIADS_iso_property1}
+    \sum_{i,j,k} \left\{ D_l^T \      b_T \right\} = 0
+  \]
+  This property is trivially satisfied since the iso-neutral diffusive operator is written in flux form.
+\item [No increase of tracer variance] The iso-neutral diffusion does not increase the tracer variance, \ie
+  \[
+    % \label{eq:TRIADS_iso_property2}
+    \sum_{i,j,k} \left\{ T \ D_l^T      \ b_T \right\} \leq 0
+  \]
+  The property is demonstrated in \autoref{subsec:TRIADS_variance} above.
+  It is a key property for a diffusion term.
+  It means that it is also a dissipation term,
+  \ie\ it dissipates the square of the quantity on which it is applied.
+  It therefore ensures that, when the diffusivity coefficient is large enough,
+  the field on which it is applied becomes free of grid-point noise.
+\item [Self-adjoint operator] The iso-neutral diffusion operator is self-adjoint, \ie
+  \begin{equation}
+    \label{eq:TRIADS_iso_property3}
+    \sum_{i,j,k} \left\{ S \ D_l^T \ b_T \right\} = \sum_{i,j,k} \left\{ D_l^S \ T \ b_T \right\}
+  \end{equation}
+  In other word, there is no need to develop a specific routine from the adjoint of this operator.
+  We just have to apply the same routine.
+  This property can be demonstrated similarly to the proof of the `no increase of tracer variance' property.
+  The contribution by a single triad towards the left hand side of \autoref{eq:TRIADS_iso_property3},
+  can be found by replacing $\delta[T]$ by $\delta[S]$ in \autoref{eq:TRIADS_dvar_iso_i} and \autoref{eq:TRIADS_dvar_iso_k}.
+  This results in a term similar to \autoref{eq:TRIADS_perfect-square},
+  \[
+    % \label{eq:TRIADS_TScovar}
+    - {A}_i^k{\:} _i^k\mathbb{V}_{i_p}^{k_p}
+    \left(
+      \frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
+      -{\:}_i^k\mathbb{R}_{i_p}^{k_p}
+      \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
+    \right)
+    \left(
+      \frac{ \delta_{i+ i_p}[S^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }
+      -{\:}_i^k\mathbb{R}_{i_p}^{k_p}
+      \frac{ \delta_{k+k_p} [S^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }
+    \right).
+  \]
+This is symmetrical in $T $ and $S$, so exactly the same term arises from
+the discretization of this triad's contribution towards the RHS of \autoref{eq:TRIADS_iso_property3}.
+\end{description}
+
+%% =================================================================================================
+\subsection{Treatment of the triads at the boundaries}
+\label{sec:TRIADS_iso_bdry}
+
+The triad slope can only be defined where both the grid boxes centred at the end of the arms exist.
+Triads that would poke up through the upper ocean surface into the atmosphere,
+or down into the ocean floor, must be masked out.
+See \autoref{fig:TRIADS_bdry_triads}.
+Surface layer triads \triad{i}{1}{R}{1/2}{-1/2} (magenta) and \triad{i+1}{1}{R}{-1/2}{-1/2} (blue) that
+require density to be specified above the ocean surface are masked (\autoref{fig:TRIADS_bdry_triads}a):
+this ensures that lateral tracer gradients produce no flux through the ocean surface.
+However, to prevent surface noise, it is customary to retain the $_{11}$ contributions towards
+the lateral triad fluxes \triad[u]{i}{1}{F}{1/2}{-1/2} and \triad[u]{i+1}{1}{F}{-1/2}{-1/2};
+this drives diapycnal tracer fluxes.
+Similar comments apply to triads that would intersect the ocean floor (\autoref{fig:TRIADS_bdry_triads}b).
+Note that both near bottom triad slopes \triad{i}{k}{R}{1/2}{1/2} and \triad{i+1}{k}{R}{-1/2}{1/2} are masked when
+either of the $i,k+1$ or $i+1,k+1$ tracer points is masked, \ie\ the $i,k+1$ $u$-point is masked.
+The associated lateral fluxes (grey-black dashed line) are masked if \np[=.false.]{ln_botmix_triad}{ln\_botmix\_triad},
+but left unmasked, giving bottom mixing, if \np[=.true.]{ln_botmix_triad}{ln\_botmix\_triad}.
+
+The default option \np[=.false.]{ln_botmix_triad}{ln\_botmix\_triad} is suitable when the bbl mixing option is enabled
+(\np[=.true.]{ln_trabbl}{ln\_trabbl}, with \np[=1]{nn_bbl_ldf}{nn\_bbl\_ldf}), or for simple idealized problems.
+For setups with topography without bbl mixing, \np[=.true.]{ln_botmix_triad}{ln\_botmix\_triad} may be necessary.
+\begin{figure}[h]
+  \centering
+  \includegraphics[width=0.66\textwidth]{TRIADS_GRIFF_bdry_triads}
+  \caption[Boundary triads]{
+    (a) Uppermost model layer $k=1$ with $i,1$ and $i+1,1$ tracer points (black dots),
+    and $i+1/2,1$ $u$-point (blue square).
+    Triad slopes \triad{i}{1}{R}{1/2}{-1/2} (magenta) and
+    \triad{i+1}{1}{R}{-1/2}{-1/2} (blue) poking through the ocean surface are masked
+    (faded in figure).
+    However,
+    the lateral $_{11}$ contributions towards \triad[u]{i}{1}{F}{1/2}{-1/2} and
+    \triad[u]{i+1}{1}{F}{-1/2}{-1/2} (yellow line) are still applied,
+    giving diapycnal diffusive fluxes.
+    \newline
+    (b) Both near bottom triad slopes \triad{i}{k}{R}{1/2}{1/2} and
+    \triad{i+1}{k}{R}{-1/2}{1/2} are masked when
+    either of the $i,k+1$ or $i+1,k+1$ tracer points is masked,
+    \ie\ the $i,k+1$ $u$-point is masked.
+    The associated lateral fluxes (grey-black dashed line) are masked if
+    \protect\np[=.false.]{ln_botmix_triad}{ln\_botmix\_triad}, but left unmasked,
+    giving bottom mixing, if \protect\np[=.true.]{ln_botmix_triad}{ln\_botmix\_triad}}
+  \label{fig:TRIADS_bdry_triads}
+\end{figure}
+
+%% =================================================================================================
+\subsection{ Limiting of the slopes within the interior}
+\label{sec:TRIADS_limit}
+
+As discussed in \autoref{subsec:LDF_slp_iso},
+iso-neutral slopes relative to geopotentials must be bounded everywhere,
+both for consistency with the small-slope approximation and for numerical stability \citep{cox_OM87, griffies_bk04}.
+The bound chosen in \NEMO\ is applied to each component of the slope separately and
+has a value of $1/100$ in the ocean interior.
+%, ramping linearly down above 70~m depth to zero at the surface
+It is of course relevant to the iso-neutral slopes $\tilde{r}_i=r_i+\sigma_i$ relative to geopotentials
+(here the $\sigma_i$ are the slopes of the coordinate surfaces relative to geopotentials)
+\autoref{eq:MB_slopes_eiv} rather than the slope $r_i$ relative to coordinate surfaces, so we require
+\[
+  |\tilde{r}_i|\leq \tilde{r}_\mathrm{max}=0.01.
+\]
+and then recalculate the slopes $r_i$ relative to coordinates.
+Each individual triad slope
+\begin{equation}
+  \label{eq:TRIADS_Rtilde}
+  _i^k\tilde{\mathbb{R}}_{i_p}^{k_p} = {}_i^k\mathbb{R}_{i_p}^{k_p}  + \frac{\delta_{i+i_p}[z_T^k]}{{e_{1u}}_{\,i + i_p}^{\,k}}
+\end{equation}
+is limited like this and then the corresponding $_i^k\mathbb{R}_{i_p}^{k_p} $ are recalculated and
+combined to form the fluxes.
+Note that where the slopes have been limited, there is now a non-zero iso-neutral density flux that
+drives dianeutral mixing.
+In particular this iso-neutral density flux is always downwards,
+and so acts to reduce gravitational potential energy.
+
+%% =================================================================================================
+\subsection{Tapering within the surface mixed layer}
+\label{sec:TRIADS_taper}
+
+Additional tapering of the iso-neutral fluxes is necessary within the surface mixed layer.
+When the Griffies triads are used, we offer two options for this.
+
+%% =================================================================================================
+\subsubsection{Linear slope tapering within the surface mixed layer}
+\label{sec:TRIADS_lintaper}
+
+This is the option activated by the default choice \np[=.false.]{ln_triad_iso}{ln\_triad\_iso}.
+Slopes $\tilde{r}_i$ relative to geopotentials are tapered linearly from their value immediately below
+the mixed layer to zero at the surface, as described in option (c) of \autoref{fig:LDF_eiv_slp}, to values
+\begin{equation}
+  \label{eq:TRIADS_rmtilde}
+  \rMLt = -\frac{z}{h}\left.\tilde{r}_i\right|_{z=-h}\quad \text{ for  } z>-h,
+\end{equation}
+and then the $r_i$ relative to vertical coordinate surfaces are appropriately adjusted to
+\[
+  % \label{eq:TRIADS_rm}
+  \rML =\rMLt -\sigma_i \quad \text{ for  } z>-h.
+\]
+Thus the diffusion operator within the mixed layer is given by:
+\[
+  % \label{eq:TRIADS_iso_tensor_ML}
+  D^{lT}=\nabla {\mathrm {\mathbf .}}\left( {A^{lT}\;\Re \;\nabla T} \right) \qquad
+  \mbox{with}\quad \;\;\Re =\left( {{
+        \begin{array}{*{20}c}
+          1 \hfill & 0 \hfill & {-\rML[1]}\hfill \\
+          0 \hfill & 1 \hfill & {-\rML[2]} \hfill \\
+          {-\rML[1]}\hfill &   {-\rML[2]} \hfill & {\rML[1]^2+\rML[2]^2} \hfill
+        \end{array}
+      }} \right)
+\]
+
+This slope tapering gives a natural connection between tracer in the mixed-layer and
+in isopycnal layers immediately below, in the thermocline.
+It is consistent with the way the $\tilde{r}_i$ are tapered within the mixed layer
+(see \autoref{sec:TRIADS_taperskew} below) so as to ensure a uniform GM eddy-induced velocity throughout the mixed layer.
+However, it gives a downwards density flux and so acts so as to reduce potential energy in the same way as
+does the slope limiting discussed above in \autoref{sec:TRIADS_limit}.
+
+As in \autoref{sec:TRIADS_limit} above, the tapering \autoref{eq:TRIADS_rmtilde} is applied separately to
+each triad $_i^k\tilde{\mathbb{R}}_{i_p}^{k_p}$, and the $_i^k\mathbb{R}_{i_p}^{k_p}$ adjusted.
+For clarity, we assume $z$-coordinates in the following;
+the conversion from $\mathbb{R}$ to $\tilde{\mathbb{R}}$ and back to $\mathbb{R}$ follows exactly as
+described above by \autoref{eq:TRIADS_Rtilde}.
+\begin{enumerate}
+\item Mixed-layer depth is defined so as to avoid including regions of weak vertical stratification in
+  the slope definition.
+  At each $i,j$ (simplified to $i$ in \autoref{fig:TRIADS_MLB_triad}),
+  we define the mixed-layer by setting the vertical index of the tracer point immediately below the mixed layer,
+  $k_{\mathrm{ML}}$, as the maximum $k$ (shallowest tracer point) such that
+  the potential density ${\rho_0}_{i,k}>{\rho_0}_{i,k_{10}}+\Delta\rho_c$,
+  where $i,k_{10}$ is the tracer gridbox within which the depth reaches 10~m.
+  See the left side of \autoref{fig:TRIADS_MLB_triad}.
+  We use the $k_{10}$-gridbox instead of the surface gridbox to avoid problems \eg\ with thin daytime mixed-layers.
+  Currently we use the same $\Delta\rho_c=0.01\;\mathrm{kg\:m^{-3}}$ for ML triad tapering as is used to
+  output the diagnosed mixed-layer depth $h_{\mathrm{ML}}=|z_{W}|_{k_{\mathrm{ML}}+1/2}$,
+  the depth of the $w$-point above the $i,k_{\mathrm{ML}}$ tracer point.
+\item We define `basal' triad slopes ${\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p}$ as
+  the slopes of those triads whose vertical `arms' go down from the $i,k_{\mathrm{ML}}$ tracer point to
+  the $i,k_{\mathrm{ML}}-1$ tracer point below.
+  This is to ensure that the vertical density gradients associated with
+  these basal triad slopes ${\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p}$ are representative of the thermocline.
+  The four basal triads defined in the bottom part of \autoref{fig:TRIADS_MLB_triad} are then
+  \begin{align*}
+    {\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p} &=
+                                                       {\:}^{k_{\mathrm{ML}}-k_p-1/2}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p},
+                                                       % \label{eq:TRIADS_Rbase}
+    \\
+    \intertext{with \eg\ the green triad}
+    {\:}_i{\mathbb{R}_{\mathrm{base}}}_{1/2}^{-1/2}&=
+                                                     {\:}^{k_{\mathrm{ML}}}_i{\mathbb{R}_{\mathrm{base}}}_{\,1/2}^{-1/2}.
+  \end{align*}
+The vertical flux associated with each of these triads passes through
+the $w$-point $i,k_{\mathrm{ML}}-1/2$ lying \emph{below} the $i,k_{\mathrm{ML}}$ tracer point, so it is this depth
+\[
+  % \label{eq:TRIADS_zbase}
+  {z_\mathrm{base}}_{\,i}={z_{w}}_{k_\mathrm{ML}-1/2}
+\]
+one gridbox deeper than the diagnosed ML depth $z_{\mathrm{ML}})$ that sets the $h$ used to taper the slopes in
+\autoref{eq:TRIADS_rmtilde}.
+\item Finally, we calculate the adjusted triads ${\:}_i^k{\mathbb{R}_{\mathrm{ML}}}_{\,i_p}^{k_p}$ within
+  the mixed layer, by multiplying the appropriate ${\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p}$ by
+  the ratio of the depth of the $w$-point ${z_w}_{k+k_p}$ to ${z_{\mathrm{base}}}_{\,i}$.
+  For instance the green triad centred on $i,k$
+  \begin{align*}
+    {\:}_i^k{\mathbb{R}_{\mathrm{ML}}}_{\,1/2}^{-1/2} &=
+                                                        \frac{{z_w}_{k-1/2}}{{z_{\mathrm{base}}}_{\,i}}{\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,1/2}^{-1/2} \\
+    \intertext{and more generally}
+    {\:}_i^k{\mathbb{R}_{\mathrm{ML}}}_{\,i_p}^{k_p} &=
+                                                       \frac{{z_w}_{k+k_p}}{{z_{\mathrm{base}}}_{\,i}}{\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p}.
+                                                       % \label{eq:TRIADS_RML}
+  \end{align*}
+\end{enumerate}
+
+\begin{figure}[h]
+  \centering
+  \includegraphics[width=0.66\textwidth]{TRIADS_GRIFF_MLB_triads}
+  \caption[Definition of mixed-layer depth and calculation of linearly tapered triads]{
+    Definition of mixed-layer depth and calculation of linearly tapered triads.
+    The figure shows a water column at a given $i,j$ (simplified to $i$),
+    with the ocean surface at the top.
+    Tracer points are denoted by bullets, and black lines the edges of the tracer cells;
+    $k$ increases upwards.
+    \newline
+    We define the mixed-layer by setting the vertical index of the tracer point immediately below
+    the mixed layer, $k_{\mathrm{ML}}$, as the maximum $k$ (shallowest tracer point) such that
+    ${\rho_0}_{i,k}>{\rho_0}_{i,k_{10}}+\Delta\rho_c$,
+    where $i,k_{10}$ is the tracer gridbox within which the depth reaches 10~m.
+    We calculate the triad slopes within the mixed layer by linearly tapering them from zero
+    (at the surface) to the `basal' slopes,
+    the slopes of the four triads passing through the $w$-point $i,k_{\mathrm{ML}}-1/2$ (blue square),
+    ${\:}_i{\mathbb{R}_{\mathrm{base}}}_{\,i_p}^{k_p}$.
+    Triads with different $i_p,k_p$, denoted by different colours,
+    (\eg\ the green triad $i_p=1/2,k_p=-1/2$) are tapered to the appropriate basal triad.}
+  \label{fig:TRIADS_MLB_triad}
+\end{figure}
+
+%% =================================================================================================
+\subsubsection{Additional truncation of skew iso-neutral flux components}
+\label{subsec:TRIADS_Gerdes-taper}
+
+The alternative option is activated by setting \np{ln_triad_iso}{ln\_triad\_iso} = true.
+This retains the same tapered slope $\rML$  described above for the calculation of the $_{33}$ term of
+the iso-neutral diffusion tensor (the vertical tracer flux driven by vertical tracer gradients),
+but replaces the $\rML$ in the skew term by
+\begin{equation}
+  \label{eq:TRIADS_rm*}
+  \rML^*=\left.\rMLt^2\right/\tilde{r}_i-\sigma_i,
+\end{equation}
+giving a ML diffusive operator
+\[
+  % \label{eq:TRIADS_iso_tensor_ML2}
+  D^{lT}=\nabla {\mathrm {\mathbf .}}\left( {A^{lT}\;\Re \;\nabla T} \right) \qquad
+  \mbox{with}\quad \;\;\Re =\left( {{
+        \begin{array}{*{20}c}
+          1 \hfill & 0 \hfill & {-\rML[1]^*}\hfill \\
+          0 \hfill & 1 \hfill & {-\rML[2]^*} \hfill \\
+          {-\rML[1]^*}\hfill &   {-\rML[2]^*} \hfill & {\rML[1]^2+\rML[2]^2} \hfill \\
+        \end{array}
+      }} \right).
+\]
+This operator
+\footnote{
+  To ensure good behaviour where horizontal density gradients are weak,
+  we in fact follow \citet{gerdes.koberle.ea_CD91} and
+  set $\rML^*=\mathrm{sgn}(\tilde{r}_i)\min(|\rMLt^2/\tilde{r}_i|,|\tilde{r}_i|)-\sigma_i$.
+}
+then has the property it gives no vertical density flux, and so does not change the potential energy.
+This approach is similar to multiplying the iso-neutral diffusion coefficient by
+$\tilde{r}_{\mathrm{max}}^{-2}\tilde{r}_i^{-2}$ for steep slopes,
+as suggested by \citet{gerdes.koberle.ea_CD91} (see also \citet{griffies_bk04}).
+Again it is applied separately to each triad $_i^k\mathbb{R}_{i_p}^{k_p}$
+
+In practice, this approach gives weak vertical tracer fluxes through the mixed-layer,
+as well as vanishing density fluxes.
+While it is theoretically advantageous that it does not change the potential energy,
+it may give a discontinuity between the fluxes within the mixed-layer (purely horizontal) and
+just below (along iso-neutral surfaces).
+% This may give strange looking results,
+% particularly where the mixed-layer depth varies strongly laterally.
+%% =================================================================================================
+\section{Eddy induced advection formulated as a skew flux}
+\label{sec:TRIADS_skew-flux}
+
+%% =================================================================================================
+\subsection{Continuous skew flux formulation}
+\label{sec:TRIADS_continuous-skew-flux}
+
+When Gent and McWilliams's [1990] diffusion is used, an additional advection term is added.
+The associated velocity is the so called eddy induced velocity,
+the formulation of which depends on the slopes of iso-neutral surfaces.
+Contrary to the case of iso-neutral mixing, the slopes used here are referenced to the geopotential surfaces,
+\ie\ \autoref{eq:LDF_slp_geo} is used in $z$-coordinate,
+and the sum \autoref{eq:LDF_slp_geo} + \autoref{eq:LDF_slp_iso} in $z^*$ or $s$-coordinates.
+
+The eddy induced velocity is given by:
+\begin{subequations}
+  % \label{eq:TRIADS_eiv}
+  \begin{equation}
+    \label{eq:TRIADS_eiv_v}
+    \begin{split}
+      u^* & = - \frac{1}{e_{3}}\;          \partial_i\psi_1,  \\
+      v^* & = - \frac{1}{e_{3}}\;          \partial_j\psi_2,    \\
+      w^* & =    \frac{1}{e_{1}e_{2}}\; \left\{ \partial_i  \left( e_{2} \, \psi_1\right)
+        + \partial_j  \left( e_{1} \, \psi_2\right) \right\},
+    \end{split}
+  \end{equation}
+  where the streamfunctions $\psi_i$ are given by
+  \begin{equation}
+    \label{eq:TRIADS_eiv_psi}
+    \begin{split}
+      \psi_1 & = A_{e} \; \tilde{r}_1,   \\
+      \psi_2 & = A_{e} \; \tilde{r}_2,
+    \end{split}
+  \end{equation}
+\end{subequations}
+with $A_{e}$ the eddy induced velocity coefficient,
+and $\tilde{r}_1$ and $\tilde{r}_2$ the slopes between the iso-neutral and the geopotential surfaces.
+
+The traditional way to implement this additional advection is to add it to the Eulerian velocity prior to
+computing the tracer advection.
+This is implemented if \texttt{traldf\_eiv?} is set in the default implementation,
+where \np{ln_traldf_triad}{ln\_traldf\_triad} is set false.
+This allows us to take advantage of all the advection schemes offered for the tracers
+(see \autoref{sec:TRA_adv}) and not just a $2^{nd}$ order advection scheme.
+This is particularly useful for passive tracers where
+\emph{positivity} of the advection scheme is of paramount importance.
+
+However, when \np{ln_traldf_triad}{ln\_traldf\_triad} is set true,
+\NEMO\ instead implements eddy induced advection according to the so-called skew form \citep{griffies_JPO98}.
+It is based on a transformation of the advective fluxes using the non-divergent nature of the eddy induced velocity.
+For example in the (\textbf{i},\textbf{k}) plane,
+the tracer advective fluxes per unit area in $ijk$ space can be transformed as follows:
+\begin{flalign*}
+  \begin{split}
+    \textbf{F}_{\mathrm{eiv}}^T =
+    \begin{pmatrix}
+      {e_{2}\,e_{3}\;  u^*} \\
+ 		{e_{1}\,e_{2}\; w^*}
+    \end{pmatrix}   \;   T
+    &=
+    \begin{pmatrix}
+      { - \partial_k \left( e_{2} \,\psi_1 \right) \; T \;} \\
+ 		{+ \partial_i  \left( e_{2} \, \psi_1 \right) \; T \;}
+    \end{pmatrix} 			\\
+    &=
+    \begin{pmatrix}
+      { - \partial_k \left( e_{2} \, \psi_1  \; T \right) \;} \\
+ 		{+ \partial_i  \left( e_{2} \,\psi_1 \; T \right) \;}
+    \end{pmatrix}
+    +
+    \begin{pmatrix}
+      {+ e_{2} \, \psi_1  \; \partial_k T} \\
+ 		{ - e_{2} \, \psi_1  \; \partial_i  T}
+    \end{pmatrix}
+  \end{split}
+\end{flalign*}
+and since the eddy induced velocity field is non-divergent,
+we end up with the skew form of the eddy induced advective fluxes per unit area in $ijk$ space:
+\begin{equation}
+  \label{eq:TRIADS_eiv_skew_ijk}
+  \textbf{F}_\mathrm{eiv}^T =
+  \begin{pmatrix}
+    {+ e_{2} \, \psi_1  \; \partial_k T}   \\
+    { - e_{2} \, \psi_1  \; \partial_i  T}
+  \end{pmatrix}
+\end{equation}
+The total fluxes per unit physical area are then
+\begin{equation}
+  \label{eq:TRIADS_eiv_skew_physical}
+  \begin{split}
+    f^*_1 & = \frac{1}{e_{3}}\; \psi_1 \partial_k T   \\
+    f^*_2 & = \frac{1}{e_{3}}\; \psi_2 \partial_k T   \\
+    f^*_3 & =  -\frac{1}{e_{1}e_{2}}\; \left\{ e_{2} \psi_1 \partial_i T + e_{1} \psi_2 \partial_j T \right\}.
+\end{split}
+\end{equation}
+Note that \autoref{eq:TRIADS_eiv_skew_physical} takes the same form whatever the vertical coordinate,
+though of course the slopes $\tilde{r}_i$ which define the $\psi_i$ in \autoref{eq:TRIADS_eiv_psi} are relative to
+geopotentials.
+The tendency associated with eddy induced velocity is then simply the convergence of the fluxes
+(\autoref{eq:TRIADS_eiv_skew_ijk}, \autoref{eq:TRIADS_eiv_skew_physical}), so
+\[
+  % \label{eq:TRIADS_skew_eiv_conv}
+  \frac{\partial T}{\partial t}= -\frac{1}{e_1 \, e_2 \, e_3 }      \left[
+    \frac{\partial}{\partial i} \left( e_2 \psi_1 \partial_k T\right)
+    + \frac{\partial}{\partial j} \left( e_1  \;
+      \psi_2 \partial_k T\right)
+    -  \frac{\partial}{\partial k} \left( e_{2} \psi_1 \partial_i T
+      + e_{1} \psi_2 \partial_j T \right)  \right]
+\]
+It naturally conserves the tracer content, as it is expressed in flux form.
+Since it has the same divergence as the advective form it also preserves the tracer variance.
+
+%% =================================================================================================
+\subsection{Discrete skew flux formulation}
+
+The skew fluxes in (\autoref{eq:TRIADS_eiv_skew_physical}, \autoref{eq:TRIADS_eiv_skew_ijk}),
+like the off-diagonal terms (\autoref{eq:TRIADS_i13c}, \autoref{eq:TRIADS_i31c}) of the small angle diffusion tensor,
+are best expressed in terms of the triad slopes, as in \autoref{fig:TRIADS_ISO_triad} and
+(\autoref{eq:TRIADS_i13}, \autoref{eq:TRIADS_i31});
+but now in terms of the triad slopes $\tilde{\mathbb{R}}$ relative to geopotentials instead of
+the $\mathbb{R}$ relative to coordinate surfaces.
+The discrete form of \autoref{eq:TRIADS_eiv_skew_ijk} using the slopes \autoref{eq:TRIADS_R} and
+defining $A_e$ at $T$-points is then given by:
+
+\begin{subequations}
+  % \label{eq:TRIADS_allskewflux}
+  \begin{flalign*}
+    % \label{eq:TRIADS_vect_skew_flux}
+    \vect{F}_{\mathrm{eiv}}(T) &\equiv    \sum_{\substack{i_p,\,k_p}}
+    \begin{pmatrix}
+      {_{i+1/2-i_p}^k {\mathbb{S}_u}_{i_p}^{k_p} } (T)      \\      \\
+      {_i^{k+1/2-k_p} {\mathbb{S}_w}_{i_p}^{k_p} } (T)      \\
+    \end{pmatrix},
+  \end{flalign*}
+  where the skew flux in the $i$-direction associated with a given triad is (\autoref{eq:TRIADS_latflux-triad},
+  \autoref{eq:TRIADS_triadfluxu}):
+  \begin{align}
+    \label{eq:TRIADS_skewfluxu}
+    _i^k {\mathbb{S}_u}_{i_p}^{k_p} (T) &= + \fractext{1}{4} {A_e}_i^k{
+                                          \:}\frac{{b_u}_{i+i_p}^k}{{e_{1u}}_{\,i + i_p}^{\,k}}
+                                          \ {_i^k\tilde{\mathbb{R}}_{i_p}^{k_p}} \
+                                          \frac{ \delta_{k+k_p} [T^i] }{{e_{3w}}_{\,i}^{\,k+k_p} }, \\
+    \intertext{
+    and \autoref{eq:TRIADS_triadfluxw} in the $k$-direction, changing the sign
+    to be consistent with \autoref{eq:TRIADS_eiv_skew_ijk}:
+    }
+    _i^k {\mathbb{S}_w}_{i_p}^{k_p} (T)
+                                        &= -\fractext{1}{4} {A_e}_i^k{\: }\frac{{b_u}_{i+i_p}^k}{{e_{3w}}_{\,i}^{\,k+k_p}}
+                                          {_i^k\tilde{\mathbb{R}}_{i_p}^{k_p}}\frac{ \delta_{i+ i_p}[T^k] }{ {e_{1u}}_{\,i + i_p}^{\,k} }.\label{eq:TRIADS_skewfluxw}
+  \end{align}
+\end{subequations}
+
+Such a discretisation is consistent with the iso-neutral operator as it uses the same definition for the slopes.
+It also ensures the following two key properties.
+
+%% =================================================================================================
+\subsubsection{No change in tracer variance}
+
+The discretization conserves tracer variance, \ie\ it does not include a diffusive component but is a `pure' advection term.
+This can be seen %either from Appendix \autoref{apdx:eiv_skew} or
+by considering the fluxes associated with a given triad slope $_i^k{\mathbb{R}}_{i_p}^{k_p} (T)$.
+For, following \autoref{subsec:TRIADS_variance} and \autoref{eq:TRIADS_dvar_iso_i},
+the associated horizontal skew-flux $_i^k{\mathbb{S}_u}_{i_p}^{k_p} (T)$ drives a net rate of change of variance,
+summed over the two $T$-points $i+i_p-\fractext{1}{2},k$ and $i+i_p+\fractext{1}{2},k$, of
+\begin{equation}
+  \label{eq:TRIADS_dvar_eiv_i}
+  _i^k{\mathbb{S}_u}_{i_p}^{k_p} (T)\,\delta_{i+ i_p}[T^k],
+\end{equation}
+while the associated vertical skew-flux gives a variance change summed over
+the $T$-points $i,k+k_p-\fractext{1}{2}$ (above) and $i,k+k_p+\fractext{1}{2}$ (below) of
+\begin{equation}
+  \label{eq:TRIADS_dvar_eiv_k}
+  _i^k{\mathbb{S}_w}_{i_p}^{k_p} (T) \,\delta_{k+ k_p}[T^i].
+\end{equation}
+Inspection of the definitions (\autoref{eq:TRIADS_skewfluxu}, \autoref{eq:TRIADS_skewfluxw}) shows that
+these two variance changes (\autoref{eq:TRIADS_dvar_eiv_i}, \autoref{eq:TRIADS_dvar_eiv_k}) sum to zero.
+Hence the two fluxes associated with each triad make no net contribution to the variance budget.
+
+%% =================================================================================================
+\subsubsection{Reduction in gravitational PE}
+
+The vertical density flux associated with the vertical skew-flux always has the same sign as
+the vertical density gradient;
+thus, so long as the fluid is stable (the vertical density gradient is negative)
+the vertical density flux is negative (downward) and hence reduces the gravitational PE.
+
+For the change in gravitational PE driven by the $k$-flux is
+\begin{align}
+  \label{eq:TRIADS_vert_densityPE}
+  g {e_{3w}}_{\,i}^{\,k+k_p}{\mathbb{S}_w}_{i_p}^{k_p} (\rho)
+  &=g {e_{3w}}_{\,i}^{\,k+k_p}\left[-\alpha _i^k {\:}_i^k
+    {\mathbb{S}_w}_{i_p}^{k_p} (T) + \beta_i^k {\:}_i^k
+    {\mathbb{S}_w}_{i_p}^{k_p} (S) \right]. \notag \\
+  \intertext{Substituting  ${\:}_i^k {\mathbb{S}_w}_{i_p}^{k_p}$ from \autoref{eq:TRIADS_skewfluxw}, gives}
+  % and separating out
+  % $\rtriadt{R}=\rtriad{R} + \delta_{i+i_p}[z_T^k]$,
+  % gives two terms. The
+  % first $\rtriad{R}$ term (the only term for $z$-coordinates) is:
+  &=-\fractext{1}{4} g{A_e}_i^k{\: }{b_u}_{i+i_p}^k {_i^k\tilde{\mathbb{R}}_{i_p}^{k_p}}
+    \frac{ -\alpha _i^k\delta_{i+ i_p}[T^k]+ \beta_i^k\delta_{i+ i_p}[S^k]} { {e_{1u}}_{\,i + i_p}^{\,k} } \notag \\
+  &=+\fractext{1}{4} g{A_e}_i^k{\: }{b_u}_{i+i_p}^k
+    \left({_i^k\mathbb{R}_{i_p}^{k_p}}+\frac{\delta_{i+i_p}[z_T^k]}{{e_{1u}}_{\,i + i_p}^{\,k}}\right) {_i^k\mathbb{R}_{i_p}^{k_p}}
+    \frac{-\alpha_i^k \delta_{k+ k_p}[T^i]+ \beta_i^k\delta_{k+ k_p}[S^i]} {{e_{3w}}_{\,i}^{\,k+k_p}},
+\end{align}
+using the definition of the triad slope $\rtriad{R}$, \autoref{eq:TRIADS_R} to
+express $-\alpha _i^k\delta_{i+ i_p}[T^k]+\beta_i^k\delta_{i+ i_p}[S^k]$ in terms of
+$-\alpha_i^k \delta_{k+ k_p}[T^i]+ \beta_i^k\delta_{k+ k_p}[S^i]$.
+
+Where the coordinates slope, the $i$-flux gives a PE change
+\begin{multline}
+  \label{eq:TRIADS_lat_densityPE}
+  g \delta_{i+i_p}[z_T^k]
+  \left[
+    -\alpha _i^k {\:}_i^k {\mathbb{S}_u}_{i_p}^{k_p} (T) + \beta_i^k {\:}_i^k {\mathbb{S}_u}_{i_p}^{k_p} (S)
+  \right] \\
+  = +\fractext{1}{4} g{A_e}_i^k{\: }{b_u}_{i+i_p}^k
+  \frac{\delta_{i+i_p}[z_T^k]}{{e_{1u}}_{\,i + i_p}^{\,k}}
+  \left({_i^k\mathbb{R}_{i_p}^{k_p}}+\frac{\delta_{i+i_p}[z_T^k]}{{e_{1u}}_{\,i + i_p}^{\,k}}\right)
+  \frac{-\alpha_i^k \delta_{k+ k_p}[T^i]+ \beta_i^k\delta_{k+ k_p}[S^i]} {{e_{3w}}_{\,i}^{\,k+k_p}},
+\end{multline}
+(using \autoref{eq:TRIADS_skewfluxu}) and so the total PE change \autoref{eq:TRIADS_vert_densityPE} +
+\autoref{eq:TRIADS_lat_densityPE} associated with the triad fluxes is
+\begin{multline*}
+  % \label{eq:TRIADS_tot_densityPE}
+  g{e_{3w}}_{\,i}^{\,k+k_p}{\mathbb{S}_w}_{i_p}^{k_p} (\rho) +
+  g\delta_{i+i_p}[z_T^k] {\:}_i^k {\mathbb{S}_u}_{i_p}^{k_p} (\rho) \\
+  = +\fractext{1}{4} g{A_e}_i^k{\: }{b_u}_{i+i_p}^k
+  \left({_i^k\mathbb{R}_{i_p}^{k_p}}+\frac{\delta_{i+i_p}[z_T^k]}{{e_{1u}}_{\,i + i_p}^{\,k}}\right)^2
+  \frac{-\alpha_i^k \delta_{k+ k_p}[T^i]+ \beta_i^k\delta_{k+ k_p}[S^i]} {{e_{3w}}_{\,i}^{\,k+k_p}}.
+\end{multline*}
+Where the fluid is stable, with $-\alpha_i^k \delta_{k+ k_p}[T^i]+
+\beta_i^k\delta_{k+ k_p}[S^i]<0$, this PE change is negative.
+
+%% =================================================================================================
+\subsection{Treatment of the triads at the boundaries}
+\label{sec:TRIADS_skew_bdry}
+
+Triad slopes \rtriadt{R} used for the calculation of the eddy-induced skew-fluxes are masked at the boundaries
+in exactly the same way as are the triad slopes \rtriad{R} used for the iso-neutral diffusive fluxes,
+as described in \autoref{sec:TRIADS_iso_bdry} and \autoref{fig:TRIADS_bdry_triads}.
+Thus surface layer triads $\triadt{i}{1}{R}{1/2}{-1/2}$ and $\triadt{i+1}{1}{R}{-1/2}{-1/2}$ are masked,
+and both near bottom triad slopes $\triadt{i}{k}{R}{1/2}{1/2}$ and $\triadt{i+1}{k}{R}{-1/2}{1/2}$ are masked when
+either of the $i,k+1$ or $i+1,k+1$ tracer points is masked, \ie\ the $i,k+1$ $u$-point is masked.
+The namelist parameter \np{ln_botmix_triad}{ln\_botmix\_triad} has no effect on the eddy-induced skew-fluxes.
+
+%% =================================================================================================
+\subsection{Limiting of the slopes within the interior}
+\label{sec:TRIADS_limitskew}
+
+Presently, the iso-neutral slopes $\tilde{r}_i$ relative to geopotentials are limited to be less than $1/100$,
+exactly as in calculating the iso-neutral diffusion, \S \autoref{sec:TRIADS_limit}.
+Each individual triad \rtriadt{R} is so limited.
+
+%% =================================================================================================
+\subsection{Tapering within the surface mixed layer}
+\label{sec:TRIADS_taperskew}
+
+The slopes $\tilde{r}_i$ relative to geopotentials (and thus the individual triads \rtriadt{R})
+are always tapered linearly from their value immediately below the mixed layer to zero at the surface
+\autoref{eq:TRIADS_rmtilde}, as described in \autoref{sec:TRIADS_lintaper}.
+This is option (c) of \autoref{fig:LDF_eiv_slp}.
+This linear tapering for the slopes used to calculate the eddy-induced fluxes is unaffected by
+the value of \np{ln_triad_iso}{ln\_triad\_iso}.
+
+The justification for this linear slope tapering is that, for $A_e$ that is constant or varies only in
+the horizontal (the most commonly used options in \NEMO: see \autoref{sec:LDF_coef}),
+it is equivalent to a horizontal eiv (eddy-induced velocity) that is uniform within the mixed layer
+\autoref{eq:TRIADS_eiv_v}.
+This ensures that the eiv velocities do not restratify the mixed layer \citep{treguier.held.ea_JPO97,danabasoglu.ferrari.ea_JC08}.
+Equivantly, in terms of the skew-flux formulation we use here,
+the linear slope tapering within the mixed-layer gives a linearly varying vertical flux,
+and so a tracer convergence uniform in depth
+(the horizontal flux convergence is relatively insignificant within the mixed-layer).
+
+%% =================================================================================================
+\subsection{Streamfunction diagnostics}
+\label{sec:TRIADS_sfdiag}
+
+Where the namelist parameter \np[=.true.]{ln_traldf_gdia}{ln\_traldf\_gdia},
+diagnosed mean eddy-induced velocities are output.
+Each time step, streamfunctions are calculated in the $i$-$k$ and $j$-$k$ planes at
+$uw$ (integer +1/2 $i$, integer $j$, integer +1/2 $k$) and $vw$ (integer $i$, integer +1/2 $j$, integer +1/2 $k$)
+points (see Table \autoref{tab:DOM_cell}) respectively.
+We follow \citep{griffies_bk04} and calculate the streamfunction at a given $uw$-point from
+the surrounding four triads according to:
+\[
+  % \label{eq:TRIADS_sfdiagi}
+  {\psi_1}_{i+1/2}^{k+1/2}={\fractext{1}{4}}\sum_{\substack{i_p,\,k_p}}
+  {A_e}_{i+1/2-i_p}^{k+1/2-k_p}\:\triadd{i+1/2-i_p}{k+1/2-k_p}{R}{i_p}{k_p}.
+\]
+The streamfunction $\psi_1$ is calculated similarly at $vw$ points.
+The eddy-induced velocities are then calculated from the straightforward discretisation of \autoref{eq:TRIADS_eiv_v}:
+\[
+  % \label{eq:TRIADS_eiv_v_discrete}
+  \begin{split}
+    {u^*}_{i+1/2}^{k} & = - \frac{1}{{e_{3u}}_{i}^{k}}\left({\psi_1}_{i+1/2}^{k+1/2}-{\psi_1}_{i+1/2}^{k+1/2}\right),   \\
+    {v^*}_{j+1/2}^{k} & = - \frac{1}{{e_{3v}}_{j}^{k}}\left({\psi_2}_{j+1/2}^{k+1/2}-{\psi_2}_{j+1/2}^{k+1/2}\right),   \\
+    {w^*}_{i,j}^{k+1/2} & =    \frac{1}{e_{1t}e_{2t}}\; \left\{
+      {e_{2u}}_{i+1/2}^{k+1/2} \,{\psi_1}_{i+1/2}^{k+1/2} -
+      {e_{2u}}_{i-1/2}^{k+1/2} \,{\psi_1}_{i-1/2}^{k+1/2} \right. + \\
+    \phantom{=} & \qquad\qquad\left. {e_{2v}}_{j+1/2}^{k+1/2} \,{\psi_2}_{j+1/2}^{k+1/2} - {e_{2v}}_{j-1/2}^{k+1/2} \,{\psi_2}_{j-1/2}^{k+1/2} \right\},
+  \end{split}
+\]
+
+\subinc{\input{../../global/epilogue}}
+
+\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/blocks.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/blocks.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/blocks.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/blocks.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_ASM.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_ASM.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_ASM.tex	(revision 12143)
@@ -2,26 +2,39 @@
 
 \begin{document}
-% ================================================================
-% Chapter Assimilation increments (ASM)
-% ================================================================
+
 \chapter{Apply Assimilation Increments (ASM)}
 \label{chap:ASM}
 
-Authors: D. Lea,  M. Martin, K. Mogensen, A. Weaver, ...   % do we keep
+%    {\em 4.0} & {\em D. J. Lea} & {\em \NEMO\ 4.0 updates}  \\
+%    {\em 3.4} & {\em D. J. Lea, M. Martin, K. Mogensen, A. Weaver} & {\em Initial version}  \\
 
-\minitoc
+\thispagestyle{plain}
 
-\newpage
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
 
 The ASM code adds the functionality to apply increments to the model variables: temperature, salinity,
-sea surface height, velocity and sea ice concentration. 
+sea surface height, velocity and sea ice concentration.
 These are read into the model from a NetCDF file which may be produced by separate data assimilation code.
 The code can also output model background fields which are used as an input to data assimilation code.
-This is all controlled by the namelist \textit{\ngn{nam\_asminc} }.
+This is all controlled by the namelist \nam{_asminc}{\_asminc}.
 There is a brief description of all the namelist options provided.
 To build the ASM code \key{asminc} must be set.
 
-%===============================================================
-
+%% =================================================================================================
 \section{Direct initialization}
 \label{sec:ASM_DI}
@@ -29,6 +42,7 @@
 Direct initialization (DI) refers to the instantaneous correction of the model background state using
 the analysis increment.
-DI is used when \np{ln\_asmdin} is set to true.
+DI is used when \np{ln_asmdin}{ln\_asmdin} is set to true.
 
+%% =================================================================================================
 \section{Incremental analysis updates}
 \label{sec:ASM_IAU}
@@ -39,5 +53,5 @@
 This technique is referred to as Incremental Analysis Updates (IAU) \citep{bloom.takacs.ea_MWR96}.
 IAU is a common technique used with 3D assimilation methods such as 3D-Var or OI.
-IAU is used when \np{ln\_asmiau} is set to true.
+IAU is used when \np{ln_asmiau}{ln\_asmiau} is set to true.
 
 With IAU, the model state trajectory ${\mathbf x}$ in the assimilation window ($t_{0} \leq t_{i} \leq t_{N}$)
@@ -45,5 +59,5 @@
 additional tendency terms to the prognostic equations:
 \begin{align*}
-  % \label{eq:wa_traj_iau}
+  % \label{eq:ASM_wa_traj_iau}
   {\mathbf x}^{a}(t_{i}) = M(t_{i}, t_{0})[{\mathbf x}^{b}(t_{0})] \; + \; F_{i} \delta \tilde{\mathbf x}^{a}
 \end{align*}
@@ -56,7 +70,7 @@
 Typically the increments are spread evenly over the full window.
 In addition, two different weighting functions have been implemented.
-The first function employs constant weights, 
+The first function (namelist option \np{niaufn}{niaufn}=0) employs constant weights,
 \begin{align}
-  \label{eq:F1_i}
+  \label{eq:ASM_F1_i}
   F^{(1)}_{i}
   =\left\{
@@ -66,11 +80,11 @@
     0     &    {\mathrm if} \; \; \; t_{i} > t_{n}
   \end{array}
-            \right. 
+            \right.
 \end{align}
 where $M = m-n$.
-The second function employs peaked hat-like weights in order to give maximum weight in the centre of the sub-window,
+The second function (namelist option \np{niaufn}{niaufn}=1) employs peaked hat-like weights in order to give maximum weight in the centre of the sub-window,
 with the weighting reduced linearly to a small value at the window end-points:
 \begin{align}
-  \label{eq:F2_i}
+  \label{eq:ASM_F2_i}
   F^{(2)}_{i}
   =\left\{
@@ -83,17 +97,19 @@
                                    \right.
 \end{align}
-where $\alpha^{-1} = \sum_{i=1}^{M/2} 2i$ and $M$ is assumed to be even. 
-The weights described by \autoref{eq:F2_i} provide a smoother transition of the analysis trajectory from
-one assimilation cycle to the next than that described by \autoref{eq:F1_i}.
+where $\alpha^{-1} = \sum_{i=1}^{M/2} 2i$ and $M$ is assumed to be even.
+The weights described by \autoref{eq:ASM_F2_i} provide a smoother transition of the analysis trajectory from
+one assimilation cycle to the next than that described by \autoref{eq:ASM_F1_i}.
 
-%==========================================================================
-% Divergence damping description %%%
+%% =================================================================================================
 \section{Divergence damping initialisation}
 \label{sec:ASM_div_dmp}
 
-The velocity increments may be initialized by the iterative application of a divergence damping operator.
-In iteration step $n$ new estimates of velocity increments $u^{n}_I$ and $v^{n}_I$ are updated by:
+It is quite challenging for data assimilation systems to provide non-divergent velocity increments.
+Applying divergent velocity increments will likely cause spurious vertical velocities in the model. This section describes a method to take velocity increments provided to \NEMO\ ($u^0_I$ and $v^0_I$) and adjust them by the iterative application of a divergence damping operator. The method is also described in \citet{dobricic.pinardi.ea_OS07}.
+
+In iteration step $n$ (starting at $n=1$) new estimates of velocity increments $u^{n}_I$ and $v^{n}_I$ are updated by:
+
 \begin{equation}
-  \label{eq:asm_dmp}
+  \label{eq:ASM_dmp}
   \left\{
     \begin{aligned}
@@ -105,12 +121,15 @@
   \right.,
 \end{equation}
-where
+
+where the divergence is defined as
+
 \[
-  % \label{eq:asm_div}
+  % \label{eq:ASM_div}
   \chi^{n-1}_I = \frac{1}{e_{1t}\,e_{2t}\,e_{3t} }
   \left( {\delta_i \left[ {e_{2u}\,e_{3u}\,u^{n-1}_I} \right]
       +\delta_j \left[ {e_{1v}\,e_{3v}\,v^{n-1}_I} \right]} \right).
 \]
-By the application of \autoref{eq:asm_dmp} and \autoref{eq:asm_dmp} the divergence is filtered in each iteration,
+
+By the application of \autoref{eq:ASM_dmp} the divergence is filtered in each iteration,
 and the vorticity is left unchanged.
 In the presence of coastal boundaries with zero velocity increments perpendicular to the coast
@@ -120,22 +139,20 @@
 \citep{talagrand_JAS72, dobricic.pinardi.ea_OS07}.
 Diffusion coefficients are defined as $A_D = \alpha e_{1t} e_{2t}$, where $\alpha = 0.2$.
-The divergence damping is activated by assigning to \np{nn\_divdmp} in the \textit{nam\_asminc} namelist
+The divergence damping is activated by assigning to \np{nn_divdmp}{nn\_divdmp} in the \nam{_asminc}{\_asminc} namelist
 a value greater than zero.
-By choosing this value to be of the order of 100 the increments in
-the vertical velocity will be significantly reduced.
+This specifies the number of iterations of the divergence damping. Setting a value of the order of 100 will result in a significant reduction in the vertical velocity induced by the increments.
 
-
-%==========================================================================
-
+%% =================================================================================================
 \section{Implementation details}
 \label{sec:ASM_details}
 
-Here we show an example \ngn{namasm} namelist and the header of an example assimilation increments file on
+Here we show an example \nam{_asminc}{\_asminc} namelist and the header of an example assimilation increments file on
 the ORCA2 grid.
 
-%------------------------------------------namasm-----------------------------------------------------
-%
-\nlst{nam_asminc}
-%-------------------------------------------------------------------------------------------------------------
+\begin{listing}
+  \nlst{nam_asminc}
+  \caption{\forcode{&nam_asminc}}
+  \label{lst:nam_asminc}
+\end{listing}
 
 The header of an assimilation increments file produced using the NetCDF tool
@@ -177,7 +194,5 @@
 \end{clines}
 
-\biblio
-
-\pindex
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_CONFIG.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_CONFIG.tex	(revision 12062)
+++ 	(revision )
@@ -1,320 +1,0 @@
-\documentclass[../main/NEMO_manual]{subfiles}
-
-\begin{document}
-% ================================================================
-% Chapter Configurations
-% ================================================================
-\chapter{Configurations}
-\label{chap:CFG}
-
-\minitoc
-
-\newpage
-
-% ================================================================
-% Introduction
-% ================================================================
-\section{Introduction}
-\label{sec:CFG_intro}
-
-The purpose of this part of the manual is to introduce the NEMO reference configurations.
-These configurations are offered as means to explore various numerical and physical options,
-thus allowing the user to verify that the code is performing in a manner consistent with that we are running.
-This form of verification is critical as one adopts the code for his or her particular research purposes.
-The reference configurations also provide a sense for some of the options available in the code,
-though by no means are all options exercised in the reference configurations.
-Configuration is defined manually through the \textit{namcfg} namelist variables.
-
-%------------------------------------------namcfg----------------------------------------------------
-
-\nlst{namcfg}
-%-------------------------------------------------------------------------------------------------------------
-
-% ================================================================
-% 1D model configuration
-% ================================================================
-\section[C1D: 1D Water column model (\texttt{\textbf{key\_c1d}})]
-{C1D: 1D Water column model (\protect\key{c1d})}
-\label{sec:CFG_c1d}
-
-The 1D model option simulates a stand alone water column within the 3D NEMO system.
-It can be applied to the ocean alone or to the ocean-ice system and can include passive tracers or a biogeochemical model.
-It is set up by defining the position of the 1D water column in the grid
-(see \textit{cfgs/SHARED/namelist\_ref}). 
-The 1D model is a very useful tool
-\textit{(a)} to learn about the physics and numerical treatment of vertical mixing processes;
-\textit{(b)} to investigate suitable parameterisations of unresolved turbulence
-(surface wave breaking, Langmuir circulation, ...);
-\textit{(c)} to compare the behaviour of different vertical mixing schemes;
-\textit{(d)} to perform sensitivity studies on the vertical diffusion at a particular point of an ocean domain;
-\textit{(d)} to produce extra diagnostics, without the large memory requirement of the full 3D model.
-
-The methodology is based on the configuration of the smallest possible domain:
-a 3x3 domain with 75 vertical levels.
-
-The 1D model has some specifies. First, all the horizontal derivatives are assumed to be zero,
-and second, the two components of the velocity are moved on a $T$-point. 
-Therefore, defining \key{c1d} changes some things in the code behaviour: 
-\begin{description}
-\item[(1)]
-  a simplified \rou{stp} routine is used (\rou{stp\_c1d}, see \mdl{step\_c1d} module) in which
-  both lateral tendancy terms and lateral physics are not called;
-\item[(2)]
-  the vertical velocity is zero
-  (so far, no attempt at introducing a Ekman pumping velocity has been made);
-\item[(3)]
-  a simplified treatment of the Coriolis term is performed as $U$- and $V$-points are the same
-  (see \mdl{dyncor\_c1d}).
-\end{description}
-All the relevant \textit{\_c1d} modules can be found in the src/OCE/C1D directory of
-the NEMO distribution.
-
-% to be added:  a test case on the yearlong Ocean Weather Station (OWS) Papa dataset of Martin (1985)
-
-% ================================================================
-% ORCA family configurations
-% ================================================================
-\section{ORCA family: global ocean with tripolar grid}
-\label{sec:CFG_orca}
-
-The ORCA family is a series of global ocean configurations that are run together with
-the SI3 model (ORCA-ICE) and possibly with PISCES biogeochemical model (ORCA-ICE-PISCES).
-An appropriate namelist is available in \path{cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg} for ORCA2.
-The domain of ORCA2 configuration is defined in \ifile{ORCA\_R2\_zps\_domcfg} file,
-this file is available in tar file on the NEMO community zenodo platform: \\
-https://doi.org/10.5281/zenodo.2640723
-
-In this namelist\_cfg the name of domain input file is set in \ngn{namcfg} block of namelist. 
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_ORCA_NH_mesh}
-    \caption{
-      \protect\label{fig:MISC_ORCA_msh}
-      ORCA mesh conception.
-      The departure from an isotropic Mercator grid start poleward of 20\deg{N}.
-      The two "north pole" are the foci of a series of embedded ellipses (blue curves) which
-      are determined analytically and form the i-lines of the ORCA mesh (pseudo latitudes).
-      Then, following \citet{madec.imbard_CD96}, the normal to the series of ellipses (red curves) is computed which
-      provides the j-lines of the mesh (pseudo longitudes).
-    }
-  \end{center}
-\end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -------------------------------------------------------------------------------------------------------------
-%       ORCA tripolar grid
-% -------------------------------------------------------------------------------------------------------------
-\subsection{ORCA tripolar grid}
-\label{subsec:CFG_orca_grid}
-
-The ORCA grid is a tripolar grid based on the semi-analytical method of \citet{madec.imbard_CD96}.
-It allows to construct a global orthogonal curvilinear ocean mesh which has no singularity point inside
-the computational domain since two north mesh poles are introduced and placed on lands.
-The method involves defining an analytical set of mesh parallels in the stereographic polar plan,
-computing the associated set of mesh meridians, and projecting the resulting mesh onto the sphere.
-The set of mesh parallels used is a series of embedded ellipses which foci are the two mesh north poles
-(\autoref{fig:MISC_ORCA_msh}).
-The resulting mesh presents no loss of continuity in either the mesh lines or the scale factors,
-or even the scale factor derivatives over the whole ocean domain, as the mesh is not a composite mesh. 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!tbp]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_ORCA_NH_msh05_e1_e2}
-    \includegraphics[width=\textwidth]{Fig_ORCA_aniso}
-    \caption {
-      \protect\label{fig:MISC_ORCA_e1e2}
-      \textit{Top}: Horizontal scale factors ($e_1$, $e_2$) and
-      \textit{Bottom}: ratio of anisotropy ($e_1 / e_2$)
-      for ORCA 0.5\deg ~mesh.
-      South of 20\deg{N} a Mercator grid is used ($e_1 = e_2$) so that the anisotropy ratio is 1.
-      Poleward of 20\deg{N}, the two "north pole" introduce a weak anisotropy over the ocean areas ($< 1.2$) except in
-      vicinity of Victoria Island (Canadian Arctic Archipelago).
-    }
-  \end{center}
-\end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-The method is applied to Mercator grid (\ie same zonal and meridional grid spacing) poleward of 20\deg{N},
-so that the Equator is a mesh line, which provides a better numerical solution for equatorial dynamics.
-The choice of the series of embedded ellipses (position of the foci and variation of the ellipses)
-is a compromise between maintaining the ratio of mesh anisotropy ($e_1 / e_2$) close to one in the ocean
-(especially in area of strong eddy activities such as the Gulf Stream) and keeping the smallest scale factor in
-the northern hemisphere larger than the smallest one in the southern hemisphere.
-The resulting mesh is shown in \autoref{fig:MISC_ORCA_msh} and \autoref{fig:MISC_ORCA_e1e2} for
-a half a degree grid (ORCA\_R05).
-The smallest ocean scale factor is found in along Antarctica,
-while the ratio of anisotropy remains close to one except near the Victoria Island in the Canadian Archipelago. 
-
-% -------------------------------------------------------------------------------------------------------------
-%       ORCA-ICE(-PISCES) configurations
-% -------------------------------------------------------------------------------------------------------------
-\subsection{ORCA pre-defined resolution}
-\label{subsec:CFG_orca_resolution}
-
-The NEMO system is provided with five built-in ORCA configurations which differ in the horizontal resolution.
-The value of the resolution is given by the resolution at the Equator expressed in degrees.
-Each of configuration is set through the \textit{domain\_cfg} domain configuration file,
-which sets the grid size and configuration name parameters.
-The NEMO System Team provides only ORCA2 domain input file "\ifile{ORCA\_R2\_zps\_domcfg}" file
-(Tab. \autoref{tab:ORCA}).
-
-%--------------------------------------------------TABLE--------------------------------------------------
-\begin{table}[!t]
-  \begin{center}
-    \begin{tabular}{p{4cm} c c c c}
-      Horizontal Grid         	             & \np{ORCA\_index} &  \np{jpiglo} & \np{jpjglo} &       \\
-      \hline
-      \hline
-      \~4\deg	   &        4         &         92     &      76      &       \\
-      \~2\deg        &        2         &       182     &    149      &        \\
-      \~1\deg        &        1         &       362     &     292     &        \\
-      \~0.5\deg     &        05       &       722     &     511     &        \\
-      \~0.25\deg   &        025     &      1442    &   1021     &        \\
-      % \key{orca\_r8}       &        8         &      2882    &   2042     &        \\
-      % \key{orca\_r12}     &      12         &      4322    &   3062      &       \\
-      \hline
-      \hline
-    \end{tabular}
-    \caption{
-      \protect\label{tab:ORCA}
-      Domain size of ORCA family configurations.
-      The flag for configurations of ORCA family need to be set in \textit{domain\_cfg} file.
-    }
-  \end{center}
-\end{table}
-%--------------------------------------------------------------------------------------------------------------
-
-
-The ORCA\_R2 configuration has the following specificity: starting from a 2\deg~ORCA mesh,
-local mesh refinements were applied to the Mediterranean, Red, Black and Caspian Seas,
-so that the resolution is 1\deg~ there.
-A local transformation were also applied with in the Tropics in order to refine the meridional resolution up to
-0.5\deg~ at the Equator.
-
-The ORCA\_R1 configuration has only a local tropical transformation to refine the meridional resolution up to
-1/3\deg~at the Equator.
-Note that the tropical mesh refinements in ORCA\_R2 and R1 strongly increases the mesh anisotropy there.
-
-The ORCA\_R05 and higher global configurations do not incorporate any regional refinements.  
-
-For ORCA\_R1 and R025, setting the configuration key to 75 allows to use 75 vertical levels, otherwise 46 are used.
-In the other ORCA configurations, 31 levels are used
-(see \autoref{tab:orca_zgr}). %\sfcomment{HERE I need to put new table for ORCA2 values} and \autoref{fig:zgr}).
-
-Only the ORCA\_R2 is provided with all its input files in the NEMO distribution.
-%It is very similar to that used as part of the climate model developed at IPSL for the 4th IPCC assessment of
-%climate change (Marti et al., 2009).
-%It is also the basis for the \NEMO contribution to the Coordinate Ocean-ice Reference Experiments (COREs)
-%documented in \citet{griffies.biastoch.ea_OM09}. 
-
-This version of ORCA\_R2 has 31 levels in the vertical, with the highest resolution (10m) in the upper 150m
-(see \autoref{tab:orca_zgr} and \autoref{fig:zgr}). 
-The bottom topography and the coastlines are derived from the global atlas of Smith and Sandwell (1997). 
-The default forcing uses the boundary forcing from \citet{large.yeager_rpt04} (see \autoref{subsec:SBC_blk_core}), 
-which was developed for the purpose of running global coupled ocean-ice simulations without
-an interactive atmosphere.
-This \citet{large.yeager_rpt04} dataset is available through
-the \href{http://nomads.gfdl.noaa.gov/nomads/forms/mom4/CORE.html}{GFDL web site}.
-The "normal year" of \citet{large.yeager_rpt04} has been chosen of the NEMO distribution since release v3.3. 
-
-ORCA\_R2 pre-defined configuration can also be run with multiply online nested zooms (\ie with AGRIF, \key{agrif} defined). This is available as the AGRIF\_DEMO configuration that can be found in the \path{cfgs/AGRIF_DEMO/} directory.
-
-A regional Arctic or peri-Antarctic configuration is extracted from an ORCA\_R2 or R05 configurations using
-sponge layers at open boundaries. 
-
-% -------------------------------------------------------------------------------------------------------------
-%       GYRE family: double gyre basin
-% -------------------------------------------------------------------------------------------------------------
-\section{GYRE family: double gyre basin}
-\label{sec:CFG_gyre}
-
-The GYRE configuration \citep{levy.klein.ea_OM10} has been built to
-simulate the seasonal cycle of a double-gyre box model.
-It consists in an idealized domain similar to that used in the studies of \citet{drijfhout_JPO94} and
-\citet{hazeleger.drijfhout_JPO98, hazeleger.drijfhout_JPO99, hazeleger.drijfhout_JGR00, hazeleger.drijfhout_JPO00},
-over which an analytical seasonal forcing is applied.
-This allows to investigate the spontaneous generation of a large number of interacting, transient mesoscale eddies 
-and their contribution to the large scale circulation. 
-
-The GYRE configuration run together with the PISCES biogeochemical model (GYRE-PISCES).
-The domain geometry is a closed rectangular basin on the $\beta$-plane centred at $\sim$ 30\deg{N} and
-rotated by 45\deg, 3180~km long, 2120~km wide and 4~km deep (\autoref{fig:MISC_strait_hand}).
-The domain is bounded by vertical walls and by a flat bottom.
-The configuration is meant to represent an idealized North Atlantic or North Pacific basin.
-The circulation is forced by analytical profiles of wind and buoyancy fluxes.
-The applied forcings vary seasonally in a sinusoidal manner between winter and summer extrema \citep{levy.klein.ea_OM10}. 
-The wind stress is zonal and its curl changes sign at 22\deg{N} and 36\deg{N}.
-It forces a subpolar gyre in the north, a subtropical gyre in the wider part of the domain and
-a small recirculation gyre in the southern corner.
-The net heat flux takes the form of a restoring toward a zonal apparent air temperature profile.
-A portion of the net heat flux which comes from the solar radiation is allowed to penetrate within the water column.
-The fresh water flux is also prescribed and varies zonally.
-It is determined such as, at each time step, the basin-integrated flux is zero.
-The basin is initialised at rest with vertical profiles of temperature and salinity uniformly applied to
-the whole domain.
-
-The GYRE configuration is set like an analytical configuration.
-Through \np{ln\_read\_cfg}\forcode{ = .false.} in \textit{namcfg} namelist defined in
-the reference configuration \path{cfgs/GYRE_PISCES/EXPREF/namelist_cfg}
-analytical definition of grid in GYRE is done in usrdef\_hrg, usrdef\_zgr routines.
-Its horizontal resolution (and thus the size of the domain) is determined by
-setting \np{nn\_GYRE} in \ngn{namusr\_def}: \\
-
-\np{jpiglo} $= 30 \times$ \np{nn\_GYRE} + 2   \\
-
-\np{jpjglo} $= 20 \times$ \np{nn\_GYRE} + 2   \\
-
-Obviously, the namelist parameters have to be adjusted to the chosen resolution,
-see the Configurations pages on the NEMO web site (NEMO Configurations).
-In the vertical, GYRE uses the default 30 ocean levels (\jp{jpk}\forcode{ = 31}) (\autoref{fig:zgr}).
-
-The GYRE configuration is also used in benchmark test as it is very simple to increase its resolution and
-as it does not requires any input file.
-For example, keeping a same model size on each processor while increasing the number of processor used is very easy,
-even though the physical integrity of the solution can be compromised.
-Benchmark is activate via \np{ln\_bench}\forcode{ = .true.} in \ngn{namusr\_def} in
-namelist \path{cfgs/GYRE_PISCES/EXPREF/namelist_cfg}.
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_GYRE}
-    \caption{
-      \protect\label{fig:GYRE}
-      Snapshot of relative vorticity at the surface of the model domain in GYRE R9, R27 and R54.
-      From \citet{levy.klein.ea_OM10}.
-    }
-  \end{center}
-\end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -------------------------------------------------------------------------------------------------------------
-%       AMM configuration
-% -------------------------------------------------------------------------------------------------------------
-\section{AMM: atlantic margin configuration}
-\label{sec:MISC_config_AMM}
-
-The AMM, Atlantic Margins Model, is a regional model covering the Northwest European Shelf domain on
-a regular lat-lon grid at approximately 12km horizontal resolution.
-The appropriate \textit{\&namcfg} namelist  is available in \textit{cfgs/AMM12/EXPREF/namelist\_cfg}.
-It is used to build the correct dimensions of the AMM domain.
-
-This configuration tests several features of NEMO functionality specific to the shelf seas.
-In particular, the AMM uses $s$-coordinates in the vertical rather than $z$-coordinates and
-is forced with tidal lateral boundary conditions using a Flather boundary condition from the BDY module.
-Also specific to the AMM configuration is the use of the GLS turbulence scheme (\np{ln\_zdfgls} \forcode{= .true.}).
-
-In addition to the tidal boundary condition the model may also take open boundary conditions from
-a North Atlantic model.
-Boundaries may be completely omitted by setting \np{ln\_bdy} to false.
-Sample surface fluxes, river forcing and a sample initial restart file are included to test a realistic model run.
-The Baltic boundary is included within the river input file and is specified as a river source.
-Unlike ordinary river points the Baltic inputs also include salinity and temperature data.
-
-\biblio
-
-\pindex
-
-\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DIA.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DIA.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DIA.tex	(revision 12143)
@@ -2,17 +2,34 @@
 
 \begin{document}
-% ================================================================
-% Chapter I/O & Diagnostics
-% ================================================================
+
 \chapter{Output and Diagnostics (IOM, DIA, TRD, FLO)}
 \label{chap:DIA}
 
-\minitoc
-
-\newpage
-
-% ================================================================
-%       Old Model Output 
-% ================================================================
+%    {\em 4.0} & {\em Mirek Andrejczuk, Massimiliano Drudi} & {\em }  \\
+%    {\em }      & {\em Dorotea Iovino, Nicolas Martin} & {\em }  \\
+%    {\em 3.6} & {\em Gurvan Madec, Sebastien Masson } & {\em }  \\
+%    {\em 3.4} & {\em Gurvan Madec, Rachid Benshila, Andrew Coward } & {\em }  \\
+%    {\em }      & {\em Christian Ethe, Sebastien Masson } & {\em }  \\
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+%% =================================================================================================
 \section{Model output}
 \label{sec:DIA_io_old}
@@ -28,6 +45,6 @@
 
 The output listing and file(s) are predefined but should be checked and eventually adapted to the user's needs.
-The output listing is stored in the $ocean.output$ file.
-The information is printed from within the code on the logical unit $numout$.
+The output listing is stored in the \textit{ocean.output} file.
+The information is printed from within the code on the logical unit \texttt{numout}.
 To locate these prints, use the UNIX command "\textit{grep -i numout}" in the source code directory.
 
@@ -38,42 +55,32 @@
 A complete description of the use of this I/O server is presented in the next section.
 
-%\gmcomment{                    % start of gmcomment
-
-% ================================================================
-% Diagnostics
-% ================================================================
+%\cmtgm{                    % start of gmcomment
+
+%% =================================================================================================
 \section{Standard model output (IOM)}
 \label{sec:DIA_iom}
 
-Since version 3.2, iomput is the NEMO output interface of choice.
+Since version 3.2, iomput is the \NEMO\ output interface of choice.
 It has been designed to be simple to use, flexible and efficient.
-The two main purposes of iomput are: 
+The two main purposes of iomput are:
 
 \begin{enumerate}
-\item
-  The complete and flexible control of the output files through external XML files adapted by
+\item The complete and flexible control of the output files through external XML files adapted by
   the user from standard templates.
-\item
-  To achieve high performance and scalable output through the optional distribution of
+\item To achieve high performance and scalable output through the optional distribution of
   all diagnostic output related tasks to dedicated processes.
 \end{enumerate}
 
-The first functionality allows the user to specify, without code changes or recompilation, 
+The first functionality allows the user to specify, without code changes or recompilation,
 aspects of the diagnostic output stream, such as:
 
 \begin{itemize}
-\item
-  The choice of output frequencies that can be different for each file (including real months and years).
-\item
-  The choice of file contents; includes complete flexibility over which data are written in which files
+\item The choice of output frequencies that can be different for each file (including real months and years).
+\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).
-\item
-  The possibility to split output files at a chosen frequency.
-\item
-  The possibility to extract a vertical or an horizontal subdomain.
-\item
-  The choice of the temporal operation to perform, \eg: average, accumulate, instantaneous, min, max and once.
-\item
-  Control over metadata via a large XML "database" of possible output fields.
+\item The possibility to split output files at a chosen frequency.
+\item The possibility to extract a vertical or an horizontal subdomain.
+\item The choice of the temporal operation to perform, \eg: average, accumulate, instantaneous, min, max and once.
+\item Control over metadata via a large XML "database" of possible output fields.
 \end{itemize}
 
@@ -81,5 +88,5 @@
 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: 
+Examples of the XML files that control the outputs can be found in:
 \path{cfgs/ORCA2_ICE_PISCES/EXPREF/iodef.xml},
 \path{cfgs/SHARED/field_def_nemo-oce.xml},
@@ -88,32 +95,33 @@
 
 The 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)
+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.
 
-In version 3.6, the iom\_put interface depends on
-an external code called \href{https://forge.ipsl.jussieu.fr/ioserver/browser/XIOS/branchs/xios-2.5}{XIOS-2.5} 
-(use of revision 618 or higher is required).
+In version 3.6, the \rou{iom\_put} interface depends on
+an external code called \href{https://forge.ipsl.jussieu.fr/ioserver/browser/XIOS/branchs/xios-2.5}{XIOS-2.5}
+%(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 (\ie with the configure option $--$enable-parallel).
+an HDF5 library that has been correctly compiled (\ie\ 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.
 
 Even 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.
+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.
 
+%% =================================================================================================
 \subsection{XIOS: Reading and writing restart file}
 
-XIOS may be used to read single file restart produced by NEMO. Currently only the variables written to 
-file \forcode{numror} can be handled by XIOS. To activate restart reading using XIOS, set \np{ln\_xios\_read}\forcode{ = .true. }
-in \textit{namelist\_cfg}. This setting will be ignored when multiple restart files are present, and default NEMO 
-functionality will be used for reading. There is no need to change iodef.xml file to use XIOS to read 
-restart, all definitions are done within the NEMO code. For high resolution configuration, however, 
+XIOS may be used to read single file restart produced by \NEMO. Currently only the variables written to
+file \forcode{numror} can be handled by XIOS. To activate restart reading using XIOS, set \np[=.true. ]{ln_xios_read}{ln\_xios\_read}
+in \textit{namelist\_cfg}. This setting will be ignored when multiple restart files are present, and default \NEMO
+functionality will be used for reading. There is no need to change iodef.xml file to use XIOS to read
+restart, all definitions are done within the \NEMO\ code. For high resolution configuration, however,
 there may be a need to add the following line in iodef.xml (xios context):
 
@@ -122,34 +130,34 @@
 \end{xmllines}
 
-This variable sets timeout for reading. 
-
-If XIOS is to be used to read restart from file generated with an earlier NEMO version (3.6 for instance),
+This variable sets timeout for reading.
+
+If XIOS is to be used to read restart from file generated with an earlier \NEMO\ version (3.6 for instance),
 dimension \forcode{z} defined in restart file must be renamed to \forcode{nav_lev}.\\
 
-XIOS can also be used to write NEMO restart. A namelist parameter \np{nn\_wxios} is used to determine the 
-type of restart NEMO will write. If it is set to 0, default NEMO functionality will be used - each 
-processor writes its own restart file; if it is set to 1 XIOS will write restart into a single file; 
-for \np{nn\_wxios = 2} the restart will be written by XIOS into multiple files, one for each XIOS server. 
-Note, however, that \textbf{NEMO will not read restart generated by XIOS when \np{nn\_wxios = 2}}. The restart will 
-have to be rebuild before continuing the run. This option aims to reduce number of restart files generated by NEMO only, 
-and may be useful when there is a need to change number of processors used to run simulation. 
+XIOS can also be used to write \NEMO\ restart. A namelist parameter \np{nn_wxios}{nn\_wxios} is used to determine the
+type of restart \NEMO\ will write. If it is set to 0, default \NEMO\ functionality will be used - each
+processor writes its own restart file; if it is set to 1 XIOS will write restart into a single file;
+for \np[=2]{nn_wxios}{nn\_wxios} the restart will be written by XIOS into multiple files, one for each XIOS server.
+Note, however, that \textbf{\NEMO\ will not read restart generated by XIOS when \np[=2]{nn_wxios}{nn\_wxios}}. The restart will
+have to be rebuild before continuing the run. This option aims to reduce number of restart files generated by \NEMO\ only,
+and may be useful when there is a need to change number of processors used to run simulation.
 
 If an additional variable must be written to a restart file, the following steps are needed:
-\begin{description}
-   \item[step 1:] add variable name to a list of restart variables (in subroutine \rou{iom\_set\_rst\_vars,} \mdl{iom}) and 
-define correct grid for the variable (\forcode{grid_N_3D} - 3D variable, \forcode{grid_N} - 2D variable, \forcode{grid_vector} - 
+\begin{enumerate}
+\item Add variable name to a list of restart variables (in subroutine \rou{iom\_set\_rst\_vars,} \mdl{iom}) and
+define correct grid for the variable (\forcode{grid_N_3D} - 3D variable, \forcode{grid_N} - 2D variable, \forcode{grid_vector} -
 1D variable, \forcode{grid_scalar} - scalar),
-   \item[step 2:] add variable to the list of fields written by restart.  This can be done either in subroutine 
-\rou{iom\_set\_rstw\_core} (\mdl{iom}) or by calling  \rou{iom\_set\_rstw\_active} (\mdl{iom}) with the name of a variable 
-as an argument. This convention follows approach for writing restart using iom, where variables are 
+\item Add variable to the list of fields written by restart.  This can be done either in subroutine
+\rou{iom\_set\_rstw\_core} (\mdl{iom}) or by calling  \rou{iom\_set\_rstw\_active} (\mdl{iom}) with the name of a variable
+as an argument. This convention follows approach for writing restart using iom, where variables are
 written either by \rou{rst\_write} or by calling \rou{iom\_rstput} from individual routines.
-\end{description}
-
+\end{enumerate}
 
 An older versions of XIOS do not support reading functionality. It's recommended to use at least XIOS2@1451.
 
-
+%% =================================================================================================
 \subsection{XIOS: XML Inputs-Outputs Server}
 
+%% =================================================================================================
 \subsubsection{Attached or detached mode?}
 
@@ -161,12 +169,14 @@
 \xmlline|<variable id="using_server" type="bool"></variable>|
 
-The {\ttfamily using\_server} setting determines whether or not the server will be used in \textit{attached mode}
-(as a library) [{\ttfamily> false <}] or in \textit{detached mode}
-(as an external executable on N additional, dedicated cpus) [{\ttfamily > true <}].
-The \textit{attached mode} is simpler to use but much less efficient for massively parallel applications.
+The \texttt{using\_server} setting determines whether or not the server will be used in
+\textit{attached mode}
+(as a library) [\texttt{> false <}] or in \textit{detached mode}
+(as an external executable on N additional, dedicated cpus) [\texttt{ > true <}].
+The \textit{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''.
 
 In \textit{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.
+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
@@ -180,17 +190,18 @@
 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. 
+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.
 
+%% =================================================================================================
 \subsubsection{Number of cpu used by XIOS in detached mode}
 
 The number of cores used by the XIOS is specified when launching the model.
-The number of cores dedicated to XIOS should be from \texttildelow1/10 to \texttildelow1/50 of the number of 
-cores dedicated to NEMO.
+The number of cores dedicated to XIOS should be from \texttildelow1/10 to \texttildelow1/50 of the number of
+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.
+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 
+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.
@@ -198,11 +209,12 @@
 \cmd|mpirun -np 62 ./nemo.exe : -np 2 ./xios_server.exe|
 
+%% =================================================================================================
 \subsubsection{Control of XIOS: the context in iodef.xml}
 
-As well as the {\ttfamily using\_server} flag, other controls on the use of XIOS are set in the XIOS context in iodef.xml.
+As well as the \texttt{using\_server} flag, other controls on the use of XIOS are set in
+the XIOS context in \textit{iodef.xml}.
 See the XML basics section below for more details on XML syntax and rules.
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|lXl|}
     \hline
@@ -213,5 +225,5 @@
     \hline
     buffer\_size                                                            &
-    buffer size used by XIOS to send data from NEMO to XIOS.
+    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 &
@@ -219,5 +231,5 @@
     \hline
     buffer\_server\_factor\_size                                            &
-    ratio between NEMO and XIOS buffer size.
+    ratio between \NEMO\ and XIOS buffer size.
     Should be 2.                                                            &
     2        \\
@@ -236,5 +248,5 @@
     \hline
     oasis\_codes\_id                                                        &
-    when using oasis, define the identifier of NEMO in the namcouple.
+    when using oasis, define the identifier of \NEMO\ in the namcouple.
     Note that the identifier of XIOS is xios.x                              &
     oceanx   \\
@@ -243,14 +255,17 @@
 \end{table}
 
+%% =================================================================================================
 \subsection{Practical issues}
 
+%% =================================================================================================
 \subsubsection{Installation}
 
-As mentioned, XIOS is supported separately and must be downloaded and compiled before it can be used with NEMO.
+As 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.
+\NEMO\ will need to link to the compiled XIOS library.
 The \href{https://forge.ipsl.jussieu.fr/nemo/chrome/site/doc/NEMO/guide/html/install.html#extract-and-install-xios}
 {Extract and install XIOS} guide provides an example illustration of how this can be achieved.
 
+%% =================================================================================================
 \subsubsection{Add your own outputs}
 
@@ -261,23 +276,18 @@
 
 \begin{enumerate}
-\item[1.]
-  in NEMO code, add a \forcode{CALL iom_put( 'identifier', array )} where you want to output a 2D or 3D array.
-\item[2.]
-  If necessary, add \forcode{USE iom ! I/O manager library} to the list of used modules in
+\item in \NEMO\ code, add a \forcode{CALL iom_put( 'identifier', array )} where you want to output a 2D or 3D array.
+\item If necessary, add \forcode{USE iom ! I/O manager library} to the list of used modules in
   the upper part of your module.
-\item[3.]
-  in the field\_def.xml file, add the definition of your variable using the same identifier you used in the f90 code
+\item 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:
-
 \begin{xmllines}
 <field_definition>
 	<field_group id="grid_T" grid_ref="grid_T_3D"> <!-- T grid -->
 	...
-		<field id="identifier" long_name="blabla" ... />   
+		<field id="identifier" long_name="blabla" ... />
 		...
-</field_definition> 
-\end{xmllines}
-
+</field_definition>
+\end{xmllines}
 Note your definition must be added to the field\_group whose reference grid is consistent with the size of
 the array passed to iomput.
@@ -286,29 +296,26 @@
 (iom\_set\_domain\_attr and iom\_set\_axis\_attr in \mdl{iom}) or defined in the domain\_def.xml file.
 \eg:
-
 \begin{xmllines}
 <grid id="grid_T_3D" domain_ref="grid_T" axis_ref="deptht"/>
 \end{xmllines}
-
-Note, if your array is computed within the surface module each \np{nn\_fsbc} time\_step,
+Note, if your array is computed within the surface module each \np{nn_fsbc}{nn\_fsbc} time\_step,
 add the field definition within the field\_group defined with the id "SBC":
 \xmlcode{<field_group id="SBC" ...>} which has been defined with the correct frequency of operations
 (iom\_set\_field\_attr in \mdl{iom})
-\item[4.]
-  add your field in one of the output files defined in iodef.xml
+\item add your field in one of the output files defined in iodef.xml
   (again see subsequent sections for syntax and rules)
-
-\begin{xmllines}
-<file id="file1" .../>   
+\begin{xmllines}
+<file id="file1" .../>
 ...
-	<field field_ref="identifier" />   
+	<field field_ref="identifier" />
 	...
-</file>   
-\end{xmllines}
-
+</file>
+\end{xmllines}
 \end{enumerate}
 
+%% =================================================================================================
 \subsection{XML fundamentals}
 
+%% =================================================================================================
 \subsubsection{ XML basic rules}
 
@@ -320,5 +327,6 @@
 See \href{http://www.xmlnews.org/docs/xml-basics.html}{here} for more details.
 
-\subsubsection{Structure of the XML file used in NEMO}
+%% =================================================================================================
+\subsubsection{Structure of the XML file used in \NEMO}
 
 The XML file used in XIOS is structured by 7 families of tags:
@@ -327,5 +335,4 @@
 
 \begin{table}
-  \scriptsize
   \begin{tabular*}{\textwidth}{|p{0.15\textwidth}p{0.4\textwidth}p{0.35\textwidth}|}
     \hline
@@ -359,5 +366,4 @@
 
 \begin{table}
-  \scriptsize
   \begin{tabular}{|p{0.15\textwidth}p{0.4\textwidth}p{0.35\textwidth}|}
     \hline
@@ -369,11 +375,11 @@
                                                                                                      \xmlcode{<context id="xios" ... >}   \\
     \hline
-    context nemo    &	context containing IO information for NEMO (mother grid when using AGRIF)  & 
+    context nemo    &	context containing IO information for \NEMO\ (mother grid when using AGRIF)  &
                                                                                                      \xmlcode{<context id="nemo" ... >}   \\
     \hline
-    context 1\_nemo &	context containing IO information for NEMO child grid 1 (when using AGRIF) & 
+    context 1\_nemo &	context containing IO information for \NEMO\ child grid 1 (when using AGRIF) &
                                                                                                      \xmlcode{<context id="1_nemo" ... >} \\
     \hline
-    context n\_nemo &	context containing IO information for NEMO child grid n (when using AGRIF) & 
+    context n\_nemo &	context containing IO information for \NEMO\ child grid n (when using AGRIF) &
                                                                                                      \xmlcode{<context id="n_nemo" ... >} \\
     \hline
@@ -384,5 +390,4 @@
 
 \begin{table}
-  \scriptsize
   \begin{tabular}{|p{0.15\textwidth}p{0.4\textwidth}p{0.35\textwidth}|}
     \hline
@@ -400,9 +405,8 @@
 \end{table}
 
-\noindent Each context tag related to NEMO (mother or child grids) is divided into 5 parts 
+\noindent Each context tag related to \NEMO\ (mother or child grids) is divided into 5 parts
 (that can be defined in any order):
 
 \begin{table}
-  \scriptsize
   \begin{tabular}{|p{0.15\textwidth}p{0.4\textwidth}p{0.35\textwidth}|}
     \hline
@@ -429,4 +433,5 @@
 \end{table}
 
+%% =================================================================================================
 \subsubsection{Nesting XML files}
 
@@ -434,6 +439,6 @@
 The inclusion of XML files into the main XML file can be done through the attribute src:
 \xmlline|<context src="./nemo_def.xml" />|
- 
-\noindent In NEMO, by default, the field definition is done in 3 separate files (
+
+\noindent In \NEMO, by default, the field definition is done in 3 separate files (
 \path{cfgs/SHARED/field_def_nemo-oce.xml},
 \path{cfgs/SHARED/field_def_nemo-pisces.xml} and
@@ -442,7 +447,8 @@
 are included in the main iodef.xml file through the following commands:
 \begin{xmllines}
-<context id="nemo" src="./context_nemo.xml"/> 
-\end{xmllines}
-
+<context id="nemo" src="./context_nemo.xml"/>
+\end{xmllines}
+
+%% =================================================================================================
 \subsubsection{Use of inheritance}
 
@@ -457,7 +463,7 @@
 \begin{xmllines}
 <field_definition operation="average" >
-	<field id="sst"                    />   <!-- averaged      sst --> 
-	<field id="sss" operation="instant"/>   <!-- instantaneous sss --> 
-</field_definition> 
+	<field id="sst"                    />   <!-- averaged      sst -->
+	<field id="sss" operation="instant"/>   <!-- instantaneous sss -->
+</field_definition>
 \end{xmllines}
 
@@ -476,13 +482,14 @@
 </field_definition>
 <file_definition>
-	<file id="myfile" output_freq="1d" />   
+	<file id="myfile" output_freq="1d" />
 		<field field_ref="sst"                            />  <!-- default def -->
 		<field field_ref="sss" long_name="my description" />  <!-- overwrite   -->
 	</file>
-</file_definition> 
+</file_definition>
 \end{xmllines}
 
 Inherit (and overwrite, if needed) the attributes of a tag you are refering to.
 
+%% =================================================================================================
 \subsubsection{Use of groups}
 
@@ -523,7 +530,8 @@
 	<field_group group_ref="groupU" />
 	<field field_ref="uocetr_eff"   />  <!-- add another field -->
-</file>   
-\end{xmllines}
-
+</file>
+\end{xmllines}
+
+%% =================================================================================================
 \subsection{Detailed functionalities}
 
@@ -531,10 +539,11 @@
 the new functionalities offered by the XML interface of XIOS.
 
+%% =================================================================================================
 \subsubsection{Define horizontal subdomains}
 
 Horizontal 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 \path{cfgs/SHARED/domain_def.xml}, we provide the following example of a definition of 
+It must therefore be done in the domain part of the XML file.
+For example, in \path{cfgs/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).
 
@@ -553,5 +562,5 @@
 \end{xmllines}
 
-Moorings are seen as an extrem case corresponding to a 1 by 1 subdomain. 
+Moorings are seen as an extrem case corresponding to a 1 by 1 subdomain.
 The Equatorial section, the TAO, RAMA and PIRATA moorings are already registered in the code and
 can therefore be outputted without taking care of their (i,j) position in the grid.
@@ -566,10 +575,11 @@
 \end{xmllines}
 
-Note 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, 
+Note 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.
 
+%% =================================================================================================
 \subsubsection{Define vertical zooms}
 
@@ -595,4 +605,5 @@
 \end{xmllines}
 
+%% =================================================================================================
 \subsubsection{Control of the output file names}
 
@@ -601,5 +612,5 @@
 
 \begin{xmllines}
-<file_group id="1d" output_freq="1d" name="myfile_1d" > 
+<file_group id="1d" output_freq="1d" name="myfile_1d" >
 	<file id="myfileA" name_suffix="_AAA" > <!-- will create file "myfile_1d_AAA"  -->
 		...
@@ -620,5 +631,4 @@
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|lX|}
     \hline
@@ -656,5 +666,5 @@
 \end{table}
 
-\noindent For example, 
+\noindent For example,
 \xmlline|<file id="myfile_hzoom" name="myfile_@expname@_@startdate@_freq@freq@" output_freq="1d" >|
 
@@ -668,7 +678,8 @@
 \noindent will give the following file name radical: \ifile{myfile\_ORCA2\_19891231\_freq1d}
 
-\subsubsection{Other controls of the XML attributes from NEMO}
-
-The values of some attributes are defined by subroutine calls within NEMO 
+%% =================================================================================================
+\subsubsection{Other controls of the XML attributes from \NEMO}
+
+The values of some attributes are defined by subroutine calls within \NEMO
 (calls to iom\_set\_domain\_attr, iom\_set\_axis\_attr and iom\_set\_field\_attr in \mdl{iom}).
 Any definition given in the XML file will be overwritten.
@@ -681,53 +692,53 @@
 
 \begin{table}
-  \scriptsize
-  \begin{tabularx}{\textwidth}{|X|c|c|c|}
+  \begin{tabular}{|l|c|c|}
     \hline
     tag ids affected by automatic definition of some of their attributes &
     name attribute                                                       &
-    attribute value                      \\
+    attribute value                                                      \\
     \hline
     \hline
     field\_definition                                                    &
     freq\_op                                                             &
-    \np{rn\_rdt}                         \\
+    \np{rn_rdt}{rn\_rdt}                                                         \\
     \hline
     SBC                                                                  &
     freq\_op                                                             &
-    \np{rn\_rdt} $\times$ \np{nn\_fsbc}  \\
+    \np{rn_rdt}{rn\_rdt} $\times$ \np{nn_fsbc}{nn\_fsbc}                                  \\
     \hline
     ptrc\_T                                                              &
     freq\_op                                                             &
-    \np{rn\_rdt} $\times$ \np{nn\_dttrc} \\
+    \np{rn_rdt}{rn\_rdt} $\times$ \np{nn_dttrc}{nn\_dttrc}                                 \\
     \hline
     diad\_T                                                              &
     freq\_op                                                             &
-    \np{rn\_rdt} $\times$ \np{nn\_dttrc} \\
+    \np{rn_rdt}{rn\_rdt} $\times$ \np{nn_dttrc}{nn\_dttrc}                                 \\
     \hline
     EqT, EqU, EqW                                                        &
     jbegin, ni,                                                          &
-    according to the grid                \\
-    &
+    according to the grid                                                \\
+                                                                         &
     name\_suffix                                                         &
-    \\
+                                                                         \\
     \hline
     TAO, RAMA and PIRATA moorings                                        &
     zoom\_ibegin, zoom\_jbegin,                                          &
-    according to the grid                \\
-    &
+    according to the grid                                                \\
+                                                                         &
     name\_suffix                                                         &
-    \\
-    \hline
-  \end{tabularx}
+                                                                         \\
+    \hline
+  \end{tabular}
 \end{table}
 
+%% =================================================================================================
 \subsubsection{Advanced use of XIOS functionalities}
 
+%% =================================================================================================
 \subsection{XML reference tables}
-\label{subsec:IOM_xmlref}
+\label{subsec:DIA_IOM_xmlref}
 
 \begin{enumerate}
-\item
-  Simple computation: directly define the computation when refering to the variable in the file definition.
+\item Simple computation: directly define the computation when refering to the variable in the file definition.
 
 \begin{xmllines}
@@ -737,6 +748,5 @@
 \end{xmllines}
 
-\item
-  Simple computation: define a new variable and use it in the file definition.
+\item Simple computation: define a new variable and use it in the file definition.
 
 in field\_definition:
@@ -755,6 +765,5 @@
 sst2 won't be evaluated.
 
-\item
-  Change of variable precision:
+\item Change of variable precision:
 
 \begin{xmllines}
@@ -765,13 +774,12 @@
 \end{xmllines}
 
-Note that, then the code is crashing, writting real4 variables forces a numerical conversion from 
+Note that, then the code is crashing, writting real4 variables forces a numerical conversion 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.
 
-\item
-  add user defined attributes:
-
-\begin{xmllines}
-<file_group id="1d" output_freq="1d" output_level="10" enabled=".true."> <!-- 1d files --> 
+\item add user defined attributes:
+
+\begin{xmllines}
+<file_group id="1d" output_freq="1d" output_level="10" enabled=".true."> <!-- 1d files -->
 	<file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
 		<field field_ref="sst" name="tos" >
@@ -782,9 +790,8 @@
 		<variable id="my_global_attribute" type="string" > blabla_global </variable>
 	</file>
-</file_group> 
-\end{xmllines}
-
-\item
-  use of the ``@'' function: example 1, weighted temporal average
+</file_group>
+\end{xmllines}
+
+\item use of the ``@'' function: example 1, weighted temporal average
 
  - define a new variable in field\_definition
@@ -797,9 +804,9 @@
 
 \begin{xmllines}
-<file_group id="5d" output_freq="5d"  output_level="10" enabled=".true." >  <!-- 5d files -->  
+<file_group id="5d" output_freq="5d"  output_level="10" enabled=".true." >  <!-- 5d files -->
 	<file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
 		<field field_ref="toce" operation="instant" freq_op="5d" > @toce_e3t / @e3t </field>
 	</file>
-</file_group> 
+</file_group>
 \end{xmllines}
 
@@ -814,6 +821,5 @@
 Note that in this case, freq\_op must be equal to the file output\_freq.
 
-\item
-  use of the ``@'' function: example 2, monthly SSH standard deviation
+\item use of the ``@'' function: example 2, monthly SSH standard deviation
 
  - define a new variable in field\_definition
@@ -826,12 +832,12 @@
 
 \begin{xmllines}
-<file_group id="1m" output_freq="1m"  output_level="10" enabled=".true." >  <!-- 1m files -->  
+<file_group id="1m" output_freq="1m"  output_level="10" enabled=".true." >  <!-- 1m files -->
 	<file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
-		<field field_ref="ssh" name="sshstd" long_name="sea_surface_temperature_standard_deviation" 
+		<field field_ref="ssh" name="sshstd" long_name="sea_surface_temperature_standard_deviation"
 		operation="instant" freq_op="1m" >
 			sqrt( @ssh2 - @ssh * @ssh )
 		</field>
 	</file>
-</file_group> 
+</file_group>
 \end{xmllines}
 
@@ -840,11 +846,10 @@
 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 )'': 
+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.
 
-\item
-  use of the ``@'' function: example 3, monthly average of SST diurnal cycle
+\item use of the ``@'' function: example 3, monthly average of SST diurnal cycle
 
  - define 2 new variables in field\_definition
@@ -858,5 +863,5 @@
 
 \begin{xmllines}
-<file_group id="1m" output_freq="1m"  output_level="10" enabled=".true." >  <!-- 1m files -->  
+<file_group id="1m" output_freq="1m"  output_level="10" enabled=".true." >  <!-- 1m files -->
 	<file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
 		<field field_ref="sst" name="sstdcy" long_name="amplitude of sst diurnal cycle" operation="average" freq_op="1d" >
@@ -864,5 +869,5 @@
 		</field>
 	</file>
-</file_group> 
+</file_group>
 \end{xmllines}
 
@@ -877,8 +882,8 @@
 field\_ref="sst" means that attributes not explicitely defined, are inherited from sst field.
 
+%% =================================================================================================
 \subsubsection{Tag list per family}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|X|l|X|}
     \hline
@@ -903,9 +908,8 @@
     \hline
   \end{tabularx}
-  \caption{Context tags}
+  \caption{XIOS: context tags}
 \end{table}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|X|X|l|}
     \hline
@@ -938,9 +942,8 @@
     \hline
   \end{tabularx}
-  \caption{Field tags ("\ttfamily{field\_*}")}
+  \caption{XIOS: field tags ("\texttt{field\_*}")}
 \end{table}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|X|X|l|}
     \hline
@@ -974,9 +977,8 @@
     \hline
   \end{tabularx}
-  \caption{File tags ("\ttfamily{file\_*}")}
+  \caption{XIOS: file tags ("\texttt{file\_*}")}
 \end{table}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|X|X|X|}
     \hline
@@ -1007,9 +1009,8 @@
     \hline
   \end{tabularx}
-  \caption{Axis tags ("\ttfamily{axis\_*}")}
+  \caption{XIOS: axis tags ("\texttt{axis\_*}")}
 \end{table}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|X|X|X|}
     \hline
@@ -1040,9 +1041,8 @@
     \hline
   \end{tabularx}
-  \caption{Domain tags ("\ttfamily{domain\_*)}"}
+  \caption{XIOS: domain tags ("\texttt{domain\_*)}"}
 \end{table}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|X|X|X|}
     \hline
@@ -1073,11 +1073,11 @@
     \hline
   \end{tabularx}
-  \caption{Grid tags ("\ttfamily{grid\_*}")}
+  \caption{XIOS: grid tags ("\texttt{grid\_*}")}
 \end{table}
 
+%% =================================================================================================
 \subsubsection{Attributes list per family}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|l|l|}
     \hline
@@ -1114,9 +1114,8 @@
     \hline
   \end{tabularx}
-  \caption{Reference attributes ("\ttfamily{*\_ref}")}
+  \caption{XIOS: reference attributes ("\texttt{*\_ref}")}
 \end{table}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|l|l|}
     \hline
@@ -1150,9 +1149,8 @@
     \hline
   \end{tabularx}
-  \caption{Domain attributes ("\ttfamily{zoom\_*}")}
+  \caption{XIOS: domain attributes ("\texttt{zoom\_*}")}
 \end{table}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|l|l|}
     \hline
@@ -1205,9 +1203,8 @@
     \hline
   \end{tabularx}
-  \caption{File attributes}
+  \caption{XIOS: file attributes}
 \end{table}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|l|l|}
     \hline
@@ -1254,9 +1251,8 @@
     \hline
   \end{tabularx}
-  \caption{Field attributes}
+  \caption{XIOS: field attributes}
 \end{table}
 
 \begin{table}
-  \scriptsize
   \begin{tabularx}{\textwidth}{|l|X|X|X|}
     \hline
@@ -1313,25 +1309,22 @@
     \hline
   \end{tabularx}
-  \caption{Miscellaneous attributes}
+  \caption{XIOS: miscellaneous attributes}
 \end{table}
 
+%% =================================================================================================
 \subsection{CF metadata standard compliance}
 
-Output from the XIOS IO server is compliant with 
+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. 
+the CF metadata standard.
 Therefore while a user may wish to add their own metadata to the output files (as demonstrated in example 4 of
-section \autoref{subsec:IOM_xmlref}) the metadata should, for the most part, comply with the CF-1.5 standard.
+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} in the \ngn{namrun} namelist.
+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.
 
-
-% ================================================================
-%       NetCDF4 support
-% ================================================================
-\section[NetCDF4 support (\texttt{\textbf{key\_netcdf4}})]
-{NetCDF4 support (\protect\key{netcdf4})}
+%% =================================================================================================
+\section[NetCDF4 support (\texttt{\textbf{key\_netcdf4}})]{NetCDF4 support (\protect\key{netcdf4})}
 \label{sec:DIA_nc4}
 
@@ -1347,14 +1340,15 @@
 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} logical to false in the \textit{namnc4} namelist:
-
-%------------------------------------------namnc4----------------------------------------------------
-
-\nlst{namnc4}
-%-------------------------------------------------------------------------------------------------------------
+\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} is set false and dummy routines for a few NetCDF4-specific functions are defined.
+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.
 
@@ -1390,15 +1384,13 @@
 \end{forlines}
 
-\noindent for a standard ORCA2\_LIM configuration gives chunksizes of {\small\ttfamily 46x38x1} respectively in
-the mono-processor case (\ie global domain of {\small\ttfamily 182x149x31}).
-An illustration of the potential space savings that NetCDF4 chunking and compression provides is given in 
-table \autoref{tab:NC4} which compares the results of two short runs of the ORCA2\_LIM reference configuration with
+\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.
 
-%------------------------------------------TABLE----------------------------------------------------
 \begin{table}
-  \scriptsize
   \centering
   \begin{tabular}{lrrr}
@@ -1432,95 +1424,83 @@
     ORCA2\_2d\_grid\_W\_0007.nc & 4416		& 1368	  & 70\%      \\
   \end{tabular}
-  \caption{
-    \protect\label{tab:NC4}
-    Filesize comparison between NetCDF3 and NetCDF4 with chunking and compression
-  }
+  \caption{Filesize comparison between NetCDF3 and NetCDF4 with chunking and compression}
+  \label{tab:DIA_NC4}
 \end{table}
-%----------------------------------------------------------------------------------------------------
 
 When \key{iomput} is activated with \key{netcdf4} chunking and compression parameters for fields produced via
-\np{iom\_put} calls are set via an equivalent and identically named namelist to \textit{namnc4} in
-\np{xmlio\_server.def}.
-Typically this namelist serves the mean files whilst the \ngn{ namnc4} in the main namelist file continues to
+\rou{iom\_put} calls are set via an equivalent and identically named namelist to \nam{nc4}{nc4} in
+\textit{xmlio\_server.def}.
+Typically this namelist serves the mean files whilst the \nam{nc4}{nc4} in the main namelist file continues to
 serve the restart files.
 This duplication is unfortunate but appropriate since, if using io\_servers, the domain sizes of
 the individual files produced by the io\_server processes may be different to those produced by
 the invidual processing regions and different chunking choices may be desired.
- 
-% -------------------------------------------------------------------------------------------------------------
-%       Tracer/Dynamics Trends
-% -------------------------------------------------------------------------------------------------------------
-\section[Tracer/Dynamics trends (\texttt{namtrd})]
-{Tracer/Dynamics trends (\protect\ngn{namtrd})}
+
+%% =================================================================================================
+\section[Tracer/Dynamics trends (\forcode{&namtrd})]{Tracer/Dynamics trends (\protect\nam{trd}{trd})}
 \label{sec:DIA_trd}
 
-%------------------------------------------namtrd----------------------------------------------------
-
-\nlst{namtrd} 
-%-------------------------------------------------------------------------------------------------------------
+\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 $dyn\cdots.F90$ and/or $tra\cdots.F90$ routines).
-This capability is controlled by options offered in \ngn{namtrd} namelist.
+(\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{iomput} is required.
 
-What is done depends on the \ngn{namtrd} logical set to \forcode{.true.}:
+What is done depends on the \nam{trd}{trd} logical set to \forcode{.true.}:
 
 \begin{description}
-\item[\np{ln\_glo\_trd}]:
-  at each \np{nn\_trd} time-step a check of the basin averaged properties of
+\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}]:
-  each 3D trend of the evolution of the two momentum components is output;
-\item[\np{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}]:
-  a vertical summation of the moment tendencies is performed,
+\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}] :
-  each 3D trend of the Kinetic Energy equation is output;
-\item[\np{ln\_tra\_trd}]:
-  each 3D trend of the evolution of temperature and salinity is output;
-\item[\np{ln\_tra\_mxl}]:
-  each 2D trend of the evolution of temperature and salinity averaged over the mixed layer is 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 
+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 (v3.6), many changes has been introduced but not fully tested.
-In particular, options associated with \np{ln\_dyn\_mxl}, \np{ln\_vor\_trd}, and \np{ln\_tra\_mxl} are not working,
-and none of the options have been tested with variable volume (\ie \np{ln\_linssh}\forcode{ = .true.}).
-
-% -------------------------------------------------------------------------------------------------------------
-%       On-line Floats trajectories
-% -------------------------------------------------------------------------------------------------------------
-\section[FLO: On-Line Floats trajectories (\texttt{\textbf{key\_floats}})]
-{FLO: On-Line Floats trajectories (\protect\key{floats})}
-\label{sec:FLO}
-%--------------------------------------------namflo-------------------------------------------------------
-
-\nlst{namflo} 
-%--------------------------------------------------------------------------------------------------------------
+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 (\texttt{\textbf{key\_floats}})]{FLO: On-Line Floats trajectories (\protect\key{floats})}
+\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 \ngn{namflo} namelist variables.
+Options are defined by \nam{flo}{flo} namelist variables.
 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{ln\_flork4}\forcode{ = .true.}).
+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{ln\_ariane}\forcode{ = .true.}) ) or with longitude and latitude.
-
-In case of Ariane convention, input filename is \np{init\_float\_ariane}.
+(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: \\
-{\scriptsize \texttt{I J K nisobfl itrash}}
+{ \texttt{I J K nisobfl itrash}}
 
 \noindent with:
@@ -1528,5 +1508,5 @@
  - I,J,K  : indexes of initial position
 
- - nisobfl: 0 for an isobar float, 1 for a float following the w velocity  
+ - 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
@@ -1534,5 +1514,5 @@
 \noindent Example: \\
 \noindent
-{\scriptsize
+{
   \texttt{
     100.00000  90.00000  -1.50000 1.00000   0.00000   \\
@@ -1545,5 +1525,5 @@
 In the other case (longitude and latitude), input filename is init\_float.
 Its format is: \\
-{\scriptsize \texttt{Long Lat depth nisobfl ngrpfl itrash}}
+{ \texttt{Long Lat depth nisobfl ngrpfl itrash}}
 
 \noindent with:
@@ -1559,5 +1539,5 @@
 \noindent Example: \\
 \noindent
-{\scriptsize
+{
   \texttt{
     20.0 0.0 0.0 0 1 1    \\
@@ -1568,17 +1548,18 @@
 } \\
 
-\np{jpnfl} is the total number of floats during the run.
-When initial positions are read in a restart file (\np{ln\_rstflo}\forcode{ = .true.} ),
-\np{jpnflnewflo} can be added in the initialization file.
-
+\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} is the frequency of writing in float output file and \np{nn\_stockfl} is the frequency of
+\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{ln\_flo\_ascii}\forcode{ = .true.}).
+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{ln\_flo\_ascii}\forcode{ = .false.}) with
+Another possiblity of writing format is Netcdf (\np[=.false.]{ln_flo_ascii}{ln\_flo\_ascii}) with
 \key{iomput} and outputs selected in iodef.xml.
 Here it is an example of specification to put in files description section:
@@ -1598,33 +1579,30 @@
 \end{xmllines}
 
-
-% -------------------------------------------------------------------------------------------------------------
-%       Harmonic analysis of tidal constituents
-% -------------------------------------------------------------------------------------------------------------
-\section[Harmonic analysis of tidal constituents (\texttt{\textbf{key\_diaharm}})]
-{Harmonic analysis of tidal constituents (\protect\key{diaharm})}
+%% =================================================================================================
+\section[Harmonic analysis of tidal constituents (\texttt{\textbf{key\_diaharm}})]{Harmonic analysis of tidal constituents (\protect\key{diaharm})}
 \label{sec:DIA_diag_harm}
 
-%------------------------------------------nam_diaharm----------------------------------------------------
-%
-\nlst{nam_diaharm}
-%----------------------------------------------------------------------------------------------------------
+\begin{listing}
+  \nlst{nam_diaharm}
+  \caption{\forcode{&nam_diaharm}}
+  \label{lst:nam_diaharm}
+\end{listing}
 
 A module is available to compute the amplitude and phase of tidal waves.
 This on-line Harmonic analysis is actived with \key{diaharm}.
 
-Some parameters are available in namelist \ngn{nam\_diaharm}:
-
- - \np{nit000\_han} is the first time step used for harmonic analysis
-
- - \np{nitend\_han} is the  last time step used for harmonic analysis
-
- - \np{nstep\_han}  is the  time step frequency for harmonic analysis
-
- - \np{nb\_ana}     is the number of harmonics to analyse
-
- - \np{tname}       is an array with names of tidal constituents to analyse
-
- \np{nit000\_han} and \np{nitend\_han} must be between \np{nit000} and \np{nitend} of the simulation.
+Some parameters are available in namelist \nam{_diaharm}{\_diaharm}:
+
+ - \np{nit000_han}{nit000\_han} is the first time step used for harmonic analysis
+
+ - \np{nitend_han}{nitend\_han} is the  last time step used for harmonic analysis
+
+ - \np{nstep_han}{nstep\_han}  is the  time step frequency for harmonic analysis
+
+% - \np{nb_ana}{nb\_ana}     is the number of harmonics to analyse
+
+ - \np{tname}{tname}       is an array with names of tidal constituents to analyse
+
+ \np{nit000_han}{nit000\_han} and \np{nitend_han}{nitend\_han} must be between \np{nit000}{nit000} and \np{nitend}{nitend} of the simulation.
  The restart capability is not implemented.
 
@@ -1647,15 +1625,13 @@
 We obtain in output $C_{j}$ and $S_{j}$ for each tidal wave.
 
-% -------------------------------------------------------------------------------------------------------------
-%       Sections transports
-% -------------------------------------------------------------------------------------------------------------
-\section[Transports across sections (\texttt{\textbf{key\_diadct}})]
-{Transports across sections (\protect\key{diadct})}
+%% =================================================================================================
+\section[Transports across sections (\texttt{\textbf{key\_diadct}})]{Transports across sections (\protect\key{diadct})}
 \label{sec:DIA_diag_dct}
 
-%------------------------------------------namdct----------------------------------------------------
-
-\nlst{namdct}
-%-------------------------------------------------------------------------------------------------------------
+\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.
@@ -1665,5 +1641,5 @@
 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.
+\NEMO\ to compute on-line transports.
 
 The on-line transports module creates three output ascii files:
@@ -1675,10 +1651,11 @@
 - \texttt{salt\_transport}   for   salt transports (unit: $10^{9}Kg s^{-1}$) \\
 
-Namelist variables in \ngn{namdct} control how frequently the flows are summed and the time scales over which
+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}   : frequency of instantaneous transports computing
-\np{nn\_dctwri}: frequency of writing ( mean of instantaneous transports )
-\np{nn\_debug} : debugging of the section
-
+\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}
 
@@ -1690,5 +1667,5 @@
 
 Each section is defined by: \\
-\noindent {\scriptsize \texttt{long1 lat1 long2 lat2 nclass (ok/no)strpond (no)ice section\_name}} \\
+\noindent { \texttt{long1 lat1 long2 lat2 nclass (ok/no)strpond (no)ice section\_name}} \\
 with:
 
@@ -1697,5 +1674,5 @@
  - \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{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;
@@ -1707,5 +1684,5 @@
 
 \noindent If nclass $\neq$ 0, the next lines contain the class type and the nclass bounds: \\
-{\scriptsize
+{
   \texttt{
     long1 lat1 long2 lat2 nclass (ok/no)strpond (no)ice section\_name \\
@@ -1730,7 +1707,7 @@
 
  - \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. \\
+ \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
@@ -1740,5 +1717,5 @@
  and the ATL\_Cuba\_Florida with 4 temperature clases (5 class bounds), are shown: \\
  \noindent
- {\scriptsize
+ {
    \texttt{
      -68.    -54.5   -60.    -64.7  00 okstrpond noice ACC\_Drake\_Passage \\
@@ -1752,8 +1729,9 @@
  }
 
+%% =================================================================================================
 \subsubsection{To read the output files}
 
 The output format is: \\
-{\scriptsize
+{
   \texttt{
     date, time-step number, section number,                \\
@@ -1777,5 +1755,4 @@
 
 \begin{table}
-  \scriptsize
   \begin{tabular}{|l|l|l|l|l|}
     \hline
@@ -1791,10 +1768,7 @@
 \end{table}
 
-% ================================================================
-% Steric effect in sea surface height
-% ================================================================
+%% =================================================================================================
 \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
@@ -1818,10 +1792,10 @@
 
 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 
+$\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}$ the global mean sea level
 ($\bar{\eta} = 1/\mathcal{A} \int_S \eta \,ds$).
 
@@ -1833,5 +1807,5 @@
     \mathcal{V} &=  \mathcal{A}  \;\bar{\eta}
   \end{split}
-  \label{eq:MV_nBq}
+  \label{eq:DIA_MV_nBq}
 \end{equation}
 
@@ -1841,18 +1815,18 @@
   \frac{1}{e_3} \partial_t ( e_3\,\rho) + \nabla( \rho \, \textbf{U} )
   = \left. \frac{\textit{emp}}{e_3}\right|_\textit{surface}
-  \label{eq:Co_nBq}
+  \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 
+Its global averaged leads to the total mass change
 
 \begin{equation}
   \partial_t \mathcal{M} = \mathcal{A} \;\overline{\textit{emp}}
-  \label{eq:Mass_nBq}
+  \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:Mass_nBq} and the time derivative of \autoref{eq:MV_nBq} together leads to
+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
 
@@ -1860,17 +1834,17 @@
   \partial_t \bar{\eta} = \frac{\overline{\textit{emp}}}{ \bar{\rho}}
   - \frac{\mathcal{V}}{\mathcal{A}} \;\frac{\partial_t \bar{\rho} }{\bar{\rho}}
-  \label{eq:ssh_nBq}
+  \label{eq:DIA_ssh_nBq}
 \end{equation}
 
-The first term in equation \autoref{eq: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.
+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:Co_nBq}, degenerates into the incompressibility equation:
+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:Co_Bq}
+  % \label{eq:DIA_Co_Bq}
 \]
 
@@ -1879,5 +1853,5 @@
 \[
   \partial_t \mathcal{V} = \mathcal{A} \;\frac{\overline{\textit{emp}}}{\rho_o}
-  % \label{eq:V_Bq}
+  % \label{eq:DIA_V_Bq}
 \]
 
@@ -1888,5 +1862,5 @@
 
 Nevertheless, following \citep{greatbatch_JGR94}, the steric effect on the volume can be diagnosed by
-considering the mass budget of the ocean. 
+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
@@ -1898,5 +1872,5 @@
 \begin{equation}
   \mathcal{M}_o = \mathcal{M} + \rho_o \,\eta_s \,\mathcal{A}
-  \label{eq:M_Bq}
+  \label{eq:DIA_M_Bq}
 \end{equation}
 
@@ -1904,15 +1878,15 @@
 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:M_Bq} leads to a very simple form for the steric height:
+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:steric_Bq}
+  \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.
+\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.
@@ -1928,11 +1902,11 @@
 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:steric_Bq} depends on the type of free surface which is considered.
-In the non linear free surface case, \ie \np{ln\_linssh}\forcode{ = .true.}, it is given by
+
+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:discrete_steric_Bq_nfs}
+  % \label{eq:DIA_discrete_steric_Bq_nfs}
 \]
 
@@ -1944,5 +1918,5 @@
   \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:discrete_steric_Bq_fs}
+  % \label{eq:DIA_discrete_steric_Bq_fs}
 \]
 
@@ -1953,6 +1927,6 @@
 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
+\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.
@@ -1964,5 +1938,5 @@
 \[
   \eta_s = - \frac{1}{\mathcal{A}} \int_D d_a(T,S_o,p_o) \,dv
-  % \label{eq:thermosteric_Bq}
+  % \label{eq:DIA_thermosteric_Bq}
 \]
 
@@ -1971,9 +1945,6 @@
 Both steric and thermosteric sea level are computed in \mdl{diaar5}.
 
-% -------------------------------------------------------------------------------------------------------------
-%       Other Diagnostics
-% -------------------------------------------------------------------------------------------------------------
-\section[Other diagnostics]
-{Other diagnostics}
+%% =================================================================================================
+\section{Other diagnostics}
 \label{sec:DIA_diag_others}
 
@@ -1981,6 +1952,6 @@
 The available ready-to-add diagnostics modules can be found in directory DIA.
 
-\subsection[Depth of various quantities (\textit{diahth.F90})]
-{Depth of various quantities (\protect\mdl{diahth})}
+%% =================================================================================================
+\subsection[Depth of various quantities (\textit{diahth.F90})]{Depth of various quantities (\protect\mdl{diahth})}
 
 Among the available diagnostics the following ones are obtained when defining the \key{diahth} CPP key:
@@ -1994,53 +1965,54 @@
 - the depth of the thermocline (maximum of the vertical temperature gradient) (\mdl{diahth})
 
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_mask_subasins}
-    \caption{
-      \protect\label{fig:mask_subasins}
-		Decomposition of the World Ocean (here ORCA2) into sub-basin used in to
-      compute the heat and salt transports as well as the meridional stream-function:
-      Atlantic basin (red), Pacific basin (green), Indian basin (bleue), Indo-Pacific basin (bleue+green).
-		Note that semi-enclosed seas (Red, Med and Baltic seas) as well as Hudson Bay are removed from the sub-basins.
-      Note also that the Arctic Ocean has been split into Atlantic and Pacific basins along the North fold line.
-    }
-  \end{center}
-\end{figure}  
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -----------------------------------------------------------
-%       CMIP specific diagnostics 
-% -----------------------------------------------------------
-\subsection[CMIP specific diagnostics (\textit{diaar5.F90}, \textit{diaptr.F90})]
-{CMIP specific diagnostics (\protect\mdl{diaar5})}
+  \centering
+  \includegraphics[width=0.66\textwidth]{DIA_mask_subasins}
+  \caption[Decomposition of the World Ocean to compute transports as well as
+  the meridional stream-function]{
+    Decomposition of the World Ocean (here ORCA2) into sub-basin used in to
+    compute the heat and salt transports as well as the meridional stream-function:
+    Atlantic basin (red), Pacific basin (green),
+    Indian basin (blue), Indo-Pacific basin (blue+green).
+    Note that semi-enclosed seas (Red, Med and Baltic seas) as well as
+    Hudson Bay are removed from the sub-basins.
+    Note also that the Arctic Ocean has been split into Atlantic and
+    Pacific basins along the North fold line.
+  }
+  \label{fig:DIA_mask_subasins}
+\end{figure}
+
+%% =================================================================================================
+\subsection[CMIP specific diagnostics (\textit{diaar5.F90}, \textit{diaptr.F90})]{CMIP specific diagnostics (\protect\mdl{diaar5})}
 
 A series of diagnostics has been added in the \mdl{diaar5} and \mdl{diaptr}.
 In \mdl{diaar5} they correspond to outputs that are required for AR5 simulations (CMIP5)
 (see also \autoref{sec:DIA_steric} for one of them).
-The module \mdl{diaar5} is active when one of the following outputs is required : global total volume (voltot), global mean ssh (sshtot), global total mass (masstot), global mean temperature (temptot), global mean ssh steric (sshsteric), global mean ssh thermosteric (sshthster), global mean salinity (saltot), sea water pressure at sea floor (botpres), dynamic sea surface height (sshdyn).
-
-In \mdl{diaptr} when \np{ln\_diaptr}\forcode{ = .true.} 
-(see the \textit{\ngn{namptr} } namelist below) can be computed on-line the poleward heat and salt transports, their advective and diffusive component, and the meriodional stream function .
-When \np{ln\_subbas}\forcode{ = .true.}, transports and stream function are computed for the Atlantic, Indian,
+The module \mdl{diaar5} is active when one of the following outputs is required :
+global total volume (voltot), global mean ssh (sshtot), global total mass (masstot), global mean temperature (temptot),
+global mean ssh steric (sshsteric), global mean ssh thermosteric (sshthster), global mean salinity (saltot),
+sea water pressure at sea floor (botpres), dynamic sea surface height (sshdyn).
+
+In \mdl{diaptr} when \np[=.true.]{ln_diaptr}{ln\_diaptr}
+(see the \nam{ptr}{ptr} namelist below) can be computed on-line the poleward heat and salt transports,
+their advective and diffusive component, and the meriodional stream function .
+When \np[=.true.]{ln_subbas}{ln\_subbas}, transports and stream function are computed for the Atlantic, Indian,
 Pacific and Indo-Pacific Oceans (defined north of 30\deg{S}) as well as for the World Ocean.
 The sub-basin decomposition requires an input file (\ifile{subbasins}) which contains three 2D mask arrays,
-the Indo-Pacific mask been deduced from the sum of the Indian and Pacific mask (\autoref{fig:mask_subasins}).
-
-%------------------------------------------namptr-----------------------------------------
-
-\nlst{namptr} 
-%-----------------------------------------------------------------------------------------
-
-% -----------------------------------------------------------
-%       25 hour mean and hourly Surface, Mid and Bed 
-% -----------------------------------------------------------
+the Indo-Pacific mask been deduced from the sum of the Indian and Pacific mask (\autoref{fig:DIA_mask_subasins}).
+
+\begin{listing}
+  \nlst{namptr}
+  \caption{\forcode{&namptr}}
+  \label{lst:namptr}
+\end{listing}
+
+%% =================================================================================================
 \subsection{25 hour mean output for tidal models}
 
-%------------------------------------------nam_dia25h-------------------------------------
-
-\nlst{nam_dia25h}
-%-----------------------------------------------------------------------------------------
+\begin{listing}
+  \nlst{nam_dia25h}
+  \caption{\forcode{&nam_dia25h}}
+  \label{lst:nam_dia25h}
+\end{listing}
 
 A module is available to compute a crudely detided M2 signal by obtaining a 25 hour mean.
@@ -2049,13 +2021,12 @@
 This diagnostic is actived with the logical $ln\_dia25h$.
 
-% -----------------------------------------------------------
-%     Top Middle and Bed hourly output
-% -----------------------------------------------------------
+%% =================================================================================================
 \subsection{Top middle and bed hourly output}
 
-%------------------------------------------nam_diatmb-----------------------------------------------------
-
-\nlst{nam_diatmb}
-%----------------------------------------------------------------------------------------------------------
+\begin{listing}
+  \nlst{nam_diatmb}
+  \caption{\forcode{&nam_diatmb}}
+  \label{lst:nam_diatmb}
+\end{listing}
 
 A module is available to output the surface (top), mid water and bed diagnostics of a set of standard variables.
@@ -2065,7 +2036,5 @@
 This diagnostic is actived with the logical $ln\_diatmb$.
 
-% -----------------------------------------------------------
-%     Courant numbers
-% -----------------------------------------------------------
+%% =================================================================================================
 \subsection{Courant numbers}
 
@@ -2075,5 +2044,5 @@
 \[
   C_u = |u|\frac{\rdt}{e_{1u}}, \quad C_v = |v|\frac{\rdt}{e_{2v}}, \quad C_w = |w|\frac{\rdt}{e_{3w}}
-  % \label{eq:CFL}
+  % \label{eq:DIA_CFL}
 \]
 
@@ -2084,5 +2053,5 @@
 Values greater than 1 indicate that information is propagated across more than one grid cell in a single time step.
 
-The variables can be activated by setting the \np{nn\_diacfl} namelist parameter to 1 in the \ngn{namctl} namelist.
+The variables can be activated by setting the \np{nn_diacfl}{nn\_diacfl} namelist parameter to 1 in the \nam{ctl}{ctl} namelist.
 The diagnostics will be written out to an ascii file named cfl\_diagnostics.ascii.
 In this file the maximum value of $C_u$, $C_v$, and $C_w$ are printed at each timestep along with the coordinates of
@@ -2090,11 +2059,7 @@
 At the end of the model run the maximum value of $C_u$, $C_v$, and $C_w$ for the whole model run is printed along
 with the coordinates of each.
-The maximum values from the run are also copied to the ocean.output file. 
-
-% ================================================================
-
-\biblio
-
-\pindex
+The maximum values from the run are also copied to the ocean.output file.
+
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DIU.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DIU.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DIU.tex	(revision 12143)
@@ -2,48 +2,58 @@
 
 \begin{document}
-% ================================================================
-% Diurnal SST models (DIU)
-% Edited by James While
-% ================================================================
+
 \chapter{Diurnal SST Models (DIU)}
 \label{chap:DIU}
 
-\minitoc
+\thispagestyle{plain}
 
+\chaptertoc
 
-\newpage
-$\ $\newline % force a new line
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
 
 Code to produce an estimate of the diurnal warming and cooling of the sea surface skin
-temperature (skin SST) is found in the DIU directory.  
+temperature (skin SST) is found in the DIU directory.
 The skin temperature can be split into three parts:
 \begin{itemize}
-\item
-  A foundation SST which is free from diurnal warming.
-\item
-  A warm layer, typically ~3\,m thick,
+\item A foundation SST which is free from diurnal warming.
+\item A warm layer, typically ~3\,m thick,
   where heating from solar radiation can cause a warm stably stratified layer during the daytime
-\item
-  A cool skin, a thin layer, approximately ~1\, mm thick,
+\item A cool skin, a thin layer, approximately ~1\, mm thick,
   where long wave cooling is dominant and cools the immediate ocean surface.
 \end{itemize}
 
 Models are provided for both the warm layer, \mdl{diurnal\_bulk}, and the cool skin, \mdl{cool\_skin}.
-Foundation SST is not considered as it can be obtained either from the main NEMO model
-(\ie from the temperature of the top few model levels) or from some other source.  
+Foundation SST is not considered as it can be obtained either from the main \NEMO\ model
+(\ie\ from the temperature of the top few model levels) or from some other source.
 It must be noted that both the cool skin and warm layer models produce estimates of the change in temperature
 ($\Delta T_{\mathrm{cs}}$ and $\Delta T_{\mathrm{wl}}$) and
 both must be added to a foundation SST to obtain the true skin temperature.
 
-Both the cool skin and warm layer models are controlled through the namelist \ngn{namdiu}:
+Both the cool skin and warm layer models are controlled through the namelist \nam{diu}{diu}:
 
-\nlst{namdiu}
+\begin{listing}
+  \nlst{namdiu}
+  \caption{\forcode{&namdiu}}
+  \label{lst:namdiu}
+\end{listing}
+
 This namelist contains only two variables:
 \begin{description}
-\item[\np{ln\_diurnal}]
-  A logical switch for turning on/off both the cool skin and warm layer.
-\item[\np{ln\_diurnal\_only}]
-  A logical switch which if \forcode{.true.} will run the diurnal model without the other dynamical parts of NEMO.
-  \np{ln\_diurnal\_only} must be \forcode{.false.} if \np{ln\_diurnal} is \forcode{.false.}.
+\item [{\np{ln_diurnal}{ln\_diurnal}}] A logical switch for turning on/off both the cool skin and warm layer.
+\item [{\np{ln_diurnal_only}{ln\_diurnal\_only}}] A logical switch which if \forcode{.true.} will run the diurnal model without the other dynamical parts of \NEMO.
+  \np{ln_diurnal_only}{ln\_diurnal\_only} must be \forcode{.false.} if \np{ln_diurnal}{ln\_diurnal} is \forcode{.false.}.
 \end{description}
 
@@ -53,10 +63,9 @@
 Initialisation is through the restart file.
 Specifically the code will expect the presence of the 2-D variable ``Dsst'' to initialise the warm layer.
-The cool skin model, which is determined purely by the instantaneous fluxes, has no initialisation variable.  
+The cool skin model, which is determined purely by the instantaneous fluxes, has no initialisation variable.
 
-%===============================================================
+%% =================================================================================================
 \section{Warm layer model}
-\label{sec:warm_layer_sec}
-%===============================================================
+\label{sec:DIU_warm_layer_sec}
 
 The warm layer is calculated using the model of \citet{takaya.bidlot.ea_JGR10} (TAKAYA10 model hereafter).
@@ -65,9 +74,9 @@
 \frac{\partial{\Delta T_{\mathrm{wl}}}}{\partial{t}}&=&\frac{Q(\nu+1)}{D_T\rho_w c_p
 \nu}-\frac{(\nu+1)ku^*_{w}f(L_a)\Delta T}{D_T\Phi\!\left(\frac{D_T}{L}\right)} \mbox{,}
-\label{eq:ecmwf1} \\
-L&=&\frac{\rho_w c_p u^{*^3}_{w}}{\kappa g \alpha_w Q }\mbox{,}\label{eq:ecmwf2}
+\label{eq:DIU_ecmwf1} \\
+L&=&\frac{\rho_w c_p u^{*^3}_{w}}{\kappa g \alpha_w Q }\mbox{,}\label{eq:DIU_ecmwf2}
 \end{align}
 where $\Delta T_{\mathrm{wl}}$ is the temperature difference between the top of the warm layer and the depth $D_T=3$\,m at which there is assumed to be no diurnal signal.
-In equation (\autoref{eq:ecmwf1}) $\alpha_w=2\times10^{-4}$ is the thermal expansion coefficient of water,
+In equation (\autoref{eq:DIU_ecmwf1}) $\alpha_w=2\times10^{-4}$ is the thermal expansion coefficient of water,
 $\kappa=0.4$ is von K\'{a}rm\'{a}n's constant, $c_p$ is the heat capacity at constant pressure of sea water,
 $\rho_w$ is the water density, and $L$ is the Monin-Obukhov length.
@@ -79,14 +88,14 @@
 the relationship $u^*_{w} = u_{10}\sqrt{\frac{C_d\rho_a}{\rho_w}}$, where $C_d$ is the drag coefficient,
 and $\rho_a$ is the density of air.
-The symbol $Q$ in equation (\autoref{eq:ecmwf1}) is the instantaneous total thermal energy flux into
+The symbol $Q$ in equation (\autoref{eq:DIU_ecmwf1}) is the instantaneous total thermal energy flux into
 the diurnal layer, \ie
 \[
   Q = Q_{\mathrm{sol}} + Q_{\mathrm{lw}} + Q_{\mathrm{h}}\mbox{,}
-  % \label{eq:e_flux_eqn}
+  % \label{eq:DIU_e_flux_eqn}
 \]
 where $Q_{\mathrm{h}}$ is the sensible and latent heat flux, $Q_{\mathrm{lw}}$ is the long wave flux,
 and $Q_{\mathrm{sol}}$ is the solar flux absorbed within the diurnal warm layer.
 For $Q_{\mathrm{sol}}$ the 9 term representation of \citet{gentemann.minnett.ea_JGR09} is used.
-In equation \autoref{eq:ecmwf1} the function $f(L_a)=\max(1,L_a^{\frac{2}{3}})$,
+In equation \autoref{eq:DIU_ecmwf1} the function $f(L_a)=\max(1,L_a^{\frac{2}{3}})$,
 where $L_a=0.3$\footnote{
   This is a global average value, more accurately $L_a$ could be computed as $L_a=(u^*_{w}/u_s)^{\frac{1}{2}}$,
@@ -99,11 +108,11 @@
 4\zeta^2}{1+3\zeta+0.25\zeta^2} &(\zeta \ge 0) \\
                                     (1 - 16\zeta)^{-\frac{1}{2}} & (\zeta < 0) \mbox{,}
-                                    \end{array} \right. \label{eq:stab_func_eqn}
+                                    \end{array} \right. \label{eq:DIU_stab_func_eqn}
 \end{equation}
-where $\zeta=\frac{D_T}{L}$.  It is clear that the first derivative of (\autoref{eq:stab_func_eqn}),
-and thus of (\autoref{eq:ecmwf1}), is discontinuous at $\zeta=0$ (\ie $Q\rightarrow0$ in
-equation (\autoref{eq:ecmwf2})).
+where $\zeta=\frac{D_T}{L}$.  It is clear that the first derivative of (\autoref{eq:DIU_stab_func_eqn}),
+and thus of (\autoref{eq:DIU_ecmwf1}), is discontinuous at $\zeta=0$ (\ie\ $Q\rightarrow0$ in
+equation (\autoref{eq:DIU_ecmwf2})).
 
-The two terms on the right hand side of (\autoref{eq:ecmwf1}) represent different processes.
+The two terms on the right hand side of (\autoref{eq:DIU_ecmwf1}) represent different processes.
 The first term is simply the diabatic heating or cooling of the diurnal warm layer due to
 thermal energy fluxes into and out of the layer.
@@ -111,15 +120,12 @@
 In practice the second term acts as a relaxation on the temperature.
 
-%===============================================================
-
+%% =================================================================================================
 \section{Cool skin model}
-\label{sec:cool_skin_sec}
-
-%===============================================================
+\label{sec:DIU_cool_skin_sec}
 
 The cool skin is modelled using the framework of \citet{saunders_JAS67} who used a formulation of the near surface temperature difference based upon the heat flux and the friction velocity $u^*_{w}$.
 As the cool skin is so thin (~1\,mm) we ignore the solar flux component to the heat flux and the Saunders equation for the cool skin temperature difference $\Delta T_{\mathrm{cs}}$ becomes
 \[
-  % \label{eq:sunders_eqn}
+  % \label{eq:DIU_sunders_eqn}
   \Delta T_{\mathrm{cs}}=\frac{Q_{\mathrm{ns}}\delta}{k_t} \mbox{,}
 \]
@@ -128,5 +134,5 @@
 $\delta$ is the thickness of the skin layer and is given by
 \begin{equation}
-\label{eq:sunders_thick_eqn}
+\label{eq:DIU_sunders_thick_eqn}
 \delta=\frac{\lambda \mu}{u^*_{w}} \mbox{,}
 \end{equation}
@@ -134,10 +140,10 @@
 \citet{saunders_JAS67} suggested varied between 5 and 10.
 
-The value of $\lambda$ used in equation (\autoref{eq:sunders_thick_eqn}) is that of \citet{artale.iudicone.ea_JGR02},
+The value of $\lambda$ used in equation (\autoref{eq:DIU_sunders_thick_eqn}) is that of \citet{artale.iudicone.ea_JGR02},
 which is shown in \citet{tu.tsuang_GRL05} to outperform a number of other parametrisations at
 both low and high wind speeds.
 Specifically,
 \[
-  % \label{eq:artale_lambda_eqn}
+  % \label{eq:DIU_artale_lambda_eqn}
   \lambda = \frac{ 8.64\times10^4 u^*_{w} k_t }{ \rho c_p h \mu \gamma }\mbox{,}
 \]
@@ -145,5 +151,5 @@
 $\gamma$ is a dimensionless function of wind speed $u$:
 \[
-  % \label{eq:artale_gamma_eqn}
+  % \label{eq:DIU_artale_gamma_eqn}
   \gamma =
   \begin{cases}
@@ -154,7 +160,5 @@
 \]
 
-\biblio
-
-\pindex
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DOM.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DOM.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DOM.tex	(revision 12143)
@@ -2,127 +2,174 @@
 
 \begin{document}
-% ================================================================
-% Chapter 2 ——— Space and Time Domain (DOM)
-% ================================================================
+
 \chapter{Space Domain (DOM)}
 \label{chap:DOM}
 
-\minitoc
-
-% Missing things:
-% 	- istate: description of the initial state   ==> this has to be put elsewhere..
-%                  perhaps in MISC ?  By the way the initialisation of T S and dynamics 
-%                  should be put outside of DOM routine (better with TRC staff and off-line
-%                  tracers)
-% 	-geo2ocean:  how to switch from geographic to mesh coordinate
-%     - domclo:  closed sea and lakes.... management of closea sea area : specific to global configuration, both forced and coupled
-
-\newpage
-
-Having defined the continuous equations in \autoref{chap:PE} and chosen a time discretization \autoref{chap:STP},
-we need to choose a discretization on a grid, and numerical algorithms.
+% Missing things
+% -    istate: description of the initial state   ==> this has to be put elsewhere..
+%              perhaps in MISC ?  By the way the initialisation of T S and dynamics
+%              should be put outside of DOM routine (better with TRC staff and off-line
+%              tracers)
+% - geo2ocean: how to switch from geographic to mesh coordinate
+% -    domclo: closed sea and lakes....
+%              management of closea sea area: specific to global cfg, both forced and coupled
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{0.8\textwidth}{l||X|X}
+    Release                                                                                 &
+    Author(s)                                                                               &
+    Modifications                                                                           \\
+    \hline
+    {\em 4.0                                                                              } &
+    {\em Simon M\"{u}ller \& Andrew Coward \newline \newline
+      Simona Flavoni and Tim Graham                                                       } &
+    {\em Compatibility changes: many options moved to external domain configuration tools
+      (see \autoref{apdx:DOMCFG}). \newline
+      Updates                                                                             } \\
+    {\em 3.6                                                                              } &
+    {\em Rachid Benshila, Christian \'{E}th\'{e}, Pierre Mathiot and Gurvan Madec         } &
+    {\em Updates                                                                          } \\
+    {\em $\leq$ 3.4                                                                       } &
+    {\em Gurvan Madec and S\'{e}bastien Masson                                            } &
+    {\em First version                                                                    }
+  \end{tabularx}
+}
+
+\clearpage
+
+Having defined the continuous equations in \autoref{chap:MB} and
+chosen a time discretisation \autoref{chap:TD},
+we need to choose a grid for spatial discretisation and related numerical algorithms.
 In the present chapter, we provide a general description of the staggered grid used in \NEMO,
-and other information relevant to the main directory routines as well as the DOM (DOMain) directory.
-
-% ================================================================
-% Fundamentals of the Discretisation
-% ================================================================
+and other relevant information about the DOM (DOMain) source code modules.
+
+%% =================================================================================================
 \section{Fundamentals of the discretisation}
 \label{sec:DOM_basics}
 
-% -------------------------------------------------------------------------------------------------------------
-%        Arrangement of Variables 
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \subsection{Arrangement of variables}
 \label{subsec:DOM_cell}
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!tb]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_cell}
-    \caption{
-      \protect\label{fig:cell}
-      Arrangement of variables.
-      $t$ indicates scalar points where temperature, salinity, density, pressure and
-      horizontal divergence are defined.
-      $(u,v,w)$ indicates vector points, and $f$ indicates vorticity points where both relative and
-      planetary vorticities are defined.
-    }
-  \end{center}
+\begin{figure}
+  \centering
+  \includegraphics[width=0.33\textwidth]{DOM_cell}
+  \caption[Arrangement of variables in the unit cell of space domain]{
+    Arrangement of variables in the unit cell of space domain.
+    $t$ indicates scalar points where
+    temperature, salinity, density, pressure and horizontal divergence are defined.
+    $(u,v,w)$ indicates vector points, and $f$ indicates vorticity points where
+    both relative and planetary vorticities are defined.}
+  \label{fig:DOM_cell}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-The numerical techniques used to solve the Primitive Equations in this model are based on the traditional,
-centred second-order finite difference approximation.
-Special attention has been given to the homogeneity of the solution in the three space directions.
+
+The numerical techniques used to solve the Primitive Equations in this model are based on
+the traditional, centred second-order finite difference approximation.
+Special attention has been given to the homogeneity of the solution in the three spatial directions.
 The arrangement of variables is the same in all directions.
-It consists of cells centred on scalar points ($t$, $S$, $p$, $\rho$) with vector points $(u, v, w)$ defined in
-the centre of each face of the cells (\autoref{fig:cell}).
-This is the generalisation to three dimensions of the well-known ``C'' grid in Arakawa's classification
-\citep{mesinger.arakawa_bk76}.
-The relative and planetary vorticity, $\zeta$ and $f$, are defined in the centre of each vertical edge and
-the barotropic stream function $\psi$ is defined at horizontal points overlying the $\zeta$ and $f$-points.
-
-The ocean mesh (\ie the position of all the scalar and vector points) is defined by the transformation that
-gives $(\lambda,\varphi,z)$ as a function of $(i,j,k)$.
-The grid-points are located at integer or integer and a half value of $(i,j,k)$ as indicated on \autoref{tab:cell}.
-In all the following, subscripts $u$, $v$, $w$, $f$, $uw$, $vw$ or $fw$ indicate the position of
-the grid-point where the scale factors are defined.
-Each scale factor is defined as the local analytical value provided by \autoref{eq:scale_factors}.
+It consists of cells centred on scalar points ($t$, $S$, $p$, $\rho$) with
+vector points $(u, v, w)$ defined in the centre of each face of the cells (\autoref{fig:DOM_cell}).
+This is the generalisation to three dimensions of the well-known ``C'' grid in
+Arakawa's classification \citep{mesinger.arakawa_bk76}.
+The relative and planetary vorticity, $\zeta$ and $f$, are defined in the centre of each
+vertical edge and the barotropic stream function $\psi$ is defined at horizontal points overlying
+the $\zeta$ and $f$-points.
+
+The ocean mesh (\ie\ the position of all the scalar and vector points) is defined by
+the transformation that gives $(\lambda,\varphi,z)$ as a function of $(i,j,k)$.
+The grid-points are located at integer or integer and a half value of $(i,j,k)$ as indicated on
+\autoref{tab:DOM_cell}.
+In all the following,
+subscripts $u$, $v$, $w$, $f$, $uw$, $vw$ or $fw$ indicate the position of the grid-point where
+the scale factors are defined.
+Each scale factor is defined as the local analytical value provided by \autoref{eq:MB_scale_factors}.
 As a result, the mesh on which partial derivatives $\pd[]{\lambda}$, $\pd[]{\varphi}$ and
-$\pd[]{z}$ are evaluated in a uniform mesh with a grid size of unity.
-Discrete partial derivatives are formulated by the traditional, centred second order finite difference approximation
-while the scale factors are chosen equal to their local analytical value.
+$\pd[]{z}$ are evaluated is a uniform mesh with a grid size of unity.
+Discrete partial derivatives are formulated by
+the traditional, centred second order finite difference approximation while
+the scale factors are chosen equal to their local analytical value.
 An important point here is that the partial derivative of the scale factors must be evaluated by
 centred finite difference approximation, not from their analytical expression.
-This preserves the symmetry of the discrete set of equations and therefore satisfies many of
-the continuous properties (see \autoref{apdx:C}).
+This preserves the symmetry of the discrete set of equations and
+therefore satisfies many of the continuous properties (see \autoref{apdx:INVARIANTS}).
 A similar, related remark can be made about the domain size:
-when needed, an area, volume, or the total ocean depth must be evaluated as the sum of the relevant scale factors
-(see \autoref{eq:DOM_bar} in the next section).
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{table}[!tb]
-  \begin{center}
-    \begin{tabular}{|p{46pt}|p{56pt}|p{56pt}|p{56pt}|}
-      \hline
-      T	& $i 		 $ & $j      $ & $k      $ \\
-      \hline
-      u	& $i + 1/2$ & $j      $ & $k      $ \\
-      \hline
-      v	& $i	 	 $ & $j + 1/2$ & $k      $ \\
-      \hline
-      w	& $i	 	 $ & $j      $ & $k + 1/2$ \\
-      \hline
-      f	& $i + 1/2$ & $j + 1/2$ & $k      $ \\
-      \hline
-      uw	& $i + 1/2$ & $j      $ & $k + 1/2$ \\
-      \hline
-      vw	& $i	 	 $ & $j + 1/2$ & $k + 1/2$ \\
-      \hline
-      fw	& $i + 1/2$ & $j + 1/2$ & $k + 1/2$ \\
-      \hline
-    \end{tabular}
-    \caption{
-      \protect\label{tab:cell}
-      Location of grid-points as a function of integer or integer and a half value of the column, line or level.
-      This indexing is only used for the writing of the semi -discrete equation.
-      In the code, the indexing uses integer values only and has a reverse direction in the vertical
-      (see \autoref{subsec:DOM_Num_Index})
-    }
-  \end{center}
+when needed, an area, volume, or the total ocean depth must be evaluated as
+the product or sum of the relevant scale factors (see \autoref{eq:DOM_bar} in the next section).
+
+\begin{table}
+  \centering
+  \begin{tabular}{|l|l|l|l|}
+    \hline
+    t   & $i      $ & $j      $ & $k      $ \\
+    \hline
+    u   & $i + 1/2$ & $j      $ & $k      $ \\
+    \hline
+    v   & $i      $ & $j + 1/2$ & $k      $ \\
+    \hline
+    w   & $i      $ & $j      $ & $k + 1/2$ \\
+    \hline
+    f   & $i + 1/2$ & $j + 1/2$ & $k      $ \\
+    \hline
+    uw  & $i + 1/2$ & $j      $ & $k + 1/2$ \\
+    \hline
+    vw  & $i      $ & $j + 1/2$ & $k + 1/2$ \\
+    \hline
+    fw  & $i + 1/2$ & $j + 1/2$ & $k + 1/2$ \\
+    \hline
+  \end{tabular}
+  \caption[Location of grid-points]{
+    Location of grid-points as a function of integer or
+    integer and a half value of the column, line or level.
+    This indexing is only used for the writing of the semi-discrete equations.
+    In the code, the indexing uses integer values only and
+    is positive downwards in the vertical with $k=1$ at the surface.
+    (see \autoref{subsec:DOM_Num_Index})}
+  \label{tab:DOM_cell}
 \end{table}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -------------------------------------------------------------------------------------------------------------
-%        Vector Invariant Formulation 
-% -------------------------------------------------------------------------------------------------------------
+
+Note that the definition of the scale factors
+(\ie\ as the analytical first derivative of the transformation that
+results in $(\lambda,\varphi,z)$ as a function of $(i,j,k)$)
+is specific to the \NEMO\ model \citep{marti.madec.ea_JGR92}.
+As an example, a scale factor in the $i$ direction is defined locally at a $t$-point,
+whereas many other models on a C grid choose to define such a scale factor as
+the distance between the $u$-points on each side of the $t$-point.
+Relying on an analytical transformation has two advantages:
+firstly, there is no ambiguity in the scale factors appearing in the discrete equations,
+since they are first introduced in the continuous equations;
+secondly, analytical transformations encourage good practice by
+the definition of smoothly varying grids
+(rather than allowing the user to set arbitrary jumps in thickness between adjacent layers)
+\citep{treguier.dukowicz.ea_JGR96}.
+An example of the effect of such a choice is shown in \autoref{fig:DOM_zgr_e3}.
+\begin{figure}
+  \centering
+  \includegraphics[width=0.5\textwidth]{DOM_zgr_e3}
+  \caption[Comparison of grid-point position, vertical grid-size and scale factors]{
+    Comparison of (a) traditional definitions of grid-point position and grid-size in the vertical,
+    and (b) analytically derived grid-point position and scale factors.
+    For both grids here, the same $w$-point depth has been chosen but
+    in (a) the $t$-points are set half way between $w$-points while
+    in (b) they are defined from an analytical function:
+    $z(k) = 5 \, (k - 1/2)^3 - 45 \, (k - 1/2)^2 + 140 \, (k - 1/2) - 150$.
+    Note the resulting difference between the value of the grid-size $\Delta_k$ and
+    those of the scale factor $e_k$.}
+  \label{fig:DOM_zgr_e3}
+\end{figure}
+
+%% =================================================================================================
 \subsection{Discrete operators}
 \label{subsec:DOM_operators}
 
-Given the values of a variable $q$ at adjacent points, the differencing and averaging operators at
-the midpoint between them are:
+Given the values of a variable $q$ at adjacent points,
+the differencing and averaging operators at the midpoint between them are:
 \begin{alignat*}{2}
-  % \label{eq:di_mi}
+  % \label{eq:DOM_di_mi}
   \delta_i [q]      &= &       &q (i + 1/2) - q (i - 1/2) \\
   \overline q^{\, i} &= &\big\{ &q (i + 1/2) + q (i - 1/2) \big\} / 2
@@ -130,27 +177,27 @@
 
 Similar operators are defined with respect to $i + 1/2$, $j$, $j + 1/2$, $k$, and $k + 1/2$.
-Following \autoref{eq:PE_grad} and \autoref{eq:PE_lap}, the gradient of a variable $q$ defined at
-a $t$-point has its three components defined at $u$-, $v$- and $w$-points while
-its Laplacian is defined at $t$-point.
+Following \autoref{eq:MB_grad} and \autoref{eq:MB_lap},
+the gradient of a variable $q$ defined at a $t$-point has
+its three components defined at $u$-, $v$- and $w$-points while
+its Laplacian is defined at the $t$-point.
 These operators have the following discrete forms in the curvilinear $s$-coordinates system:
-\[
+\begin{gather*}
   % \label{eq:DOM_grad}
   \nabla q \equiv   \frac{1}{e_{1u}} \delta_{i + 1/2} [q] \; \, \vect i
                   + \frac{1}{e_{2v}} \delta_{j + 1/2} [q] \; \, \vect j
-                  + \frac{1}{e_{3w}} \delta_{k + 1/2} [q] \; \, \vect k
-\]
-\begin{multline*}
+                  + \frac{1}{e_{3w}} \delta_{k + 1/2} [q] \; \, \vect k \\
   % \label{eq:DOM_lap}
   \Delta q \equiv   \frac{1}{e_{1t} \, e_{2t} \, e_{3t}}
                     \; \lt[   \delta_i \lt( \frac{e_{2u} \, e_{3u}}{e_{1u}} \; \delta_{i + 1/2} [q] \rt)
-                            + \delta_j \lt( \frac{e_{1v} \, e_{3v}}{e_{2v}} \; \delta_{j + 1/2} [q] \rt) \; \rt] \\
+                            + \delta_j \lt( \frac{e_{1v} \, e_{3v}}{e_{2v}} \; \delta_{j + 1/2} [q] \rt) \; \rt]
                   + \frac{1}{e_{3t}}
                               \delta_k \lt[ \frac{1              }{e_{3w}} \; \delta_{k + 1/2} [q] \rt]
-\end{multline*}
-
-Following \autoref{eq:PE_curl} and \autoref{eq:PE_div}, a vector $\vect A = (a_1,a_2,a_3)$ defined at
-vector points $(u,v,w)$ has its three curl components defined at $vw$-, $uw$, and $f$-points, and
+\end{gather*}
+
+Following \autoref{eq:MB_curl} and \autoref{eq:MB_div},
+a vector $\vect A = (a_1,a_2,a_3)$ defined at vector points $(u,v,w)$ has
+its three curl components defined at $vw$-, $uw$, and $f$-points, and
 its divergence defined at $t$-points:
-\begin{multline}
+\begin{multline*}
 % \label{eq:DOM_curl}
   \nabla \times \vect A \equiv   \frac{1}{e_{2v} \, e_{3vw}}
@@ -163,14 +210,14 @@
                                  \Big[   \delta_{i + 1/2} (e_{2v} \, a_2)
                                        - \delta_{j + 1/2} (e_{1u} \, a_1) \Big] \vect k
-\end{multline}
-\begin{equation}
+\end{multline*}
+\[
 % \label{eq:DOM_div}
   \nabla \cdot \vect A \equiv   \frac{1}{e_{1t} \, e_{2t} \, e_{3t}}
                                 \Big[ \delta_i (e_{2u} \, e_{3u} \, a_1) + \delta_j (e_{1v} \, e_{3v} \, a_2) \Big]
                               + \frac{1}{e_{3t}} \delta_k (a_3)
-\end{equation}
-
-The vertical average over the whole water column denoted by an overbar becomes for a quantity $q$ which
-is a masked field (i.e. equal to zero inside solid area):
+\]
+
+The vertical average over the whole water column is denoted by an overbar and
+is for a masked field $q$ (\ie\ a quantity that is equal to zero inside solid areas):
 \begin{equation}
   \label{eq:DOM_bar}
@@ -178,6 +225,7 @@
 \end{equation}
 where $H_q$  is the ocean depth, which is the masked sum of the vertical scale factors at $q$ points,
-$k^b$ and $k^o$ are the bottom and surface $k$-indices, and the symbol $k^o$ refers to a summation over
-all grid points of the same type in the direction indicated by the subscript (here $k$).
+$k^b$ and $k^o$ are the bottom and surface $k$-indices,
+and the symbol $\sum \limits_k$ refers to a summation over all grid points of the same type in
+the direction indicated by the subscript (here $k$).
 
 In continuous form, the following properties are satisfied:
@@ -189,13 +237,14 @@
 \end{gather}
 
-It is straightforward to demonstrate that these properties are verified locally in discrete form as soon as
-the scalar $q$ is taken at $t$-points and the vector $\vect A$ has its components defined at
+It is straightforward to demonstrate that these properties are verified locally in discrete form as
+soon as the scalar $q$ is taken at $t$-points and the vector $\vect A$ has its components defined at
 vector points $(u,v,w)$.
 
-Let $a$ and $b$ be two fields defined on the mesh, with value zero inside continental area.
-Using integration by parts it can be shown that the differencing operators ($\delta_i$, $\delta_j$ and $\delta_k$)
-are skew-symmetric linear operators, and further that the averaging operators $\overline{\cdots}^{\, i}$,
-$\overline{\cdots}^{\, j}$ and $\overline{\cdots}^{\, k}$) are symmetric linear operators, \ie
-\begin{alignat}{4}
+Let $a$ and $b$ be two fields defined on the mesh, with a value of zero inside continental areas.
+It can be shown that the differencing operators ($\delta_i$, $\delta_j$ and
+$\delta_k$) are skew-symmetric linear operators,
+and further that the averaging operators ($\overline{\cdots}^{\, i}$, $\overline{\cdots}^{\, j}$ and
+$\overline{\cdots}^{\, k}$) are symmetric linear operators, \ie
+\begin{alignat}{5}
   \label{eq:DOM_di_adj}
   &\sum \limits_i a_i \; \delta_i [b]      &\equiv &- &&\sum \limits_i \delta      _{   i + 1/2} [a] &b_{i + 1/2} \\
@@ -204,846 +253,447 @@
 \end{alignat}
 
-In other words, the adjoint of the differencing and averaging operators are $\delta_i^* = \delta_{i + 1/2}$ and 
+In other words,
+the adjoint of the differencing and averaging operators are $\delta_i^* = \delta_{i + 1/2}$ and
 $(\overline{\cdots}^{\, i})^* = \overline{\cdots}^{\, i + 1/2}$, respectively.
-These two properties will be used extensively in the \autoref{apdx:C} to
+These two properties will be used extensively in the \autoref{apdx:INVARIANTS} to
 demonstrate integral conservative properties of the discrete formulation chosen.
 
-% -------------------------------------------------------------------------------------------------------------
-%        Numerical Indexing 
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \subsection{Numerical indexing}
 \label{subsec:DOM_Num_Index}
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!tb]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_index_hor}
-    \caption{
-      \protect\label{fig:index_hor}
-      Horizontal integer indexing used in the \fortran code.
-      The dashed area indicates the cell in which variables contained in arrays have the same $i$- and $j$-indices
-    }
-  \end{center}
+\begin{figure}
+  \centering
+  \includegraphics[width=0.33\textwidth]{DOM_index_hor}
+  \caption[Horizontal integer indexing]{
+    Horizontal integer indexing used in the \fortran\ code.
+    The dashed area indicates the cell in which
+    variables contained in arrays have the same $i$- and $j$-indices}
+  \label{fig:DOM_index_hor}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-The array representation used in the \fortran code requires an integer indexing while
-the analytical definition of the mesh (see \autoref{subsec:DOM_cell}) is associated with the use of
-integer values for $t$-points and both integer and integer and a half values for all the other points.
-Therefore a specific integer indexing must be defined for points other than $t$-points
-(\ie velocity and vorticity grid-points).
-Furthermore, the direction of the vertical indexing has been changed so that the surface level is at $k = 1$.
-
-% -----------------------------------
-%        Horizontal Indexing 
-% -----------------------------------
+
+The array representation used in the \fortran\ code requires an integer indexing.
+However, the analytical definition of the mesh (see \autoref{subsec:DOM_cell}) is associated with
+the use of integer values for $t$-points only while
+all the other points involve integer and a half values.
+Therefore, a specific integer indexing has been defined for points other than $t$-points
+(\ie\ velocity and vorticity grid-points).
+Furthermore, the direction of the vertical indexing has been reversed and
+the surface level set at $k = 1$.
+
+%% =================================================================================================
 \subsubsection{Horizontal indexing}
 \label{subsec:DOM_Num_Index_hor}
 
-The indexing in the horizontal plane has been chosen as shown in \autoref{fig:index_hor}.
+The indexing in the horizontal plane has been chosen as shown in \autoref{fig:DOM_index_hor}.
 For an increasing $i$ index ($j$ index),
 the $t$-point and the eastward $u$-point (northward $v$-point) have the same index
-(see the dashed area in \autoref{fig:index_hor}).
-A $t$-point and its nearest northeast $f$-point have the same $i$-and $j$-indices.
-
-% -----------------------------------
-%        Vertical indexing 
-% -----------------------------------
+(see the dashed area in \autoref{fig:DOM_index_hor}).
+A $t$-point and its nearest north-east $f$-point have the same $i$-and $j$-indices.
+
+%% =================================================================================================
 \subsubsection{Vertical indexing}
 \label{subsec:DOM_Num_Index_vertical}
 
-In the vertical, the chosen indexing requires special attention since the $k$-axis is re-orientated downward in
-the \fortran code compared to the indexing used in the semi -discrete equations and
-given in \autoref{subsec:DOM_cell}.
-The sea surface corresponds to the $w$-level $k = 1$ which is the same index as $t$-level just below
-(\autoref{fig:index_vert}).
-The last $w$-level ($k = jpk$) either corresponds to the ocean floor or is inside the bathymetry while
-the last $t$-level is always inside the bathymetry (\autoref{fig:index_vert}).
-Note that for an increasing $k$ index, a $w$-point and the $t$-point just below have the same $k$ index,
-in opposition to what is done in the horizontal plane where
-it is the $t$-point and the nearest velocity points in the direction of the horizontal axis that
-have the same $i$ or $j$ index
-(compare the dashed area in \autoref{fig:index_hor} and \autoref{fig:index_vert}).
+In the vertical, the chosen indexing requires special attention since
+the direction of the $k$-axis in the \fortran\ code is the reverse of
+that used in the semi-discrete equations and given in \autoref{subsec:DOM_cell}.
+The sea surface corresponds to the $w$-level $k = 1$,
+which is the same index as the $t$-level just below (\autoref{fig:DOM_index_vert}).
+The last $w$-level ($k = jpk$) either corresponds to or is below the ocean floor while
+the last $t$-level is always outside the ocean domain (\autoref{fig:DOM_index_vert}).
+Note that a $w$-point and the directly underlaying $t$-point have a common $k$ index
+(\ie\ $t$-points and their nearest $w$-point neighbour in negative index direction),
+in contrast to the indexing on the horizontal plane where
+the $t$-point has the same index as the nearest velocity points in
+the positive direction of the respective horizontal axis index
+(compare the dashed area in \autoref{fig:DOM_index_hor} and \autoref{fig:DOM_index_vert}).
 Since the scale factors are chosen to be strictly positive,
-a \textit{minus sign} appears in the \fortran code \textit{before all the vertical derivatives} of
-the discrete equations given in this documentation.
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!pt]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_index_vert}
-    \caption{
-      \protect\label{fig:index_vert}
-      Vertical integer indexing used in the \fortran code.
-      Note that the $k$-axis is orientated downward.
-      The dashed area indicates the cell in which variables contained in arrays have the same $k$-index.
-    }
-  \end{center}
+a \textit{minus sign} is included in the \fortran\ implementations of
+\textit{all the vertical derivatives} of the discrete equations given in this manual in order to
+accommodate the opposing vertical index directions in implementation and documentation.
+
+\begin{figure}
+  \centering
+  \includegraphics[width=0.33\textwidth]{DOM_index_vert}
+  \caption[Vertical integer indexing]{
+    Vertical integer indexing used in the \fortran\ code.
+    Note that the $k$-axis is oriented downward.
+    The dashed area indicates the cell in which
+    variables contained in arrays have a common $k$-index.}
+  \label{fig:DOM_index_vert}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -----------------------------------
-%        Domain Size
-% -----------------------------------
-\subsubsection{Domain size}
+
+%% =================================================================================================
+\section{Spatial domain configuration}
+\label{subsec:DOM_config}
+
+Two typical methods are available to specify the spatial domain configuration;
+they can be selected using parameter \np{ln_read_cfg}{ln\_read\_cfg} parameter in
+namelist \nam{cfg}{cfg}.
+
+If \np{ln_read_cfg}{ln\_read\_cfg} is set to \forcode{.true.},
+the domain-specific parameters and fields are read from a NetCDF input file,
+whose name (without its .nc suffix) can be specified as
+the value of the \np{cn_domcfg}{cn\_domcfg} parameter in namelist \nam{cfg}{cfg}.
+
+If \np{ln_read_cfg}{ln\_read\_cfg} is set to \forcode{.false.},
+the domain-specific parameters and fields can be provided (\eg\ analytically computed) by
+subroutines \mdl{usrdef\_hgr} and \mdl{usrdef\_zgr}.
+These subroutines can be supplied in the \path{MY_SRC} directory of the configuration,
+and default versions that configure the spatial domain for the GYRE reference configuration are
+present in the \path{./src/OCE/USR} directory.
+
+In version 4.0 there are no longer any options for reading complex bathymetries and
+performing a vertical discretisation at run-time.
+Whilst it is occasionally convenient to have a common bathymetry file and, for example,
+to run similar models with and without partial bottom boxes and/or sigma-coordinates,
+supporting such choices leads to overly complex code.
+Worse still is the difficulty of ensuring the model configurations intended to be identical are
+indeed so when the model domain itself can be altered by runtime selections.
+The code previously used to perform vertical discretisation has been incorporated into
+an external tool (\path{./tools/DOMAINcfg}) which is briefly described in \autoref{apdx:DOMCFG}.
+
+The next subsections summarise the parameter and fields related to
+the configuration of the whole model domain.
+These represent the minimum information that must be provided either via
+the \np{cn_domcfg}{cn\_domcfg} file or
+set by code inserted into user-supplied versions of the \texttt{usrdef\_*} subroutines.
+The requirements are presented in three sections:
+the domain size (\autoref{subsec:DOM_size}), the horizontal mesh (\autoref{subsec:DOM_hgr}),
+and the vertical grid (\autoref{subsec:DOM_zgr}).
+
+%% =================================================================================================
+\subsection{Domain size}
 \label{subsec:DOM_size}
 
-The total size of the computational domain is set by the parameters \np{jpiglo},
-\np{jpjglo} and \np{jpkglo} in the $i$, $j$ and $k$ directions respectively.
-Parameters $jpi$ and $jpj$ refer to the size of each processor subdomain when
-the code is run in parallel using domain decomposition (\key{mpp\_mpi} defined,
-see \autoref{sec:LBC_mpp}).
-
-% ================================================================
-% Domain: List of fields needed
-% ================================================================
-\section{Needed fields}
-\label{sec:DOM_fields}
-The ocean mesh (\ie the position of all the scalar and vector points) is defined by the transformation that
-gives $(\lambda,\varphi,z)$ as a function of $(i,j,k)$.
-The grid-points are located at integer or integer and a half values of as indicated in \autoref{tab:cell}.
-The associated scale factors are defined using the analytical first derivative of the transformation
-\autoref{eq:scale_factors}.
-Necessary fields for configuration definition are:
+The total size of the computational domain is set by the parameters \jp{jpiglo}, \jp{jpjglo} and
+\jp{jpkglo} for the $i$, $j$ and $k$ directions, respectively.
+Note, that the variables \texttt{jpi} and \texttt{jpj} refer to
+the size of each processor subdomain when the code is run in parallel using domain decomposition
+(\key{mpp\_mpi} defined, see \autoref{sec:LBC_mpp}).
+
+The name of the configuration is set through parameter \np{cn_cfg}{cn\_cfg},
+and the nominal resolution through parameter \np{nn_cfg}{nn\_cfg}
+(unless in the input file both of variables \texttt{ORCA} and \texttt{ORCA\_index} are present,
+in which case \np{cn_cfg}{cn\_cfg} and \np{nn_cfg}{nn\_cfg} are set from these values accordingly).
+
+The global lateral boundary condition type is selected from 8 options using parameter \jp{jperio}.
+See \autoref{sec:LBC_jperio} for details on the available options and
+the corresponding values for \jp{jperio}.
+
+%% =================================================================================================
+\subsection[Horizontal grid mesh (\textit{domhgr.F90}]{Horizontal grid mesh (\protect\mdl{domhgr})}
+\label{subsec:DOM_hgr}
+
+%% =================================================================================================
+\subsubsection{Required fields}
+\label{sec:DOM_hgr_fields}
+
+The explicit specification of a range of mesh-related fields are required for
+the definition of a configuration.
+These include:
+
+\begin{clines}
+int    jpiglo, jpjglo, jpkglo     /* global domain sizes                                    */
+int    jperio                     /* lateral global domain b.c.                             */
+double glamt, glamu, glamv, glamf /* geographic longitude (t,u,v and f points respectively) */
+double gphit, gphiu, gphiv, gphif /* geographic latitude                                    */
+double e1t, e1u, e1v, e1f         /* horizontal scale factors                               */
+double e2t, e2u, e2v, e2f         /* horizontal scale factors                               */
+\end{clines}
+
+The values of the geographic longitude and latitude arrays at indices $i,j$ correspond to
+the analytical expressions of the longitude $\lambda$ and latitude $\varphi$ as a function of $(i,j)$,
+evaluated at the values as specified in \autoref{tab:DOM_cell} for the respective grid-point position.
+The calculation of the values of the horizontal scale factor arrays in general additionally involves
+partial derivatives of $\lambda$ and $\varphi$ with respect to $i$ and $j$,
+evaluated for the same arguments as $\lambda$ and $\varphi$.
+
+%% =================================================================================================
+\subsubsection{Optional fields}
+
+\begin{clines}
+                        /* Optional:                                                 */
+int    ORCA, ORCA_index /* configuration name, configuration resolution              */
+double e1e2u, e1e2v     /* U and V surfaces (if grid size reduction in some straits) */
+double ff_f, ff_t       /* Coriolis parameter (if not on the sphere)                 */
+\end{clines}
+
+\NEMO\ can support the local reduction of key strait widths by
+altering individual values of e2u or e1v at the appropriate locations.
+This is particularly useful for locations such as Gibraltar or Indonesian Throughflow pinch-points
+(see \autoref{sec:MISC_strait} for illustrated examples).
+The key is to reduce the faces of $T$-cell
+(\ie\ change the value of the horizontal scale factors at $u$- or $v$-point) but
+not the volume of the cells.
+Doing otherwise can lead to numerical instability issues.
+In normal operation the surface areas are computed from $e1u * e2u$ and $e1v * e2v$ but
+in cases where a gridsize reduction is required,
+the unaltered surface areas at $u$ and $v$ grid points
+(\texttt{e1e2u} and \texttt{e1e2v}, respectively) must be read or pre-computed in \mdl{usrdef\_hgr}.
+If these arrays are present in the \np{cn_domcfg}{cn\_domcfg} file they are read and
+the internal computation is suppressed.
+Versions of \mdl{usrdef\_hgr} which set their own values of \texttt{e1e2u} and \texttt{e1e2v} should
+set the surface-area computation flag:
+\texttt{ie1e2u\_v} to a non-zero value to suppress their re-computation.
+
+\smallskip
+Similar logic applies to the other optional fields:
+\texttt{ff\_f} and \texttt{ff\_t} which can be used to
+provide the Coriolis parameter at F- and T-points respectively if the mesh is not on a sphere.
+If present these fields will be read and used and
+the normal calculation ($2 * \Omega * \sin(\varphi)$) suppressed.
+Versions of \mdl{usrdef\_hgr} which set their own values of \texttt{ff\_f} and \texttt{ff\_t} should
+set the Coriolis computation flag:
+\texttt{iff} to a non-zero value to suppress their re-computation.
+
+Note that longitudes, latitudes, and scale factors at $w$ points are exactly equal to
+those of $t$ points, thus no specific arrays are defined at $w$ points.
+
+%% =================================================================================================
+\subsection[Vertical grid (\textit{domzgr.F90})]{Vertical grid (\protect\mdl{domzgr})}
+\label{subsec:DOM_zgr}
+
+\begin{listing}
+  \nlst{namdom}
+  \caption{\forcode{&namdom}}
+  \label{lst:namdom}
+\end{listing}
+
+In the vertical, the model mesh is determined by four things:
+\begin{enumerate}
+\item the bathymetry given in meters;
+\item the number of levels of the model (\jp{jpk});
+\item the analytical transformation $z(i,j,k)$ and the vertical scale factors
+  (derivatives of the transformation); and
+\item the masking system,
+  \ie\ the number of wet model levels at each $(i,j)$ location of the horizontal grid.
+\end{enumerate}
+
+\begin{figure}
+  \centering
+  \includegraphics[width=0.5\textwidth]{DOM_z_zps_s_sps}
+  \caption[Ocean bottom regarding coordinate systems ($z$, $s$ and hybrid $s-z$)]{
+    The ocean bottom as seen by the model:
+    \begin{enumerate*}[label=(\textit{\alph*})]
+    \item $z$-coordinate with full step,
+    \item $z$-coordinate with partial step,
+    \item $s$-coordinate: terrain following representation,
+    \item hybrid $s-z$ coordinate,
+    \item hybrid $s-z$ coordinate with partial step, and
+    \item same as (e) but in the non-linear free surface
+      (\protect\np[=.false.]{ln_linssh}{ln\_linssh}).
+  \end{enumerate*}
+  Note that the non-linear free surface can be used with any of the 5 coordinates (a) to (e).}
+  \label{fig:DOM_z_zps_s_sps}
+\end{figure}
+
+The choice of a vertical coordinate is made when setting up the configuration;
+it is not intended to be an option which can be changed in the middle of an experiment.
+The one exception to this statement being the choice of linear or non-linear free surface.
+In v4.0 the linear free surface option is implemented as
+a special case of the non-linear free surface.
+This is computationally wasteful since it uses the structures for time-varying 3D metrics
+for fields that (in the linear free surface case) are fixed.
+However, the linear free-surface is rarely used and
+implementing it this way means a single configuration file can support both options.
+
+By default a non-linear free surface is used
+(\np{ln_linssh}{ln\_linssh} set to \forcode{=.false.} in \nam{dom}{dom}):
+the coordinate follow the time-variation of the free surface so that
+the transformation is time dependent: $z(i,j,k,t)$ (\eg\ \autoref{fig:DOM_z_zps_s_sps}f).
+When a linear free surface is assumed
+(\np{ln_linssh}{ln\_linssh} set to \forcode{=.true.} in \nam{dom}{dom}),
+the vertical coordinates are fixed in time, but
+the seawater can move up and down across the $z_0$ surface
+(in other words, the top of the ocean in not a rigid lid).
+
+Note that settings:
+\np{ln_zco}{ln\_zco}, \np{ln_zps}{ln\_zps}, \np{ln_sco}{ln\_sco} and \np{ln_isfcav}{ln\_isfcav}
+mentioned in the following sections appear to be namelist options but
+they are no longer truly namelist options for \NEMO.
+Their value is written to and read from the domain configuration file and
+they should be treated as fixed parameters for a particular configuration.
+They are namelist options for the \texttt{DOMAINcfg} tool that can be used to
+build the configuration file and serve both to provide a record of the choices made whilst
+building the configuration and to trigger appropriate code blocks within \NEMO.
+These values should not be altered in the \np{cn_domcfg}{cn\_domcfg} file.
+
+\medskip
+The decision on these choices must be made when the \np{cn_domcfg}{cn\_domcfg} file is constructed.
+Three main choices are offered (\autoref{fig:DOM_z_zps_s_sps}a-c):
 
 \begin{itemize}
-\item
-  Geographic position:
-  longitude with \texttt{glamt}, \texttt{glamu}, \texttt{glamv}, \texttt{glamf} and
-  latitude  with \texttt{gphit}, \texttt{gphiu}, \texttt{gphiv}, \texttt{gphif}
-  (all respectively at T, U, V and F point)
-\item
-  Coriolis parameter (if domain not on the sphere): \texttt{ff\_f} and \texttt{ff\_t}
-  (at T and F point)
-\item
-  Scale factors:
-  \texttt{e1t}, \texttt{e1u}, \texttt{e1v} and \texttt{e1f} (on i direction),
-  \texttt{e2t}, \texttt{e2u}, \texttt{e2v} and \texttt{e2f} (on j direction) and
-  \texttt{ie1e2u\_v}, \texttt{e1e2u}, \texttt{e1e2v}. \\
-  \texttt{e1e2u}, \texttt{e1e2v} are u and v surfaces (if gridsize reduction in some straits), 
-  \texttt{ie1e2u\_v} is to flag set u and v surfaces are neither read nor computed.
+\item $z$-coordinate with full step bathymetry (\np[=.true.]{ln_zco}{ln\_zco}),
+\item $z$-coordinate with partial step ($zps$) bathymetry (\np[=.true.]{ln_zps}{ln\_zps}),
+\item Generalized, $s$-coordinate (\np[=.true.]{ln_sco}{ln\_sco}).
 \end{itemize}
- 
-These fields can be read in an domain input file which name is setted in \np{cn\_domcfg} parameter specified in
-\ngn{namcfg}.
-
-\nlst{namcfg}
-
-Or they can be defined in an analytical way in \path{MY_SRC} directory of the configuration.
-For Reference Configurations of NEMO input domain files are supplied by NEMO System Team.
-For analytical definition of input fields two routines are supplied: \mdl{usrdef\_hgr} and \mdl{usrdef\_zgr}.
-They are an example of GYRE configuration parameters, and they are available in \path{src/OCE/USR} directory,
-they provide the horizontal and vertical mesh.
-% -------------------------------------------------------------------------------------------------------------
-%        Needed fields 
-% -------------------------------------------------------------------------------------------------------------
-%\subsection{List of needed fields to build DOMAIN}
-%\label{subsec:DOM_fields_list}
-
-
-% ================================================================
-% Domain: Horizontal Grid (mesh) 
-% ================================================================
-\section[Horizontal grid mesh (\textit{domhgr.F90})]
-{Horizontal grid mesh (\protect\mdl{domhgr})}
-\label{sec:DOM_hgr}
-
-% -------------------------------------------------------------------------------------------------------------
-%        Coordinates and scale factors 
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Coordinates and scale factors}
-\label{subsec:DOM_hgr_coord_e}
-
-The ocean mesh (\ie the position of all the scalar and vector points) is defined by
-the transformation that gives $(\lambda,\varphi,z)$ as a function of $(i,j,k)$.
-The grid-points are located at integer or integer and a half values of as indicated in \autoref{tab:cell}.
-The associated scale factors are defined using the analytical first derivative of the transformation
-\autoref{eq:scale_factors}.
-These definitions are done in two modules, \mdl{domhgr} and \mdl{domzgr},
-which provide the horizontal and vertical meshes, respectively.
-This section deals with the horizontal mesh parameters.
-
-In a horizontal plane, the location of all the model grid points is defined from
-the analytical expressions of the longitude $\lambda$ and latitude $\varphi$ as a function of $(i,j)$.
-The horizontal scale factors are calculated using \autoref{eq:scale_factors}.
-For example, when the longitude and latitude are function of a single value
-($i$ and $j$, respectively) (geographical configuration of the mesh),
-the horizontal mesh definition reduces to define the wanted $\lambda(i)$, $\varphi(j)$,
-and their derivatives $\lambda'(i) \ \varphi'(j)$ in the \mdl{domhgr} module.
-The model computes the grid-point positions and scale factors in the horizontal plane as follows:
+
+Additionally, hybrid combinations of the three main coordinates are available:
+$s-z$ or $s-zps$ coordinate (\autoref{fig:DOM_z_zps_s_sps}d and \autoref{fig:DOM_z_zps_s_sps}e).
+
+A further choice related to vertical coordinate concerns
+the presence (or not) of ocean cavities beneath ice shelves within the model domain.
+A setting of \np{ln_isfcav}{ln\_isfcav} as \forcode{.true.} indicates that
+the domain contains ocean cavities,
+otherwise the top, wet layer of the ocean will always be at the ocean surface.
+This option is currently only available for $z$- or $zps$-coordinates.
+In the latter case, partial steps are also applied at the ocean/ice shelf interface.
+
+Within the model,
+the arrays describing the grid point depths and vertical scale factors are
+three set of three dimensional arrays $(i,j,k)$ defined at
+\textit{before}, \textit{now} and \textit{after} time step.
+The time at which they are defined is indicated by a suffix: $\_b$, $\_n$, or $\_a$, respectively.
+They are updated at each model time step.
+The initial fixed reference coordinate system is held in variable names with a $\_0$ suffix.
+When the linear free surface option is used (\np[=.true.]{ln_linssh}{ln\_linssh}),
+\textit{before}, \textit{now} and \textit{after} arrays are initially set to
+their reference counterpart and remain fixed.
+
+%% =================================================================================================
+\subsubsection{Required fields}
+\label{sec:DOM_zgr_fields}
+
+The explicit specification of a range of fields related to the vertical grid are required for
+the definition of a configuration.
+These include:
+
+\begin{clines}
+int    ln_zco, ln_zps, ln_sco            /* flags for z-coord, z-coord with partial steps and s-coord    */
+int    ln_isfcav                         /* flag  for ice shelf cavities                                 */
+double e3t_1d, e3w_1d                    /* reference vertical scale factors at T and W points           */
+double e3t_0, e3u_0, e3v_0, e3f_0, e3w_0 /* vertical scale factors 3D coordinate at T,U,V,F and W points */
+double e3uw_0, e3vw_0                    /* vertical scale factors 3D coordinate at UW and VW points     */
+int    bottom_level, top_level           /* last wet T-points, 1st wet T-points (for ice shelf cavities) */
+                                         /* For reference:                                               */
+float  bathy_metry                       /* bathymetry used in setting top and bottom levels             */
+\end{clines}
+
+This set of vertical metrics is sufficient to describe the initial depth and thickness of
+every gridcell in the model regardless of the choice of vertical coordinate.
+With constant z-levels, e3 metrics will be uniform across each horizontal level.
+In the partial step case each e3 at the \jp{bottom\_level}
+(and, possibly, \jp{top\_level} if ice cavities are present)
+may vary from its horizontal neighbours.
+And, in s-coordinates, variations can occur throughout the water column.
+With the non-linear free-surface, all the coordinates behave more like the s-coordinate in that
+variations occur throughout the water column with displacements related to the sea surface height.
+These variations are typically much smaller than those arising from bottom fitted coordinates.
+The values for vertical metrics supplied in the domain configuration file can be considered as
+those arising from a flat sea surface with zero elevation.
+
+The \jp{bottom\_level} and \jp{top\_level} 2D arrays define
+the \jp{bottom\_level} and top wet levels in each grid column.
+Without ice cavities, \jp{top\_level} is essentially a land mask (0 on land; 1 everywhere else).
+With ice cavities, \jp{top\_level} determines the first wet point below the overlying ice shelf.
+
+%% =================================================================================================
+\subsubsection{Level bathymetry and mask}
+\label{subsec:DOM_msk}
+
+From \jp{top\_level} and \jp{bottom\_level} fields, the mask fields are defined as follows:
 \begin{align*}
-   \lambda_t &\equiv \text{glamt} =      \lambda (i      )
-  &\varphi_t &\equiv \text{gphit} =      \varphi (j      ) \\
-   \lambda_u &\equiv \text{glamu} =      \lambda (i + 1/2)
-  &\varphi_u &\equiv \text{gphiu} =      \varphi (j      ) \\
-   \lambda_v &\equiv \text{glamv} =      \lambda (i      )
-  &\varphi_v &\equiv \text{gphiv} =      \varphi (j + 1/2) \\
-   \lambda_f &\equiv \text{glamf} =      \lambda (i + 1/2)
-  &\varphi_f &\equiv \text{gphif} =      \varphi (j + 1/2) \\
-   e_{1t}    &\equiv \text{e1t}   = r_a |\lambda'(i      ) \; \cos\varphi(j      ) |
-  &e_{2t}    &\equiv \text{e2t}   = r_a |\varphi'(j      )                         | \\
-   e_{1u}    &\equiv \text{e1t}   = r_a |\lambda'(i + 1/2) \; \cos\varphi(j      ) |
-  &e_{2u}    &\equiv \text{e2t}   = r_a |\varphi'(j      )                         | \\
-   e_{1v}    &\equiv \text{e1t}   = r_a |\lambda'(i      ) \; \cos\varphi(j + 1/2) |
-  &e_{2v}    &\equiv \text{e2t}   = r_a |\varphi'(j + 1/2)                         | \\
-   e_{1f}    &\equiv \text{e1t}   = r_a |\lambda'(i + 1/2) \; \cos\varphi(j + 1/2) |
-  &e_{2f}    &\equiv \text{e2t}   = r_a |\varphi'(j + 1/2)                         |
+  tmask(i,j,k) &=
+  \begin{cases}
+    0 &\text{if $                             k <    top\_level(i,j)$} \\
+    1 &\text{if $     bottom\_level(i,j) \leq k \leq top\_level(i,j)$} \\
+    0 &\text{if $k >  bottom\_level(i,j)                            $}
+  \end{cases} \\
+  umask(i,j,k) &= tmask(i,j,k) * tmask(i + 1,j,    k) \\
+  vmask(i,j,k) &= tmask(i,j,k) * tmask(i    ,j + 1,k) \\
+  fmask(i,j,k) &= tmask(i,j,k) * tmask(i + 1,j,    k) * tmask(i,j,k) * tmask(i + 1,j,    k) \\
+  wmask(i,j,k) &= tmask(i,j,k) * tmask(i    ,j,k - 1) \\
+  \text{with~} wmask(i,j,1) &= tmask(i,j,1)
 \end{align*}
-where the last letter of each computational name indicates the grid point considered and
-$r_a$ is the earth radius (defined in \mdl{phycst} along with all universal constants).
-Note that the horizontal position of and scale factors at $w$-points are exactly equal to those of $t$-points,
-thus no specific arrays are defined at $w$-points.
-
-Note that the definition of the scale factors
-(\ie as the analytical first derivative of the transformation that
-gives $(\lambda,\varphi,z)$ as a function of $(i,j,k)$)
-is specific to the \NEMO model \citep{marti.madec.ea_JGR92}.
-As an example, $e_{1t}$ is defined locally at a $t$-point,
-whereas many other models on a C grid choose to define such a scale factor as
-the distance between the $U$-points on each side of the $t$-point.
-Relying on an analytical transformation has two advantages:
-firstly, there is no ambiguity in the scale factors appearing in the discrete equations,
-since they are first introduced in the continuous equations;
-secondly, analytical transformations encourage good practice by the definition of smoothly varying grids
-(rather than allowing the user to set arbitrary jumps in thickness between adjacent layers) \citep{treguier.dukowicz.ea_JGR96}.
-An example of the effect of such a choice is shown in \autoref{fig:zgr_e3}.
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_zgr_e3}
-    \caption{
-      \protect\label{fig:zgr_e3}
-      Comparison of (a) traditional definitions of grid-point position and grid-size in the vertical,
-      and (b) analytically derived grid-point position and scale factors.
-      For both grids here, the same $w$-point depth has been chosen but
-      in (a) the $t$-points are set half way between $w$-points while
-      in (b) they are defined from an analytical function:
-      $z(k) = 5 \, (k - 1/2)^3 - 45 \, (k - 1/2)^2 + 140 \, (k - 1/2) - 150$.
-      Note the resulting difference between the value of the grid-size $\Delta_k$ and
-      those of the scale factor $e_k$.
-    }
-  \end{center}
-\end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -------------------------------------------------------------------------------------------------------------
-%        Choice of horizontal grid
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Choice of horizontal grid}
-\label{subsec:DOM_hgr_msh_choice}
-
-% -------------------------------------------------------------------------------------------------------------
-%        Grid files
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Output grid files}
-\label{subsec:DOM_hgr_files}
-
-All the arrays relating to a particular ocean model configuration (grid-point position, scale factors, masks)
-can be saved in files if \np{nn\_msh} $\not = 0$ (namelist variable in \ngn{namdom}).
-This can be particularly useful for plots and off-line diagnostics.
-In some cases, the user may choose to make a local modification of a scale factor in the code.
-This is the case in global configurations when restricting the width of a specific strait
-(usually a one-grid-point strait that happens to be too wide due to insufficient model resolution).
-An example is Gibraltar Strait in the ORCA2 configuration.
-When such modifications are done,
-the output grid written when \np{nn\_msh} $\not = 0$ is no more equal to the input grid.
-
-% ================================================================
-% Domain: Vertical Grid (domzgr)
-% ================================================================
-\section[Vertical grid (\textit{domzgr.F90})]
-{Vertical grid (\protect\mdl{domzgr})}
-\label{sec:DOM_zgr}
-%-----------------------------------------nam_zgr & namdom-------------------------------------------
-%
-%\nlst{namzgr} 
-
-\nlst{namdom} 
-%-------------------------------------------------------------------------------------------------------------
-
-Variables are defined through the \ngn{namzgr} and \ngn{namdom} namelists.
-In the vertical, the model mesh is determined by four things: 
-(1) the bathymetry given in meters; 
-(2) the number of levels of the model (\jp{jpk}); 
-(3) the analytical transformation $z(i,j,k)$ and the vertical scale factors (derivatives of the transformation); and
-(4) the masking system, \ie the number of wet model levels at each 
-$(i,j)$ column of points.
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!tb]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_z_zps_s_sps}
-    \caption{
-      \protect\label{fig:z_zps_s_sps}
-      The ocean bottom as seen by the model:
-      (a) $z$-coordinate with full step,
-      (b) $z$-coordinate with partial step,
-      (c) $s$-coordinate: terrain following representation,
-      (d) hybrid $s-z$ coordinate,
-      (e) hybrid $s-z$ coordinate with partial step, and
-      (f) same as (e) but in the non-linear free surface (\protect\np{ln\_linssh}\forcode{ = .false.}).
-      Note that the non-linear free surface can be used with any of the 5 coordinates (a) to (e).
-    }
-  \end{center}
-\end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-The choice of a vertical coordinate, even if it is made through \ngn{namzgr} namelist parameters, 
-must be done once of all at the beginning of an experiment.
-It is not intended as an option which can be enabled or disabled in the middle of an experiment.
-Three main choices are offered (\autoref{fig:z_zps_s_sps}):
-$z$-coordinate with full step bathymetry (\np{ln\_zco}\forcode{ = .true.}),
-$z$-coordinate with partial step bathymetry (\np{ln\_zps}\forcode{ = .true.}),
-or generalized, $s$-coordinate (\np{ln\_sco}\forcode{ = .true.}).
-Hybridation of the three main coordinates are available:
-$s-z$ or $s-zps$ coordinate (\autoref{fig:z_zps_s_sps} and \autoref{fig:z_zps_s_sps}).
-By default a non-linear free surface is used: the coordinate follow the time-variation of the free surface so that
-the transformation is time dependent: $z(i,j,k,t)$ (\autoref{fig:z_zps_s_sps}).
-When a linear free surface is assumed (\np{ln\_linssh}\forcode{ = .true.}),
-the vertical coordinate are fixed in time, but the seawater can move up and down across the $z_0$ surface
-(in other words, the top of the ocean in not a rigid-lid).
-The last choice in terms of vertical coordinate concerns the presence (or not) in
-the model domain of ocean cavities beneath ice shelves.
-Setting \np{ln\_isfcav} to true allows to manage ocean cavities, otherwise they are filled in.
-This option is currently only available in $z$- or $zps$-coordinate,
-and partial step are also applied at the ocean/ice shelf interface.
-
-Contrary to the horizontal grid, the vertical grid is computed in the code and no provision is made for
-reading it from a file.
-The only input file is the bathymetry (in meters) (\ifile{bathy\_meter})
-\footnote{
-  N.B. in full step $z$-coordinate, a \ifile{bathy\_level} file can replace the \ifile{bathy\_meter} file,
-  so that the computation of the number of wet ocean point in each water column is by-passed}.
-If \np{ln\_isfcav}\forcode{ = .true.}, an extra file input file (\ifile{isf\_draft\_meter}) describing
-the ice shelf draft (in meters) is needed.
-
-After reading the bathymetry, the algorithm for vertical grid definition differs between the different options:
-\begin{description}
-\item[\textit{zco}]
-  set a reference coordinate transformation $z_0(k)$, and set $z(i,j,k,t) = z_0(k)$.
-\item[\textit{zps}]
-  set a reference coordinate transformation $z_0(k)$, and calculate the thickness of the deepest level at
-  each $(i,j)$ point using the bathymetry, to obtain the final three-dimensional depth and scale factor arrays.
-\item[\textit{sco}]
-  smooth the bathymetry to fulfill the hydrostatic consistency criteria and
-  set the three-dimensional transformation.
-\item[\textit{s-z} and \textit{s-zps}]
-  smooth the bathymetry to fulfill the hydrostatic consistency criteria and
-  set the three-dimensional transformation $z(i,j,k)$,
-  and possibly introduce masking of extra land points to better fit the original bathymetry file.
-\end{description}
-%%%
-\gmcomment{   add the description of the smoothing:  envelop topography...}
-%%%
-
-Unless a linear free surface is used (\np{ln\_linssh}\forcode{ = .false.}),
-the arrays describing the grid point depths and vertical scale factors are three set of
-three dimensional arrays $(i,j,k)$ defined at \textit{before}, \textit{now} and \textit{after} time step.
-The time at which they are defined is indicated by a suffix: $\_b$, $\_n$, or $\_a$, respectively.
-They are updated at each model time step using a fixed reference coordinate system which
-computer names have a $\_0$ suffix.
-When the linear free surface option is used (\np{ln\_linssh}\forcode{ = .true.}), \textit{before},
-\textit{now} and \textit{after} arrays are simply set one for all to their reference counterpart.
-
-% -------------------------------------------------------------------------------------------------------------
-%        Meter Bathymetry
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Meter bathymetry}
-\label{subsec:DOM_bathy}
-
-Three options are possible for defining the bathymetry, according to the namelist variable \np{nn\_bathy}
-(found in \ngn{namdom} namelist): 
-\begin{description}
-\item[\np{nn\_bathy}\forcode{ = 0}]:
-  a flat-bottom domain is defined.
-  The total depth $z_w (jpk)$ is given by the coordinate transformation.
-  The domain can either be a closed basin or a periodic channel depending on the parameter \np{jperio}.
-\item[\np{nn\_bathy}\forcode{ = -1}]:
-  a domain with a bump of topography one third of the domain width at the central latitude.
-  This is meant for the "EEL-R5" configuration, a periodic or open boundary channel with a seamount.
-\item[\np{nn\_bathy}\forcode{ = 1}]:
-  read a bathymetry and ice shelf draft (if needed).
-  The \ifile{bathy\_meter} file (Netcdf format) provides the ocean depth (positive, in meters) at
-  each grid point of the model grid.
-  The bathymetry is usually built by interpolating a standard bathymetry product (\eg ETOPO2) onto
-  the horizontal ocean mesh.
-  Defining the bathymetry also defines the coastline: where the bathymetry is zero,
-  no model levels are defined (all levels are masked).
-
-  The \ifile{isfdraft\_meter} file (Netcdf format) provides the ice shelf draft (positive, in meters) at
-  each grid point of the model grid.
-  This file is only needed if \np{ln\_isfcav}\forcode{ = .true.}.
-  Defining the ice shelf draft will also define the ice shelf edge and the grounding line position.
-\end{description}
-
-When a global ocean is coupled to an atmospheric model it is better to represent all large water bodies
-(\eg great lakes, Caspian sea...) even if the model resolution does not allow their communication with
-the rest of the ocean.
+
+Note that, without ice shelves cavities,
+masks at $t-$ and $w-$points are identical with the numerical indexing used
+(\autoref{subsec:DOM_Num_Index}).
+Nevertheless,
+$wmask$ are required with ocean cavities to deal with the top boundary (ice shelf/ocean interface)
+exactly in the same way as for the bottom boundary.
+
+%% The specification of closed lateral boundaries requires that at least
+%% the first and last rows and columns of the \textit{mbathy} array are set to zero.
+%% In the particular case of an east-west cyclical boundary condition, \textit{mbathy} has its last column equal to
+%% the second one and its first column equal to the last but one (and so too the mask arrays)
+%% (see \autoref{fig:LBC_jperio}).
+
+%        Closed seas
+%% =================================================================================================
+\subsection{Closed seas}
+\label{subsec:DOM_closea}
+
+When a global ocean is coupled to an atmospheric model it is better to
+represent all large water bodies (\eg\ Great Lakes, Caspian sea, \dots) even if
+the model resolution does not allow their communication with the rest of the ocean.
 This is unnecessary when the ocean is forced by fixed atmospheric conditions,
 so these seas can be removed from the ocean domain.
-The user has the option to set the bathymetry in closed seas to zero (see \autoref{sec:MISC_closea}),
-but the code has to be adapted to the user's configuration.
-
-% -------------------------------------------------------------------------------------------------------------
-%        z-coordinate  and reference coordinate transformation
-% -------------------------------------------------------------------------------------------------------------
-\subsection[$Z$-coordinate (\forcode{ln_zco = .true.}) and ref. coordinate]
-{$Z$-coordinate (\protect\np{ln\_zco}\forcode{ = .true.}) and reference coordinate}
-\label{subsec:DOM_zco}
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!tb]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_zgr}
-    \caption{
-      \protect\label{fig:zgr}
-      Default vertical mesh for ORCA2: 30 ocean levels (L30).
-      Vertical level functions for (a) T-point depth and (b) the associated scale factor as computed from
-      \autoref{eq:DOM_zgr_ana_1} using \autoref{eq:DOM_zgr_coef} in $z$-coordinate.
-    }
-  \end{center}
-\end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-The reference coordinate transformation $z_0(k)$ defines the arrays $gdept_0$ and $gdepw_0$ for $t$- and $w$-points,
-respectively.
-As indicated on \autoref{fig:index_vert} \jp{jpk} is the number of $w$-levels.
-$gdepw_0(1)$ is the ocean surface.
-There are at most \jp{jpk}-1 $t$-points inside the ocean,
-the additional $t$-point at $jk = jpk$ is below the sea floor and is not used.
-The vertical location of $w$- and $t$-levels is defined from the analytic expression of the depth $z_0(k)$ whose
-analytical derivative with respect to $k$ provides the vertical scale factors.
-The user must provide the analytical expression of both $z_0$ and its first derivative with respect to $k$.
-This is done in routine \mdl{domzgr} through statement functions,
-using parameters provided in the \ngn{namcfg} namelist.
-
-It is possible to define a simple regular vertical grid by giving zero stretching (\np{ppacr}\forcode{ = 0}).
-In that case, the parameters \jp{jpk} (number of $w$-levels) and
-\np{pphmax} (total ocean depth in meters) fully define the grid.
-
-For climate-related studies it is often desirable to concentrate the vertical resolution near the ocean surface.
-The following function is proposed as a standard for a $z$-coordinate (with either full or partial steps): 
-\begin{gather}
-  \label{eq:DOM_zgr_ana_1}
-    z_0  (k) = h_{sur} - h_0 \; k - \; h_1 \; \log  \big[ \cosh ((k - h_{th}) / h_{cr}) \big] \\
-    e_3^0(k) = \lt|    - h_0      -    h_1 \; \tanh \big[        (k - h_{th}) / h_{cr}  \big] \rt|
-\end{gather}
-where $k = 1$ to \jp{jpk} for $w$-levels and $k = 1$ to $k = 1$ for $T-$levels.
-Such an expression allows us to define a nearly uniform vertical location of levels at the ocean top and bottom with
-a smooth hyperbolic tangent transition in between (\autoref{fig:zgr}).
-
-If the ice shelf cavities are opened (\np{ln\_isfcav}\forcode{ = .true.}), the definition of $z_0$ is the same.
-However, definition of $e_3^0$ at $t$- and $w$-points is respectively changed to:
-\begin{equation}
-  \label{eq:DOM_zgr_ana_2}
-  \begin{split}
-    e_3^T(k) &= z_W (k + 1) - z_W (k    ) \\
-    e_3^W(k) &= z_T (k    ) - z_T (k - 1)
-  \end{split}
-\end{equation}
-This formulation decrease the self-generated circulation into the ice shelf cavity 
-(which can, in extreme case, leads to blow up).\\
- 
-The most used vertical grid for ORCA2 has $10~m$ ($500~m$) resolution in the surface (bottom) layers and
-a depth which varies from 0 at the sea surface to a minimum of $-5000~m$.
-This leads to the following conditions:
-\begin{equation}
-  \label{eq:DOM_zgr_coef}
-  \begin{array}{ll}
-    e_3 (1   + 1/2) =  10. & z(1  ) =     0. \\
-    e_3 (jpk - 1/2) = 500. & z(jpk) = -5000.
-  \end{array}
-\end{equation}
-
-With the choice of the stretching $h_{cr} = 3$ and the number of levels \jp{jpk}~$= 31$,
-the four coefficients $h_{sur}$, $h_0$, $h_1$, and $h_{th}$ in
-\autoref{eq:DOM_zgr_ana_2} have been determined such that
-\autoref{eq:DOM_zgr_coef} is satisfied, through an optimisation procedure using a bisection method.
-For the first standard ORCA2 vertical grid this led to the following values:
-$h_{sur} = 4762.96$, $h_0 = 255.58, h_1 = 245.5813$, and $h_{th} = 21.43336$.
-The resulting depths and scale factors as a function of the model levels are shown in
-\autoref{fig:zgr} and given in \autoref{tab:orca_zgr}.
-Those values correspond to the parameters \np{ppsur}, \np{ppa0}, \np{ppa1}, \np{ppkth} in \ngn{namcfg} namelist.
-
-Rather than entering parameters $h_{sur}$, $h_0$, and $h_1$ directly, it is possible to recalculate them.
-In that case the user sets \np{ppsur}~$=$~\np{ppa0}~$=$~\np{ppa1}~$= 999999$.,
-in \ngn{namcfg} namelist, and specifies instead the four following parameters:
-\begin{itemize}
-\item
-  \np{ppacr}~$= h_{cr}$: stretching factor (nondimensional).
-  The larger \np{ppacr}, the smaller the stretching.
-  Values from $3$ to $10$ are usual.
-\item
-  \np{ppkth}~$= h_{th}$: is approximately the model level at which maximum stretching occurs
-  (nondimensional, usually of order 1/2 or 2/3 of \jp{jpk})
-\item
-  \np{ppdzmin}: minimum thickness for the top layer (in meters).
-\item
-  \np{pphmax}: total depth of the ocean (meters).
-\end{itemize}
-As an example, for the $45$ layers used in the DRAKKAR configuration those parameters are:
-\jp{jpk}~$= 46$, \np{ppacr}~$= 9$, \np{ppkth}~$= 23.563$, \np{ppdzmin}~$= 6~m$, \np{pphmax}~$= 5750~m$.
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{table}
-  \begin{center}
-    \begin{tabular}{c||r|r|r|r}
-      \hline
-      \textbf{LEVEL} & \textbf{gdept\_1d} & \textbf{gdepw\_1d} & \textbf{e3t\_1d } & \textbf{e3w\_1d} \\
-      \hline
-      1              & \textbf{     5.00} &               0.00 & \textbf{   10.00} &            10.00 \\
-      \hline
-      2              & \textbf{    15.00} &	            10.00 & \textbf{   10.00} &            10.00 \\
-      \hline
-      3              & \textbf{    25.00} &              20.00 & \textbf{   10.00} &            10.00 \\
-      \hline
-      4              & \textbf{    35.01} &	            30.00 & \textbf{   10.01} &            10.00 \\
-      \hline
-      5              & \textbf{    45.01} &              40.01 & \textbf{   10.01} &            10.01 \\
-      \hline
-      6              & \textbf{    55.03} &              50.02 & \textbf{   10.02} &            10.02 \\
-      \hline
-      7              & \textbf{    65.06} &              60.04 & \textbf{   10.04} &            10.03 \\
-      \hline
-      8              & \textbf{    75.13} &              70.09 & \textbf{   10.09} &            10.06 \\
-      \hline
-      9              & \textbf{    85.25} &              80.18 & \textbf{   10.17} &            10.12 \\
-      \hline
-      10             & \textbf{    95.49} &              90.35 & \textbf{   10.33} &            10.24 \\
-      \hline
-      11             & \textbf{   105.97} &             100.69 & \textbf{   10.65} &            10.47 \\
-      \hline
-      12             & \textbf{   116.90} &             111.36 & \textbf{   11.27} &            10.91 \\
-      \hline
-      13             & \textbf{   128.70} &             122.65 & \textbf{   12.47} &            11.77 \\
-      \hline
-      14             & \textbf{   142.20} &             135.16 & \textbf{   14.78} &            13.43 \\
-      \hline
-      15             & \textbf{   158.96} &             150.03 & \textbf{   19.23} &            16.65 \\
-      \hline
-      16             & \textbf{   181.96} &             169.42 & \textbf{   27.66} &            22.78 \\
-      \hline
-      17             & \textbf{   216.65} &             197.37 & \textbf{   43.26} &            34.30 \\
-      \hline
-      18             & \textbf{   272.48} &             241.13 & \textbf{   70.88} &            55.21 \\
-      \hline
-      19             & \textbf{   364.30} &             312.74 & \textbf{  116.11} &            90.99 \\
-      \hline
-      20             & \textbf{   511.53} &             429.72 & \textbf{  181.55} &           146.43 \\
-      \hline
-      21             & \textbf{   732.20} &             611.89 & \textbf{  261.03} &           220.35 \\
-      \hline
-      22             & \textbf{  1033.22} &             872.87 & \textbf{  339.39} &           301.42 \\
-      \hline
-      23             & \textbf{  1405.70} &            1211.59 & \textbf{  402.26} &           373.31 \\
-      \hline
-      24             & \textbf{  1830.89} &            1612.98 & \textbf{  444.87} &           426.00 \\
-      \hline
-      25             & \textbf{  2289.77} &            2057.13 & \textbf{  470.55} &           459.47 \\
-      \hline
-      26             & \textbf{  2768.24} &            2527.22 & \textbf{  484.95} &           478.83 \\
-      \hline
-      27             & \textbf{  3257.48} &            3011.90 & \textbf{  492.70} &           489.44 \\
-      \hline
-      28             & \textbf{  3752.44} &            3504.46 & \textbf{  496.78} &           495.07 \\
-      \hline
-      29             & \textbf{  4250.40} &            4001.16 & \textbf{  498.90} &           498.02 \\
-      \hline
-      30             & \textbf{  4749.91} &            4500.02 & \textbf{  500.00} &           499.54 \\
-      \hline
-      31             & \textbf{  5250.23} &            5000.00 & \textbf{  500.56} &           500.33 \\
-      \hline
-    \end{tabular}
-  \end{center}
-  \caption{
-    \protect\label{tab:orca_zgr}
-    Default vertical mesh in $z$-coordinate for 30 layers ORCA2 configuration as computed from
-    \autoref{eq:DOM_zgr_ana_2} using the coefficients given in \autoref{eq:DOM_zgr_coef}
-  }
-\end{table}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -------------------------------------------------------------------------------------------------------------
-%        z-coordinate with partial step
-% -------------------------------------------------------------------------------------------------------------
-\subsection[$Z$-coordinate with partial step (\forcode{ln_zps = .true.})]
-{$Z$-coordinate with partial step (\protect\np{ln\_zps}\forcode{ = .true.})}
-\label{subsec:DOM_zps}
-%--------------------------------------------namdom-------------------------------------------------------
-
-\nlst{namdom} 
-%--------------------------------------------------------------------------------------------------------------
-
-In $z$-coordinate partial step,
-the depths of the model levels are defined by the reference analytical function $z_0(k)$ as described in
-the previous section, \textit{except} in the bottom layer.
-The thickness of the bottom layer is allowed to vary as a function of geographical location $(\lambda,\varphi)$ to
-allow a better representation of the bathymetry, especially in the case of small slopes
-(where the bathymetry varies by less than one level thickness from one grid point to the next).
-The reference layer thicknesses $e_{3t}^0$ have been defined in the absence of bathymetry.
-With partial steps, layers from 1 to \jp{jpk}-2 can have a thickness smaller than $e_{3t}(jk)$.
-The model deepest layer (\jp{jpk}-1) is allowed to have either a smaller or larger thickness than $e_{3t}(jpk)$:
-the maximum thickness allowed is $2*e_{3t}(jpk - 1)$.
-This has to be kept in mind when specifying values in \ngn{namdom} namelist,
-as the maximum depth \np{pphmax} in partial steps:
-for example, with \np{pphmax}~$= 5750~m$ for the DRAKKAR 45 layer grid,
-the maximum ocean depth allowed is actually $6000~m$ (the default thickness $e_{3t}(jpk - 1)$ being $250~m$).
-Two variables in the namdom namelist are used to define the partial step vertical grid.
-The mimimum water thickness (in meters) allowed for a cell partially filled with bathymetry at level jk is
-the minimum of \np{rn\_e3zps\_min} (thickness in meters, usually $20~m$) or $e_{3t}(jk)*$\np{rn\_e3zps\_rat}
-(a fraction, usually 10\%, of the default thickness $e_{3t}(jk)$).
-
-\gmcomment{ \colorbox{yellow}{Add a figure here of pstep especially at last ocean level }  }
-
-% -------------------------------------------------------------------------------------------------------------
-%        s-coordinate
-% -------------------------------------------------------------------------------------------------------------
-\subsection[$S$-coordinate (\forcode{ln_sco = .true.})]
-{$S$-coordinate (\protect\np{ln\_sco}\forcode{ = .true.})}
-\label{subsec:DOM_sco}
-%------------------------------------------nam_zgr_sco---------------------------------------------------
-%
-%\nlst{namzgr_sco} 
-%--------------------------------------------------------------------------------------------------------------
-Options are defined in \ngn{namzgr\_sco}.
-In $s$-coordinate (\np{ln\_sco}\forcode{ = .true.}), the depth and thickness of the model levels are defined from
-the product of a depth field and either a stretching function or its derivative, respectively:
-
-\begin{align*}
-  % \label{eq:DOM_sco_ana}
-  z(k)   &= h(i,j) \; z_0 (k) \\
-  e_3(k) &= h(i,j) \; z_0'(k)
-\end{align*}
-
-where $h$ is the depth of the last $w$-level ($z_0(k)$) defined at the $t$-point location in the horizontal and
-$z_0(k)$ is a function which varies from $0$ at the sea surface to $1$ at the ocean bottom.
-The depth field $h$ is not necessary the ocean depth,
-since a mixed step-like and bottom-following representation of the topography can be used
-(\autoref{fig:z_zps_s_sps}) or an envelop bathymetry can be defined (\autoref{fig:z_zps_s_sps}).
-The namelist parameter \np{rn\_rmax} determines the slope at which
-the terrain-following coordinate intersects the sea bed and becomes a pseudo z-coordinate.
-The coordinate can also be hybridised by specifying \np{rn\_sbot\_min} and \np{rn\_sbot\_max} as
-the minimum and maximum depths at which the terrain-following vertical coordinate is calculated.
-
-Options for stretching the coordinate are provided as examples,
-but care must be taken to ensure that the vertical stretch used is appropriate for the application.
-
-The original default NEMO s-coordinate stretching is available if neither of the other options are specified as true
-(\np{ln\_s\_SH94}\forcode{ = .false.} and \np{ln\_s\_SF12}\forcode{ = .false.}).
-This uses a depth independent $\tanh$ function for the stretching \citep{madec.delecluse.ea_JPO96}:
-
-\[
-  z = s_{min} + C (s) (H - s_{min})
-  % \label{eq:SH94_1}
-\]
-
-where $s_{min}$ is the depth at which the $s$-coordinate stretching starts and
-allows a $z$-coordinate to placed on top of the stretched coordinate,
-and $z$ is the depth (negative down from the asea surface).
-\begin{gather*}
-  s = - \frac{k}{n - 1} \quad \text{and} \quad 0 \leq k \leq n - 1
-  % \label{eq:DOM_s}
- \\
-  % \label{eq:DOM_sco_function}
-  C(s) = \frac{[\tanh(\theta \, (s + b)) - \tanh(\theta \, b)]}{2 \; \sinh(\theta)}
-\end{gather*}
-
-A stretching function,
-modified from the commonly used \citet{song.haidvogel_JCP94} stretching (\np{ln\_s\_SH94}\forcode{ = .true.}),
-is also available and is more commonly used for shelf seas modelling:
-
-\[
-  C(s) =   (1 - b) \frac{\sinh(\theta s)}{\sinh(\theta)}
-         + b       \frac{\tanh \lt[ \theta \lt(s + \frac{1}{2} \rt) \rt] -   \tanh \lt( \frac{\theta}{2} \rt)}
-                        {                                                  2 \tanh \lt( \frac{\theta}{2} \rt)}
-  % \label{eq:SH94_2}
-\]
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!ht]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_sco_function}
-    \caption{
-      \protect\label{fig:sco_function}
-      Examples of the stretching function applied to a seamount;
-      from left to right: surface, surface and bottom, and bottom intensified resolutions
-    }
-  \end{center}
-\end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-where $H_c$ is the critical depth (\np{rn\_hc}) at which the coordinate transitions from pure $\sigma$ to
-the stretched coordinate, and $\theta$ (\np{rn\_theta}) and $b$ (\np{rn\_bb}) are the surface and
-bottom control parameters such that $0 \leqslant \theta \leqslant 20$, and $0 \leqslant b \leqslant 1$.
-$b$ has been designed to allow surface and/or bottom increase of the vertical resolution
-(\autoref{fig:sco_function}).
-
-Another example has been provided at version 3.5 (\np{ln\_s\_SF12}) that allows a fixed surface resolution in
-an analytical terrain-following stretching \citet{siddorn.furner_OM13}.
-In this case the a stretching function $\gamma$ is defined such that:
-
-\begin{equation}
-  z = - \gamma h \quad \text{with} \quad 0 \leq \gamma \leq 1
-  % \label{eq:z}
-\end{equation}
-
-The function is defined with respect to $\sigma$, the unstretched terrain-following coordinate:
-
-\begin{gather*}
-  % \label{eq:DOM_gamma_deriv}
-  \gamma =   A \lt( \sigma   - \frac{1}{2} (\sigma^2     + f (\sigma)) \rt)
-           + B \lt( \sigma^3 - f           (\sigma) \rt) + f (\sigma)       \\
-  \intertext{Where:}
-  % \label{eq:DOM_gamma}
-  f(\sigma) = (\alpha + 2) \sigma^{\alpha + 1} - (\alpha + 1) \sigma^{\alpha + 2}
-  \quad \text{and} \quad \sigma = \frac{k}{n - 1}
-\end{gather*}
-
-This gives an analytical stretching of $\sigma$ that is solvable in $A$ and $B$ as a function of
-the user prescribed stretching parameter $\alpha$ (\np{rn\_alpha}) that stretches towards
-the surface ($\alpha > 1.0$) or the bottom ($\alpha < 1.0$) and
-user prescribed surface (\np{rn\_zs}) and bottom depths.
-The bottom cell depth in this example is given as a function of water depth:
-
-\[
-  % \label{eq:DOM_zb}
-  Z_b = h a + b
-\]
-
-where the namelist parameters \np{rn\_zb\_a} and \np{rn\_zb\_b} are $a$ and $b$ respectively.
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!ht]
-  \includegraphics[width=\textwidth]{Fig_DOM_compare_coordinates_surface}
-  \caption{
-    A comparison of the \citet{song.haidvogel_JCP94} $S$-coordinate (solid lines),
-    a 50 level $Z$-coordinate (contoured surfaces) and
-    the \citet{siddorn.furner_OM13} $S$-coordinate (dashed lines) in the surface $100~m$ for
-    a idealised bathymetry that goes from $50~m$ to $5500~m$ depth.
-    For clarity every third coordinate surface is shown.
-  }
-  \label{fig:fig_compare_coordinates_surface}
-\end{figure}
- % >>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-This gives a smooth analytical stretching in computational space that is constrained to
-given specified surface and bottom grid cell thicknesses in real space.
-This is not to be confused with the hybrid schemes that
-superimpose geopotential coordinates on terrain following coordinates thus
-creating a non-analytical vertical coordinate that
-therefore may suffer from large gradients in the vertical resolutions.
-This stretching is less straightforward to implement than the \citet{song.haidvogel_JCP94} stretching,
-but has the advantage of resolving diurnal processes in deep water and has generally flatter slopes.
-
-As with the \citet{song.haidvogel_JCP94} stretching the stretch is only applied at depths greater than
-the critical depth $h_c$.
-In this example two options are available in depths shallower than $h_c$,
-with pure sigma being applied if the \np{ln\_sigcrit} is true and pure z-coordinates if it is false
-(the z-coordinate being equal to the depths of the stretched coordinate at $h_c$).
-
-Minimising the horizontal slope of the vertical coordinate is important in terrain-following systems as
-large slopes lead to hydrostatic consistency.
-A hydrostatic consistency parameter diagnostic following \citet{haney_JPO91} has been implemented,
-and is output as part of the model mesh file at the start of the run.
-
-% -------------------------------------------------------------------------------------------------------------
-%        z*- or s*-coordinate
-% -------------------------------------------------------------------------------------------------------------
-\subsection[\zstar- or \sstar-coordinate (\forcode{ln_linssh = .false.})]
-{\zstar- or \sstar-coordinate (\protect\np{ln\_linssh}\forcode{ = .false.})}
-\label{subsec:DOM_zgr_star}
-
-This option is described in the Report by Levier \textit{et al.} (2007), available on the \NEMO web site.
-
-%gm% key advantage: minimise the diffusion/dispertion associated with advection in response to high frequency surface disturbances
-
-% -------------------------------------------------------------------------------------------------------------
-%        level bathymetry and mask 
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Level bathymetry and mask}
-\label{subsec:DOM_msk}
-
-Whatever the vertical coordinate used, the model offers the possibility of representing the bottom topography with
-steps that follow the face of the model cells (step like topography) \citep{madec.delecluse.ea_JPO96}.
-The distribution of the steps in the horizontal is defined in a 2D integer array, mbathy, which
-gives the number of ocean levels (\ie those that are not masked) at each $t$-point.
-mbathy is computed from the meter bathymetry using the definiton of gdept as the number of $t$-points which
-gdept $\leq$ bathy.
-
-Modifications of the model bathymetry are performed in the \textit{bat\_ctl} routine (see \mdl{domzgr} module) after
-mbathy is computed.
-Isolated grid points that do not communicate with another ocean point at the same level are eliminated.
-
-As for the representation of bathymetry, a 2D integer array, misfdep, is created.
-misfdep defines the level of the first wet $t$-point.
-All the cells between $k = 1$ and $misfdep(i,j) - 1$ are masked.
-By default, $misfdep(:,:) = 1$ and no cells are masked.
-
-In case of ice shelf cavities, modifications of the model bathymetry and ice shelf draft into 
-the cavities are performed in the \textit{zgr\_isf} routine.
-The compatibility between ice shelf draft and bathymetry is checked.
-All the locations where the isf cavity is thinnest than \np{rn\_isfhmin} meters are grounded (\ie masked).
-If only one cell on the water column is opened at $t$-, $u$- or $v$-points,
-the bathymetry or the ice shelf draft is dug to fit this constrain.
-If the incompatibility is too strong (need to dig more than 1 cell), the cell is masked.
-
-From the \textit{mbathy} and \textit{misfdep} array, the mask fields are defined as follows:
-\begin{alignat*}{2}
-  tmask(i,j,k) &= &  &
-    \begin{cases}
-                  0 &\text{if $                  k  <    misfdep(i,j)$} \\
-                  1 &\text{if $misfdep(i,j) \leq k \leq   mbathy(i,j)$} \\
-                  0 &\text{if $                  k  >     mbathy(i,j)$}
-    \end{cases}
-  \\
-  umask(i,j,k) &= &  &tmask(i,j,k) * tmask(i + 1,j,    k) \\
-  vmask(i,j,k) &= &  &tmask(i,j,k) * tmask(i    ,j + 1,k) \\
-  fmask(i,j,k) &= &  &tmask(i,j,k) * tmask(i + 1,j,    k) \\
-               &  &* &tmask(i,j,k) * tmask(i + 1,j,    k) \\
-  wmask(i,j,k) &= &  &tmask(i,j,k) * tmask(i    ,j,k - 1) \\
-  \text{with~} wmask(i,j,1) &= & &tmask(i,j,1)
-\end{alignat*}
-
-Note that, without ice shelves cavities,
-masks at $t-$ and $w-$points are identical with the numerical indexing used (\autoref{subsec:DOM_Num_Index}).
-Nevertheless, $wmask$ are required with ocean cavities to deal with the top boundary (ice shelf/ocean interface) 
-exactly in the same way as for the bottom boundary.
-
-The specification of closed lateral boundaries requires that at least
-the first and last rows and columns of the \textit{mbathy} array are set to zero.
-In the particular case of an east-west cyclical boundary condition, \textit{mbathy} has its last column equal to
-the second one and its first column equal to the last but one (and so too the mask arrays)
-(see \autoref{fig:LBC_jperio}).
-
-% ================================================================
-% Domain: Initial State (dtatsd & istate)
-% ================================================================
-\section[Initial state (\textit{istate.F90} and \textit{dtatsd.F90})]
-{Initial state (\protect\mdl{istate} and \protect\mdl{dtatsd})}
-\label{sec:DTA_tsd}
-%-----------------------------------------namtsd-------------------------------------------
-
-\nlst{namtsd} 
-%------------------------------------------------------------------------------------------
-
-Options are defined in \ngn{namtsd}.
-By default, the ocean start from rest (the velocity field is set to zero) and the initialization of temperature and
-salinity fields is controlled through the \np{ln\_tsd\_ini} namelist parameter.
+The user has the option to
+set the bathymetry in closed seas to zero (see \autoref{sec:MISC_closea}) and to
+optionally decide on the fate of any freshwater imbalance over the area.
+The options are explained in \autoref{sec:MISC_closea} but
+it should be noted here that a successful use of these options requires
+appropriate mask fields to be present in the domain configuration file.
+Among the possibilities are:
+
+\begin{clines}
+int closea_mask     /* non-zero values in closed sea areas for optional masking                */
+int closea_mask_rnf /* non-zero values in closed sea areas with runoff locations (precip only) */
+int closea_mask_emp /* non-zero values in closed sea areas with runoff locations (total emp)   */
+\end{clines}
+
+%% =================================================================================================
+\subsection{Output grid files}
+\label{subsec:DOM_meshmask}
+
+Most of the arrays relating to a particular ocean model configuration discussed in this chapter
+(grid-point position, scale factors) can be saved in a file if
+namelist parameter \np{ln_write_cfg}{ln\_write\_cfg} (namelist \nam{cfg}{cfg}) is set to
+\forcode{.true.};
+the output filename is set through parameter \np{cn_domcfg_out}{cn\_domcfg\_out}.
+This is only really useful if
+the fields are computed in subroutines \mdl{usrdef\_hgr} or \mdl{usrdef\_zgr} and
+checking or confirmation is required.
+
+Alternatively, all the arrays relating to a particular ocean model configuration
+(grid-point position, scale factors, depths and masks) can be saved in
+a file called \texttt{mesh\_mask} if
+namelist parameter \np{ln_meshmask}{ln\_meshmask} (namelist \nam{dom}{dom}) is set to
+\forcode{.true.}.
+This file contains additional fields that can be useful for post-processing applications.
+
+%% =================================================================================================
+\section[Initial state (\textit{istate.F90} and \textit{dtatsd.F90})]{Initial state (\protect\mdl{istate} and \protect\mdl{dtatsd})}
+\label{sec:DOM_DTA_tsd}
+
+\begin{listing}
+  \nlst{namtsd}
+  \caption{\forcode{&namtsd}}
+  \label{lst:namtsd}
+\end{listing}
+
+Basic initial state options are defined in \nam{tsd}{tsd}.
+By default, the ocean starts from rest (the velocity field is set to zero) and
+the initialization of temperature and salinity fields is controlled through the \np{ln_tsd_init}{ln\_tsd\_init} namelist parameter.
+
 \begin{description}
-\item[\np{ln\_tsd\_init}\forcode{ = .true.}]
-  use a T and S input files that can be given on the model grid itself or on their native input data grid.
+\item [{\np[=.true.]{ln_tsd_init}{ln\_tsd\_init}}] Use T and S input files that can be given on
+  the model grid itself or on their native input data grids.
   In the latter case,
   the data will be interpolated on-the-fly both in the horizontal and the vertical to the model grid
   (see \autoref{subsec:SBC_iof}).
-  The information relative to the input files are given in the \np{sn\_tem} and \np{sn\_sal} structures.
+  The information relating to the input files are specified in
+  the \np{sn_tem}{sn\_tem} and \np{sn_sal}{sn\_sal} structures.
   The computation is done in the \mdl{dtatsd} module.
-\item[\np{ln\_tsd\_init}\forcode{ = .false.}]
-  use constant salinity value of $35.5~psu$ and an analytical profile of temperature
-  (typical of the tropical ocean), see \rou{istate\_t\_s} subroutine called from \mdl{istate} module.
+\item [{\np[=.false.]{ln_tsd_init}{ln\_tsd\_init}}] Initial values for T and S are set via
+  a user supplied \rou{usr\_def\_istate} routine contained in \mdl{userdef\_istate}.
+  The default version sets horizontally uniform T and profiles as used in the GYRE configuration
+  (see \autoref{sec:CFGS_gyre}).
 \end{description}
 
-\biblio
-
-\pindex
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DYN.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DYN.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_DYN.tex	(revision 12143)
@@ -2,11 +2,26 @@
 
 \begin{document}
-% ================================================================
-% Chapter ——— Ocean Dynamics (DYN)
-% ================================================================
+
 \chapter{Ocean Dynamics (DYN)}
 \label{chap:DYN}
 
-\minitoc
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
 
 Using the representation described in \autoref{chap:DOM},
@@ -36,48 +51,42 @@
 (surface wind stress calculation using bulk formulae, estimation of mixing coefficients)
 that are carried out in modules SBC, LDF and ZDF and are described in
-\autoref{chap:SBC}, \autoref{chap:LDF} and \autoref{chap:ZDF}, respectively. 
+\autoref{chap:SBC}, \autoref{chap:LDF} and \autoref{chap:ZDF}, respectively.
 
 In the present chapter we also describe the diagnostic equations used to compute the horizontal divergence,
 curl of the velocities (\emph{divcur} module) and the vertical velocity (\emph{wzvmod} module).
 
-The different options available to the user are managed by namelist variables. 
-For term \textit{ttt} in the momentum equations, the logical namelist variables are \textit{ln\_dynttt\_xxx}, 
+The different options available to the user are managed by namelist variables.
+For term \textit{ttt} in the momentum equations, the logical namelist variables are \textit{ln\_dynttt\_xxx},
 where \textit{xxx} is a 3 or 4 letter acronym corresponding to each optional scheme.
-If a CPP key is used for this term its name is \key{ttt}.
+%If a CPP key is used for this term its name is \key{ttt}.
 The corresponding code can be found in the \textit{dynttt\_xxx} module in the DYN directory,
 and it is usually computed in the \textit{dyn\_ttt\_xxx} subroutine.
 
 The user has the option of extracting and outputting each tendency term from the 3D momentum equations
-(\key{trddyn} defined), as described in \autoref{chap:MISC}.
-Furthermore, the tendency terms associated with the 2D barotropic vorticity balance (when \key{trdvor} is defined)
+(\texttt{trddyn?} defined), as described in \autoref{chap:MISC}.
+Furthermore, the tendency terms associated with the 2D barotropic vorticity balance (when \texttt{trdvor?} is defined)
 can be derived from the 3D terms.
-%%%
-\gmcomment{STEVEN: not quite sure I've got the sense of the last sentence. does 
-MISC correspond to "extracting tendency terms" or "vorticity balance"?}
-
-% ================================================================
-% Sea Surface Height evolution & Diagnostics variables
-% ================================================================
+\cmtgm{STEVEN: not quite sure I've got the sense of the last sentence.
+  Does MISC correspond to "extracting tendency terms" or "vorticity balance"?}
+
+%% =================================================================================================
 \section{Sea surface height and diagnostic variables ($\eta$, $\zeta$, $\chi$, $w$)}
 \label{sec:DYN_divcur_wzv}
 
-%--------------------------------------------------------------------------------------------------------------
-%           Horizontal divergence and relative vorticity
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Horizontal divergence and relative vorticity (\textit{divcur.F90})]
-{Horizontal divergence and relative vorticity (\protect\mdl{divcur})}
+%% =================================================================================================
+\subsection[Horizontal divergence and relative vorticity (\textit{divcur.F90})]{Horizontal divergence and relative vorticity (\protect\mdl{divcur})}
 \label{subsec:DYN_divcur}
 
-The vorticity is defined at an $f$-point (\ie corner point) as follows:
-\begin{equation}
-  \label{eq:divcur_cur}
+The vorticity is defined at an $f$-point (\ie\ corner point) as follows:
+\begin{equation}
+  \label{eq:DYN_divcur_cur}
   \zeta =\frac{1}{e_{1f}\,e_{2f} }\left( {\;\delta_{i+1/2} \left[ {e_{2v}\;v} \right]
       -\delta_{j+1/2} \left[ {e_{1u}\;u} \right]\;} \right)
-\end{equation} 
+\end{equation}
 
 The horizontal divergence is defined at a $T$-point.
 It is given by:
 \[
-  % \label{eq:divcur_div}
+  % \label{eq:DYN_divcur_div}
   \chi =\frac{1}{e_{1t}\,e_{2t}\,e_{3t} }
   \left( {\delta_i \left[ {e_{2u}\,e_{3u}\,u} \right]
@@ -97,16 +106,13 @@
 ensure perfect restartability.
 The vorticity and divergence at the \textit{now} time step are used for the computation of
-the nonlinear advection and of the vertical velocity respectively. 
-
-%--------------------------------------------------------------------------------------------------------------
-%           Sea Surface Height evolution
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Horizontal divergence and relative vorticity (\textit{sshwzv.F90})]
-{Horizontal divergence and relative vorticity (\protect\mdl{sshwzv})}
+the nonlinear advection and of the vertical velocity respectively.
+
+%% =================================================================================================
+\subsection[Horizontal divergence and relative vorticity (\textit{sshwzv.F90})]{Horizontal divergence and relative vorticity (\protect\mdl{sshwzv})}
 \label{subsec:DYN_sshwzv}
 
 The sea surface height is given by:
 \begin{equation}
-  \label{eq:dynspg_ssh}
+  \label{eq:DYN_spg_ssh}
   \begin{aligned}
     \frac{\partial \eta }{\partial t}
@@ -117,13 +123,13 @@
   \end{aligned}
 \end{equation}
-where \textit{emp} is the surface freshwater budget (evaporation minus precipitation), 
+where \textit{emp} is the surface freshwater budget (evaporation minus precipitation),
 expressed in Kg/m$^2$/s (which is equal to mm/s),
 and $\rho_w$=1,035~Kg/m$^3$ is the reference density of sea water (Boussinesq approximation).
 If river runoff is expressed as a surface freshwater flux (see \autoref{chap:SBC}) then
-\textit{emp} can be written as the evaporation minus precipitation, minus the river runoff. 
+\textit{emp} can be written as the evaporation minus precipitation, minus the river runoff.
 The sea-surface height is evaluated using exactly the same time stepping scheme as
-the tracer equation \autoref{eq:tra_nxt}:
+the tracer equation \autoref{eq:TRA_nxt}:
 a leapfrog scheme in combination with an Asselin time filter,
-\ie the velocity appearing in \autoref{eq:dynspg_ssh} is centred in time (\textit{now} velocity).
+\ie\ the velocity appearing in \autoref{eq:DYN_spg_ssh} is centred in time (\textit{now} velocity).
 This is of paramount importance.
 Replacing $T$ by the number $1$ in the tracer equation and summing over the water column must lead to
@@ -134,5 +140,5 @@
 taking into account the change of the thickness of the levels:
 \begin{equation}
-  \label{eq:wzv}
+  \label{eq:DYN_wzv}
   \left\{
     \begin{aligned}
@@ -144,53 +150,51 @@
 \end{equation}
 
-In the case of a non-linear free surface (\key{vvl}), the top vertical velocity is $-\textit{emp}/\rho_w$, 
+In the case of a non-linear free surface (\texttt{vvl?}), the top vertical velocity is $-\textit{emp}/\rho_w$,
 as changes in the divergence of the barotropic transport are absorbed into the change of the level thicknesses,
 re-orientated downward.
-\gmcomment{not sure of this...  to be modified with the change in emp setting}
-In the case of a linear free surface, the time derivative in \autoref{eq:wzv} disappears.
+\cmtgm{not sure of this...  to be modified with the change in emp setting}
+In the case of a linear free surface, the time derivative in \autoref{eq:DYN_wzv} disappears.
 The upper boundary condition applies at a fixed level $z=0$.
 The top vertical velocity is thus equal to the divergence of the barotropic transport
-(\ie the first term in the right-hand-side of \autoref{eq:dynspg_ssh}).
+(\ie\ the first term in the right-hand-side of \autoref{eq:DYN_spg_ssh}).
 
 Note also that whereas the vertical velocity has the same discrete expression in $z$- and $s$-coordinates,
 its physical meaning is not the same:
 in the second case, $w$ is the velocity normal to the $s$-surfaces.
-Note also that the $k$-axis is re-orientated downwards in the \fortran code compared to
-the indexing used in the semi-discrete equations such as \autoref{eq:wzv}
-(see \autoref{subsec:DOM_Num_Index_vertical}). 
-
-
-% ================================================================
-% Coriolis and Advection terms: vector invariant form
-% ================================================================
+Note also that the $k$-axis is re-orientated downwards in the \fortran\ code compared to
+the indexing used in the semi-discrete equations such as \autoref{eq:DYN_wzv}
+(see \autoref{subsec:DOM_Num_Index_vertical}).
+
+%% =================================================================================================
 \section{Coriolis and advection: vector invariant form}
 \label{sec:DYN_adv_cor_vect}
-%-----------------------------------------nam_dynadv----------------------------------------------------
-
-\nlst{namdyn_adv} 
-%-------------------------------------------------------------------------------------------------------------
+
+\begin{listing}
+  \nlst{namdyn_adv}
+  \caption{\forcode{&namdyn_adv}}
+  \label{lst:namdyn_adv}
+\end{listing}
 
 The vector invariant form of the momentum equations is the one most often used in
-applications of the \NEMO ocean model.
+applications of the \NEMO\ ocean model.
 The flux form option (see next section) has been present since version $2$.
-Options are defined through the \ngn{namdyn\_adv} namelist variables Coriolis and
+Options are defined through the \nam{dyn_adv}{dyn\_adv} namelist variables Coriolis and
 momentum advection terms are evaluated using a leapfrog scheme,
-\ie the velocity appearing in these expressions is centred in time (\textit{now} velocity). 
+\ie\ the velocity appearing in these expressions is centred in time (\textit{now} velocity).
 At the lateral boundaries either free slip, no slip or partial slip boundary conditions are applied following
 \autoref{chap:LBC}.
 
-% -------------------------------------------------------------------------------------------------------------
-%        Vorticity term 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Vorticity term (\textit{dynvor.F90})]
-{Vorticity term (\protect\mdl{dynvor})}
+%% =================================================================================================
+\subsection[Vorticity term (\textit{dynvor.F90})]{Vorticity term (\protect\mdl{dynvor})}
 \label{subsec:DYN_vor}
-%------------------------------------------nam_dynvor----------------------------------------------------
-
-\nlst{namdyn_vor} 
-%-------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{namdyn\_vor} namelist variables.
-Four discretisations of the vorticity term (\np{ln\_dynvor\_xxx}\forcode{ = .true.}) are available:
+
+\begin{listing}
+  \nlst{namdyn_vor}
+  \caption{\forcode{&namdyn_vor}}
+  \label{lst:namdyn_vor}
+\end{listing}
+
+Options are defined through the \nam{dyn_vor}{dyn\_vor} namelist variables.
+Four discretisations of the vorticity term (\texttt{ln\_dynvor\_xxx}\forcode{=.true.}) are available:
 conserving potential enstrophy of horizontally non-divergent flow (ENS scheme);
 conserving horizontal kinetic energy (ENE scheme);
@@ -198,23 +202,21 @@
 horizontal kinetic energy for the planetary vorticity term (MIX scheme);
 or conserving both the potential enstrophy of horizontally non-divergent flow and horizontal kinetic energy
-(EEN scheme) (see \autoref{subsec:C_vorEEN}).
+(EEN scheme) (see \autoref{subsec:INVARIANTS_vorEEN}).
 In the case of ENS, ENE or MIX schemes the land sea mask may be slightly modified to ensure the consistency of
-vorticity term with analytical equations (\np{ln\_dynvor\_con}\forcode{ = .true.}).
+vorticity term with analytical equations (\np[=.true.]{ln_dynvor_con}{ln\_dynvor\_con}).
 The vorticity terms are all computed in dedicated routines that can be found in the \mdl{dynvor} module.
 
-%-------------------------------------------------------------
 %                 enstrophy conserving scheme
-%-------------------------------------------------------------
-\subsubsection[Enstrophy conserving scheme (\forcode{ln_dynvor_ens = .true.})]
-{Enstrophy conserving scheme (\protect\np{ln\_dynvor\_ens}\forcode{ = .true.})}
+%% =================================================================================================
+\subsubsection[Enstrophy conserving scheme (\forcode{ln_dynvor_ens})]{Enstrophy conserving scheme (\protect\np{ln_dynvor_ens}{ln\_dynvor\_ens})}
 \label{subsec:DYN_vor_ens}
 
 In the enstrophy conserving case (ENS scheme),
 the discrete formulation of the vorticity term provides a global conservation of the enstrophy
-($ [ (\zeta +f ) / e_{3f} ]^2 $ in $s$-coordinates) for a horizontally non-divergent flow (\ie $\chi$=$0$),
+($ [ (\zeta +f ) / e_{3f} ]^2 $ in $s$-coordinates) for a horizontally non-divergent flow (\ie\ $\chi$=$0$),
 but does not conserve the total kinetic energy.
 It is given by:
 \begin{equation}
-  \label{eq:dynvor_ens}
+  \label{eq:DYN_vor_ens}
   \left\{
     \begin{aligned}
@@ -225,11 +227,9 @@
     \end{aligned}
   \right.
-\end{equation} 
-
-%-------------------------------------------------------------
+\end{equation}
+
 %                 energy conserving scheme
-%-------------------------------------------------------------
-\subsubsection[Energy conserving scheme (\forcode{ln_dynvor_ene = .true.})]
-{Energy conserving scheme (\protect\np{ln\_dynvor\_ene}\forcode{ = .true.})}
+%% =================================================================================================
+\subsubsection[Energy conserving scheme (\forcode{ln_dynvor_ene})]{Energy conserving scheme (\protect\np{ln_dynvor_ene}{ln\_dynvor\_ene})}
 \label{subsec:DYN_vor_ene}
 
@@ -237,5 +237,5 @@
 It is given by:
 \begin{equation}
-  \label{eq:dynvor_ene}
+  \label{eq:DYN_vor_ene}
   \left\{
     \begin{aligned}
@@ -246,18 +246,16 @@
     \end{aligned}
   \right.
-\end{equation} 
-
-%-------------------------------------------------------------
+\end{equation}
+
 %                 mix energy/enstrophy conserving scheme
-%-------------------------------------------------------------
-\subsubsection[Mixed energy/enstrophy conserving scheme (\forcode{ln_dynvor_mix = .true.})]
-{Mixed energy/enstrophy conserving scheme (\protect\np{ln\_dynvor\_mix}\forcode{ = .true.})}
+%% =================================================================================================
+\subsubsection[Mixed energy/enstrophy conserving scheme (\forcode{ln_dynvor_mix})]{Mixed energy/enstrophy conserving scheme (\protect\np{ln_dynvor_mix}{ln\_dynvor\_mix})}
 \label{subsec:DYN_vor_mix}
 
 For the mixed energy/enstrophy conserving scheme (MIX scheme), a mixture of the two previous schemes is used.
-It consists of the ENS scheme (\autoref{eq:dynvor_ens}) for the relative vorticity term,
-and of the ENE scheme (\autoref{eq:dynvor_ene}) applied to the planetary vorticity term.
-\[
-  % \label{eq:dynvor_mix}
+It consists of the ENS scheme (\autoref{eq:DYN_vor_ens}) for the relative vorticity term,
+and of the ENE scheme (\autoref{eq:DYN_vor_ene}) applied to the planetary vorticity term.
+\[
+  % \label{eq:DYN_vor_mix}
   \left\{ {
       \begin{aligned}
@@ -274,9 +272,7 @@
 \]
 
-%-------------------------------------------------------------
 %                 energy and enstrophy conserving scheme
-%-------------------------------------------------------------
-\subsubsection[Energy and enstrophy conserving scheme (\forcode{ln_dynvor_een = .true.})]
-{Energy and enstrophy conserving scheme (\protect\np{ln\_dynvor\_een}\forcode{ = .true.})}
+%% =================================================================================================
+\subsubsection[Energy and enstrophy conserving scheme (\forcode{ln_dynvor_een})]{Energy and enstrophy conserving scheme (\protect\np{ln_dynvor_een}{ln\_dynvor\_een})}
 \label{subsec:DYN_vor_een}
 
@@ -285,5 +281,5 @@
 the presence of grid point oscillation structures that will be invisible to the operator.
 These structures are \textit{computational modes} that will be at least partly damped by
-the momentum diffusion operator (\ie the subgrid-scale advection), but not by the resolved advection term.
+the momentum diffusion operator (\ie\ the subgrid-scale advection), but not by the resolved advection term.
 The ENS and ENE schemes therefore do not contribute to dump any grid point noise in the horizontal velocity field.
 Such noise would result in more noise in the vertical velocity field, an undesirable feature.
@@ -291,5 +287,5 @@
 $u$ and $v$ are located at different grid points,
 a price worth paying to avoid a double averaging in the pressure gradient term as in the $B$-grid.
-\gmcomment{ To circumvent this, Adcroft (ADD REF HERE) 
+\cmtgm{ To circumvent this, Adcroft (ADD REF HERE)
 Nevertheless, this technique strongly distort the phase and group velocity of Rossby waves....}
 
@@ -297,36 +293,32 @@
 The idea is to get rid of the double averaging by considering triad combinations of vorticity.
 It is noteworthy that this solution is conceptually quite similar to the one proposed by
-\citep{griffies.gnanadesikan.ea_JPO98} for the discretization of the iso-neutral diffusion operator (see \autoref{apdx:C}).
-
-The \citet{arakawa.hsu_MWR90} vorticity advection scheme for a single layer is modified 
-for spherical coordinates as described by \citet{arakawa.lamb_MWR81} to obtain the EEN scheme. 
-First consider the discrete expression of the potential vorticity, $q$, defined at an $f$-point: 
-\[
-  % \label{eq:pot_vor}
+\citep{griffies.gnanadesikan.ea_JPO98} for the discretization of the iso-neutral diffusion operator (see \autoref{apdx:INVARIANTS}).
+
+The \citet{arakawa.hsu_MWR90} vorticity advection scheme for a single layer is modified
+for spherical coordinates as described by \citet{arakawa.lamb_MWR81} to obtain the EEN scheme.
+First consider the discrete expression of the potential vorticity, $q$, defined at an $f$-point:
+\[
+  % \label{eq:DYN_pot_vor}
   q  = \frac{\zeta +f} {e_{3f} }
 \]
-where the relative vorticity is defined by (\autoref{eq:divcur_cur}),
-the Coriolis parameter is given by $f=2 \,\Omega \;\sin \varphi _f $ and the layer thickness at $f$-points is: 
-\begin{equation}
-  \label{eq:een_e3f}
+where the relative vorticity is defined by (\autoref{eq:DYN_divcur_cur}),
+the Coriolis parameter is given by $f=2 \,\Omega \;\sin \varphi _f $ and the layer thickness at $f$-points is:
+\begin{equation}
+  \label{eq:DYN_een_e3f}
   e_{3f} = \overline{\overline {e_{3t} }} ^{\,i+1/2,j+1/2}
 \end{equation}
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!ht]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_DYN_een_triad}
-    \caption{
-      \protect\label{fig:DYN_een_triad}
-      Triads used in the energy and enstrophy conserving scheme (een) for
-      $u$-component (upper panel) and $v$-component (lower panel).
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{DYN_een_triad}
+  \caption[Triads used in the energy and enstrophy conserving scheme (EEN)]{
+    Triads used in the energy and enstrophy conserving scheme (EEN) for
+    $u$-component (upper panel) and $v$-component (lower panel).}
+  \label{fig:DYN_een_triad}
 \end{figure}
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-A key point in \autoref{eq:een_e3f} is how the averaging in the \textbf{i}- and \textbf{j}- directions is made. 
+
+A key point in \autoref{eq:DYN_een_e3f} is how the averaging in the \textbf{i}- and \textbf{j}- directions is made.
 It uses the sum of masked t-point vertical scale factor divided either by the sum of the four t-point masks
-(\np{nn\_een\_e3f}\forcode{ = 1}), or just by $4$ (\np{nn\_een\_e3f}\forcode{ = .true.}).
+(\np[=1]{nn_een_e3f}{nn\_een\_e3f}), or just by $4$ (\np[=.true.]{nn_een_e3f}{nn\_een\_e3f}).
 The latter case preserves the continuity of $e_{3f}$ when one or more of the neighbouring $e_{3t}$ tends to zero and
 extends by continuity the value of $e_{3f}$ into the land areas.
@@ -334,19 +326,19 @@
 (with a systematic reduction of $e_{3f}$ when a model level intercept the bathymetry)
 that tends to reinforce the topostrophy of the flow
-(\ie the tendency of the flow to follow the isobaths) \citep{penduff.le-sommer.ea_OS07}. 
+(\ie\ the tendency of the flow to follow the isobaths) \citep{penduff.le-sommer.ea_OS07}.
 
 Next, the vorticity triads, $ {^i_j}\mathbb{Q}^{i_p}_{j_p}$ can be defined at a $T$-point as
 the following triad combinations of the neighbouring potential vorticities defined at f-points
-(\autoref{fig:DYN_een_triad}): 
-\begin{equation}
-  \label{eq:Q_triads}
+(\autoref{fig:DYN_een_triad}):
+\begin{equation}
+  \label{eq:DYN_Q_triads}
   _i^j \mathbb{Q}^{i_p}_{j_p}
   = \frac{1}{12} \ \left(   q^{i-i_p}_{j+j_p} + q^{i+j_p}_{j+i_p} + q^{i+i_p}_{j-j_p}  \right)
 \end{equation}
-where the indices $i_p$ and $k_p$ take the values: $i_p = -1/2$ or $1/2$ and $j_p = -1/2$ or $1/2$. 
-
-Finally, the vorticity terms are represented as: 
-\begin{equation}
-  \label{eq:dynvor_een}
+where the indices $i_p$ and $k_p$ take the values: $i_p = -1/2$ or $1/2$ and $j_p = -1/2$ or $1/2$.
+
+Finally, the vorticity terms are represented as:
+\begin{equation}
+  \label{eq:DYN_vor_een}
   \left\{ {
       \begin{aligned}
@@ -357,28 +349,25 @@
       \end{aligned}
     } \right.
-\end{equation} 
+\end{equation}
 
 This EEN scheme in fact combines the conservation properties of the ENS and ENE schemes.
 It conserves both total energy and potential enstrophy in the limit of horizontally nondivergent flow
-(\ie $\chi$=$0$) (see \autoref{subsec:C_vorEEN}). 
+(\ie\ $\chi$=$0$) (see \autoref{subsec:INVARIANTS_vorEEN}).
 Applied to a realistic ocean configuration, it has been shown that it leads to a significant reduction of
 the noise in the vertical velocity field \citep{le-sommer.penduff.ea_OM09}.
 Furthermore, used in combination with a partial steps representation of bottom topography,
 it improves the interaction between current and topography,
-leading to a larger topostrophy of the flow \citep{barnier.madec.ea_OD06, penduff.le-sommer.ea_OS07}. 
-
-%--------------------------------------------------------------------------------------------------------------
-%           Kinetic Energy Gradient term
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Kinetic energy gradient term (\textit{dynkeg.F90})]
-{Kinetic energy gradient term (\protect\mdl{dynkeg})}
+leading to a larger topostrophy of the flow \citep{barnier.madec.ea_OD06, penduff.le-sommer.ea_OS07}.
+
+%% =================================================================================================
+\subsection[Kinetic energy gradient term (\textit{dynkeg.F90})]{Kinetic energy gradient term (\protect\mdl{dynkeg})}
 \label{subsec:DYN_keg}
 
-As demonstrated in \autoref{apdx:C},
+As demonstrated in \autoref{apdx:INVARIANTS},
 there is a single discrete formulation of the kinetic energy gradient term that,
 together with the formulation chosen for the vertical advection (see below),
 conserves the total kinetic energy:
 \[
-  % \label{eq:dynkeg}
+  % \label{eq:DYN_keg}
   \left\{
     \begin{aligned}
@@ -389,9 +378,6 @@
 \]
 
-%--------------------------------------------------------------------------------------------------------------
-%           Vertical advection term
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Vertical advection term (\textit{dynzad.F90})]
-{Vertical advection term (\protect\mdl{dynzad})}
+%% =================================================================================================
+\subsection[Vertical advection term (\textit{dynzad.F90})]{Vertical advection term (\protect\mdl{dynzad})}
 \label{subsec:DYN_zad}
 
@@ -400,7 +386,7 @@
 conserves the total kinetic energy.
 Indeed, the change of KE due to the vertical advection is exactly balanced by
-the change of KE due to the gradient of KE (see \autoref{apdx:C}).
-\[
-  % \label{eq:dynzad}
+the change of KE due to the gradient of KE (see \autoref{apdx:INVARIANTS}).
+\[
+  % \label{eq:DYN_zad}
   \left\{
     \begin{aligned}
@@ -410,62 +396,48 @@
   \right.
 \]
-When \np{ln\_dynzad\_zts}\forcode{ = .true.},
+When \np[=.true.]{ln_dynzad_zts}{ln\_dynzad\_zts},
 a split-explicit time stepping with 5 sub-timesteps is used on the vertical advection term.
-This option can be useful when the value of the timestep is limited by vertical advection \citep{lemarie.debreu.ea_OM15}. 
+This option can be useful when the value of the timestep is limited by vertical advection \citep{lemarie.debreu.ea_OM15}.
 Note that in this case,
 a similar split-explicit time stepping should be used on vertical advection of tracer to ensure a better stability,
-an option which is only available with a TVD scheme (see \np{ln\_traadv\_tvd\_zts} in \autoref{subsec:TRA_adv_tvd}).
-
-
-% ================================================================
-% Coriolis and Advection : flux form
-% ================================================================
+an option which is only available with a TVD scheme (see \np{ln_traadv_tvd_zts}{ln\_traadv\_tvd\_zts} in \autoref{subsec:TRA_adv_tvd}).
+
+%% =================================================================================================
 \section{Coriolis and advection: flux form}
 \label{sec:DYN_adv_cor_flux}
-%------------------------------------------nam_dynadv----------------------------------------------------
-
-\nlst{namdyn_adv} 
-%-------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{namdyn\_adv} namelist variables.
+
+Options are defined through the \nam{dyn_adv}{dyn\_adv} namelist variables.
 In the flux form (as in the vector invariant form),
 the Coriolis and momentum advection terms are evaluated using a leapfrog scheme,
-\ie the velocity appearing in their expressions is centred in time (\textit{now} velocity).
+\ie\ the velocity appearing in their expressions is centred in time (\textit{now} velocity).
 At the lateral boundaries either free slip,
 no slip or partial slip boundary conditions are applied following \autoref{chap:LBC}.
 
-
-%--------------------------------------------------------------------------------------------------------------
-%           Coriolis plus curvature metric terms
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Coriolis plus curvature metric terms (\textit{dynvor.F90})]
-{Coriolis plus curvature metric terms (\protect\mdl{dynvor})}
+%% =================================================================================================
+\subsection[Coriolis plus curvature metric terms (\textit{dynvor.F90})]{Coriolis plus curvature metric terms (\protect\mdl{dynvor})}
 \label{subsec:DYN_cor_flux}
 
 In flux form, the vorticity term reduces to a Coriolis term in which the Coriolis parameter has been modified to account for the "metric" term.
 This altered Coriolis parameter is thus discretised at $f$-points.
-It is given by: 
+It is given by:
 \begin{multline*}
-  % \label{eq:dyncor_metric}
+  % \label{eq:DYN_cor_metric}
   f+\frac{1}{e_1 e_2 }\left( {v\frac{\partial e_2 }{\partial i}  -  u\frac{\partial e_1 }{\partial j}} \right)  \\
   \equiv   f + \frac{1}{e_{1f} e_{2f} } \left( { \ \overline v ^{i+1/2}\delta_{i+1/2} \left[ {e_{2u} } \right]
       -  \overline u ^{j+1/2}\delta_{j+1/2} \left[ {e_{1u} } \right]  }  \ \right)
-\end{multline*} 
-
-Any of the (\autoref{eq:dynvor_ens}), (\autoref{eq:dynvor_ene}) and (\autoref{eq:dynvor_een}) schemes can be used to
+\end{multline*}
+
+Any of the (\autoref{eq:DYN_vor_ens}), (\autoref{eq:DYN_vor_ene}) and (\autoref{eq:DYN_vor_een}) schemes can be used to
 compute the product of the Coriolis parameter and the vorticity.
-However, the energy-conserving scheme (\autoref{eq:dynvor_een}) has exclusively been used to date.
-This term is evaluated using a leapfrog scheme, \ie the velocity is centred in time (\textit{now} velocity).
-
-%--------------------------------------------------------------------------------------------------------------
-%           Flux form Advection term
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Flux form advection term (\textit{dynadv.F90})]
-{Flux form advection term (\protect\mdl{dynadv})}
+However, the energy-conserving scheme (\autoref{eq:DYN_vor_een}) has exclusively been used to date.
+This term is evaluated using a leapfrog scheme, \ie\ the velocity is centred in time (\textit{now} velocity).
+
+%% =================================================================================================
+\subsection[Flux form advection term (\textit{dynadv.F90})]{Flux form advection term (\protect\mdl{dynadv})}
 \label{subsec:DYN_adv_flux}
 
 The discrete expression of the advection term is given by:
 \[
-  % \label{eq:dynadv}
+  % \label{eq:DYN_adv}
   \left\{
     \begin{aligned}
@@ -487,19 +459,17 @@
 or a $3^{rd}$ order upstream biased scheme, UBS.
 The latter is described in \citet{shchepetkin.mcwilliams_OM05}.
-The schemes are selected using the namelist logicals \np{ln\_dynadv\_cen2} and \np{ln\_dynadv\_ubs}. 
+The schemes are selected using the namelist logicals \np{ln_dynadv_cen2}{ln\_dynadv\_cen2} and \np{ln_dynadv_ubs}{ln\_dynadv\_ubs}.
 In flux form, the schemes differ by the choice of a space and time interpolation to define the value of
-$u$ and $v$ at the centre of each face of $u$- and $v$-cells, \ie at the $T$-, $f$-,
-and $uw$-points for $u$ and at the $f$-, $T$- and $vw$-points for $v$. 
-
-%-------------------------------------------------------------
+$u$ and $v$ at the centre of each face of $u$- and $v$-cells, \ie\ at the $T$-, $f$-,
+and $uw$-points for $u$ and at the $f$-, $T$- and $vw$-points for $v$.
+
 %                 2nd order centred scheme
-%-------------------------------------------------------------
-\subsubsection[CEN2: $2^{nd}$ order centred scheme (\forcode{ln_dynadv_cen2 = .true.})]
-{CEN2: $2^{nd}$ order centred scheme (\protect\np{ln\_dynadv\_cen2}\forcode{ = .true.})}
+%% =================================================================================================
+\subsubsection[CEN2: $2^{nd}$ order centred scheme (\forcode{ln_dynadv_cen2})]{CEN2: $2^{nd}$ order centred scheme (\protect\np{ln_dynadv_cen2}{ln\_dynadv\_cen2})}
 \label{subsec:DYN_adv_cen2}
 
 In the centered $2^{nd}$ order formulation, the velocity is evaluated as the mean of the two neighbouring points:
 \begin{equation}
-  \label{eq:dynadv_cen2}
+  \label{eq:DYN_adv_cen2}
   \left\{
     \begin{aligned}
@@ -508,7 +478,7 @@
     \end{aligned}
   \right.
-\end{equation} 
-
-The scheme is non diffusive (\ie conserves the kinetic energy) but dispersive (\ie it may create false extrema).
+\end{equation}
+
+The scheme is non diffusive (\ie\ conserves the kinetic energy) but dispersive (\ie\ it may create false extrema).
 It is therefore notoriously noisy and must be used in conjunction with an explicit diffusion operator to
 produce a sensible solution.
@@ -516,9 +486,7 @@
 so $u$ and $v$ are the \emph{now} velocities.
 
-%-------------------------------------------------------------
 %                 UBS scheme
-%-------------------------------------------------------------
-\subsubsection[UBS: Upstream Biased Scheme (\forcode{ln_dynadv_ubs = .true.})]
-{UBS: Upstream Biased Scheme (\protect\np{ln\_dynadv\_ubs}\forcode{ = .true.})}
+%% =================================================================================================
+\subsubsection[UBS: Upstream Biased Scheme (\forcode{ln_dynadv_ubs})]{UBS: Upstream Biased Scheme (\protect\np{ln_dynadv_ubs}{ln\_dynadv\_ubs})}
 \label{subsec:DYN_adv_ubs}
 
@@ -527,5 +495,5 @@
 For example, the evaluation of $u_T^{ubs} $ is done as follows:
 \begin{equation}
-  \label{eq:dynadv_ubs}
+  \label{eq:DYN_adv_ubs}
   u_T^{ubs} =\overline u ^i-\;\frac{1}{6}
   \begin{cases}
@@ -535,5 +503,5 @@
 \end{equation}
 where $u"_{i+1/2} =\delta_{i+1/2} \left[ {\delta_i \left[ u \right]} \right]$.
-This results in a dissipatively dominant (\ie hyper-diffusive) truncation error
+This results in a dissipatively dominant (\ie\ hyper-diffusive) truncation error
 \citep{shchepetkin.mcwilliams_OM05}.
 The overall performance of the advection scheme is similar to that reported in \citet{farrow.stevens_JPO95}.
@@ -541,15 +509,15 @@
 It is not a \emph{positive} scheme, meaning that false extrema are permitted.
 But the amplitudes of the false extrema are significantly reduced over those in the centred second order method.
-As the scheme already includes a diffusion component, it can be used without explicit lateral diffusion on momentum 
-(\ie \np{ln\_dynldf\_lap}\forcode{ = }\np{ln\_dynldf\_bilap}\forcode{ = .false.}),
+As the scheme already includes a diffusion component, it can be used without explicit lateral diffusion on momentum
+(\ie\ \np[=]{ln_dynldf_lap}{ln\_dynldf\_lap}\np[=.false.]{ln_dynldf_bilap}{ln\_dynldf\_bilap}),
 and it is recommended to do so.
 
 The UBS scheme is not used in all directions.
-In the vertical, the centred $2^{nd}$ order evaluation of the advection is preferred, \ie $u_{uw}^{ubs}$ and
-$u_{vw}^{ubs}$ in \autoref{eq:dynadv_cen2} are used.
-UBS is diffusive and is associated with vertical mixing of momentum. \gmcomment{ gm  pursue the 
+In the vertical, the centred $2^{nd}$ order evaluation of the advection is preferred, \ie\ $u_{uw}^{ubs}$ and
+$u_{vw}^{ubs}$ in \autoref{eq:DYN_adv_cen2} are used.
+UBS is diffusive and is associated with vertical mixing of momentum. \cmtgm{ gm  pursue the
 sentence:Since vertical mixing of momentum is a source term of the TKE equation...  }
 
-For stability reasons, the first term in (\autoref{eq:dynadv_ubs}),
+For stability reasons, the first term in (\autoref{eq:DYN_adv_ubs}),
 which corresponds to a second order centred scheme, is evaluated using the \textit{now} velocity (centred in time),
 while the second term, which is the diffusion part of the scheme,
@@ -559,5 +527,5 @@
 Note that the UBS and QUICK (Quadratic Upstream Interpolation for Convective Kinematics) schemes only differ by
 one coefficient.
-Replacing $1/6$ by $1/8$ in (\autoref{eq:dynadv_ubs}) leads to the QUICK advection scheme \citep{webb.de-cuevas.ea_JAOT98}.
+Replacing $1/6$ by $1/8$ in (\autoref{eq:DYN_adv_ubs}) leads to the QUICK advection scheme \citep{webb.de-cuevas.ea_JAOT98}.
 This option is not available through a namelist parameter, since the $1/6$ coefficient is hard coded.
 Nevertheless it is quite easy to make the substitution in the \mdl{dynadv\_ubs} module and obtain a QUICK scheme.
@@ -566,36 +534,30 @@
 there is also the possibility of using a $4^{th}$ order evaluation of the advective velocity as in ROMS.
 This is an error and should be suppressed soon.
-%%%
-\gmcomment{action :  this have to be done}
-%%%
-
-% ================================================================
-%           Hydrostatic pressure gradient term
-% ================================================================
-\section[Hydrostatic pressure gradient (\textit{dynhpg.F90})]
-{Hydrostatic pressure gradient (\protect\mdl{dynhpg})}
+\cmtgm{action :  this have to be done}
+
+%% =================================================================================================
+\section[Hydrostatic pressure gradient (\textit{dynhpg.F90})]{Hydrostatic pressure gradient (\protect\mdl{dynhpg})}
 \label{sec:DYN_hpg}
-%------------------------------------------nam_dynhpg---------------------------------------------------
-
-\nlst{namdyn_hpg} 
-%-------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{namdyn\_hpg} namelist variables.
+
+\begin{listing}
+  \nlst{namdyn_hpg}
+  \caption{\forcode{&namdyn_hpg}}
+  \label{lst:namdyn_hpg}
+\end{listing}
+
+Options are defined through the \nam{dyn_hpg}{dyn\_hpg} namelist variables.
 The key distinction between the different algorithms used for
 the hydrostatic pressure gradient is the vertical coordinate used,
-since HPG is a \emph{horizontal} pressure gradient, \ie computed along geopotential surfaces.
+since HPG is a \emph{horizontal} pressure gradient, \ie\ computed along geopotential surfaces.
 As a result, any tilt of the surface of the computational levels will require a specific treatment to
 compute the hydrostatic pressure gradient.
 
 The hydrostatic pressure gradient term is evaluated either using a leapfrog scheme,
-\ie the density appearing in its expression is centred in time (\emph{now} $\rho$),
+\ie\ the density appearing in its expression is centred in time (\emph{now} $\rho$),
 or a semi-implcit scheme.
 At the lateral boundaries either free slip, no slip or partial slip boundary conditions are applied.
 
-%--------------------------------------------------------------------------------------------------------------
-%           z-coordinate with full step
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Full step $Z$-coordinate (\forcode{ln_dynhpg_zco = .true.})]
-{Full step $Z$-coordinate (\protect\np{ln\_dynhpg\_zco}\forcode{ = .true.})}
+%% =================================================================================================
+\subsection[Full step $Z$-coordinate (\forcode{ln_dynhpg_zco})]{Full step $Z$-coordinate (\protect\np{ln_dynhpg_zco}{ln\_dynhpg\_zco})}
 \label{subsec:DYN_hpg_zco}
 
@@ -607,5 +569,5 @@
 for $k=km$ (surface layer, $jk=1$ in the code)
 \begin{equation}
-  \label{eq:dynhpg_zco_surf}
+  \label{eq:DYN_hpg_zco_surf}
   \left\{
     \begin{aligned}
@@ -616,9 +578,9 @@
     \end{aligned}
   \right.
-\end{equation} 
+\end{equation}
 
 for $1<k<km$ (interior layer)
 \begin{equation}
-  \label{eq:dynhpg_zco}
+  \label{eq:DYN_hpg_zco}
   \left\{
     \begin{aligned}
@@ -631,17 +593,14 @@
     \end{aligned}
   \right.
-\end{equation} 
-
-Note that the $1/2$ factor in (\autoref{eq:dynhpg_zco_surf}) is adequate because of the definition of $e_{3w}$ as
+\end{equation}
+
+Note that the $1/2$ factor in (\autoref{eq:DYN_hpg_zco_surf}) is adequate because of the definition of $e_{3w}$ as
 the vertical derivative of the scale factor at the surface level ($z=0$).
-Note also that in case of variable volume level (\key{vvl} defined),
-the surface pressure gradient is included in \autoref{eq:dynhpg_zco_surf} and
-\autoref{eq:dynhpg_zco} through the space and time variations of the vertical scale factor $e_{3w}$.
-
-%--------------------------------------------------------------------------------------------------------------
-%           z-coordinate with partial step
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Partial step $Z$-coordinate (\forcode{ln_dynhpg_zps = .true.})]
-{Partial step $Z$-coordinate (\protect\np{ln\_dynhpg\_zps}\forcode{ = .true.})}
+Note also that in case of variable volume level (\texttt{vvl?} defined),
+the surface pressure gradient is included in \autoref{eq:DYN_hpg_zco_surf} and
+\autoref{eq:DYN_hpg_zco} through the space and time variations of the vertical scale factor $e_{3w}$.
+
+%% =================================================================================================
+\subsection[Partial step $Z$-coordinate (\forcode{ln_dynhpg_zps})]{Partial step $Z$-coordinate (\protect\np{ln_dynhpg_zps}{ln\_dynhpg\_zps})}
 \label{subsec:DYN_hpg_zps}
 
@@ -649,5 +608,5 @@
 Before taking horizontal gradients between these tracer points,
 a linear interpolation is used to approximate the deeper tracer as if
-it actually lived at the depth of the shallower tracer point. 
+it actually lived at the depth of the shallower tracer point.
 
 Apart from this modification,
@@ -661,18 +620,16 @@
 module \mdl{zpsdhe} located in the TRA directory and described in \autoref{sec:TRA_zpshde}.
 
-%--------------------------------------------------------------------------------------------------------------
-%           s- and s-z-coordinates
-%--------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \subsection{$S$- and $Z$-$S$-coordinates}
 \label{subsec:DYN_hpg_sco}
 
 Pressure gradient formulations in an $s$-coordinate have been the subject of a vast number of papers
-(\eg, \citet{song_MWR98, shchepetkin.mcwilliams_OM05}). 
+(\eg, \citet{song_MWR98, shchepetkin.mcwilliams_OM05}).
 A number of different pressure gradient options are coded but the ROMS-like,
 density Jacobian with cubic polynomial method is currently disabled whilst known bugs are under investigation.
 
-$\bullet$ Traditional coding (see for example \citet{madec.delecluse.ea_JPO96}: (\np{ln\_dynhpg\_sco}\forcode{ = .true.})
-\begin{equation}
-  \label{eq:dynhpg_sco}
+$\bullet$ Traditional coding (see for example \citet{madec.delecluse.ea_JPO96}: (\np[=.true.]{ln_dynhpg_sco}{ln\_dynhpg\_sco})
+\begin{equation}
+  \label{eq:DYN_hpg_sco}
   \left\{
     \begin{aligned}
@@ -683,24 +640,24 @@
     \end{aligned}
   \right.
-\end{equation} 
+\end{equation}
 
 Where the first term is the pressure gradient along coordinates,
-computed as in \autoref{eq:dynhpg_zco_surf} - \autoref{eq:dynhpg_zco},
-and $z_T$ is the depth of the $T$-point evaluated from the sum of the vertical scale factors at the $w$-point 
+computed as in \autoref{eq:DYN_hpg_zco_surf} - \autoref{eq:DYN_hpg_zco},
+and $z_T$ is the depth of the $T$-point evaluated from the sum of the vertical scale factors at the $w$-point
 ($e_{3w}$).
- 
-$\bullet$ Traditional coding with adaptation for ice shelf cavities (\np{ln\_dynhpg\_isf}\forcode{ = .true.}).
-This scheme need the activation of ice shelf cavities (\np{ln\_isfcav}\forcode{ = .true.}).
-
-$\bullet$ Pressure Jacobian scheme (prj) (a research paper in preparation) (\np{ln\_dynhpg\_prj}\forcode{ = .true.})
-
-$\bullet$ Density Jacobian with cubic polynomial scheme (DJC) \citep{shchepetkin.mcwilliams_OM05} 
-(\np{ln\_dynhpg\_djc}\forcode{ = .true.}) (currently disabled; under development)
-
-Note that expression \autoref{eq:dynhpg_sco} is commonly used when the variable volume formulation is activated
-(\key{vvl}) because in that case, even with a flat bottom,
+
+$\bullet$ Traditional coding with adaptation for ice shelf cavities (\np[=.true.]{ln_dynhpg_isf}{ln\_dynhpg\_isf}).
+This scheme need the activation of ice shelf cavities (\np[=.true.]{ln_isfcav}{ln\_isfcav}).
+
+$\bullet$ Pressure Jacobian scheme (prj) (a research paper in preparation) (\np[=.true.]{ln_dynhpg_prj}{ln\_dynhpg\_prj})
+
+$\bullet$ Density Jacobian with cubic polynomial scheme (DJC) \citep{shchepetkin.mcwilliams_OM05}
+(\np[=.true.]{ln_dynhpg_djc}{ln\_dynhpg\_djc}) (currently disabled; under development)
+
+Note that expression \autoref{eq:DYN_hpg_sco} is commonly used when the variable volume formulation is activated
+(\texttt{vvl?}) because in that case, even with a flat bottom,
 the coordinate surfaces are not horizontal but follow the free surface \citep{levier.treguier.ea_rpt07}.
-The pressure jacobian scheme (\np{ln\_dynhpg\_prj}\forcode{ = .true.}) is available as
-an improved option to \np{ln\_dynhpg\_sco}\forcode{ = .true.} when \key{vvl} is active.
+The pressure jacobian scheme (\np[=.true.]{ln_dynhpg_prj}{ln\_dynhpg\_prj}) is available as
+an improved option to \np[=.true.]{ln_dynhpg_sco}{ln\_dynhpg\_sco} when \texttt{vvl?} is active.
 The pressure Jacobian scheme uses a constrained cubic spline to
 reconstruct the density profile across the water column.
@@ -710,8 +667,10 @@
 This method can provide a more accurate calculation of the horizontal pressure gradient than the standard scheme.
 
+%% =================================================================================================
 \subsection{Ice shelf cavity}
 \label{subsec:DYN_hpg_isf}
+
 Beneath an ice shelf, the total pressure gradient is the sum of the pressure gradient due to the ice shelf load and
-the pressure gradient due to the ocean load (\np{ln\_dynhpg\_isf}\forcode{ = .true.}).\\
+the pressure gradient due to the ocean load (\np[=.true.]{ln_dynhpg_isf}{ln\_dynhpg\_isf}).\\
 
 The main hypothesis to compute the ice shelf load is that the ice shelf is in an isostatic equilibrium.
@@ -722,12 +681,9 @@
 A detailed description of this method is described in \citet{losch_JGR08}.\\
 
-The pressure gradient due to ocean load is computed using the expression \autoref{eq:dynhpg_sco} described in
-\autoref{subsec:DYN_hpg_sco}. 
-
-%--------------------------------------------------------------------------------------------------------------
-%           Time-scheme
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Time-scheme (\forcode{ln_dynhpg_imp = .{true,false}.})]
-{Time-scheme (\protect\np{ln\_dynhpg\_imp}\forcode{ = .\{true,false\}}.)}
+The pressure gradient due to ocean load is computed using the expression \autoref{eq:DYN_hpg_sco} described in
+\autoref{subsec:DYN_hpg_sco}.
+
+%% =================================================================================================
+\subsection[Time-scheme (\forcode{ln_dynhpg_imp})]{Time-scheme (\protect\np{ln_dynhpg_imp}{ln\_dynhpg\_imp})}
 \label{subsec:DYN_hpg_imp}
 
@@ -742,34 +698,34 @@
 It involves the evaluation of the hydrostatic pressure gradient as
 an average over the three time levels $t-\rdt$, $t$, and $t+\rdt$
-(\ie \textit{before}, \textit{now} and  \textit{after} time-steps),
-rather than at the central time level $t$ only, as in the standard leapfrog scheme. 
-
-$\bullet$ leapfrog scheme (\np{ln\_dynhpg\_imp}\forcode{ = .true.}):
-
-\begin{equation}
-  \label{eq:dynhpg_lf}
+(\ie\ \textit{before}, \textit{now} and  \textit{after} time-steps),
+rather than at the central time level $t$ only, as in the standard leapfrog scheme.
+
+$\bullet$ leapfrog scheme (\np[=.true.]{ln_dynhpg_imp}{ln\_dynhpg\_imp}):
+
+\begin{equation}
+  \label{eq:DYN_hpg_lf}
   \frac{u^{t+\rdt}-u^{t-\rdt}}{2\rdt} = \;\cdots \;
   -\frac{1}{\rho_o \,e_{1u} }\delta_{i+1/2} \left[ {p_h^t } \right]
 \end{equation}
 
-$\bullet$ semi-implicit scheme (\np{ln\_dynhpg\_imp}\forcode{ = .true.}):
-\begin{equation}
-  \label{eq:dynhpg_imp}
+$\bullet$ semi-implicit scheme (\np[=.true.]{ln_dynhpg_imp}{ln\_dynhpg\_imp}):
+\begin{equation}
+  \label{eq:DYN_hpg_imp}
   \frac{u^{t+\rdt}-u^{t-\rdt}}{2\rdt} = \;\cdots \;
   -\frac{1}{4\,\rho_o \,e_{1u} } \delta_{i+1/2} \left[ p_h^{t+\rdt} +2\,p_h^t +p_h^{t-\rdt}  \right]
 \end{equation}
 
-The semi-implicit time scheme \autoref{eq:dynhpg_imp} is made possible without
+The semi-implicit time scheme \autoref{eq:DYN_hpg_imp} is made possible without
 significant additional computation since the density can be updated to time level $t+\rdt$ before
 computing the horizontal hydrostatic pressure gradient.
 It can be easily shown that the stability limit associated with the hydrostatic pressure gradient doubles using
-\autoref{eq:dynhpg_imp} compared to that using the standard leapfrog scheme \autoref{eq:dynhpg_lf}.
-Note that \autoref{eq:dynhpg_imp} is equivalent to applying a time filter to the pressure gradient to
+\autoref{eq:DYN_hpg_imp} compared to that using the standard leapfrog scheme \autoref{eq:DYN_hpg_lf}.
+Note that \autoref{eq:DYN_hpg_imp} is equivalent to applying a time filter to the pressure gradient to
 eliminate high frequency IGWs.
-Obviously, when using \autoref{eq:dynhpg_imp},
+Obviously, when using \autoref{eq:DYN_hpg_imp},
 the doubling of the time-step is achievable only if no other factors control the time-step,
 such as the stability limits associated with advection or diffusion.
 
-In practice, the semi-implicit scheme is used when \np{ln\_dynhpg\_imp}\forcode{ = .true.}.
+In practice, the semi-implicit scheme is used when \np[=.true.]{ln_dynhpg_imp}{ln\_dynhpg\_imp}.
 In this case, we choose to apply the time filter to temperature and salinity used in the equation of state,
 instead of applying it to the hydrostatic pressure or to the density,
@@ -777,5 +733,5 @@
 The density used to compute the hydrostatic pressure gradient (whatever the formulation) is evaluated as follows:
 \[
-  % \label{eq:rho_flt}
+  % \label{eq:DYN_rho_flt}
   \rho^t = \rho( \widetilde{T},\widetilde {S},z_t)
   \quad	  \text{with}	\quad
@@ -785,39 +741,37 @@
 Note that in the semi-implicit case, it is necessary to save the filtered density,
 an extra three-dimensional field, in the restart file to restart the model with exact reproducibility.
-This option is controlled by  \np{nn\_dynhpg\_rst}, a namelist parameter.
-
-% ================================================================
-% Surface Pressure Gradient
-% ================================================================
-\section[Surface pressure gradient (\textit{dynspg.F90})]
-{Surface pressure gradient (\protect\mdl{dynspg})}
+This option is controlled by  \np{nn_dynhpg_rst}{nn\_dynhpg\_rst}, a namelist parameter.
+
+%% =================================================================================================
+\section[Surface pressure gradient (\textit{dynspg.F90})]{Surface pressure gradient (\protect\mdl{dynspg})}
 \label{sec:DYN_spg}
-%-----------------------------------------nam_dynspg----------------------------------------------------
-
-\nlst{namdyn_spg} 
-%------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{namdyn\_spg} namelist variables.
-The surface pressure gradient term is related to the representation of the free surface (\autoref{sec:PE_hor_pg}).
+
+\begin{listing}
+  \nlst{namdyn_spg}
+  \caption{\forcode{&namdyn_spg}}
+  \label{lst:namdyn_spg}
+\end{listing}
+
+Options are defined through the \nam{dyn_spg}{dyn\_spg} namelist variables.
+The surface pressure gradient term is related to the representation of the free surface (\autoref{sec:MB_hor_pg}).
 The main distinction is between the fixed volume case (linear free surface) and
-the variable volume case (nonlinear free surface, \key{vvl} is defined).
-In the linear free surface case (\autoref{subsec:PE_free_surface})
+the variable volume case (nonlinear free surface, \texttt{vvl?} is defined).
+In the linear free surface case (\autoref{subsec:MB_free_surface})
 the vertical scale factors $e_{3}$ are fixed in time,
-while they are time-dependent in the nonlinear case (\autoref{subsec:PE_free_surface}).
-With both linear and nonlinear free surface, external gravity waves are allowed in the equations, 
+while they are time-dependent in the nonlinear case (\autoref{subsec:MB_free_surface}).
+With both linear and nonlinear free surface, external gravity waves are allowed in the equations,
 which imposes a very small time step when an explicit time stepping is used.
-Two methods are proposed to allow a longer time step for the three-dimensional equations: 
-the filtered free surface, which is a modification of the continuous equations (see \autoref{eq:PE_flt?}), 
+Two methods are proposed to allow a longer time step for the three-dimensional equations:
+the filtered free surface, which is a modification of the continuous equations (see \autoref{eq:MB_flt?}),
 and the split-explicit free surface described below.
-The extra term introduced in the filtered method is calculated implicitly, 
+The extra term introduced in the filtered method is calculated implicitly,
 so that the update of the next velocities is done in module \mdl{dynspg\_flt} and not in \mdl{dynnxt}.
 
-
 The form of the surface pressure gradient term depends on how the user wants to
-handle the fast external gravity waves that are a solution of the analytical equation (\autoref{sec:PE_hor_pg}).
+handle the fast external gravity waves that are a solution of the analytical equation (\autoref{sec:MB_hor_pg}).
 Three formulations are available, all controlled by a CPP key (ln\_dynspg\_xxx):
 an explicit formulation which requires a small time step;
 a filtered free surface formulation which allows a larger time step by
-adding a filtering term into the momentum equation; 
+adding a filtering term into the momentum equation;
 and a split-explicit free surface formulation, described below, which also allows a larger time step.
 
@@ -825,19 +779,15 @@
 As a consequence the update of the $next$ velocities is done in module \mdl{dynspg\_flt} and not in \mdl{dynnxt}.
 
-
-%--------------------------------------------------------------------------------------------------------------
-% Explicit free surface formulation
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Explicit free surface (\texttt{\textbf{key\_dynspg\_exp}})]
-{Explicit free surface (\protect\key{dynspg\_exp})}
+%% =================================================================================================
+\subsection[Explicit free surface (\forcode{ln_dynspg_exp})]{Explicit free surface (\protect\np{ln_dynspg_exp}{ln\_dynspg\_exp})}
 \label{subsec:DYN_spg_exp}
 
-In the explicit free surface formulation (\key{dynspg\_exp} defined),
+In the explicit free surface formulation (\np{ln_dynspg_exp}{ln\_dynspg\_exp} set to true),
 the model time step is chosen to be small enough to resolve the external gravity waves
 (typically a few tens of seconds).
-The surface pressure gradient, evaluated using a leap-frog scheme (\ie centered in time),
+The surface pressure gradient, evaluated using a leap-frog scheme (\ie\ centered in time),
 is thus simply given by :
 \begin{equation}
-  \label{eq:dynspg_exp}
+  \label{eq:DYN_spg_exp}
   \left\{
     \begin{aligned}
@@ -846,40 +796,33 @@
     \end{aligned}
   \right.
-\end{equation} 
-
-Note that in the non-linear free surface case (\ie \key{vvl} defined),
+\end{equation}
+
+Note that in the non-linear free surface case (\ie\ \texttt{vvl?} defined),
 the surface pressure gradient is already included in the momentum tendency through
 the level thickness variation allowed in the computation of the hydrostatic pressure gradient.
 Thus, nothing is done in the \mdl{dynspg\_exp} module.
 
-%--------------------------------------------------------------------------------------------------------------
-% Split-explict free surface formulation
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Split-explicit free surface (\texttt{\textbf{key\_dynspg\_ts}})]
-{Split-explicit free surface (\protect\key{dynspg\_ts})}
+%% =================================================================================================
+\subsection[Split-explicit free surface (\forcode{ln_dynspg_ts})]{Split-explicit free surface (\protect\np{ln_dynspg_ts}{ln\_dynspg\_ts})}
 \label{subsec:DYN_spg_ts}
-%------------------------------------------namsplit-----------------------------------------------------------
-%
 %\nlst{namsplit}
-%-------------------------------------------------------------------------------------------------------------
-
-The split-explicit free surface formulation used in \NEMO (\key{dynspg\_ts} defined),
+
+The split-explicit free surface formulation used in \NEMO\ (\np{ln_dynspg_ts}{ln\_dynspg\_ts} set to true),
 also called the time-splitting formulation, follows the one proposed by \citet{shchepetkin.mcwilliams_OM05}.
 The general idea is to solve the free surface equation and the associated barotropic velocity equations with
 a smaller time step than $\rdt$, the time step used for the three dimensional prognostic variables
-(\autoref{fig:DYN_dynspg_ts}).
+(\autoref{fig:DYN_spg_ts}).
 The size of the small time step, $\rdt_e$ (the external mode or barotropic time step) is provided through
-the \np{nn\_baro} namelist parameter as: $\rdt_e = \rdt / nn\_baro$.
-This parameter can be optionally defined automatically (\np{ln\_bt\_nn\_auto}\forcode{ = .true.}) considering that
+the \np{nn_baro}{nn\_baro} namelist parameter as: $\rdt_e = \rdt / nn\_baro$.
+This parameter can be optionally defined automatically (\np[=.true.]{ln_bt_nn_auto}{ln\_bt\_nn\_auto}) considering that
 the stability of the barotropic system is essentially controled by external waves propagation.
 Maximum Courant number is in that case time independent, and easily computed online from the input bathymetry.
-Therefore, $\rdt_e$ is adjusted so that the Maximum allowed Courant number is smaller than \np{rn\_bt\_cmax}.
-
-%%%
+Therefore, $\rdt_e$ is adjusted so that the Maximum allowed Courant number is smaller than \np{rn_bt_cmax}{rn\_bt\_cmax}.
+
 The barotropic mode solves the following equations:
 % \begin{subequations}
-%  \label{eq:BT}
-\begin{equation}
-  \label{eq:BT_dyn}
+%  \label{eq:DYN_BT}
+\begin{equation}
+  \label{eq:DYN_BT_dyn}
   \frac{\partial {\mathrm \overline{{\mathbf U}}_h} }{\partial t}=
   -f\;{\mathrm {\mathbf k}}\times {\mathrm \overline{{\mathbf U}}_h}
@@ -887,5 +830,5 @@
 \end{equation}
 \[
-  % \label{eq:BT_ssh}
+  % \label{eq:DYN_BT_ssh}
   \frac{\partial \eta }{\partial t}=-\nabla \cdot \left[ {\left( {H+\eta } \right) \; {\mathrm{\mathbf \overline{U}}}_h \,} \right]+P-E
 \]
@@ -893,51 +836,50 @@
 where $\mathrm {\overline{\mathbf G}}$ is a forcing term held constant, containing coupling term between modes,
 surface atmospheric forcing as well as slowly varying barotropic terms not explicitly computed to gain efficiency.
-The third term on the right hand side of \autoref{eq:BT_dyn} represents the bottom stress
-(see section \autoref{sec:ZDF_bfr}), explicitly accounted for at each barotropic iteration.
+The third term on the right hand side of \autoref{eq:DYN_BT_dyn} represents the bottom stress
+(see section \autoref{sec:ZDF_drg}), explicitly accounted for at each barotropic iteration.
 Temporal discretization of the system above follows a three-time step Generalized Forward Backward algorithm
 detailed in \citet{shchepetkin.mcwilliams_OM05}.
-AB3-AM4 coefficients used in \NEMO follow the second-order accurate,
+AB3-AM4 coefficients used in \NEMO\ follow the second-order accurate,
 "multi-purpose" stability compromise as defined in \citet{shchepetkin.mcwilliams_ibk09}
-(see their figure 12, lower left). 
-
-%>   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >
+(see their figure 12, lower left).
+
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_DYN_dynspg_ts}
-    \caption{
-      \protect\label{fig:DYN_dynspg_ts}
-      Schematic of the split-explicit time stepping scheme for the external and internal modes.
-      Time increases to the right. In this particular exemple,
-      a boxcar averaging window over $nn\_baro$ barotropic time steps is used ($nn\_bt\_flt=1$) and $nn\_baro=5$.
-      Internal mode time steps (which are also the model time steps) are denoted by $t-\rdt$, $t$ and $t+\rdt$.
-      Variables with $k$ superscript refer to instantaneous barotropic variables,
-      $< >$ and $<< >>$ operator refer to time filtered variables using respectively primary (red vertical bars) and
-      secondary weights (blue vertical bars).
-      The former are used to obtain time filtered quantities at $t+\rdt$ while
-      the latter are used to obtain time averaged transports to advect tracers.
-      a) Forward time integration: \protect\np{ln\_bt\_fw}\forcode{ = .true.},
-      \protect\np{ln\_bt\_av}\forcode{ = .true.}.
-      b) Centred time integration: \protect\np{ln\_bt\_fw}\forcode{ = .false.},
-      \protect\np{ln\_bt\_av}\forcode{ = .true.}.
-      c) Forward time integration with no time filtering (POM-like scheme):
-      \protect\np{ln\_bt\_fw}\forcode{ = .true.}, \protect\np{ln\_bt\_av}\forcode{ = .false.}.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{DYN_dynspg_ts}
+  \caption[Split-explicit time stepping scheme for the external and internal modes]{
+    Schematic of the split-explicit time stepping scheme for the external and internal modes.
+    Time increases to the right.
+    In this particular exemple,
+    a boxcar averaging window over \np{nn_baro}{nn\_baro} barotropic time steps is used
+    (\np[=1]{nn_bt_flt}{nn\_bt\_flt}) and \np[=5]{nn_baro}{nn\_baro}.
+    Internal mode time steps (which are also the model time steps) are denoted by
+    $t-\rdt$, $t$ and $t+\rdt$.
+    Variables with $k$ superscript refer to instantaneous barotropic variables,
+    $< >$ and $<< >>$ operator refer to time filtered variables using respectively primary
+    (red vertical bars) and secondary weights (blue vertical bars).
+    The former are used to obtain time filtered quantities at $t+\rdt$ while
+    the latter are used to obtain time averaged transports to advect tracers.
+    a) Forward time integration:
+    \protect\np[=.true.]{ln_bt_fw}{ln\_bt\_fw},  \protect\np[=.true.]{ln_bt_av}{ln\_bt\_av}.
+    b) Centred time integration:
+    \protect\np[=.false.]{ln_bt_fw}{ln\_bt\_fw}, \protect\np[=.true.]{ln_bt_av}{ln\_bt\_av}.
+    c) Forward time integration with no time filtering (POM-like scheme):
+    \protect\np[=.true.]{ln_bt_fw}{ln\_bt\_fw},  \protect\np[=.false.]{ln_bt_av}{ln\_bt\_av}.}
+  \label{fig:DYN_spg_ts}
 \end{figure}
-%>   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >
-
-In the default case (\np{ln\_bt\_fw}\forcode{ = .true.}),
+
+In the default case (\np[=.true.]{ln_bt_fw}{ln\_bt\_fw}),
 the external mode is integrated between \textit{now} and \textit{after} baroclinic time-steps
-(\autoref{fig:DYN_dynspg_ts}a).
+(\autoref{fig:DYN_spg_ts}a).
 To avoid aliasing of fast barotropic motions into three dimensional equations,
-time filtering is eventually applied on barotropic quantities (\np{ln\_bt\_av}\forcode{ = .true.}).
+time filtering is eventually applied on barotropic quantities (\np[=.true.]{ln_bt_av}{ln\_bt\_av}).
 In that case, the integration is extended slightly beyond \textit{after} time step to
 provide time filtered quantities.
 These are used for the subsequent initialization of the barotropic mode in the following baroclinic step.
-Since external mode equations written at baroclinic time steps finally follow a forward time stepping scheme, 
+Since external mode equations written at baroclinic time steps finally follow a forward time stepping scheme,
 asselin filtering is not applied to barotropic quantities.\\
 Alternatively, one can choose to integrate barotropic equations starting from \textit{before} time step
-(\np{ln\_bt\_fw}\forcode{ = .false.}).
-Although more computationaly expensive ( \np{nn\_baro} additional iterations are indeed necessary),
+(\np[=.false.]{ln_bt_fw}{ln\_bt\_fw}).
+Although more computationaly expensive ( \np{nn_baro}{nn\_baro} additional iterations are indeed necessary),
 the baroclinic to barotropic forcing term given at \textit{now} time step become centred in
 the middle of the integration window.
@@ -946,5 +888,4 @@
 %references to Patrick Marsaleix' work here. Also work done by SHOM group.
 
-%%%
 
 As far as tracer conservation is concerned,
@@ -960,13 +901,12 @@
 obtain exact conservation.
 
-%%%
 
 One can eventually choose to feedback instantaneous values by not using any time filter
-(\np{ln\_bt\_av}\forcode{ = .false.}). 
+(\np[=.false.]{ln_bt_av}{ln\_bt\_av}).
 In that case, external mode equations are continuous in time,
-\ie they are not re-initialized when starting a new sub-stepping sequence.
+\ie\ they are not re-initialized when starting a new sub-stepping sequence.
 This is the method used so far in the POM model, the stability being maintained by
 refreshing at (almost) each barotropic time step advection and horizontal diffusion terms.
-Since the latter terms have not been added in \NEMO for computational efficiency,
+Since the latter terms have not been added in \NEMO\ for computational efficiency,
 removing time filtering is not recommended except for debugging purposes.
 This may be used for instance to appreciate the damping effect of the standard formulation on
@@ -975,6 +915,5 @@
 it is still significant as shown by \citet{levier.treguier.ea_rpt07} in the case of an analytical barotropic Kelvin wave.
 
-%>>>>>===============
-\gmcomment{               %%% copy from griffies Book 
+\cmtgm{               %%% copy from griffies Book
 
 \textbf{title: Time stepping the barotropic system }
@@ -983,5 +922,5 @@
 Hence, we can update the surface height and vertically integrated velocity with a leap-frog scheme using
 the small barotropic time step $\rdt$.
-We have 
+We have
 
 \[
@@ -1006,5 +945,5 @@
 and total depth of the ocean $H(\tau)$ are held for the duration of the barotropic time stepping over
 a single cycle.
-This is also the time that sets the barotropic time steps via 
+This is also the time that sets the barotropic time steps via
 \[
   % \label{eq:DYN_spg_ts_t}
@@ -1012,5 +951,5 @@
 \]
 with $n$ an integer.
-The density scaled surface pressure is evaluated via 
+The density scaled surface pressure is evaluated via
 \[
   % \label{eq:DYN_spg_ts_ps}
@@ -1021,5 +960,5 @@
   \end{cases}
 \]
-To get started, we assume the following initial conditions 
+To get started, we assume the following initial conditions
 \[
   % \label{eq:DYN_spg_ts_eta}
@@ -1029,5 +968,5 @@
   \end{split}
 \]
-with 
+with
 \[
   % \label{eq:DYN_spg_ts_etaF}
@@ -1035,5 +974,5 @@
 \]
 the time averaged surface height taken from the previous barotropic cycle.
-Likewise, 
+Likewise,
 \[
   % \label{eq:DYN_spg_ts_u}
@@ -1041,5 +980,5 @@
   \textbf{U}(\tau,t_{n=1}) = \textbf{U}^{(b)}(\tau,t_{n=0}) + \rdt \ \text{RHS}_{n=0}
 \]
-with 
+with
 \[
   % \label{eq:DYN_spg_ts_u}
@@ -1047,9 +986,9 @@
 \]
 the time averaged vertically integrated transport.
-Notably, there is no Robert-Asselin time filter used in the barotropic portion of the integration. 
+Notably, there is no Robert-Asselin time filter used in the barotropic portion of the integration.
 
 Upon reaching $t_{n=N} = \tau + 2\rdt \tau$ ,
 the vertically integrated velocity is time averaged to produce the updated vertically integrated velocity at
-baroclinic time $\tau + \rdt \tau$ 
+baroclinic time $\tau + \rdt \tau$
 \[
   % \label{eq:DYN_spg_ts_u}
@@ -1057,15 +996,15 @@
 \]
 The surface height on the new baroclinic time step is then determined via a baroclinic leap-frog using
-the following form 
+the following form
 
 \begin{equation}
   \label{eq:DYN_spg_ts_ssh}
-  \eta(\tau+\Delta) - \eta^{F}(\tau-\Delta) = 2\rdt \ \left[ - \nabla \cdot \textbf{U}(\tau) + \text{EMP}_w \right]  
+  \eta(\tau+\Delta) - \eta^{F}(\tau-\Delta) = 2\rdt \ \left[ - \nabla \cdot \textbf{U}(\tau) + \text{EMP}_w \right]
 \end{equation}
 
 The use of this "big-leap-frog" scheme for the surface height ensures compatibility between
 the mass/volume budgets and the tracer budgets.
-More discussion of this point is provided in Chapter 10 (see in particular Section 10.2). 
- 
+More discussion of this point is provided in Chapter 10 (see in particular Section 10.2).
+
 In general, some form of time filter is needed to maintain integrity of the surface height field due to
 the leap-frog splitting mode in equation \autoref{eq:DYN_spg_ts_ssh}.
@@ -1078,5 +1017,5 @@
   \eta^{F}(\tau-\Delta) =  \overline{\eta^{(b)}(\tau)}
 \end{equation}
-Another approach tried was 
+Another approach tried was
 
 \[
@@ -1091,26 +1030,20 @@
 eliminating tracer and surface height time filtering (see ?? for more complete discussion).
 However, in the general case with a non-zero $\alpha$,
-the filter \autoref{eq:DYN_spg_ts_sshf} was found to be more conservative, and so is recommended. 
+the filter \autoref{eq:DYN_spg_ts_sshf} was found to be more conservative, and so is recommended.
 
 }            %%end gm comment (copy of griffies book)
 
-%>>>>>===============
-
-
-%--------------------------------------------------------------------------------------------------------------
-% Filtered free surface formulation
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Filtered free surface (\texttt{\textbf{key\_dynspg\_flt}})]
-{Filtered free surface (\protect\key{dynspg\_flt})}
+%% =================================================================================================
+\subsection{Filtered free surface (\forcode{dynspg_flt?})}
 \label{subsec:DYN_spg_fltp}
 
-The filtered formulation follows the \citet{roullet.madec_JGR00} implementation. 
-The extra term introduced in the equations (see \autoref{subsec:PE_free_surface}) is solved implicitly. 
+The filtered formulation follows the \citet{roullet.madec_JGR00} implementation.
+The extra term introduced in the equations (see \autoref{subsec:MB_free_surface}) is solved implicitly.
 The elliptic solvers available in the code are documented in \autoref{chap:MISC}.
 
 %% gm %%======>>>>   given here the discrete eqs provided to the solver
-\gmcomment{               %%% copy from chap-model basics 
+\cmtgm{               %%% copy from chap-model basics
   \[
-    % \label{eq:spg_flt}
+    % \label{eq:DYN_spg_flt}
     \frac{\partial {\mathrm {\mathbf U}}_h }{\partial t}= {\mathrm {\mathbf M}}
     - g \nabla \left( \tilde{\rho} \ \eta \right)
@@ -1120,35 +1053,34 @@
   $\widetilde{\rho} = \rho / \rho_o$ is the dimensionless density,
   and $\mathrm {\mathbf M}$ represents the collected contributions of the Coriolis, hydrostatic pressure gradient,
-  non-linear and viscous terms in \autoref{eq:PE_dyn}.
-}   %end gmcomment
-
-Note that in the linear free surface formulation (\key{vvl} not defined),
+  non-linear and viscous terms in \autoref{eq:MB_dyn}.
+}   %end cmtgm
+
+Note that in the linear free surface formulation (\texttt{vvl?} not defined),
 the ocean depth is time-independent and so is the matrix to be inverted.
-It is computed once and for all and applies to all ocean time steps. 
-
-% ================================================================
-% Lateral diffusion term
-% ================================================================
-\section[Lateral diffusion term and operators (\textit{dynldf.F90})]
-{Lateral diffusion term and operators (\protect\mdl{dynldf})}
+It is computed once and for all and applies to all ocean time steps.
+
+%% =================================================================================================
+\section[Lateral diffusion term and operators (\textit{dynldf.F90})]{Lateral diffusion term and operators (\protect\mdl{dynldf})}
 \label{sec:DYN_ldf}
-%------------------------------------------nam_dynldf----------------------------------------------------
-
-\nlst{namdyn_ldf} 
-%-------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{namdyn\_ldf} namelist variables.
+
+\begin{listing}
+  \nlst{namdyn_ldf}
+  \caption{\forcode{&namdyn_ldf}}
+  \label{lst:namdyn_ldf}
+\end{listing}
+
+Options are defined through the \nam{dyn_ldf}{dyn\_ldf} namelist variables.
 The options available for lateral diffusion are to use either laplacian (rotated or not) or biharmonic operators.
 The coefficients may be constant or spatially variable;
 the description of the coefficients is found in the chapter on lateral physics (\autoref{chap:LDF}).
 The lateral diffusion of momentum is evaluated using a forward scheme,
-\ie the velocity appearing in its expression is the \textit{before} velocity in time,
+\ie\ the velocity appearing in its expression is the \textit{before} velocity in time,
 except for the pure vertical component that appears when a tensor of rotation is used.
-This latter term is solved implicitly together with the vertical diffusion term (see \autoref{chap:STP}).
+This latter term is solved implicitly together with the vertical diffusion term (see \autoref{chap:TD}).
 
 At the lateral boundaries either free slip,
 no slip or partial slip boundary conditions are applied according to the user's choice (see \autoref{chap:LBC}).
 
-\gmcomment{
+\cmtgm{
   Hyperviscous operators are frequently used in the simulation of turbulent flows to
   control the dissipation of unresolved small scale features.
@@ -1159,46 +1091,42 @@
   In finite difference methods,
   the biharmonic operator is frequently the method of choice to achieve this scale selective dissipation since
-  its damping time (\ie its spin down time) scale like $\lambda^{-4}$ for disturbances of wavelength $\lambda$
+  its damping time (\ie\ its spin down time) scale like $\lambda^{-4}$ for disturbances of wavelength $\lambda$
   (so that short waves damped more rapidelly than long ones),
   whereas the Laplace operator damping time scales only like $\lambda^{-2}$.
 }
 
-% ================================================================
-\subsection[Iso-level laplacian (\forcode{ln_dynldf_lap = .true.})]
-{Iso-level laplacian operator (\protect\np{ln\_dynldf\_lap}\forcode{ = .true.})}
+%% =================================================================================================
+\subsection[Iso-level laplacian (\forcode{ln_dynldf_lap})]{Iso-level laplacian operator (\protect\np{ln_dynldf_lap}{ln\_dynldf\_lap})}
 \label{subsec:DYN_ldf_lap}
 
-For lateral iso-level diffusion, the discrete operator is: 
-\begin{equation}
-  \label{eq:dynldf_lap}
+For lateral iso-level diffusion, the discrete operator is:
+\begin{equation}
+  \label{eq:DYN_ldf_lap}
   \left\{
     \begin{aligned}
       D_u^{l{\mathrm {\mathbf U}}} =\frac{1}{e_{1u} }\delta_{i+1/2} \left[ {A_T^{lm}
-          \;\chi } \right]-\frac{1}{e_{2u} {\kern 1pt}e_{3u} }\delta_j \left[ 
+          \;\chi } \right]-\frac{1}{e_{2u} {\kern 1pt}e_{3u} }\delta_j \left[
         {A_f^{lm} \;e_{3f} \zeta } \right] \\ \\
       D_v^{l{\mathrm {\mathbf U}}} =\frac{1}{e_{2v} }\delta_{j+1/2} \left[ {A_T^{lm}
-          \;\chi } \right]+\frac{1}{e_{1v} {\kern 1pt}e_{3v} }\delta_i \left[ 
+          \;\chi } \right]+\frac{1}{e_{1v} {\kern 1pt}e_{3v} }\delta_i \left[
         {A_f^{lm} \;e_{3f} \zeta } \right]
     \end{aligned}
   \right.
-\end{equation} 
-
-As explained in \autoref{subsec:PE_ldf},
+\end{equation}
+
+As explained in \autoref{subsec:MB_ldf},
 this formulation (as the gradient of a divergence and curl of the vorticity) preserves symmetry and
-ensures a complete separation between the vorticity and divergence parts of the momentum diffusion. 
-
-%--------------------------------------------------------------------------------------------------------------
-%           Rotated laplacian operator
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Rotated laplacian (\forcode{ln_dynldf_iso = .true.})]
-{Rotated laplacian operator (\protect\np{ln\_dynldf\_iso}\forcode{ = .true.})}
+ensures a complete separation between the vorticity and divergence parts of the momentum diffusion.
+
+%% =================================================================================================
+\subsection[Rotated laplacian (\forcode{ln_dynldf_iso})]{Rotated laplacian operator (\protect\np{ln_dynldf_iso}{ln\_dynldf\_iso})}
 \label{subsec:DYN_ldf_iso}
 
 A rotation of the lateral momentum diffusion operator is needed in several cases:
-for iso-neutral diffusion in the $z$-coordinate (\np{ln\_dynldf\_iso}\forcode{ = .true.}) and
-for either iso-neutral (\np{ln\_dynldf\_iso}\forcode{ = .true.}) or
-geopotential (\np{ln\_dynldf\_hor}\forcode{ = .true.}) diffusion in the $s$-coordinate.
+for iso-neutral diffusion in the $z$-coordinate (\np[=.true.]{ln_dynldf_iso}{ln\_dynldf\_iso}) and
+for either iso-neutral (\np[=.true.]{ln_dynldf_iso}{ln\_dynldf\_iso}) or
+geopotential (\np[=.true.]{ln_dynldf_hor}{ln\_dynldf\_hor}) diffusion in the $s$-coordinate.
 In the partial step case, coordinates are horizontal except at the deepest level and
-no rotation is performed when \np{ln\_dynldf\_hor}\forcode{ = .true.}.
+no rotation is performed when \np[=.true.]{ln_dynldf_hor}{ln\_dynldf\_hor}.
 The diffusion operator is defined simply as the divergence of down gradient momentum fluxes on
 each momentum component.
@@ -1206,5 +1134,5 @@
 The resulting discrete representation is:
 \begin{equation}
-  \label{eq:dyn_ldf_iso}
+  \label{eq:DYN_ldf_iso}
   \begin{split}
     D_u^{l\textbf{U}} &= \frac{1}{e_{1u} \, e_{2u} \, e_{3u} }	\\
@@ -1230,60 +1158,48 @@
                 -e_{2f} \; r_{1f} \,\overline{\overline {\delta_{k+1/2}[v]}}^{\,i+1/2,\,k}}
             \right)} \right]} 	\right. \\
-    & \qquad +\ \delta_j \left[ {A_T^{lm} \left( {\frac{e_{1t}\,e_{3t} }{e_{2t} 
+    & \qquad +\ \delta_j \left[ {A_T^{lm} \left( {\frac{e_{1t}\,e_{3t} }{e_{2t}
             }\,\delta_{j} [v] - e_{1t}\, r_{2t}
             \,\overline{\overline {\delta_{k+1/2} [v]}} ^{\,j,\,k}}
         \right)} \right] \\
-    & \qquad +\ \delta_k \left[ {A_{vw}^{lm} \left( {-e_{2v} \, r_{1vw} \,\overline{\overline 
+    & \qquad +\ \delta_k \left[ {A_{vw}^{lm} \left( {-e_{2v} \, r_{1vw} \,\overline{\overline
               {\delta_{i+1/2} [v]}}^{\,i+1/2,\,k+1/2} }\right.} \right. \\
     &  \ \qquad \qquad \qquad \quad\
     - e_{1v} \, r_{2vw} \,\overline{\overline {\delta_{j+1/2} [v]}} ^{\,j+1/2,\,k+1/2} \\
-    & \left. {\left. { \ \qquad \qquad \qquad \ \ \ \left. {\ 
+    & \left. {\left. { \ \qquad \qquad \qquad \ \ \ \left. {\
                 +\frac{e_{1v}\, e_{2v} }{e_{3vw} }\,\left( {r_{1vw}^2+r_{2vw}^2}
-                \right)\,\delta_{k+1/2} [v]} \right)} \right]\;\;\;} \right\} 
+                \right)\,\delta_{k+1/2} [v]} \right)} \right]\;\;\;} \right\}
   \end{split}
 \end{equation}
 where $r_1$ and $r_2$ are the slopes between the surface along which the diffusion operator acts and
-the surface of computation ($z$- or $s$-surfaces). 
+the surface of computation ($z$- or $s$-surfaces).
 The way these slopes are evaluated is given in the lateral physics chapter (\autoref{chap:LDF}).
 
-%--------------------------------------------------------------------------------------------------------------
-%           Iso-level bilaplacian operator
-%--------------------------------------------------------------------------------------------------------------
-\subsection[Iso-level bilaplacian (\forcode{ln_dynldf_bilap = .true.})]
-{Iso-level bilaplacian operator (\protect\np{ln\_dynldf\_bilap}\forcode{ = .true.})}
+%% =================================================================================================
+\subsection[Iso-level bilaplacian (\forcode{ln_dynldf_bilap})]{Iso-level bilaplacian operator (\protect\np{ln_dynldf_bilap}{ln\_dynldf\_bilap})}
 \label{subsec:DYN_ldf_bilap}
 
-The lateral fourth order operator formulation on momentum is obtained by applying \autoref{eq:dynldf_lap} twice.
+The lateral fourth order operator formulation on momentum is obtained by applying \autoref{eq:DYN_ldf_lap} twice.
 It requires an additional assumption on boundary conditions:
 the first derivative term normal to the coast depends on the free or no-slip lateral boundary conditions chosen,
 while the third derivative terms normal to the coast are set to zero (see \autoref{chap:LBC}).
-%%%
-\gmcomment{add a remark on the the change in the position of the coefficient}
-%%%
-
-% ================================================================
-%           Vertical diffusion term
-% ================================================================
-\section[Vertical diffusion term (\textit{dynzdf.F90})]
-{Vertical diffusion term (\protect\mdl{dynzdf})}
+\cmtgm{add a remark on the the change in the position of the coefficient}
+
+%% =================================================================================================
+\section[Vertical diffusion term (\textit{dynzdf.F90})]{Vertical diffusion term (\protect\mdl{dynzdf})}
 \label{sec:DYN_zdf}
-%----------------------------------------------namzdf------------------------------------------------------
-
-\nlst{namzdf} 
-%-------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{namzdf} namelist variables.
+
+Options are defined through the \nam{zdf}{zdf} namelist variables.
 The large vertical diffusion coefficient found in the surface mixed layer together with high vertical resolution implies that in the case of explicit time stepping there would be too restrictive a constraint on the time step.
 Two time stepping schemes can be used for the vertical diffusion term:
 $(a)$ a forward time differencing scheme
-(\np{ln\_zdfexp}\forcode{ = .true.}) using a time splitting technique (\np{nn\_zdfexp} $>$ 1) or
-$(b)$ a backward (or implicit) time differencing scheme (\np{ln\_zdfexp}\forcode{ = .false.})
-(see \autoref{chap:STP}).
-Note that namelist variables \np{ln\_zdfexp} and \np{nn\_zdfexp} apply to both tracers and dynamics. 
+(\np[=.true.]{ln_zdfexp}{ln\_zdfexp}) using a time splitting technique (\np{nn_zdfexp}{nn\_zdfexp} $>$ 1) or
+$(b)$ a backward (or implicit) time differencing scheme (\np[=.false.]{ln_zdfexp}{ln\_zdfexp})
+(see \autoref{chap:TD}).
+Note that namelist variables \np{ln_zdfexp}{ln\_zdfexp} and \np{nn_zdfexp}{nn\_zdfexp} apply to both tracers and dynamics.
 
 The formulation of the vertical subgrid scale physics is the same whatever the vertical coordinate is.
-The vertical diffusion operators given by \autoref{eq:PE_zdf} take the following semi-discrete space form:
-\[
-  % \label{eq:dynzdf}
+The vertical diffusion operators given by \autoref{eq:MB_zdf} take the following semi-discrete space form:
+\[
+  % \label{eq:DYN_zdf}
   \left\{
     \begin{aligned}
@@ -1303,5 +1219,5 @@
 the vertical turbulent momentum fluxes,
 \begin{equation}
-  \label{eq:dynzdf_sbc}
+  \label{eq:DYN_zdf_sbc}
   \left.{\left( {\frac{A^{vm} }{e_3 }\ \frac{\partial \textbf{U}_h}{\partial k}} \right)} \right|_{z=1}
   = \frac{1}{\rho_o} \binom{\tau_u}{\tau_v }
@@ -1309,5 +1225,5 @@
 where $\left( \tau_u ,\tau_v \right)$ are the two components of the wind stress vector in
 the (\textbf{i},\textbf{j}) coordinate system.
-The high mixing coefficients in the surface mixed layer ensure that the surface wind stress is distributed in 
+The high mixing coefficients in the surface mixed layer ensure that the surface wind stress is distributed in
 the vertical over the mixed layer depth.
 If the vertical mixing coefficient is small (when no mixed layer scheme is used)
@@ -1316,9 +1232,7 @@
 
 The turbulent flux of momentum at the bottom of the ocean is specified through a bottom friction parameterisation
-(see \autoref{sec:ZDF_bfr})
-
-% ================================================================
-% External Forcing
-% ================================================================
+(see \autoref{sec:ZDF_drg})
+
+%% =================================================================================================
 \section{External forcings}
 \label{sec:DYN_forcing}
@@ -1326,25 +1240,23 @@
 Besides the surface and bottom stresses (see the above section)
 which are introduced as boundary conditions on the vertical mixing,
-three other forcings may enter the dynamical equations by affecting the surface pressure gradient. 
-
-(1) When \np{ln\_apr\_dyn}\forcode{ = .true.} (see \autoref{sec:SBC_apr}),
+three other forcings may enter the dynamical equations by affecting the surface pressure gradient.
+
+(1) When \np[=.true.]{ln_apr_dyn}{ln\_apr\_dyn} (see \autoref{sec:SBC_apr}),
 the atmospheric pressure is taken into account when computing the surface pressure gradient.
 
-(2) When \np{ln\_tide\_pot}\forcode{ = .true.} and \np{ln\_tide}\forcode{ = .true.} (see \autoref{sec:SBC_tide}),
+(2) When \np[=.true.]{ln_tide_pot}{ln\_tide\_pot} and \np[=.true.]{ln_tide}{ln\_tide} (see \autoref{sec:SBC_tide}),
 the tidal potential is taken into account when computing the surface pressure gradient.
 
-(3) When \np{nn\_ice\_embd}\forcode{ = 2} and LIM or CICE is used
-(\ie when the sea-ice is embedded in the ocean),
+(3) When \np[=2]{nn_ice_embd}{nn\_ice\_embd} and LIM or CICE is used
+(\ie\ when the sea-ice is embedded in the ocean),
 the snow-ice mass is taken into account when computing the surface pressure gradient.
 
-
-\gmcomment{ missing : the lateral boundary condition !!!   another external forcing
+\cmtgm{ missing : the lateral boundary condition !!!   another external forcing
  }
 
-% ================================================================
-% Wetting and drying 
-% ================================================================
+%% =================================================================================================
 \section{Wetting and drying }
 \label{sec:DYN_wetdry}
+
 There are two main options for wetting and drying code (wd):
 (a) an iterative limiter (il) and (b) a directional limiter (dl).
@@ -1356,8 +1268,12 @@
 by setting $\mathrm{ln\_wd\_dl} = \mathrm{.true.}$ and $\mathrm{ln\_wd\_il} = \mathrm{.false.}$.
 
-\nlst{namwad}
+\begin{listing}
+  \nlst{namwad}
+  \caption{\forcode{&namwad}}
+  \label{lst:namwad}
+\end{listing}
 
 The following terminology is used. The depth of the topography (positive downwards)
-at each $(i,j)$ point is the quantity stored in array $\mathrm{ht\_wd}$ in the NEMO code.
+at each $(i,j)$ point is the quantity stored in array $\mathrm{ht\_wd}$ in the \NEMO\ code.
 The height of the free surface (positive upwards) is denoted by $ \mathrm{ssh}$. Given the sign
 conventions used, the water depth, $h$, is the height of the free surface plus the depth of the
@@ -1367,5 +1283,5 @@
 covered by water. They require the topography specified with a model
 configuration to have negative depths at points where the land is higher than the
-topography's reference sea-level. The vertical grid in NEMO is normally computed relative to an
+topography's reference sea-level. The vertical grid in \NEMO\ is normally computed relative to an
 initial state with zero sea surface height elevation.
 The user can choose to compute the vertical grid and heights in the model relative to
@@ -1386,18 +1302,16 @@
 All these configurations have used pure sigma coordinates. It is expected that
 the wetting and drying code will work in domains with more general s-coordinates provided
-the coordinates are pure sigma in the region where wetting and drying actually occurs. 
+the coordinates are pure sigma in the region where wetting and drying actually occurs.
 
 The next sub-section descrbies the directional limiter and the following sub-section the iterative limiter.
 The final sub-section covers some additional considerations that are relevant to both schemes.
 
-
-%-----------------------------------------------------------------------------------------
 %   Iterative limiters
-%-----------------------------------------------------------------------------------------
-\subsection[Directional limiter (\textit{wet\_dry.F90})]
-{Directional limiter (\mdl{wet\_dry})}
+%% =================================================================================================
+\subsection[Directional limiter (\textit{wet\_dry.F90})]{Directional limiter (\mdl{wet\_dry})}
 \label{subsec:DYN_wd_directional_limiter}
+
 The principal idea of the directional limiter is that
-water should not be allowed to flow out of a dry tracer cell (i.e. one whose water depth is less than rn\_wdmin1).
+water should not be allowed to flow out of a dry tracer cell (i.e. one whose water depth is less than \np{rn_wdmin1}{rn\_wdmin1}).
 
 All the changes associated with this option are made to the barotropic solver for the non-linear
@@ -1409,8 +1323,8 @@
 
 The flux across each $u$-face of a tracer cell is multiplied by a factor zuwdmask (an array which depends on ji and jj).
-If the user sets ln\_wd\_dl\_ramp = .False. then zuwdmask is 1 when the
-flux is from a cell with water depth greater than rn\_wdmin1 and 0 otherwise. If the user sets
-ln\_wd\_dl\_ramp = .True. the flux across the face is ramped down as the water depth decreases
-from 2 * rn\_wdmin1 to rn\_wdmin1. The use of this ramp reduced grid-scale noise in idealised test cases.
+If the user sets \np[=.false.]{ln_wd_dl_ramp}{ln\_wd\_dl\_ramp} then zuwdmask is 1 when the
+flux is from a cell with water depth greater than \np{rn_wdmin1}{rn\_wdmin1} and 0 otherwise. If the user sets
+\np[=.true.]{ln_wd_dl_ramp}{ln\_wd\_dl\_ramp} the flux across the face is ramped down as the water depth decreases
+from 2 * \np{rn_wdmin1}{rn\_wdmin1} to \np{rn_wdmin1}{rn\_wdmin1}. The use of this ramp reduced grid-scale noise in idealised test cases.
 
 At the point where the flux across a $u$-face is multiplied by zuwdmask , we have chosen
@@ -1422,5 +1336,4 @@
 treatment in the calculation of the flux of mass across the cell face.
 
-
 \cite{warner.defne.ea_CG13} state that in their scheme the velocity masks at the cell faces for the baroclinic
 timesteps are set to 0 or 1 depending on whether the average of the masks over the barotropic sub-steps is respectively less than
@@ -1428,18 +1341,16 @@
 fields (tracers independent of $x$, $y$ and $z$). Our scheme conserves constant tracers because
 the velocities used at the tracer cell faces on the baroclinic timesteps are carefully calculated by dynspg\_ts
-to equal their mean value during the barotropic steps. If the user sets ln\_wd\_dl\_bc = .True., the
-baroclinic velocities are also multiplied by a suitably weighted average of zuwdmask.  
-
-%-----------------------------------------------------------------------------------------
+to equal their mean value during the barotropic steps. If the user sets \np[=.true.]{ln_wd_dl_bc}{ln\_wd\_dl\_bc}, the
+baroclinic velocities are also multiplied by a suitably weighted average of zuwdmask.
+
 %   Iterative limiters
-%-----------------------------------------------------------------------------------------
-
-\subsection[Iterative limiter (\textit{wet\_dry.F90})]
-{Iterative limiter (\mdl{wet\_dry})}
+
+%% =================================================================================================
+\subsection[Iterative limiter (\textit{wet\_dry.F90})]{Iterative limiter (\mdl{wet\_dry})}
 \label{subsec:DYN_wd_iterative_limiter}
 
-\subsubsection[Iterative flux limiter (\textit{wet\_dry.F90})]
-{Iterative flux limiter (\mdl{wet\_dry})}
-\label{subsubsec:DYN_wd_il_spg_limiter}
+%% =================================================================================================
+\subsubsection[Iterative flux limiter (\textit{wet\_dry.F90})]{Iterative flux limiter (\mdl{wet\_dry})}
+\label{subsec:DYN_wd_il_spg_limiter}
 
 The iterative limiter modifies the fluxes across the faces of cells that are either already ``dry''
@@ -1449,13 +1360,15 @@
 
 The continuity equation for the total water depth in a column
-\begin{equation} \label{dyn_wd_continuity}
- \frac{\partial h}{\partial t} + \mathbf{\nabla.}(h\mathbf{u}) = 0 .
+\begin{equation}
+  \label{eq:DYN_wd_continuity}
+  \frac{\partial h}{\partial t} + \mathbf{\nabla.}(h\mathbf{u}) = 0 .
 \end{equation}
 can be written in discrete form  as
 
-\begin{align} \label{dyn_wd_continuity_2}
-\frac{e_1 e_2}{\Delta t} ( h_{i,j}(t_{n+1}) - h_{i,j}(t_e) ) 
-&= - ( \mathrm{flxu}_{i+1,j} - \mathrm{flxu}_{i,j}  + \mathrm{flxv}_{i,j+1} - \mathrm{flxv}_{i,j} ) \\
-&= \mathrm{zzflx}_{i,j} .
+\begin{align}
+  \label{eq:DYN_wd_continuity_2}
+  \frac{e_1 e_2}{\Delta t} ( h_{i,j}(t_{n+1}) - h_{i,j}(t_e) )
+  &= - ( \mathrm{flxu}_{i+1,j} - \mathrm{flxu}_{i,j}  + \mathrm{flxv}_{i,j+1} - \mathrm{flxv}_{i,j} ) \\
+  &= \mathrm{zzflx}_{i,j} .
 \end{align}
 
@@ -1470,6 +1383,7 @@
 (zzflxp) and fluxes that are into the cell (zzflxn).  Clearly
 
-\begin{equation} \label{dyn_wd_zzflx_p_n_1}
-\mathrm{zzflx}_{i,j} = \mathrm{zzflxp}_{i,j} + \mathrm{zzflxn}_{i,j} .  
+\begin{equation}
+  \label{eq:DYN_wd_zzflx_p_n_1}
+  \mathrm{zzflx}_{i,j} = \mathrm{zzflxp}_{i,j} + \mathrm{zzflxn}_{i,j} .
 \end{equation}
 
@@ -1482,9 +1396,10 @@
 $\mathrm{zcoef}_{i,j}^{(m)}$ such that:
 
-\begin{equation} \label{dyn_wd_continuity_coef}
-\begin{split}
-\mathrm{zzflxp}^{(m)}_{i,j} =& \mathrm{zcoef}_{i,j}^{(m)} \mathrm{zzflxp}^{(0)}_{i,j} \\
-\mathrm{zzflxn}^{(m)}_{i,j} =& \mathrm{zcoef}_{i,j}^{(m)} \mathrm{zzflxn}^{(0)}_{i,j}
-\end{split}
+\begin{equation}
+  \label{eq:DYN_wd_continuity_coef}
+  \begin{split}
+    \mathrm{zzflxp}^{(m)}_{i,j} =& \mathrm{zcoef}_{i,j}^{(m)} \mathrm{zzflxp}^{(0)}_{i,j} \\
+    \mathrm{zzflxn}^{(m)}_{i,j} =& \mathrm{zcoef}_{i,j}^{(m)} \mathrm{zzflxn}^{(0)}_{i,j}
+  \end{split}
 \end{equation}
 
@@ -1494,37 +1409,41 @@
 The iteration is initialised by setting
 
-\begin{equation} \label{dyn_wd_zzflx_initial}
-\mathrm{zzflxp^{(0)}}_{i,j} = \mathrm{zzflxp}_{i,j} , \quad  \mathrm{zzflxn^{(0)}}_{i,j} = \mathrm{zzflxn}_{i,j} . 
+\begin{equation}
+  \label{eq:DYN_wd_zzflx_initial}
+  \mathrm{zzflxp^{(0)}}_{i,j} = \mathrm{zzflxp}_{i,j} , \quad  \mathrm{zzflxn^{(0)}}_{i,j} = \mathrm{zzflxn}_{i,j} .
 \end{equation}
 
 The fluxes out of cell $(i,j)$ are updated at the $m+1$th iteration if the depth of the
 cell on timestep $t_e$, namely $h_{i,j}(t_e)$, is less than the total flux out of the cell
-times the timestep divided by the cell area. Using (\ref{dyn_wd_continuity_2}) this
+times the timestep divided by the cell area. Using (\autoref{eq:DYN_wd_continuity_2}) this
 condition is
 
-\begin{equation} \label{dyn_wd_continuity_if}
-h_{i,j}(t_e)  - \mathrm{rn\_wdmin1} <  \frac{\Delta t}{e_1 e_2} ( \mathrm{zzflxp}^{(m)}_{i,j} + \mathrm{zzflxn}^{(m)}_{i,j} ) .
-\end{equation}
-
-Rearranging (\ref{dyn_wd_continuity_if}) we can obtain an expression for the maximum
+\begin{equation}
+  \label{eq:DYN_wd_continuity_if}
+  h_{i,j}(t_e)  - \mathrm{rn\_wdmin1} <  \frac{\Delta t}{e_1 e_2} ( \mathrm{zzflxp}^{(m)}_{i,j} + \mathrm{zzflxn}^{(m)}_{i,j} ) .
+\end{equation}
+
+Rearranging (\autoref{eq:DYN_wd_continuity_if}) we can obtain an expression for the maximum
 outward flux that can be allowed and still maintain the minimum wet depth:
 
-\begin{equation} \label{dyn_wd_max_flux}
-\begin{split}
-\mathrm{zzflxp}^{(m+1)}_{i,j} = \Big[ (h_{i,j}(t_e) & - \mathrm{rn\_wdmin1} - \mathrm{rn\_wdmin2})  \frac{e_1 e_2}{\Delta t} \phantom{]} \\
-\phantom{[} & -  \mathrm{zzflxn}^{(m)}_{i,j} \Big]
-\end{split}
+\begin{equation}
+  \label{eq:DYN_wd_max_flux}
+  \begin{split}
+    \mathrm{zzflxp}^{(m+1)}_{i,j} = \Big[ (h_{i,j}(t_e) & - \mathrm{rn\_wdmin1} - \mathrm{rn\_wdmin2})  \frac{e_1 e_2}{\Delta t} \phantom{]} \\
+    \phantom{[} & -  \mathrm{zzflxn}^{(m)}_{i,j} \Big]
+  \end{split}
 \end{equation}
 
 Note a small tolerance ($\mathrm{rn\_wdmin2}$) has been introduced here {\itshape [Q: Why is
-this necessary/desirable?]}. Substituting from (\ref{dyn_wd_continuity_coef}) gives an
+this necessary/desirable?]}. Substituting from (\autoref{eq:DYN_wd_continuity_coef}) gives an
 expression for the coefficient needed to multiply the outward flux at this cell in order
 to avoid drying.
 
-\begin{equation} \label{dyn_wd_continuity_nxtcoef}
-\begin{split}
-\mathrm{zcoef}^{(m+1)}_{i,j} = \Big[ (h_{i,j}(t_e) & - \mathrm{rn\_wdmin1} - \mathrm{rn\_wdmin2})  \frac{e_1 e_2}{\Delta t} \phantom{]} \\
-\phantom{[} & -  \mathrm{zzflxn}^{(m)}_{i,j} \Big] \frac{1}{ \mathrm{zzflxp}^{(0)}_{i,j} } 
-\end{split}
+\begin{equation}
+  \label{eq:DYN_wd_continuity_nxtcoef}
+  \begin{split}
+    \mathrm{zcoef}^{(m+1)}_{i,j} = \Big[ (h_{i,j}(t_e) & - \mathrm{rn\_wdmin1} - \mathrm{rn\_wdmin2})  \frac{e_1 e_2}{\Delta t} \phantom{]} \\
+    \phantom{[} & -  \mathrm{zzflxn}^{(m)}_{i,j} \Big] \frac{1}{ \mathrm{zzflxp}^{(0)}_{i,j} }
+  \end{split}
 \end{equation}
 
@@ -1541,11 +1460,8 @@
 directional limiter does.
 
-
-%----------------------------------------------------------------------------------------
 %      Surface pressure gradients
-%----------------------------------------------------------------------------------------
-\subsubsection[Modification of surface pressure gradients (\textit{dynhpg.F90})]
-{Modification of surface pressure gradients (\mdl{dynhpg})}
-\label{subsubsec:DYN_wd_il_spg}
+%% =================================================================================================
+\subsubsection[Modification of surface pressure gradients (\textit{dynhpg.F90})]{Modification of surface pressure gradients (\mdl{dynhpg})}
+\label{subsec:DYN_wd_il_spg}
 
 At ``dry'' points the water depth is usually close to $\mathrm{rn\_wdmin1}$. If the
@@ -1560,14 +1476,15 @@
 neighbouring $(i+1,j)$ and $(i,j)$ tracer points.  zcpx is calculated using two logicals
 variables, $\mathrm{ll\_tmp1}$ and $\mathrm{ll\_tmp2}$ which are evaluated for each grid
-column.  The three possible combinations are illustrated in figure \ref{Fig_WAD_dynhpg}.
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!ht] \begin{center}
-\includegraphics[width=\textwidth]{Fig_WAD_dynhpg}
-\caption{ \label{Fig_WAD_dynhpg}
-Illustrations of the three possible combinations of the logical variables controlling the
-limiting of the horizontal pressure gradient in wetting and drying regimes}
-\end{center}\end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+column.  The three possible combinations are illustrated in \autoref{fig:DYN_WAD_dynhpg}.
+
+\begin{figure}[!ht]
+  \centering
+  \includegraphics[width=0.66\textwidth]{DYN_WAD_dynhpg}
+  \caption[Combinations controlling the limiting of the horizontal pressure gradient in
+  wetting and drying regimes]{
+    Three possible combinations of the logical variables controlling the
+    limiting of the horizontal pressure gradient in wetting and drying regimes}
+  \label{fig:DYN_WAD_dynhpg}
+\end{figure}
 
 The first logical, $\mathrm{ll\_tmp1}$, is set to true if and only if the water depth at
@@ -1576,12 +1493,13 @@
 of the topography at the two points:
 
-\begin{equation} \label{dyn_ll_tmp1}
-\begin{split}
-\mathrm{ll\_tmp1}  = & \mathrm{MIN(sshn(ji,jj), sshn(ji+1,jj))} > \\
+\begin{equation}
+  \label{eq:DYN_ll_tmp1}
+  \begin{split}
+    \mathrm{ll\_tmp1}  = & \mathrm{MIN(sshn(ji,jj), sshn(ji+1,jj))} > \\
                      & \quad \mathrm{MAX(-ht\_wd(ji,jj), -ht\_wd(ji+1,jj))\  .and.} \\
-& \mathrm{MAX(sshn(ji,jj) + ht\_wd(ji,jj),} \\
-& \mathrm{\phantom{MAX(}sshn(ji+1,jj) + ht\_wd(ji+1,jj))} >\\
-& \quad\quad\mathrm{rn\_wdmin1 + rn\_wdmin2 }
-\end{split}
+                     & \mathrm{MAX(sshn(ji,jj) + ht\_wd(ji,jj),} \\
+                     & \mathrm{\phantom{MAX(}sshn(ji+1,jj) + ht\_wd(ji+1,jj))} >\\
+                     & \quad\quad\mathrm{rn\_wdmin1 + rn\_wdmin2 }
+  \end{split}
 \end{equation}
 
@@ -1590,10 +1508,11 @@
 at the two points plus $\mathrm{rn\_wdmin1} + \mathrm{rn\_wdmin2}$
 
-\begin{equation} \label{dyn_ll_tmp2}
-\begin{split}
-\mathrm{ ll\_tmp2 } = & \mathrm{( ABS( sshn(ji,jj) - sshn(ji+1,jj) ) > 1.E-12 )\ .AND.}\\
-& \mathrm{( MAX(sshn(ji,jj), sshn(ji+1,jj)) > } \\
-& \mathrm{\phantom{(} MAX(-ht\_wd(ji,jj), -ht\_wd(ji+1,jj)) + rn\_wdmin1 + rn\_wdmin2}) .
-\end{split}
+\begin{equation}
+  \label{eq:DYN_ll_tmp2}
+  \begin{split}
+    \mathrm{ ll\_tmp2 } = & \mathrm{( ABS( sshn(ji,jj) - sshn(ji+1,jj) ) > 1.E-12 )\ .AND.}\\
+    & \mathrm{( MAX(sshn(ji,jj), sshn(ji+1,jj)) > } \\
+    & \mathrm{\phantom{(} MAX(-ht\_wd(ji,jj), -ht\_wd(ji+1,jj)) + rn\_wdmin1 + rn\_wdmin2}) .
+  \end{split}
 \end{equation}
 
@@ -1611,7 +1530,7 @@
 conditions.
 
-\subsubsection[Additional considerations (\textit{usrdef\_zgr.F90})]
-{Additional considerations (\mdl{usrdef\_zgr})}
-\label{subsubsec:WAD_additional}
+%% =================================================================================================
+\subsubsection[Additional considerations (\textit{usrdef\_zgr.F90})]{Additional considerations (\mdl{usrdef\_zgr})}
+\label{subsec:DYN_WAD_additional}
 
 In the very shallow water where wetting and drying occurs the parametrisation of
@@ -1623,39 +1542,27 @@
 in uncoupled integrations the net surface heat fluxes need to be appropriately limited.
 
-%----------------------------------------------------------------------------------------
 %      The WAD test cases
-%----------------------------------------------------------------------------------------
-\subsection[The WAD test cases (\textit{usrdef\_zgr.F90})]
-{The WAD test cases (\mdl{usrdef\_zgr})}
-\label{WAD_test_cases}
+%% =================================================================================================
+\subsection[The WAD test cases (\textit{usrdef\_zgr.F90})]{The WAD test cases (\mdl{usrdef\_zgr})}
+\label{subsec:DYN_WAD_test_cases}
 
 See the WAD tests MY\_DOC documention for details of the WAD test cases.
 
-
-
-% ================================================================
-% Time evolution term 
-% ================================================================
-\section[Time evolution term (\textit{dynnxt.F90})]
-{Time evolution term (\protect\mdl{dynnxt})}
+%% =================================================================================================
+\section[Time evolution term (\textit{dynnxt.F90})]{Time evolution term (\protect\mdl{dynnxt})}
 \label{sec:DYN_nxt}
 
-%----------------------------------------------namdom----------------------------------------------------
-
-\nlst{namdom} 
-%-------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{namdom} namelist variables.
+Options are defined through the \nam{dom}{dom} namelist variables.
 The general framework for dynamics time stepping is a leap-frog scheme,
-\ie a three level centred time scheme associated with an Asselin time filter (cf. \autoref{chap:STP}).
+\ie\ a three level centred time scheme associated with an Asselin time filter (cf. \autoref{chap:TD}).
 The scheme is applied to the velocity, except when
 using the flux form of momentum advection (cf. \autoref{sec:DYN_adv_cor_flux})
-in the variable volume case (\key{vvl} defined),
-where it has to be applied to the thickness weighted velocity (see \autoref{sec:A_momentum})  
+in the variable volume case (\texttt{vvl?} defined),
+where it has to be applied to the thickness weighted velocity (see \autoref{sec:SCOORD_momentum})
 
 $\bullet$ vector invariant form or linear free surface
-(\np{ln\_dynhpg\_vec}\forcode{ = .true.} ; \key{vvl} not defined):
-\[
-  % \label{eq:dynnxt_vec}
+(\np[=.true.]{ln_dynhpg_vec}{ln\_dynhpg\_vec} ; \texttt{vvl?} not defined):
+\[
+  % \label{eq:DYN_nxt_vec}
   \left\{
     \begin{aligned}
@@ -1667,7 +1574,7 @@
 
 $\bullet$ flux form and nonlinear free surface
-(\np{ln\_dynhpg\_vec}\forcode{ = .false.} ; \key{vvl} defined):
-\[
-  % \label{eq:dynnxt_flux}
+(\np[=.false.]{ln_dynhpg_vec}{ln\_dynhpg\_vec} ; \texttt{vvl?} defined):
+\[
+  % \label{eq:DYN_nxt_flux}
   \left\{
     \begin{aligned}
@@ -1680,6 +1587,6 @@
 where RHS is the right hand side of the momentum equation,
 the subscript $f$ denotes filtered values and $\gamma$ is the Asselin coefficient.
-$\gamma$ is initialized as \np{nn\_atfp} (namelist parameter).
-Its default value is \np{nn\_atfp}\forcode{ = 10.e-3}.
+$\gamma$ is initialized as \np{nn_atfp}{nn\_atfp} (namelist parameter).
+Its default value is \np[=10.e-3]{nn_atfp}{nn\_atfp}.
 In both cases, the modified Asselin filter is not applied since perfect conservation is not an issue for
 the momentum equations.
@@ -1689,8 +1596,5 @@
 and only array swapping and Asselin filtering is done in \mdl{dynnxt}.
 
-% ================================================================
-\biblio
-
-\pindex
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_LBC.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_LBC.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_LBC.tex	(revision 12143)
@@ -2,32 +2,55 @@
 
 \begin{document}
-% ================================================================
-% Chapter — Lateral Boundary Condition (LBC) 
-% ================================================================
+
 \chapter{Lateral Boundary Condition (LBC)}
 \label{chap:LBC}
 
-\minitoc
-
-\newpage
-
-%gm% add here introduction to this chapter
-
-% ================================================================
-% Boundary Condition at the Coast
-% ================================================================
-\section[Boundary condition at the coast (\texttt{rn\_shlat})]
-{Boundary condition at the coast (\protect\np{rn\_shlat})}
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+\cmtgm{Add here introduction to this chapter}
+
+%% =================================================================================================
+\section[Boundary condition at the coast (\forcode{rn_shlat})]{Boundary condition at the coast (\protect\np{rn_shlat}{rn\_shlat})}
 \label{sec:LBC_coast}
-%--------------------------------------------nam_lbc-------------------------------------------------------
-
-\nlst{namlbc} 
-%--------------------------------------------------------------------------------------------------------------
-
-%The lateral ocean boundary conditions contiguous to coastlines are Neumann conditions for heat and salt (no flux across boundaries) and Dirichlet conditions for momentum (ranging from free-slip to "strong" no-slip). They are handled automatically by the mask system (see \autoref{subsec:DOM_msk}). 
-
-%OPA allows land and topography grid points in the computational domain due to the presence of continents or islands, and includes the use of a full or partial step representation of bottom topography. The computation is performed over the whole domain, \ie we do not try to restrict the computation to ocean-only points. This choice has two motivations. Firstly, working on ocean only grid points overloads the code and harms the code readability. Secondly, and more importantly, it drastically reduces the vector portion of the computation, leading to a dramatic increase of CPU time requirement on vector computers.  The current section describes how the masking affects the computation of the various terms of the equations with respect to the boundary condition at solid walls. The process of defining which areas are to be masked is described in \autoref{subsec:DOM_msk}.
-
-Options are defined through the \ngn{namlbc} namelist variables.
+
+\begin{listing}
+  \nlst{namlbc}
+  \caption{\forcode{&namlbc}}
+  \label{lst:namlbc}
+\end{listing}
+
+%The lateral ocean boundary conditions contiguous to coastlines are Neumann conditions for heat and salt
+%(no flux across boundaries) and Dirichlet conditions for momentum (ranging from free-slip to "strong" no-slip).
+%They are handled automatically by the mask system (see \autoref{subsec:DOM_msk}).
+
+%OPA allows land and topography grid points in the computational domain due to the presence of continents or islands,
+%and includes the use of a full or partial step representation of bottom topography.
+%The computation is performed over the whole domain, \ie\ we do not try to restrict the computation to ocean-only points.
+%This choice has two motivations.
+%Firstly, working on ocean only grid points overloads the code and harms the code readability.
+%Secondly, and more importantly, it drastically reduces the vector portion of the computation,
+%leading to a dramatic increase of CPU time requirement on vector computers.
+%The current section describes how the masking affects the computation of the various terms of the equations
+%with respect to the boundary condition at solid walls.
+%The process of defining which areas are to be masked is described in \autoref{subsec:DOM_msk}.
+
+Options are defined through the \nam{lbc}{lbc} namelist variables.
 The discrete representation of a domain with complex boundaries (coastlines and bottom topography) leads to
 arrays that include large portions where a computation is not required as the model variables remain at zero.
@@ -41,10 +64,10 @@
 Since most of the boundary conditions consist of a zero flux across the solid boundaries,
 they can be simply applied by multiplying variables by the correct mask arrays,
-\ie the mask array of the grid point where the flux is evaluated.
+\ie\ the mask array of the grid point where the flux is evaluated.
 For example, the heat flux in the \textbf{i}-direction is evaluated at $u$-points.
 Evaluating this quantity as,
 
 \[
-  % \label{eq:lbc_aaaa}
+  % \label{eq:LBC_aaaa}
   \frac{A^{lT} }{e_1 }\frac{\partial T}{\partial i}\equiv \frac{A_u^{lT}
   }{e_{1u} } \; \delta_{i+1 / 2} \left[ T \right]\;\;mask_u
@@ -52,18 +75,14 @@
 (where mask$_{u}$ is the mask array at a $u$-point) ensures that the heat flux is zero inside land and
 at the boundaries, since mask$_{u}$ is zero at solid boundaries which in this case are defined at $u$-points
-(normal velocity $u$ remains zero at the coast) (\autoref{fig:LBC_uv}). 
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+(normal velocity $u$ remains zero at the coast) (\autoref{fig:LBC_uv}).
+
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_LBC_uv}
-    \caption{
-      \protect\label{fig:LBC_uv}
-      Lateral boundary (thick line) at T-level.
-      The velocity normal to the boundary is set to zero.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{LBC_uv}
+  \caption[Lateral boundary at $T$-level]{
+    Lateral boundary (thick line) at T-level.
+    The velocity normal to the boundary is set to zero.}
+  \label{fig:LBC_uv}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 For momentum the situation is a bit more complex as two boundary conditions must be provided along the coast
@@ -79,34 +98,30 @@
 and is required in order to compute the vorticity at the coast.
 Four different types of lateral boundary condition are available,
-controlled by the value of the \np{rn\_shlat} namelist parameter
+controlled by the value of the \np{rn_shlat}{rn\_shlat} namelist parameter
 (The value of the mask$_{f}$ array along the coastline is set equal to this parameter).
 These are:
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!p]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_LBC_shlat}
-    \caption{
-      \protect\label{fig:LBC_shlat}
-      lateral boundary condition
-      (a) free-slip ($rn\_shlat=0$);
-      (b) no-slip ($rn\_shlat=2$);
-      (c) "partial" free-slip ($0<rn\_shlat<2$) and
-      (d) "strong" no-slip ($2<rn\_shlat$).
-      Implied "ghost" velocity inside land area is display in grey.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{LBC_shlat}
+  \caption[Lateral boundary conditions]{
+    Lateral boundary conditions
+    (a) free-slip                       (\protect\np[=0]{rn_shlat}{rn\_shlat});
+    (b) no-slip                         (\protect\np[=2]{rn_shlat}{rn\_shlat});
+    (c) "partial" free-slip (\forcode{0<}\protect\np[<2]{rn_shlat}{rn\_shlat}) and
+    (d) "strong" no-slip    (\forcode{2<}\protect\np{rn_shlat}{rn\_shlat}).
+    Implied "ghost" velocity inside land area is display in grey.}
+  \label{fig:LBC_shlat}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 \begin{description}
 
-\item[free-slip boundary condition (\np{rn\_shlat}\forcode{ = 0}):] the tangential velocity at
+\item [free-slip boundary condition ({\np[=0]{rn_shlat}{rn\_shlat}})] the tangential velocity at
   the coastline is equal to the offshore velocity,
-  \ie the normal derivative of the tangential velocity is zero at the coast,
+  \ie\ the normal derivative of the tangential velocity is zero at the coast,
   so the vorticity: mask$_{f}$ array is set to zero inside the land and just at the coast
   (\autoref{fig:LBC_shlat}-a).
 
-\item[no-slip boundary condition (\np{rn\_shlat}\forcode{ = 2}):] the tangential velocity vanishes at the coastline.
+\item [no-slip boundary condition ({\np[=2]{rn_shlat}{rn\_shlat}})] the tangential velocity vanishes at the coastline.
   Assuming that the tangential velocity decreases linearly from
   the closest ocean velocity grid point to the coastline,
@@ -114,5 +129,5 @@
   the closest ocean velocity gridpoint were of the same magnitude but in the opposite direction
   (\autoref{fig:LBC_shlat}-b).
-  Therefore, the vorticity along the coastlines is given by: 
+  Therefore, the vorticity along the coastlines is given by:
 
   \[
@@ -123,5 +138,5 @@
   the no-slip boundary condition, simply by multiplying it by the mask$_{f}$ :
   \[
-    % \label{eq:lbc_bbbb}
+    % \label{eq:LBC_bbbb}
     \zeta \equiv \frac{1}{e_{1f} {\kern 1pt}e_{2f} }\left( {\delta_{i+1/2}
         \left[ {e_{2v} \,v} \right]-\delta_{j+1/2} \left[ {e_{1u} \,u} \right]}
@@ -129,10 +144,10 @@
   \]
 
-\item["partial" free-slip boundary condition (0$<$\np{rn\_shlat}$<$2):] the tangential velocity at
-  the coastline is smaller than the offshore velocity, \ie there is a lateral friction but
+\item ["partial" free-slip boundary condition (0$<$\np{rn_shlat}{rn\_shlat}$<$2)] the tangential velocity at
+  the coastline is smaller than the offshore velocity, \ie\ there is a lateral friction but
   not strong enough to make the tangential velocity at the coast vanish (\autoref{fig:LBC_shlat}-c).
   This can be selected by providing a value of mask$_{f}$ strictly inbetween $0$ and $2$.
 
-\item["strong" no-slip boundary condition (2$<$\np{rn\_shlat}):] the viscous boundary layer is assumed to
+\item ["strong" no-slip boundary condition (2$<$\np{rn_shlat}{rn\_shlat})] the viscous boundary layer is assumed to
   be smaller than half the grid size (\autoref{fig:LBC_shlat}-d).
   The friction is thus larger than in the no-slip case.
@@ -140,14 +155,10 @@
 \end{description}
 
-Note that when the bottom topography is entirely represented by the $s$-coor-dinates (pure $s$-coordinate),
+Note that when the bottom topography is entirely represented by the $s$-coordinates (pure $s$-coordinate),
 the lateral boundary condition on tangential velocity is of much less importance as
 it is only applied next to the coast where the minimum water depth can be quite shallow.
 
-
-% ================================================================
-% Boundary Condition around the Model Domain
-% ================================================================
-\section[Model domain boundary condition (\texttt{jperio})]
-{Model domain boundary condition (\protect\np{jperio})}
+%% =================================================================================================
+\section[Model domain boundary condition (\forcode{jperio})]{Model domain boundary condition (\protect\jp{jperio})}
 \label{sec:LBC_jperio}
 
@@ -155,104 +166,81 @@
 closed, cyclic east-west, cyclic north-south, a north-fold, and combination closed-north fold or
 bi-cyclic east-west and north-fold.
-The north-fold boundary condition is associated with the 3-pole ORCA mesh. 
-
-% -------------------------------------------------------------------------------------------------------------
-%        Closed, cyclic (\np{jperio}\forcode{ = 0..2}) 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Closed, cyclic (\forcode{jperio = [0127]})]
-{Closed, cyclic (\protect\np{jperio}\forcode{ = [0127]})}
+The north-fold boundary condition is associated with the 3-pole ORCA mesh.
+
+%% =================================================================================================
+\subsection[Closed, cyclic (\forcode{=0,1,2,7})]{Closed, cyclic (\protect\jp{jperio}\forcode{=0,1,2,7})}
 \label{subsec:LBC_jperio012}
 
 The choice of closed or cyclic model domain boundary condition is made by
-setting \np{jperio} to 0, 1, 2 or 7 in namelist \ngn{namcfg}.
+setting \jp{jperio} to 0, 1, 2 or 7 in namelist \nam{cfg}{cfg}.
 Each time such a boundary condition is needed, it is set by a call to routine \mdl{lbclnk}.
 The computation of momentum and tracer trends proceeds from $i=2$ to $i=jpi-1$ and from $j=2$ to $j=jpj-1$,
-\ie in the model interior.
+\ie\ in the model interior.
 To choose a lateral model boundary condition is to specify the first and last rows and columns of
-the model variables. 
+the model variables.
 
 \begin{description}
 
-\item[For closed boundary (\np{jperio}\forcode{ = 0})],
-  solid walls are imposed at all model boundaries:
+\item [For closed boundary (\jp{jperio}\forcode{=0})], solid walls are imposed at all model boundaries:
   first and last rows and columns are set to zero.
 
-\item[For cyclic east-west boundary (\np{jperio}\forcode{ = 1})],
-  first and last rows are set to zero (closed) whilst the first column is set to
+\item [For cyclic east-west boundary (\jp{jperio}\forcode{=1})], first and last rows are set to zero (closed) whilst the first column is set to
   the value of the last-but-one column and the last column to the value of the second one
   (\autoref{fig:LBC_jperio}-a).
   Whatever flows out of the eastern (western) end of the basin enters the western (eastern) end.
 
-\item[For cyclic north-south boundary (\np{jperio}\forcode{ = 2})],
-  first and last columns are set to zero (closed) whilst the first row is set to
+\item [For cyclic north-south boundary (\jp{jperio}\forcode{=2})], first and last columns are set to zero (closed) whilst the first row is set to
   the value of the last-but-one row and the last row to the value of the second one
   (\autoref{fig:LBC_jperio}-a).
   Whatever flows out of the northern (southern) end of the basin enters the southern (northern) end.
 
-\item[Bi-cyclic east-west and north-south boundary (\np{jperio}\forcode{ = 7})] combines cases 1 and 2.
+\item [Bi-cyclic east-west and north-south boundary (\jp{jperio}\forcode{=7})] combines cases 1 and 2.
 
 \end{description}
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_LBC_jperio}
-    \caption{
-      \protect\label{fig:LBC_jperio}
-      setting of (a) east-west cyclic  (b) symmetric across the equator boundary conditions.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{LBC_jperio}
+  \caption[Setting of east-west cyclic and symmetric across the Equator boundary conditions]{
+    Setting of (a) east-west cyclic (b) symmetric across the Equator boundary conditions}
+  \label{fig:LBC_jperio}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -------------------------------------------------------------------------------------------------------------
-%        North fold (\textit{jperio = 3 }to $6)$ 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[North-fold (\forcode{jperio = [3-6]})]
-{North-fold (\protect\np{jperio}\forcode{ = [3-6]})}
+
+%% =================================================================================================
+\subsection[North-fold (\forcode{=3,6})]{North-fold (\protect\jp{jperio}\forcode{=3,6})}
 \label{subsec:LBC_north_fold}
 
 The north fold boundary condition has been introduced in order to handle the north boundary of
 a three-polar ORCA grid.
-Such a grid has two poles in the northern hemisphere (\autoref{fig:MISC_ORCA_msh},
-and thus requires a specific treatment illustrated in \autoref{fig:North_Fold_T}. 
+Such a grid has two poles in the northern hemisphere (\autoref{fig:CFGS_ORCA_msh},
+and thus requires a specific treatment illustrated in \autoref{fig:LBC_North_Fold_T}.
 Further information can be found in \mdl{lbcnfd} module which applies the north fold boundary condition.
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_North_Fold_T}
-    \caption{
-      \protect\label{fig:North_Fold_T}
-      North fold boundary with a $T$-point pivot and cyclic east-west boundary condition ($jperio=4$),
-      as used in ORCA 2, 1/4, and 1/12.
-      Pink shaded area corresponds to the inner domain mask (see text).
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{LBC_North_Fold_T}
+  \caption[North fold boundary in ORCA 2\deg, 1/4\deg and 1/12\deg]{
+    North fold boundary with a $T$-point pivot and cyclic east-west boundary condition ($jperio=4$),
+    as used in ORCA 2\deg, 1/4\deg and 1/12\deg.
+    Pink shaded area corresponds to the inner domain mask (see text).}
+  \label{fig:LBC_North_Fold_T}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% ====================================================================
-% Exchange with neighbouring processors 
-% ====================================================================
-\section[Exchange with neighbouring processors (\textit{lbclnk.F90}, \textit{lib\_mpp.F90})]
-{Exchange with neighbouring processors (\protect\mdl{lbclnk}, \protect\mdl{lib\_mpp})}
+
+%% =================================================================================================
+\section[Exchange with neighbouring processors (\textit{lbclnk.F90}, \textit{lib\_mpp.F90})]{Exchange with neighbouring processors (\protect\mdl{lbclnk}, \protect\mdl{lib\_mpp})}
 \label{sec:LBC_mpp}
 
+\begin{listing}
+  \nlst{nammpp}
+  \caption{\forcode{&nammpp}}
+  \label{lst:nammpp}
+\end{listing}
+
 For massively parallel processing (mpp), a domain decomposition method is used.
-The basic idea of the method is to split the large computation domain of a numerical experiment into
-several smaller domains and solve the set of equations by addressing independent local problems.
+The basic idea of the method is to split the large computation domain of a numerical experiment into several smaller domains and
+solve the set of equations by addressing independent local problems.
 Each processor has its own local memory and computes the model equation over a subdomain of the whole model domain.
-The subdomain boundary conditions are specified through communications between processors which
-are organized by explicit statements (message passing method).
-
-A big advantage is that the method does not need many modifications of the initial \fortran code.
-From the modeller's point of view, each sub domain running on a processor is identical to the "mono-domain" code.
-In addition, the programmer manages the communications between subdomains,
-and the code is faster when the number of processors is increased.
-The porting of OPA code on an iPSC860 was achieved during Guyon's PhD [Guyon et al. 1994, 1995]
-in collaboration with CETIIS and ONERA.
-The implementation in the operational context and the studies of performance on
-a T3D and T3E Cray computers have been made in collaboration with IDRIS and CNRS.
+The subdomain boundary conditions are specified through communications between processors which are organized by
+explicit statements (message passing method).
 The present implementation is largely inspired by Guyon's work [Guyon 1995].
 
@@ -261,7 +249,5 @@
 depend at the very most on one neighbouring point.
 The only non-local computations concern the vertical physics
-(implicit diffusion, turbulent closure scheme, ...) (delocalization over the whole water column),
-and the solving of the elliptic equation associated with the surface pressure gradient computation
-(delocalization over the whole horizontal domain).
+(implicit diffusion, turbulent closure scheme, ...).
 Therefore, a pencil strategy is used for the data sub-structuration:
 the 3D initial domain is laid out on local processor memories following a 2D horizontal topological splitting.
@@ -272,201 +258,169 @@
 After a computation, a communication phase starts:
 each processor sends to its neighbouring processors the update values of the points corresponding to
-the interior overlapping area to its neighbouring sub-domain (\ie the innermost of the two overlapping rows).
-The communication is done through the Message Passing Interface (MPI).
+the interior overlapping area to its neighbouring sub-domain (\ie\ the innermost of the two overlapping rows).
+Communications are first done according to the east-west direction and next according to the north-south direction.
+There is no specific communications for the corners.
+The communication is done through the Message Passing Interface (MPI) and requires \key{mpp\_mpi}.
+Use also \key{mpi2} if MPI3 is not available on your computer.
 The data exchanges between processors are required at the very place where
 lateral domain boundary conditions are set in the mono-domain computation:
 the \rou{lbc\_lnk} routine (found in \mdl{lbclnk} module) which manages such conditions is interfaced with
-routines found in \mdl{lib\_mpp} module when running on an MPP computer (\ie when \key{mpp\_mpi} defined).
-It has to be pointed out that when using the MPP version of the model,
-the east-west cyclic boundary condition is done implicitly,
-whilst the south-symmetric boundary condition option is not available.
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+routines found in \mdl{lib\_mpp} module.
+The output file \textit{communication\_report.txt} provides the list of which routines do how
+many communications during 1 time step of the model.\\
+
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_mpp}
-    \caption{
-      \protect\label{fig:mpp}
-      Positioning of a sub-domain when massively parallel processing is used.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{LBC_mpp}
+  \caption{Positioning of a sub-domain when massively parallel processing is used}
+  \label{fig:LBC_mpp}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-In the standard version of \NEMO, the splitting is regular and arithmetic.
-The i-axis is divided by \jp{jpni} and
-the j-axis by \jp{jpnj} for a number of processors \jp{jpnij} most often equal to $jpni \times jpnj$
-(parameters set in  \ngn{nammpp} namelist).
-Each processor is independent and without message passing or synchronous process,
-programs run alone and access just its own local memory.
-For this reason, the main model dimensions are now the local dimensions of the subdomain (pencil) that
-are named \jp{jpi}, \jp{jpj}, \jp{jpk}.
+
+In \NEMO, the splitting is regular and arithmetic.
+The total number of subdomains corresponds to the number of MPI processes allocated to \NEMO\ when the model is launched
+(\ie\ mpirun -np x ./nemo will automatically give x subdomains).
+The i-axis is divided by \np{jpni}{jpni} and the j-axis by \np{jpnj}{jpnj}.
+These parameters are defined in \nam{mpp}{mpp} namelist.
+If \np{jpni}{jpni} and \np{jpnj}{jpnj} are < 1, they will be automatically redefined in the code to give the best domain decomposition
+(see bellow).
+
+Each processor is independent and without message passing or synchronous process, programs run alone and access just its own local memory.
+For this reason,
+the main model dimensions are now the local dimensions of the subdomain (pencil) that are named \jp{jpi}, \jp{jpj}, \jp{jpk}.
 These dimensions include the internal domain and the overlapping rows.
-The number of rows to exchange (known as the halo) is usually set to one (\jp{jpreci}=1, in \mdl{par\_oce}).
-The whole domain dimensions are named \np{jpiglo}, \np{jpjglo} and \jp{jpk}.
+The number of rows to exchange (known as the halo) is usually set to one (nn\_hls=1, in \mdl{par\_oce},
+and must be kept to one until further notice).
+The whole domain dimensions are named \jp{jpiglo}, \jp{jpjglo} and \jp{jpk}.
 The relationship between the whole domain and a sub-domain is:
+\begin{gather*}
+  jpi = ( jpiglo-2\times nn\_hls + (jpni-1) ) / jpni + 2\times nn\_hls \\
+  jpj = ( jpjglo-2\times nn\_hls + (jpnj-1) ) / jpnj + 2\times nn\_hls
+\end{gather*}
+
+One also defines variables nldi and nlei which correspond to the internal domain bounds, and the variables nimpp and njmpp which are the position of the (1,1) grid-point in the global domain (\autoref{fig:LBC_mpp}). Note that since the version 4, there is no more extra-halo area as defined in \autoref{fig:LBC_mpp} so \jp{jpi} is now always equal to nlci and \jp{jpj} equal to nlcj.
+
+An element of $T_{l}$, a local array (subdomain) corresponds to an element of $T_{g}$,
+a global array (whole domain) by the relationship:
 \[
-  jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci
-  jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj
-\]
-where \jp{jpni}, \jp{jpnj} are the number of processors following the i- and j-axis.
-
-One also defines variables nldi and nlei which correspond to the internal domain bounds, 
-and the variables nimpp and njmpp which are the position of the (1,1) grid-point in the global domain. 
-An element of $T_{l}$, a local array (subdomain) corresponds to an element of $T_{g}$,
-a global array (whole domain) by the relationship: 
-\[
-  % \label{eq:lbc_nimpp}
+  % \label{eq:LBC_nimpp}
   T_{g} (i+nimpp-1,j+njmpp-1,k) = T_{l} (i,j,k),
 \]
-with  $1 \leq i \leq jpi$, $1  \leq j \leq jpj $ , and  $1  \leq k \leq jpk$.
-
-Processors are numbered from 0 to $jpnij-1$, the number is saved in the variable nproc.
-In the standard version, a processor has no more than
-four neighbouring processors named nono (for north), noea (east), noso (south) and nowe (west) and
-two variables, nbondi and nbondj, indicate the relative position of the processor:
-\begin{itemize}
-\item 		nbondi = -1 	an east neighbour, no west processor,
-\item 		nbondi =  0	an east neighbour, a west neighbour,
-\item 		nbondi =  1 	no east processor, a west neighbour,
-\item 		nbondi =  2 	no splitting following the i-axis.
-\end{itemize}
-During the simulation, processors exchange data with their neighbours.
-If there is effectively a neighbour, the processor receives variables from this processor on its overlapping row,
-and sends the data issued from internal domain corresponding to the overlapping row of the other processor.
-
-
-The \NEMO model computes equation terms with the help of mask arrays (0 on land points and 1 on sea points).
-It is easily readable and very efficient in the context of a computer with vectorial architecture.
-However, in the case of a scalar processor, computations over the land regions become more expensive in
-terms of CPU time. 
-It is worse when we use a complex configuration with a realistic bathymetry like the global ocean where
-more than 50 \% of points are land points.
-For this reason, a pre-processing tool can be used to choose the mpp domain decomposition with a maximum number of
-only land points processors, which can then be eliminated (\autoref{fig:mppini2})
-(For example, the mpp\_optimiz tools, available from the DRAKKAR web site).
-This optimisation is dependent on the specific bathymetry employed.
-The user then chooses optimal parameters \jp{jpni}, \jp{jpnj} and \jp{jpnij} with $jpnij < jpni \times jpnj$,
-leading to the elimination of $jpni \times jpnj - jpnij$ land processors.
-When those parameters are specified in \ngn{nammpp} namelist,
-the algorithm in the \rou{inimpp2} routine sets each processor's parameters (nbound, nono, noea,...) so that
-the land-only processors are not taken into account.
-
-\gmcomment{Note that the inimpp2 routine is general so that the original inimpp 
-routine should be suppressed from the code.}
-
-When land processors are eliminated,
-the value corresponding to these locations in the model output files is undefined.
-Note that this is a problem for the meshmask file which requires to be defined over the whole domain.
-Therefore, user should not eliminate land processors when creating a meshmask file
-(\ie when setting a non-zero value to \np{nn\_msh}).
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+with $1 \leq i \leq jpi$, $1  \leq j \leq jpj $ , and  $1  \leq k \leq jpk$.
+
+The 1-d arrays $mig(1:\jp{jpi})$ and $mjg(1:\jp{jpj})$, defined in \rou{dom\_glo} routine (\mdl{domain} module), should be used to get global domain indices from local domain indices. The 1-d arrays, $mi0(1:\jp{jpiglo})$, $mi1(1:\jp{jpiglo})$ and $mj0(1:\jp{jpjglo})$, $mj1(1:\jp{jpjglo})$ have the reverse purpose and should be used to define loop indices expressed in global domain indices (see examples in \mdl{dtastd} module).\\
+
+The \NEMO\ model computes equation terms with the help of mask arrays (0 on land points and 1 on sea points). It is therefore possible that an MPI subdomain contains only land points. To save ressources, we try to supress from the computational domain as much land subdomains as possible. For example if $N_{mpi}$ processes are allocated to NEMO, the domain decomposition will be given by the following equation:
+\[
+  N_{mpi} = jpni \times jpnj - N_{land} + N_{useless}
+\]
+$N_{land}$ is the total number of land subdomains in the domain decomposition defined by \np{jpni}{jpni} and \np{jpnj}{jpnj}. $N_{useless}$ is the number of land subdomains that are kept in the compuational domain in order to make sure that $N_{mpi}$ MPI processes are indeed allocated to a given subdomain. The values of $N_{mpi}$, \np{jpni}{jpni}, \np{jpnj}{jpnj},  $N_{land}$ and $N_{useless}$ are printed in the output file \texttt{ocean.output}. $N_{useless}$ must, of course, be as small as possible to limit the waste of ressources. A warning is issued in  \texttt{ocean.output} if $N_{useless}$ is not zero. Note that non-zero value of $N_{useless}$ is uselly required when using AGRIF as, up to now, the parent grid and each of the child grids must use all the $N_{mpi}$ processes.
+
+If the domain decomposition is automatically defined (when \np{jpni}{jpni} and \np{jpnj}{jpnj} are < 1), the decomposition chosen by the model will minimise the sub-domain size (defined as $max_{all domains}(jpi \times jpj)$) and maximize the number of eliminated land subdomains. This means that no other domain decomposition (a set of \np{jpni}{jpni} and \np{jpnj}{jpnj} values) will use less processes than $(jpni  \times  jpnj - N_{land})$ and get a smaller subdomain size.
+In order to specify $N_{mpi}$ properly (minimize $N_{useless}$), you must run the model once with \np{ln_list}{ln\_list} activated. In this case, the model will start the initialisation phase, print the list of optimum decompositions ($N_{mpi}$, \np{jpni}{jpni} and \np{jpnj}{jpnj}) in \texttt{ocean.output} and directly abort. The maximum value of $N_{mpi}$ tested in this list is given by $max(N_{MPI\_tasks}, jpni \times jpnj)$. For example, run the model on 40 nodes with ln\_list activated and $jpni = 10000$ and $jpnj = 1$, will print the list of optimum domains decomposition from 1 to about 10000.
+
+Processors are numbered from 0 to $N_{mpi} - 1$. Subdomains containning some ocean points are numbered first from 0 to $jpni * jpnj - N_{land} -1$. The remaining $N_{useless}$ land subdomains are numbered next, which means that, for a given (\np{jpni}{jpni}, \np{jpnj}{jpnj}), the numbers attributed to he ocean subdomains do not vary with $N_{useless}$.
+
+When land processors are eliminated, the value corresponding to these locations in the model output files is undefined. \np{ln_mskland}{ln\_mskland} must be activated in order avoid Not a Number values in output files. Note that it is better to not eliminate land processors when creating a meshmask file (\ie\ when setting a non-zero value to \np{nn_msh}{nn\_msh}).
+
 \begin{figure}[!ht]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_mppini2}
-    \caption {
-      \protect\label{fig:mppini2}
-      Example of Atlantic domain defined for the CLIPPER projet.
-      Initial grid is composed of 773 x 1236 horizontal points.
-      (a) the domain is split onto 9 \time 20 subdomains (jpni=9, jpnj=20).
-      52 subdomains are land areas.
-      (b) 52 subdomains are eliminated (white rectangles) and
-      the resulting number of processors really used during the computation is jpnij=128.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{LBC_mppini2}
+  \caption[Atlantic domain defined for the CLIPPER projet]{
+    Example of Atlantic domain defined for the CLIPPER projet.
+    Initial grid is composed of 773 x 1236 horizontal points.
+    (a) the domain is split onto 9 $times$ 20 subdomains (jpni=9, jpnj=20).
+    52 subdomains are land areas.
+    (b) 52 subdomains are eliminated (white rectangles) and
+    the resulting number of processors really used during the computation is jpnij=128.}
+  \label{fig:LBC_mppini2}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-% ====================================================================
-% Unstructured open boundaries BDY 
-% ====================================================================
+
+%% =================================================================================================
 \section{Unstructured open boundary conditions (BDY)}
 \label{sec:LBC_bdy}
 
-%-----------------------------------------nambdy--------------------------------------------
-
-\nlst{nambdy} 
-%-----------------------------------------------------------------------------------------------
-%-----------------------------------------nambdy_dta--------------------------------------------
-
-\nlst{nambdy_dta} 
-%-----------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{nambdy} \ngn{nambdy\_dta} namelist variables.
-The BDY module is the core implementation of open boundary conditions for regional configurations on 
-temperature, salinity, barotropic and baroclinic velocities, as well as ice concentration, ice and snow thicknesses).
-
-The BDY module was modelled on the OBC module (see NEMO 3.4) and shares many features and
+\begin{listing}
+  \nlst{nambdy}
+  \caption{\forcode{&nambdy}}
+  \label{lst:nambdy}
+\end{listing}
+
+\begin{listing}
+  \nlst{nambdy_dta}
+  \caption{\forcode{&nambdy_dta}}
+  \label{lst:nambdy_dta}
+\end{listing}
+
+Options are defined through the \nam{bdy}{bdy} and \nam{bdy_dta}{bdy\_dta} namelist variables.
+The BDY module is the core implementation of open boundary conditions for regional configurations on
+ocean temperature, salinity, barotropic-baroclinic velocities, ice-snow concentration, thicknesses, temperatures, salinity and melt ponds concentration and thickness.
+
+The BDY module was modelled on the OBC module (see \NEMO\ 3.4) and shares many features and
 a similar coding structure \citep{chanut_rpt05}.
 The specification of the location of the open boundary is completely flexible and
-allows for example the open boundary to follow an isobath or other irregular contour. 
-Boundary data files used with versions of NEMO prior to Version 3.4 may need to be re-ordered to work with this version.
+allows any type of setup, from regular boundaries to irregular contour (it includes the possibility to set an open boundary able to follow an isobath).
+Boundary data files used with versions of \NEMO\ prior to Version 3.4 may need to be re-ordered to work with this version.
 See the section on the Input Boundary Data Files for details.
 
-%----------------------------------------------
+%% =================================================================================================
 \subsection{Namelists}
-\label{subsec:BDY_namelist}
-
-The BDY module is activated by setting \np{ln\_bdy}\forcode{ = .true.} .
+\label{subsec:LBC_bdy_namelist}
+
+The BDY module is activated by setting \np[=.true.]{ln_bdy}{ln\_bdy} .
 It is possible to define more than one boundary ``set'' and apply different boundary conditions to each set.
-The number of boundary sets is defined by \np{nb\_bdy}.
-Each boundary set may be defined as a set of straight line segments in a namelist
-(\np{ln\_coords\_file}\forcode{ = .false.}) or read in from a file (\np{ln\_coords\_file}\forcode{ = .true.}).
-If the set is defined in a namelist, then the namelists \ngn{nambdy\_index} must be included separately, one for each set.
-If the set is defined by a file, then a ``\ifile{coordinates.bdy}'' file must be provided.
-The coordinates.bdy file is analagous to the usual NEMO ``\ifile{coordinates}'' file.
+The number of boundary sets is defined by \np{nb_bdy}{nb\_bdy}.
+Each boundary set can be either defined as a series of straight line segments directly in the namelist
+(\np[=.false.]{ln_coords_file}{ln\_coords\_file}, and a namelist block \nam{bdy_index}{bdy\_index} must be included for each set) or read in from a file (\np[=.true.]{ln_coords_file}{ln\_coords\_file}, and a ``\ifile{coordinates.bdy}'' file must be provided).
+The coordinates.bdy file is analagous to the usual \NEMO\ ``\ifile{coordinates}'' file.
 In the example above, there are two boundary sets, the first of which is defined via a file and
-the second is defined in a namelist.
-For more details of the definition of the boundary geometry see section \autoref{subsec:BDY_geometry}.
+the second is defined in the namelist.
+For more details of the definition of the boundary geometry see section \autoref{subsec:LBC_bdy_geometry}.
 
 For each boundary set a boundary condition has to be chosen for the barotropic solution
-(``u2d'':sea-surface height and barotropic velocities), for the baroclinic velocities (``u3d''), 
-for the active tracers \footnote{The BDY module does not deal with passive tracers at this version} (``tra''), and sea-ice (``ice'').
-For each set of variables there is a choice of algorithm and a choice for the data,
-eg. for the active tracers the algorithm is set by \np{cn\_tra} and the choice of data is set by \np{nn\_tra\_dta}.\\ 
+(``u2d'':sea-surface height and barotropic velocities), for the baroclinic velocities (``u3d''),
+for the active tracers \footnote{The BDY module does not deal with passive tracers at this version} (``tra''), and for sea-ice (``ice'').
+For each set of variables one has to choose an algorithm and the boundary data (set resp. by \np{cn_tra}{cn\_tra} and \np{nn_tra_dta}{nn\_tra\_dta} for tracers).\\
 
 The choice of algorithm is currently as follows:
 
 \begin{description}
-\item[\forcode{'none'}:] No boundary condition applied.
+\item [\forcode{'none'}:] No boundary condition applied.
   So the solution will ``see'' the land points around the edge of the edge of the domain.
-\item[\forcode{'specified'}:] Specified boundary condition applied (only available for baroclinic velocity and tracer variables).
-\item[\forcode{'neumann'}:] Value at the boundary are duplicated (No gradient). Only available for baroclinic velocity and tracer variables.
-\item[\forcode{'frs'}:] Flow Relaxation Scheme (FRS) available for all variables.
-\item[\forcode{'Orlanski'}:] Orlanski radiation scheme (fully oblique) for barotropic, baroclinic and tracer variables. 
-\item[\forcode{'Orlanski_npo'}:] Orlanski radiation scheme for barotropic, baroclinic and tracer variables. 
-\item[\forcode{'flather'}:] Flather radiation scheme for the barotropic variables only.
+\item [\forcode{'specified'}:] Specified boundary condition applied (only available for baroclinic velocity and tracer variables).
+\item [\forcode{'neumann'}:] Value at the boundary are duplicated (No gradient). Only available for baroclinic velocity and tracer variables.
+\item [\forcode{'frs'}:] Flow Relaxation Scheme (FRS) available for all variables.
+\item [\forcode{'Orlanski'}:] Orlanski radiation scheme (fully oblique) for barotropic, baroclinic and tracer variables.
+\item [\forcode{'Orlanski_npo'}:] Orlanski radiation scheme for barotropic, baroclinic and tracer variables.
+\item [\forcode{'flather'}:] Flather radiation scheme for the barotropic variables only.
 \end{description}
 
-The main choice for the boundary data is to use initial conditions as boundary data
-(\np{nn\_tra\_dta}\forcode{ = 0}) or to use external data from a file (\np{nn\_tra\_dta}\forcode{ = 1}).
-In case the 3d velocity data contain the total velocity (ie, baroclinic and barotropic velocity), 
-the bdy code can derived baroclinic and barotropic velocities by setting \np{ln\_full\_vel}\forcode{ = .true. }
+The boundary data is either set to initial conditions
+(\np[=0]{nn_tra_dta}{nn\_tra\_dta}) or forced with external data from a file (\np[=1]{nn_tra_dta}{nn\_tra\_dta}).
+In case the 3d velocity data contain the total velocity (ie, baroclinic and barotropic velocity),
+the bdy code can derived baroclinic and barotropic velocities by setting \np[=.true.]{ln_full_vel}{ln\_full\_vel}
 For the barotropic solution there is also the option to use tidal harmonic forcing either by
-itself (\np{nn\_dyn2d\_dta}\forcode{ = 2}) or in addition to other external data (\np{nn\_dyn2d\_dta}\forcode{ = 3}).\\
-Sea-ice salinity, temperature and age data at the boundary are constant and defined repectively by \np{rn\_ice\_sal}, \np{rn\_ice\_tem} and \np{rn\_ice\_age}. 
-
-If external boundary data is required then the \ngn{nambdy\_dta} namelist must be defined.
-One \ngn{nambdy\_dta} namelist is required for each boundary set in the order in which
-the boundary sets are defined in nambdy.
-In the example given, two boundary sets have been defined. The first one is reading data file in the \ngn{nambdy\_dta} namelist shown above 
-and the second one is using data from intial condition (no namelist bloc needed).
+itself (\np[=2]{nn_dyn2d_dta}{nn\_dyn2d\_dta}) or in addition to other external data (\np[=3]{nn_dyn2d_dta}{nn\_dyn2d\_dta}).\\
+If not set to initial conditions, sea-ice salinity, temperatures and melt ponds data at the boundary can either be read in a file or defined as constant (by \np{rn_ice_sal}{rn\_ice\_sal}, \np{rn_ice_tem}{rn\_ice\_tem}, \np{rn_ice_apnd}{rn\_ice\_apnd}, \np{rn_ice_hpnd}{rn\_ice\_hpnd}). Ice age is constant and defined by \np{rn_ice_age}{rn\_ice\_age}.
+
+If external boundary data is required then the \nam{bdy_dta}{bdy\_dta} namelist must be defined.
+One \nam{bdy_dta}{bdy\_dta} namelist is required for each boundary set, adopting the same order of indexes in which the boundary sets are defined in nambdy.
+In the example given, two boundary sets have been defined. The first one is reading data file in the \nam{bdy_dta}{bdy\_dta} namelist shown above
+and the second one is using data from intial condition (no namelist block needed).
 The boundary data is read in using the fldread module,
-so the \ngn{nambdy\_dta} namelist is in the format required for fldread.
-For each variable required, the filename, the frequency of the files and
-the frequency of the data in the files is given.
-Also whether or not time-interpolation is required and whether the data is climatological (time-cyclic) data.\\
+so the \nam{bdy_dta}{bdy\_dta} namelist is in the format required for fldread.
+For each required variable, the filename, the frequency of the files and
+the frequency of the data in the files are given.
+Also whether or not time-interpolation is required and whether the data is climatological (time-cyclic) data.
+For sea-ice salinity, temperatures and melt ponds, reading the files are skipped and constant values are used if filenames are defined as {'NOT USED'}.\\
 
 There is currently an option to vertically interpolate the open boundary data onto the native grid at run-time.
-If \np{nn\_bdy\_jpk} $< -1$, it is assumed that the lateral boundary data are already on the native grid. 
-However, if \np{nn\_bdy\_jpk} is set to the number of vertical levels present in the boundary data, 
-a bilinear interpolation onto the native grid will be triggered at runtime. 
-For this to be successful the additional variables: $gdept$, $gdepu$, $gdepv$, $e3t$, $e3u$ and $e3v$, are required to be present in the lateral boundary files. 
-These correspond to the depths and scale factors of the input data, 
+If \np{nn_bdy_jpk}{nn\_bdy\_jpk}$<-1$, it is assumed that the lateral boundary data are already on the native grid.
+However, if \np{nn_bdy_jpk}{nn\_bdy\_jpk} is set to the number of vertical levels present in the boundary data,
+a bilinear interpolation onto the native grid will be triggered at runtime.
+For this to be successful the additional variables: $gdept$, $gdepu$, $gdepv$, $e3t$, $e3u$ and $e3v$, are required to be present in the lateral boundary files.
+These correspond to the depths and scale factors of the input data,
 the latter used to make any adjustment to the velocity fields due to differences in the total water depths between the two vertical grids.\\
 
-In the example namelists given, two boundary sets are defined.
+In the example of given namelists, two boundary sets are defined.
 The first set is defined via a file and applies FRS conditions to temperature and salinity and
 Flather conditions to the barotropic variables. No condition specified for the baroclinic velocity and sea-ice.
@@ -474,9 +428,9 @@
 Tidal harmonic forcing is also used.
 The second set is defined in a namelist.
-FRS conditions are applied on temperature and salinity and climatological data is read from initial condition files. 
-
-%----------------------------------------------
+FRS conditions are applied on temperature and salinity and climatological data is read from initial condition files.
+
+%% =================================================================================================
 \subsection{Flow relaxation scheme}
-\label{subsec:BDY_FRS_scheme}
+\label{subsec:LBC_bdy_FRS_scheme}
 
 The Flow Relaxation Scheme (FRS) \citep{davies_QJRMS76,engedahl_T95},
@@ -485,5 +439,5 @@
 Given a model prognostic variable $\Phi$
 \[
-  % \label{eq:bdy_frs1}
+  % \label{eq:LBC_bdy_frs1}
   \Phi(d) = \alpha(d)\Phi_{e}(d) + (1-\alpha(d))\Phi_{m}(d)\;\;\;\;\; d=1,N
 \]
@@ -494,10 +448,10 @@
 the prognostic equation for $\Phi$ of the form:
 \[
-  % \label{eq:bdy_frs2}
+  % \label{eq:LBC_bdy_frs2}
   -\frac{1}{\tau}\left(\Phi - \Phi_{e}\right)
 \]
 where the relaxation time scale $\tau$ is given by a function of $\alpha$ and the model time step $\Delta t$:
 \[
-  % \label{eq:bdy_frs3}
+  % \label{eq:LBC_bdy_frs3}
   \tau = \frac{1-\alpha}{\alpha}  \,\rdt
 \]
@@ -505,23 +459,24 @@
 is relaxed towards the external conditions over the rest of the FRS zone.
 The application of a relaxation zone helps to prevent spurious reflection of
-outgoing signals from the model boundary. 
+outgoing signals from the model boundary.
 
 The function $\alpha$ is specified as a $tanh$ function:
 \[
-  % \label{eq:bdy_frs4}
+  % \label{eq:LBC_bdy_frs4}
   \alpha(d) = 1 - \tanh\left(\frac{d-1}{2}\right),       \quad d=1,N
 \]
-The width of the FRS zone is specified in the namelist as \np{nn\_rimwidth}.
+The width of the FRS zone is specified in the namelist as \np{nn_rimwidth}{nn\_rimwidth}.
 This is typically set to a value between 8 and 10.
 
-%----------------------------------------------
+%% =================================================================================================
 \subsection{Flather radiation scheme}
-\label{subsec:BDY_flather_scheme}
+\label{subsec:LBC_bdy_flather_scheme}
 
 The \citet{flather_JPO94} scheme is a radiation condition on the normal,
 depth-mean transport across the open boundary.
 It takes the form
-\begin{equation}  \label{eq:bdy_fla1}
-U = U_{e} + \frac{c}{h}\left(\eta - \eta_{e}\right),
+\begin{equation}
+  \label{eq:LBC_bdy_fla1}
+  U = U_{e} + \frac{c}{h}\left(\eta - \eta_{e}\right),
 \end{equation}
 where $U$ is the depth-mean velocity normal to the boundary and $\eta$ is the sea surface height,
@@ -532,11 +487,11 @@
 the external depth-mean normal velocity,
 plus a correction term that allows gravity waves generated internally to exit the model boundary.
-Note that the sea-surface height gradient in \autoref{eq:bdy_fla1} is a spatial gradient across the model boundary,
+Note that the sea-surface height gradient in \autoref{eq:LBC_bdy_fla1} is a spatial gradient across the model boundary,
 so that $\eta_{e}$ is defined on the $T$ points with $nbr=1$ and $\eta$ is defined on the $T$ points with $nbr=2$.
-$U$ and $U_{e}$ are defined on the $U$ or $V$ points with $nbr=1$, \ie between the two $T$ grid points.
-
-%----------------------------------------------
+$U$ and $U_{e}$ are defined on the $U$ or $V$ points with $nbr=1$, \ie\ between the two $T$ grid points.
+
+%% =================================================================================================
 \subsection{Orlanski radiation scheme}
-\label{subsec:BDY_orlanski_scheme}
+\label{subsec:LBC_bdy_orlanski_scheme}
 
 The Orlanski scheme is based on the algorithm described by \citep{marchesiello.mcwilliams.ea_OM01}, hereafter MMS.
@@ -544,7 +499,7 @@
 The adaptive Orlanski condition solves a wave plus relaxation equation at the boundary:
 \begin{equation}
-\frac{\partial\phi}{\partial t} + c_x \frac{\partial\phi}{\partial x} + c_y \frac{\partial\phi}{\partial y} =
-                                                -\frac{1}{\tau}(\phi - \phi^{ext})
-\label{eq:wave_continuous}
+  \label{eq:LBC_wave_continuous}
+  \frac{\partial\phi}{\partial t} + c_x \frac{\partial\phi}{\partial x} + c_y \frac{\partial\phi}{\partial y} =
+  -\frac{1}{\tau}(\phi - \phi^{ext})
 \end{equation}
 
@@ -552,14 +507,15 @@
 velocities are diagnosed from the model fields as:
 
-\begin{equation} \label{eq:cx}
-c_x = -\frac{\partial\phi}{\partial t}\frac{\partial\phi / \partial x}{(\partial\phi /\partial x)^2 + (\partial\phi /\partial y)^2}
+\begin{equation}
+  \label{eq:LBC_cx}
+  c_x = -\frac{\partial\phi}{\partial t}\frac{\partial\phi / \partial x}{(\partial\phi /\partial x)^2 + (\partial\phi /\partial y)^2}
 \end{equation}
 \begin{equation}
-\label{eq:cy}
-c_y = -\frac{\partial\phi}{\partial t}\frac{\partial\phi / \partial y}{(\partial\phi /\partial x)^2 + (\partial\phi /\partial y)^2}
+  \label{eq:LBC_cy}
+  c_y = -\frac{\partial\phi}{\partial t}\frac{\partial\phi / \partial y}{(\partial\phi /\partial x)^2 + (\partial\phi /\partial y)^2}
 \end{equation}
 
 (As noted by MMS, this is a circular diagnosis of the phase speeds which only makes sense on a discrete grid).
-Equation (\autoref{eq:wave_continuous}) is defined adaptively depending on the sign of the phase velocity normal to the boundary $c_x$.
+Equation (\autoref{eq:LBC_wave_continuous}) is defined adaptively depending on the sign of the phase velocity normal to the boundary $c_x$.
 For $c_x$ outward, we have
 
@@ -571,25 +527,25 @@
 
 \begin{equation}
-\tau = \tau_{in}\,\,\,;\,\,\, c_x = c_y = 0
-\label{eq:tau_in}
+  \label{eq:LBC_tau_in}
+  \tau = \tau_{in}\,\,\,;\,\,\, c_x = c_y = 0
 \end{equation}
 
-Generally the relaxation time scale at inward propagation points \np{(rn\_time\_dmp}) is set much shorter than the time scale at outward propagation
-points (\np{rn\_time\_dmp\_out}) so that the solution is constrained more strongly by the external data at inward propagation points.
-See \autoref{subsec:BDY_relaxation} for detailed on the spatial shape of the scaling.\\ 
-The ``normal propagation of oblique radiation'' or NPO approximation (called \forcode{'orlanski_npo'}) involves assuming 
-that $c_y$ is zero in equation (\autoref{eq:wave_continuous}), but including
-this term in the denominator of equation (\autoref{eq:cx}). Both versions of the scheme are options in BDY. Equations
-(\autoref{eq:wave_continuous}) - (\autoref{eq:tau_in}) correspond to equations (13) - (15) and (2) - (3) in MMS.\\
-
-%----------------------------------------------
+Generally the relaxation time scale at inward propagation points (\np{rn_time_dmp}{rn\_time\_dmp}) is set much shorter than the time scale at outward propagation
+points (\np{rn_time_dmp_out}{rn\_time\_dmp\_out}) so that the solution is constrained more strongly by the external data at inward propagation points.
+See \autoref{subsec:LBC_bdy_relaxation} for detailed on the spatial shape of the scaling.\\
+The ``normal propagation of oblique radiation'' or NPO approximation (called \forcode{'orlanski_npo'}) involves assuming
+that $c_y$ is zero in equation (\autoref{eq:LBC_wave_continuous}), but including
+this term in the denominator of equation (\autoref{eq:LBC_cx}). Both versions of the scheme are options in BDY. Equations
+(\autoref{eq:LBC_wave_continuous}) - (\autoref{eq:LBC_tau_in}) correspond to equations (13) - (15) and (2) - (3) in MMS.\\
+
+%% =================================================================================================
 \subsection{Relaxation at the boundary}
-\label{subsec:BDY_relaxation}
-
-In addition to a specific boundary condition specified as \np{cn\_tra} and \np{cn\_dyn3d}, relaxation on baroclinic velocities and tracers variables are available. 
-It is control by the namelist parameter \np{ln\_tra\_dmp} and \np{ln\_dyn3d\_dmp} for each boundary set.
-
-The relaxation time scale value (\np{rn\_time\_dmp} and \np{rn\_time\_dmp\_out}, $\tau$) are defined at the boundaries itself. 
-This time scale ($\alpha$) is weighted by the distance ($d$) from the boundary over \np{nn\_rimwidth} cells ($N$):
+\label{subsec:LBC_bdy_relaxation}
+
+In addition to a specific boundary condition specified as \np{cn_tra}{cn\_tra} and \np{cn_dyn3d}{cn\_dyn3d}, relaxation on baroclinic velocities and tracers variables are available.
+It is control by the namelist parameter \np{ln_tra_dmp}{ln\_tra\_dmp} and \np{ln_dyn3d_dmp}{ln\_dyn3d\_dmp} for each boundary set.
+
+The relaxation time scale value (\np{rn_time_dmp}{rn\_time\_dmp} and \np{rn_time_dmp_out}{rn\_time\_dmp\_out}, $\tau$) are defined at the boundaries itself.
+This time scale ($\alpha$) is weighted by the distance ($d$) from the boundary over \np{nn_rimwidth}{nn\_rimwidth} cells ($N$):
 
 \[
@@ -597,31 +553,31 @@
 \]
 
-The same scaling is applied in the Orlanski damping. 
-
-%----------------------------------------------
+The same scaling is applied in the Orlanski damping.
+
+%% =================================================================================================
 \subsection{Boundary geometry}
-\label{subsec:BDY_geometry}
+\label{subsec:LBC_bdy_geometry}
 
 Each open boundary set is defined as a list of points.
 The information is stored in the arrays $nbi$, $nbj$, and $nbr$ in the $idx\_bdy$ structure.
-The $nbi$ and $nbj$ arrays define the local $(i,j)$ indices of each point in the boundary zone and
-the $nbr$ array defines the discrete distance from the boundary with $nbr=1$ meaning that
-the point is next to the edge of the model domain and $nbr>1$ showing that
-the point is increasingly further away from the edge of the model domain.
+The $nbi$ and $nbj$ arrays define the local $(i,j)$ indexes of each point in the boundary zone and
+the $nbr$ array defines the discrete distance from the boundary: $nbr=1$ means that
+the boundary point is next to the edge of the model domain, while $nbr>1$ means that
+the boundary point is increasingly further away from the edge of the model domain.
 A set of $nbi$, $nbj$, and $nbr$ arrays is defined for each of the $T$, $U$ and $V$ grids.
-Figure \autoref{fig:LBC_bdy_geom} shows an example of an irregular boundary. 
+\autoref{fig:LBC_bdy_geom} shows an example of an irregular boundary.
 
 The boundary geometry for each set may be defined in a namelist nambdy\_index or
 by reading in a ``\ifile{coordinates.bdy}'' file.
 The nambdy\_index namelist defines a series of straight-line segments for north, east, south and west boundaries.
-One nambdy\_index namelist bloc is needed for each boundary condition defined by indexes. 
-For the northern boundary, \np{nbdysegn} gives the number of segments,
-\np{jpjnob} gives the $j$ index for each segment and \np{jpindt} and
-\np{jpinft} give the start and end $i$ indices for each segment with similar for the other boundaries.
+One nambdy\_index namelist block is needed for each boundary condition defined by indexes.
+For the northern boundary, \texttt{nbdysegn} gives the number of segments,
+\jp{jpjnob} gives the $j$ index for each segment and \jp{jpindt} and
+\jp{jpinft} give the start and end $i$ indices for each segment with similar for the other boundaries.
 These segments define a list of $T$ grid points along the outermost row of the boundary ($nbr\,=\, 1$).
-The code deduces the $U$ and $V$ points and also the points for $nbr\,>\, 1$ if \np{nn\_rimwidth}\forcode{ > 1}.
+The code deduces the $U$ and $V$ points and also the points for $nbr\,>\, 1$ if \np[>1]{nn_rimwidth}{nn\_rimwidth}.
 
 The boundary geometry may also be defined from a ``\ifile{coordinates.bdy}'' file.
-Figure \autoref{fig:LBC_nc_header} gives an example of the header information from such a file.
+\autoref{fig:LBC_nc_header} gives an example of the header information from such a file, based on the description of geometrical setup given above.
 The file should contain the index arrays for each of the $T$, $U$ and $V$ grids.
 The arrays must be in order of increasing $nbr$.
@@ -629,28 +585,23 @@
 Typically this file will be used to generate external boundary data via interpolation and so
 will also contain the latitudes and longitudes of each point as shown.
-However, this is not necessary to run the model. 
+However, this is not necessary to run the model.
 
 For some choices of irregular boundary the model domain may contain areas of ocean which
 are not part of the computational domain.
-For example if an open boundary is defined along an isobath, say at the shelf break,
+For example, if an open boundary is defined along an isobath, say at the shelf break,
 then the areas of ocean outside of this boundary will need to be masked out.
-This can be done by reading a mask file defined as \np{cn\_mask\_file} in the nam\_bdy namelist.
+This can be done by reading a mask file defined as \np{cn_mask_file}{cn\_mask\_file} in the nam\_bdy namelist.
 Only one mask file is used even if multiple boundary sets are defined.
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_LBC_bdy_geom}
-    \caption {
-      \protect\label{fig:LBC_bdy_geom}
-      Example of geometry of unstructured open boundary
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{LBC_bdy_geom}
+  \caption[Geometry of unstructured open boundary]{Example of geometry of unstructured open boundary}
+  \label{fig:LBC_bdy_geom}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-%----------------------------------------------
+
+%% =================================================================================================
 \subsection{Input boundary data files}
-\label{subsec:BDY_data}
+\label{subsec:LBC_bdy_data}
 
 The data files contain the data arrays in the order in which the points are defined in the $nbi$ and $nbj$ arrays.
@@ -658,6 +609,6 @@
 a time dimension;
 $xb$ which is the index of the boundary data point in the horizontal;
-and $yb$ which is a degenerate dimension of 1 to enable the file to be read by the standard NEMO I/O routines.
-The 3D fields also have a depth dimension. 
+and $yb$ which is a degenerate dimension of 1 to enable the file to be read by the standard \NEMO\ I/O routines.
+The 3D fields also have a depth dimension.
 
 From Version 3.4 there are new restrictions on the order in which the boundary points are defined
@@ -670,35 +621,31 @@
 \item All the data for a particular boundary set must be in the same order.
   (Prior to 3.4 it was possible to define barotropic data in a different order to
-  the data for tracers and baroclinic velocities). 
+  the data for tracers and baroclinic velocities).
 \end{enumerate}
 
 These restrictions mean that data files used with versions of the
 model prior to Version 3.4 may not work with Version 3.4 onwards.
-A \fortran utility {\itshape bdy\_reorder} exists in the TOOLS directory which
+A \fortran\ utility {\itshape bdy\_reorder} exists in the TOOLS directory which
 will re-order the data in old BDY data files.
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_LBC_nc_header}
-    \caption {
-      \protect\label{fig:LBC_nc_header}
-      Example of the header for a \protect\ifile{coordinates.bdy} file
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{LBC_nc_header}
+  \caption[Header for a \protect\ifile{coordinates.bdy} file]{
+    Example of the header for a \protect\ifile{coordinates.bdy} file}
+  \label{fig:LBC_nc_header}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-%----------------------------------------------
+
+%% =================================================================================================
 \subsection{Volume correction}
-\label{subsec:BDY_vol_corr}
+\label{subsec:LBC_bdy_vol_corr}
 
 There is an option to force the total volume in the regional model to be constant.
-This is controlled  by the \np{ln\_vol} parameter in the namelist.
-A value of \np{ln\_vol}\forcode{ = .false.} indicates that this option is not used.
-Two options to control the volume are available (\np{nn\_volctl}). 
-If \np{nn\_volctl}\forcode{ = 0} then a correction is applied to the normal barotropic velocities around the boundary at
+This is controlled  by the \np{ln_vol}{ln\_vol} parameter in the namelist.
+A value of \np[=.false.]{ln_vol}{ln\_vol} indicates that this option is not used.
+Two options to control the volume are available (\np{nn_volctl}{nn\_volctl}).
+If \np[=0]{nn_volctl}{nn\_volctl} then a correction is applied to the normal barotropic velocities around the boundary at
 each timestep to ensure that the integrated volume flow through the boundary is zero.
-If \np{nn\_volctl}\forcode{ = 1} then the calculation of the volume change on
+If \np[=1]{nn_volctl}{nn\_volctl} then the calculation of the volume change on
 the timestep includes the change due to the freshwater flux across the surface and
 the correction velocity corrects for this as well.
@@ -707,26 +654,27 @@
 applied to all boundaries at once.
 
-%----------------------------------------------
+%% =================================================================================================
 \subsection{Tidal harmonic forcing}
-\label{subsec:BDY_tides}
-
-%-----------------------------------------nambdy_tide--------------------------------------------
-
-\nlst{nambdy_tide} 
-%-----------------------------------------------------------------------------------------------
+\label{subsec:LBC_bdy_tides}
+
+\begin{listing}
+  \nlst{nambdy_tide}
+  \caption{\forcode{&nambdy_tide}}
+  \label{lst:nambdy_tide}
+\end{listing}
 
 Tidal forcing at open boundaries requires the activation of surface
-tides (i.e., in \ngn{nam\_tide}, \np{ln\_tide} needs to be set to
+tides (i.e., in \nam{_tide}{\_tide}, \np{ln_tide}{ln\_tide} needs to be set to
 \forcode{.true.} and the required constituents need to be activated by
-including their names in the \np{cname} array; see
+including their names in the \np{clname}{clname} array; see
 \autoref{sec:SBC_tide}). Specific options related to the reading in of
 the complex harmonic amplitudes of elevation (SSH) and barotropic
 velocity (u,v) at open boundaries are defined through the
-\ngn{nambdy\_tide} namelist parameters.\\
+\nam{bdy_tide}{bdy\_tide} namelist parameters.\\
 
 The tidal harmonic data at open boundaries can be specified in two
 different ways, either on a two-dimensional grid covering the entire
 model domain or along open boundary segments; these two variants can
-be selected by setting \np{ln\_bdytide\_2ddta } to \forcode{.true.} or
+be selected by setting \np{ln_bdytide_2ddta }{ln\_bdytide\_2ddta } to \forcode{.true.} or
 \forcode{.false.}, respectively. In either case, the real and
 imaginary parts of SSH and the two barotropic velocity components for
@@ -734,19 +682,19 @@
 separately: when two-dimensional data is used, variables
 \textit{tcname\_z1} and \textit{tcname\_z2} for real and imaginary SSH,
-respectively, are expected in input file \np{filtide} with suffix
+respectively, are expected in input file \np{filtide}{filtide} with suffix
 \ifile{\_grid\_T}, variables \textit{tcname\_u1} and
 \textit{tcname\_u2} for real and imaginary u, respectively, are
-expected in input file \np{filtide} with suffix \ifile{\_grid\_U}, and
+expected in input file \np{filtide}{filtide} with suffix \ifile{\_grid\_U}, and
 \textit{tcname\_v1} and \textit{tcname\_v2} for real and imaginary v,
-respectively, are expected in input file \np{filtide} with suffix
+respectively, are expected in input file \np{filtide}{filtide} with suffix
 \ifile{\_grid\_V}; when data along open boundary segments is used,
 variables \textit{z1} and \textit{z2} (real and imaginary part of SSH)
-are expected to be available from file \np{filtide} with suffix
+are expected to be available from file \np{filtide}{filtide} with suffix
 \ifile{tcname\_grid\_T}, variables \textit{u1} and \textit{u2} (real
 and imaginary part of u) are expected to be available from file
-\np{filtide} with suffix \ifile{tcname\_grid\_U}, and variables
+\np{filtide}{filtide} with suffix \ifile{tcname\_grid\_U}, and variables
 \textit{v1} and \textit{v2} (real and imaginary part of v) are
-expected to be available from file \np{filtide} with suffix
-\ifile{tcname\_grid\_V}. If \np{ln\_bdytide\_conj} is set to
+expected to be available from file \np{filtide}{filtide} with suffix
+\ifile{tcname\_grid\_V}. If \np{ln_bdytide_conj}{ln\_bdytide\_conj} is set to
 \forcode{.true.}, the data is expected to be in complex conjugate
 form.
@@ -760,7 +708,5 @@
 direction of rotation). %, e.g. anticlockwise or clockwise.
 
-\biblio
-
-\pindex
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_LDF.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_LDF.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_LDF.tex	(revision 12143)
@@ -3,15 +3,27 @@
 \begin{document}
 
-% ================================================================
-% Chapter Lateral Ocean Physics (LDF)
-% ================================================================
 \chapter{Lateral Ocean Physics (LDF)}
 \label{chap:LDF}
 
-\minitoc
-
-\newpage
-
-The lateral physics terms in the momentum and tracer equations have been described in \autoref{eq:PE_zdf} and
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+The lateral physics terms in the momentum and tracer equations have been described in \autoref{eq:MB_zdf} and
 their discrete formulation in \autoref{sec:TRA_ldf} and \autoref{sec:DYN_ldf}).
 In this section we further discuss each lateral physics option.
@@ -22,26 +34,39 @@
 (3) the space and time variations of the eddy coefficients.
 These three aspects of the lateral diffusion are set through namelist parameters
-(see the \ngn{nam\_traldf} and \ngn{nam\_dynldf} below).
-Note that this chapter describes the standard implementation of iso-neutral tracer mixing,
-and Griffies's implementation, which is used if \np{traldf\_grif}\forcode{ = .true.},
-is described in Appdx\autoref{apdx:triad}
-
-%-----------------------------------nam_traldf - nam_dynldf--------------------------------------------
-
-\nlst{namtra_ldf} 
-
-\nlst{namdyn_ldf} 
-%--------------------------------------------------------------------------------------------------------------
-
-
-% ================================================================
-% Direction of lateral Mixing
-% ================================================================
-\section[Direction of lateral mixing (\textit{ldfslp.F90})]
-{Direction of lateral mixing (\protect\mdl{ldfslp})}
+(see the \nam{tra_ldf}{tra\_ldf} and \nam{dyn_ldf}{dyn\_ldf} below).
+Note that this chapter describes the standard implementation of iso-neutral tracer mixing.
+Griffies's implementation, which is used if \np[=.true.]{ln_traldf_triad}{ln\_traldf\_triad},
+is described in \autoref{apdx:TRIADS}
+
+%% =================================================================================================
+\section[Lateral mixing operators]{Lateral mixing operators}
+\label{sec:LDF_op}
+We remind here the different lateral mixing operators that can be used. Further details can be found in \autoref{subsec:TRA_ldf_op} and  \autoref{sec:DYN_ldf}.
+
+%% =================================================================================================
+\subsection[No lateral mixing (\forcode{ln_traldf_OFF} \& \forcode{ln_dynldf_OFF})]{No lateral mixing (\protect\np{ln_traldf_OFF}{ln\_traldf\_OFF} \& \protect\np{ln_dynldf_OFF}{ln\_dynldf\_OFF})}
+
+It is possible to run without explicit lateral diffusion on tracers (\protect\np[=.true.]{ln_traldf_OFF}{ln\_traldf\_OFF}) and/or
+momentum (\protect\np[=.true.]{ln_dynldf_OFF}{ln\_dynldf\_OFF}). The latter option is even recommended if using the
+UBS advection scheme on momentum (\np[=.true.]{ln_dynadv_ubs}{ln\_dynadv\_ubs},
+see \autoref{subsec:DYN_adv_ubs}) and can be useful for testing purposes.
+
+%% =================================================================================================
+\subsection[Laplacian mixing (\forcode{ln_traldf_lap} \& \forcode{ln_dynldf_lap})]{Laplacian mixing (\protect\np{ln_traldf_lap}{ln\_traldf\_lap} \& \protect\np{ln_dynldf_lap}{ln\_dynldf\_lap})}
+Setting \protect\np[=.true.]{ln_traldf_lap}{ln\_traldf\_lap} and/or \protect\np[=.true.]{ln_dynldf_lap}{ln\_dynldf\_lap} enables
+a second order diffusion on tracers and momentum respectively. Note that in \NEMO\ 4, one can not combine
+Laplacian and Bilaplacian operators for the same variable.
+
+%% =================================================================================================
+\subsection[Bilaplacian mixing (\forcode{ln_traldf_blp} \& \forcode{ln_dynldf_blp})]{Bilaplacian mixing (\protect\np{ln_traldf_blp}{ln\_traldf\_blp} \& \protect\np{ln_dynldf_blp}{ln\_dynldf\_blp})}
+Setting \protect\np[=.true.]{ln_traldf_blp}{ln\_traldf\_blp} and/or \protect\np[=.true.]{ln_dynldf_blp}{ln\_dynldf\_blp} enables
+a fourth order diffusion on tracers and momentum respectively. It is implemented by calling the above Laplacian operator twice.
+We stress again that from \NEMO\ 4, the simultaneous use Laplacian and Bilaplacian operators is not allowed.
+
+%% =================================================================================================
+\section[Direction of lateral mixing (\textit{ldfslp.F90})]{Direction of lateral mixing (\protect\mdl{ldfslp})}
 \label{sec:LDF_slp}
 
-%%%
-\gmcomment{
+\cmtgm{
   we should emphasize here that the implementation is a rather old one.
   Better work can be achieved by using \citet{griffies.gnanadesikan.ea_JPO98, griffies_bk04} iso-neutral scheme.
@@ -50,26 +75,28 @@
 A direction for lateral mixing has to be defined when the desired operator does not act along the model levels.
 This occurs when $(a)$ horizontal mixing is required on tracer or momentum
-(\np{ln\_traldf\_hor} or \np{ln\_dynldf\_hor}) in $s$- or mixed $s$-$z$- coordinates,
+(\np{ln_traldf_hor}{ln\_traldf\_hor} or \np{ln_dynldf_hor}{ln\_dynldf\_hor}) in $s$- or mixed $s$-$z$- coordinates,
 and $(b)$ isoneutral mixing is required whatever the vertical coordinate is.
 This direction of mixing is defined by its slopes in the \textbf{i}- and \textbf{j}-directions at the face of
 the cell of the quantity to be diffused.
 For a tracer, this leads to the following four slopes:
-$r_{1u}$, $r_{1w}$, $r_{2v}$, $r_{2w}$ (see \autoref{eq:tra_ldf_iso}),
+$r_{1u}$, $r_{1w}$, $r_{2v}$, $r_{2w}$ (see \autoref{eq:TRA_ldf_iso}),
 while for momentum the slopes are  $r_{1t}$, $r_{1uw}$, $r_{2f}$, $r_{2uw}$ for $u$ and
-$r_{1f}$, $r_{1vw}$, $r_{2t}$, $r_{2vw}$ for $v$. 
-
-%gm% add here afigure of the slope in i-direction
-
+$r_{1f}$, $r_{1vw}$, $r_{2t}$, $r_{2vw}$ for $v$.
+
+\cmtgm{Add here afigure of the slope in i-direction}
+
+%% =================================================================================================
 \subsection{Slopes for tracer geopotential mixing in the $s$-coordinate}
 
-In $s$-coordinates, geopotential mixing (\ie horizontal mixing) $r_1$ and $r_2$ are the slopes between
+In $s$-coordinates, geopotential mixing (\ie\ horizontal mixing) $r_1$ and $r_2$ are the slopes between
 the geopotential and computational surfaces.
-Their discrete formulation is found by locally solving \autoref{eq:tra_ldf_iso} when
+Their discrete formulation is found by locally solving \autoref{eq:TRA_ldf_iso} when
 the diffusive fluxes in the three directions are set to zero and $T$ is assumed to be horizontally uniform,
-\ie a linear function of $z_T$, the depth of a $T$-point. 
-%gm { Steven : My version is obviously wrong since I'm left with an arbitrary constant which is the local vertical temperature gradient}
-
-\begin{equation}
-  \label{eq:ldfslp_geo}
+\ie\ a linear function of $z_T$, the depth of a $T$-point.
+\cmtgm{Steven : My version is obviously wrong since
+  I'm left with an arbitrary constant which is the local vertical temperature gradient}
+
+\begin{equation}
+  \label{eq:LDF_slp_geo}
   \begin{aligned}
     r_{1u} &= \frac{e_{3u}}{ \left( e_{1u}\;\overline{\overline{e_{3w}}}^{\,i+1/2,\,k} \right)}
@@ -86,9 +113,10 @@
 \end{equation}
 
-%gm%  caution I'm not sure the simplification was a good idea! 
-
-These slopes are computed once in \rou{ldfslp\_init} when \np{ln\_sco}\forcode{ = .true.}rue,
-and either \np{ln\_traldf\_hor}\forcode{ = .true.} or \np{ln\_dynldf\_hor}\forcode{ = .true.}. 
-
+\cmtgm{Caution I'm not sure the simplification was a good idea!}
+
+These slopes are computed once in \rou{ldf\_slp\_init} when \np[=.true.]{ln_sco}{ln\_sco},
+and either \np[=.true.]{ln_traldf_hor}{ln\_traldf\_hor} or \np[=.true.]{ln_dynldf_hor}{ln\_dynldf\_hor}.
+
+%% =================================================================================================
 \subsection{Slopes for tracer iso-neutral mixing}
 \label{subsec:LDF_slp_iso}
@@ -97,10 +125,10 @@
 Their formulation does not depend on the vertical coordinate used.
 Their discrete formulation is found using the fact that the diffusive fluxes of
-locally referenced potential density (\ie $in situ$ density) vanish.
-So, substituting $T$ by $\rho$ in \autoref{eq:tra_ldf_iso} and setting the diffusive fluxes in
+locally referenced potential density (\ie\ $in situ$ density) vanish.
+So, substituting $T$ by $\rho$ in \autoref{eq:TRA_ldf_iso} and setting the diffusive fluxes in
 the three directions to zero leads to the following definition for the neutral slopes:
 
 \begin{equation}
-  \label{eq:ldfslp_iso}
+  \label{eq:LDF_slp_iso}
   \begin{split}
     r_{1u} &= \frac{e_{3u}}{e_{1u}}\; \frac{\delta_{i+1/2}[\rho]}
@@ -117,40 +145,33 @@
 \end{equation}
 
-%gm% rewrite this as the explanation is not very clear !!!
-%In practice, \autoref{eq:ldfslp_iso} is of little help in evaluating the neutral surface slopes. Indeed, for an unsimplified equation of state, the density has a strong dependancy on pressure (here approximated as the depth), therefore applying \autoref{eq:ldfslp_iso} using the $in situ$ density, $\rho$, computed at T-points leads to a flattening of slopes as the depth increases. This is due to the strong increase of the $in situ$ density with depth. 
-
-%By definition, neutral surfaces are tangent to the local $in situ$ density \citep{mcdougall_JPO87}, therefore in \autoref{eq:ldfslp_iso}, all the derivatives have to be evaluated at the same local pressure (which in decibars is approximated by the depth in meters).
-
-%In the $z$-coordinate, the derivative of the  \autoref{eq:ldfslp_iso} numerator is evaluated at the same depth \nocite{as what?} ($T$-level, which is the same as the $u$- and $v$-levels), so  the $in situ$ density can be used for its evaluation. 
-
-As the mixing is performed along neutral surfaces, the gradient of $\rho$ in \autoref{eq:ldfslp_iso} has to
+\cmtgm{rewrite this as the explanation is not very clear !!!}
+%In practice, \autoref{eq:LDF_slp_iso} is of little help in evaluating the neutral surface slopes. Indeed, for an unsimplified equation of state, the density has a strong dependancy on pressure (here approximated as the depth), therefore applying \autoref{eq:LDF_slp_iso} using the $in situ$ density, $\rho$, computed at T-points leads to a flattening of slopes as the depth increases. This is due to the strong increase of the $in situ$ density with depth.
+
+%By definition, neutral surfaces are tangent to the local $in situ$ density \citep{mcdougall_JPO87}, therefore in \autoref{eq:LDF_slp_iso}, all the derivatives have to be evaluated at the same local pressure (which in decibars is approximated by the depth in meters).
+
+%In the $z$-coordinate, the derivative of the  \autoref{eq:LDF_slp_iso} numerator is evaluated at the same depth \nocite{as what?} ($T$-level, which is the same as the $u$- and $v$-levels), so  the $in situ$ density can be used for its evaluation.
+
+As the mixing is performed along neutral surfaces, the gradient of $\rho$ in \autoref{eq:LDF_slp_iso} has to
 be evaluated at the same local pressure
 (which, in decibars, is approximated by the depth in meters in the model).
-Therefore \autoref{eq:ldfslp_iso} cannot be used as such,
+Therefore \autoref{eq:LDF_slp_iso} cannot be used as such,
 but further transformation is needed depending on the vertical coordinate used:
 
 \begin{description}
-
-\item[$z$-coordinate with full step: ]
-  in \autoref{eq:ldfslp_iso} the densities appearing in the $i$ and $j$ derivatives  are taken at the same depth,
+\item [$z$-coordinate with full step:] in \autoref{eq:LDF_slp_iso} the densities appearing in the $i$ and $j$ derivatives  are taken at the same depth,
   thus the $in situ$ density can be used.
   This is not the case for the vertical derivatives: $\delta_{k+1/2}[\rho]$ is replaced by $-\rho N^2/g$,
   where $N^2$ is the local Brunt-Vais\"{a}l\"{a} frequency evaluated following \citet{mcdougall_JPO87}
-  (see \autoref{subsec:TRA_bn2}). 
-
-\item[$z$-coordinate with partial step: ]
-  this case is identical to the full step case except that at partial step level,
+  (see \autoref{subsec:TRA_bn2}).
+\item [$z$-coordinate with partial step:] this case is identical to the full step case except that at partial step level,
   the \emph{horizontal} density gradient is evaluated as described in \autoref{sec:TRA_zpshde}.
-
-\item[$s$- or hybrid $s$-$z$- coordinate: ]
-  in the current release of \NEMO, iso-neutral mixing is only employed for $s$-coordinates if
-  the Griffies scheme is used (\np{traldf\_grif}\forcode{ = .true.};
-  see Appdx \autoref{apdx:triad}).
+\item [$s$- or hybrid $s$-$z$- coordinate:] in the current release of \NEMO, iso-neutral mixing is only employed for $s$-coordinates if
+  the Griffies scheme is used (\np[=.true.]{ln_traldf_triad}{ln\_traldf\_triad};
+  see \autoref{apdx:TRIADS}).
   In other words, iso-neutral mixing will only be accurately represented with a linear equation of state
-  (\np{nn\_eos}\forcode{ = 1..2}).
-  In the case of a "true" equation of state, the evaluation of $i$ and $j$ derivatives in \autoref{eq:ldfslp_iso}
+  (\np[=.true.]{ln_seos}{ln\_seos}).
+  In the case of a "true" equation of state, the evaluation of $i$ and $j$ derivatives in \autoref{eq:LDF_slp_iso}
   will include a pressure dependent part, leading to the wrong evaluation of the neutral slopes.
 
-%gm% 
   Note: The solution for $s$-coordinate passes trough the use of different (and better) expression for
   the constraint on iso-neutral fluxes.
@@ -161,10 +182,10 @@
     \alpha \ \textbf{F}(T) = \beta \ \textbf{F}(S)
   \]
-  % gm{  where vector F is ....}
+  \cmtgm{where vector F is ....}
 
 This constraint leads to the following definition for the slopes:
 
 \[
-  % \label{eq:ldfslp_iso2}
+  % \label{eq:LDF_slp_iso2}
   \begin{split}
     r_{1u} &= \frac{e_{3u}}{e_{1u}}\; \frac
@@ -194,14 +215,13 @@
 
 Note that such a formulation could be also used in the $z$-coordinate and $z$-coordinate with partial steps cases.
-
 \end{description}
 
 This implementation is a rather old one.
-It is similar to the one proposed by Cox [1987], except for the background horizontal diffusion.
-Indeed, the Cox implementation of isopycnal diffusion in GFDL-type models requires
+It is similar to the one proposed by \citet{cox_OM87}, except for the background horizontal diffusion.
+Indeed, the \citet{cox_OM87} implementation of isopycnal diffusion in GFDL-type models requires
 a minimum background horizontal diffusion for numerical stability reasons.
 To overcome this problem, several techniques have been proposed in which the numerical schemes of
 the ocean model are modified \citep{weaver.eby_JPO97, griffies.gnanadesikan.ea_JPO98}.
-Griffies's scheme is now available in \NEMO if \np{traldf\_grif\_iso} is set true; see Appdx \autoref{apdx:triad}.
+Griffies's scheme is now available in \NEMO\ if \np[=.true.]{ln_traldf_triad}{ln\_traldf\_triad}; see \autoref{apdx:TRIADS}.
 Here, another strategy is presented \citep{lazar_phd97}:
 a local filtering of the iso-neutral slopes (made on 9 grid-points) prevents the development of
@@ -209,80 +229,74 @@
 This allows an iso-neutral diffusion scheme without additional background horizontal mixing.
 This technique can be viewed as a diffusion operator that acts along large-scale
-(2~$\Delta$x) \gmcomment{2deltax doesnt seem very large scale} iso-neutral surfaces.
+(2~$\Delta$x) \cmtgm{2deltax doesnt seem very large scale} iso-neutral surfaces.
 The diapycnal diffusion required for numerical stability is thus minimized and its net effect on the flow is quite small when compared to the effect of an horizontal background mixing.
 
 Nevertheless, this iso-neutral operator does not ensure that variance cannot increase,
-contrary to the \citet{griffies.gnanadesikan.ea_JPO98} operator which has that property. 
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+contrary to the \citet{griffies.gnanadesikan.ea_JPO98} operator which has that property.
+
 \begin{figure}[!ht]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_LDF_ZDF1}
-    \caption {
-      \protect\label{fig:LDF_ZDF1}
-      averaging procedure for isopycnal slope computation.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{LDF_ZDF1}
+  \caption{Averaging procedure for isopycnal slope computation}
+  \label{fig:LDF_ZDF1}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-%There are three additional questions about the slope calculation. 
-%First the expression for the rotation tensor has been obtain assuming the "small slope" approximation, so a bound has to be imposed on slopes. 
-%Second, numerical stability issues also require a bound on slopes. 
+
+%There are three additional questions about the slope calculation.
+%First the expression for the rotation tensor has been obtain assuming the "small slope" approximation, so a bound has to be imposed on slopes.
+%Second, numerical stability issues also require a bound on slopes.
 %Third, the question of boundary condition specified on slopes...
 
 %from griffies: chapter 13.1....
 
-
-
-% In addition and also for numerical stability reasons \citep{cox_OM87, griffies_bk04}, 
-% the slopes are bounded by $1/100$ everywhere. This limit is decreasing linearly 
-% to zero fom $70$ meters depth and the surface (the fact that the eddies "feel" the 
+% In addition and also for numerical stability reasons \citep{cox_OM87, griffies_bk04},
+% the slopes are bounded by $1/100$ everywhere. This limit is decreasing linearly
+% to zero fom $70$ meters depth and the surface (the fact that the eddies "feel" the
 % surface motivates this flattening of isopycnals near the surface).
 
 For numerical stability reasons \citep{cox_OM87, griffies_bk04}, the slopes must also be bounded by
-$1/100$ everywhere.
+the namelist scalar \np{rn_slpmax}{rn\_slpmax} (usually $1/100$) everywhere.
 This constraint is applied in a piecewise linear fashion, increasing from zero at the surface to
 $1/100$ at $70$ metres and thereafter decreasing to zero at the bottom of the ocean
 (the fact that the eddies "feel" the surface motivates this flattening of isopycnals near the surface).
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\colorbox{yellow}{The way slopes are tapered has be checked. Not sure that this is still what is actually done.}
+
 \begin{figure}[!ht]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_eiv_slp}
-    \caption{
-      \protect\label{fig:eiv_slp}
-      Vertical profile of the slope used for lateral mixing in the mixed layer:
-      \textit{(a)} in the real ocean the slope is the iso-neutral slope in the ocean interior,
-      which has to be adjusted at the surface boundary
-      \ie it must tend to zero at the surface since there is no mixing across the air-sea interface:
-      wall boundary condition).
-      Nevertheless, the profile between the surface zero value and the interior iso-neutral one is unknown,
-      and especially the value at the base of the mixed layer;
-      \textit{(b)} profile of slope using a linear tapering of the slope near the surface and
-      imposing a maximum slope of 1/100;
-      \textit{(c)} profile of slope actually used in \NEMO: a linear decrease of the slope from
-      zero at the surface to its ocean interior value computed just below the mixed layer.
-      Note the huge change in the slope at the base of the mixed layer between \textit{(b)} and \textit{(c)}.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{LDF_eiv_slp}
+  \caption[Vertical profile of the slope used for lateral mixing in the mixed layer]{
+    Vertical profile of the slope used for lateral mixing in the mixed layer:
+    \textit{(a)} in the real ocean the slope is the iso-neutral slope in the ocean interior,
+    which has to be adjusted at the surface boundary
+    \ie\ it must tend to zero at the surface since there is no mixing across the air-sea interface:
+    wall boundary condition).
+    Nevertheless,
+    the profile between the surface zero value and the interior iso-neutral one is unknown,
+    and especially the value at the base of the mixed layer;
+    \textit{(b)} profile of slope using a linear tapering of the slope near the surface and
+    imposing a maximum slope of 1/100;
+    \textit{(c)} profile of slope actually used in \NEMO:
+    a linear decrease of the slope from zero at the surface to
+    its ocean interior value computed just below the mixed layer.
+    Note the huge change in the slope at the base of the mixed layer between
+    \textit{(b)} and \textit{(c)}.}
+  \label{fig:LDF_eiv_slp}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 \colorbox{yellow}{add here a discussion about the flattening of the slopes, vs tapering the coefficient.}
 
+%% =================================================================================================
 \subsection{Slopes for momentum iso-neutral mixing}
 
 The iso-neutral diffusion operator on momentum is the same as the one used on tracers but
 applied to each component of the velocity separately
-(see \autoref{eq:dyn_ldf_iso} in section~\autoref{subsec:DYN_ldf_iso}).
+(see \autoref{eq:DYN_ldf_iso} in section~\autoref{subsec:DYN_ldf_iso}).
 The slopes between the surface along which the diffusion operator acts and the surface of computation
 ($z$- or $s$-surfaces) are defined at $T$-, $f$-, and \textit{uw}- points for the $u$-component, and $T$-, $f$- and
 \textit{vw}- points for the $v$-component.
 They are computed from the slopes used for tracer diffusion,
-\ie \autoref{eq:ldfslp_geo} and \autoref{eq:ldfslp_iso}:
+\ie\ \autoref{eq:LDF_slp_geo} and \autoref{eq:LDF_slp_iso}:
 
 \[
-  % \label{eq:ldfslp_dyn}
+  % \label{eq:LDF_slp_dyn}
   \begin{aligned}
     &r_{1t}\ \ = \overline{r_{1u}}^{\,i}       &&&    r_{1f}\ \ &= \overline{r_{1u}}^{\,i+1/2} \\
@@ -295,154 +309,177 @@
 The major issue remaining is in the specification of the boundary conditions.
 The same boundary conditions are chosen as those used for lateral diffusion along model level surfaces,
-\ie using the shear computed along the model levels and with no additional friction at the ocean bottom
+\ie\ using the shear computed along the model levels and with no additional friction at the ocean bottom
 (see \autoref{sec:LBC_coast}).
 
-
-% ================================================================
-% Lateral Mixing Operator
-% ================================================================
-\section[Lateral mixing operators (\textit{traldf.F90})]
-{Lateral mixing operators (\protect\mdl{traldf}, \protect\mdl{traldf})}
-\label{sec:LDF_op}
-
-
-   
-% ================================================================
-% Lateral Mixing Coefficients
-% ================================================================
-\section[Lateral mixing coefficient (\textit{ldftra.F90}, \textit{ldfdyn.F90})]
-{Lateral mixing coefficient (\protect\mdl{ldftra}, \protect\mdl{ldfdyn})}
+%% =================================================================================================
+\section[Lateral mixing coefficient (\forcode{nn_aht_ijk_t} \& \forcode{nn_ahm_ijk_t})]{Lateral mixing coefficient (\protect\np{nn_aht_ijk_t}{nn\_aht\_ijk\_t} \& \protect\np{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t})}
 \label{sec:LDF_coef}
 
-Introducing a space variation in the lateral eddy mixing coefficients changes the model core memory requirement,
-adding up to four extra three-dimensional arrays for the geopotential or isopycnal second order operator applied to 
-momentum.
-Six CPP keys control the space variation of eddy coefficients: three for momentum and three for tracer.
-The three choices allow:
-a space variation in the three space directions (\key{traldf\_c3d},  \key{dynldf\_c3d}),
-in the horizontal plane (\key{traldf\_c2d},  \key{dynldf\_c2d}),
-or in the vertical only (\key{traldf\_c1d},  \key{dynldf\_c1d}).
-The default option is a constant value over the whole ocean on both momentum and tracers. 
-   
-The number of additional arrays that have to be defined and the gridpoint position at which
-they are defined depend on both the space variation chosen and the type of operator used.
-The resulting eddy viscosity and diffusivity coefficients can be a function of more than one variable.
-Changes in the computer code when switching from one option to another have been minimized by
-introducing the eddy coefficients as statement functions
-(include file \textit{ldftra\_substitute.h90} and \textit{ldfdyn\_substitute.h90}).
-The functions are replaced by their actual meaning during the preprocessing step (CPP).
-The specification of the space variation of the coefficient is made in \mdl{ldftra} and \mdl{ldfdyn},
-or more precisely in include files \textit{traldf\_cNd.h90} and \textit{dynldf\_cNd.h90}, with N=1, 2 or 3.
-The user can modify these include files as he/she wishes.
-The way the mixing coefficient are set in the reference version can be briefly described as follows:
-
-\subsubsection{Constant mixing coefficients (default option)}
-When none of the \key{dynldf\_...} and \key{traldf\_...} keys are defined,
-a constant value is used over the whole ocean for momentum and tracers,
-which is specified through the \np{rn\_ahm0} and \np{rn\_aht0} namelist parameters.
-
-\subsubsection[Vertically varying mixing coefficients (\texttt{\textbf{key\_traldf\_c1d}} and \texttt{\textbf{key\_dynldf\_c1d}})]
-{Vertically varying mixing coefficients (\protect\key{traldf\_c1d} and \key{dynldf\_c1d})}
-The 1D option is only available when using the $z$-coordinate with full step.
-Indeed in all the other types of vertical coordinate,
-the depth is a 3D function of (\textbf{i},\textbf{j},\textbf{k}) and therefore,
-introducing depth-dependent mixing coefficients will require 3D arrays.
-In the 1D option, a hyperbolic variation of the lateral mixing coefficient is introduced in which
-the surface value is \np{rn\_aht0} (\np{rn\_ahm0}), the bottom value is 1/4 of the surface value,
-and the transition takes place around z=300~m with a width of 300~m
-(\ie both the depth and the width of the inflection point are set to 300~m).
-This profile is hard coded in file \textit{traldf\_c1d.h90}, but can be easily modified by users.
-
-\subsubsection[Horizontally varying mixing coefficients (\texttt{\textbf{key\_traldf\_c2d}} and \texttt{\textbf{key\_dynldf\_c2d}})]
-{Horizontally varying mixing coefficients (\protect\key{traldf\_c2d} and \protect\key{dynldf\_c2d})}
-By default the horizontal variation of the eddy coefficient depends on the local mesh size and
+The specification of the space variation of the coefficient is made in modules \mdl{ldftra} and \mdl{ldfdyn}.
+The way the mixing coefficients are set in the reference version can be described as follows:
+
+%% =================================================================================================
+\subsection[Mixing coefficients read from file (\forcode{=-20, -30})]{ Mixing coefficients read from file (\protect\np[=-20, -30]{nn_aht_ijk_t}{nn\_aht\_ijk\_t} \& \protect\np[=-20, -30]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t})}
+
+Mixing coefficients can be read from file if a particular geographical variation is needed. For example, in the ORCA2 global ocean model,
+the laplacian viscosity operator uses $A^l$~= 4.10$^4$ m$^2$/s poleward of 20$^{\circ}$ north and south and
+decreases linearly to $A^l$~= 2.10$^3$ m$^2$/s at the equator \citep{madec.delecluse.ea_JPO96, delecluse.madec_icol99}.
+Similar modified horizontal variations can be found with the Antarctic or Arctic sub-domain options of ORCA2 and ORCA05.
+The provided fields can either be 2d (\np[=-20]{nn_aht_ijk_t}{nn\_aht\_ijk\_t}, \np[=-20]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t}) or 3d (\np[=-30]{nn_aht_ijk_t}{nn\_aht\_ijk\_t},  \np[=-30]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t}). They must be given at U, V points for tracers and T, F points for momentum (see \autoref{tab:LDF_files}).
+
+\begin{table}[htb]
+  \centering
+  \begin{tabular}{|l|l|l|l|}
+    \hline
+    Namelist parameter				            & Input filename	                             & dimensions	& variable names                      \\	\hline
+    \np[=-20]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t}	    & \forcode{eddy_viscosity_2D.nc }            &     $(i,j)$	        & \forcode{ahmt_2d, ahmf_2d}  \\	\hline
+    \np[=-20]{nn_aht_ijk_t}{nn\_aht\_ijk\_t}           & \forcode{eddy_diffusivity_2D.nc }           &     $(i,j)$	        & \forcode{ahtu_2d, ahtv_2d}    \\	\hline
+    \np[=-30]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t} 	    & \forcode{eddy_viscosity_3D.nc }            &     $(i,j,k)$	        & \forcode{ahmt_3d, ahmf_3d}  \\	\hline
+    \np[=-30]{nn_aht_ijk_t}{nn\_aht\_ijk\_t}	    & \forcode{eddy_diffusivity_3D.nc }           &     $(i,j,k)$	        & \forcode{ahtu_3d, ahtv_3d}    \\	\hline
+  \end{tabular}
+  \caption{Description of expected input files if mixing coefficients are read from NetCDF files}
+  \label{tab:LDF_files}
+\end{table}
+
+%% =================================================================================================
+\subsection[Constant mixing coefficients (\forcode{=0})]{ Constant mixing coefficients (\protect\np[=0]{nn_aht_ijk_t}{nn\_aht\_ijk\_t} \& \protect\np[=0]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t})}
+
+If constant, mixing coefficients are set thanks to a velocity and a length scales ($U_{scl}$, $L_{scl}$) such that:
+
+\begin{equation}
+  \label{eq:LDF_constantah}
+  A_o^l = \left\{
+    \begin{aligned}
+      & \frac{1}{2} U_{scl} L_{scl}  		     & \text{for laplacian operator } \\
+      & \frac{1}{12} U_{scl} L_{scl}^3                    & \text{for bilaplacian operator }
+    \end{aligned}
+  \right.
+\end{equation}
+
+ $U_{scl}$ and $L_{scl}$ are given by the namelist parameters \np{rn_Ud}{rn\_Ud}, \np{rn_Uv}{rn\_Uv}, \np{rn_Ld}{rn\_Ld} and \np{rn_Lv}{rn\_Lv}.
+
+%% =================================================================================================
+\subsection[Vertically varying mixing coefficients (\forcode{=10})]{Vertically varying mixing coefficients (\protect\np[=10]{nn_aht_ijk_t}{nn\_aht\_ijk\_t} \& \protect\np[=10]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t})}
+
+In the vertically varying case, a hyperbolic variation of the lateral mixing coefficient is introduced in which
+the surface value is given by \autoref{eq:LDF_constantah}, the bottom value is 1/4 of the surface value,
+and the transition takes place around z=500~m with a width of 200~m.
+This profile is hard coded in module \mdl{ldfc1d\_c2d}, but can be easily modified by users.
+
+%% =================================================================================================
+\subsection[Mesh size dependent mixing coefficients (\forcode{=20})]{Mesh size dependent mixing coefficients (\protect\np[=20]{nn_aht_ijk_t}{nn\_aht\_ijk\_t} \& \protect\np[=20]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t})}
+
+In that case, the horizontal variation of the eddy coefficient depends on the local mesh size and
 the type of operator used:
 \begin{equation}
-  \label{eq:title}
+  \label{eq:LDF_title}
   A_l = \left\{
     \begin{aligned}
-      & \frac{\max(e_1,e_2)}{e_{max}} A_o^l  			& \text{for laplacian operator } \\
-      & \frac{\max(e_1,e_2)^{3}}{e_{max}^{3}} A_o^l          & \text{for bilaplacian operator }
+      & \frac{1}{2} U_{scl}  \max(e_1,e_2)  			& \text{for laplacian operator } \\
+      & \frac{1}{12} U_{scl}  \max(e_1,e_2)^{3}             & \text{for bilaplacian operator }
     \end{aligned}
   \right.
 \end{equation}
-where $e_{max}$ is the maximum of $e_1$ and $e_2$ taken over the whole masked ocean domain,
-and $A_o^l$ is the \np{rn\_ahm0} (momentum) or \np{rn\_aht0} (tracer) namelist parameter.
+where $U_{scl}$ is a user defined velocity scale (\np{rn_Ud}{rn\_Ud}, \np{rn_Uv}{rn\_Uv}).
 This variation is intended to reflect the lesser need for subgrid scale eddy mixing where
 the grid size is smaller in the domain.
 It was introduced in the context of the DYNAMO modelling project \citep{willebrand.barnier.ea_PO01}.
-Note that such a grid scale dependance of mixing coefficients significantly increase the range of stability of
-model configurations presenting large changes in grid pacing such as global ocean models.
+Note that such a grid scale dependance of mixing coefficients significantly increases the range of stability of
+model configurations presenting large changes in grid spacing such as global ocean models.
 Indeed, in such a case, a constant mixing coefficient can lead to a blow up of the model due to
-large coefficient compare to the smallest grid size (see \autoref{sec:STP_forward_imp}),
+large coefficient compare to the smallest grid size (see \autoref{sec:TD_forward_imp}),
 especially when using a bilaplacian operator.
 
-Other formulations can be introduced by the user for a given configuration.
-For example, in the ORCA2 global ocean model (see Configurations),
-the laplacian viscosity operator uses \np{rn\_ahm0}~= 4.10$^4$ m$^2$/s poleward of 20$^{\circ}$ north and south and
-decreases linearly to \np{rn\_aht0}~= 2.10$^3$ m$^2$/s at the equator \citep{madec.delecluse.ea_JPO96, delecluse.madec_icol99}.
-This modification can be found in routine \rou{ldf\_dyn\_c2d\_orca} defined in \mdl{ldfdyn\_c2d}.
-Similar modified horizontal variations can be found with the Antarctic or Arctic sub-domain options of
-ORCA2 and ORCA05 (see \&namcfg namelist).
-
-\subsubsection[Space varying mixing coefficients (\texttt{\textbf{key\_traldf\_c3d}} and \texttt{\textbf{key\_dynldf\_c3d}})]
-{Space varying mixing coefficients (\protect\key{traldf\_c3d} and \key{dynldf\_c3d})}
-
-The 3D space variation of the mixing coefficient is simply the combination of the 1D and 2D cases,
-\ie a hyperbolic tangent variation with depth associated with a grid size dependence of
-the magnitude of the coefficient. 
-
-\subsubsection{Space and time varying mixing coefficients}
-
-There is no default specification of space and time varying mixing coefficient. 
-The only case available is specific to the ORCA2 and ORCA05 global ocean configurations.
-It provides only a tracer mixing coefficient for eddy induced velocity (ORCA2) or both iso-neutral and
-eddy induced velocity (ORCA05) that depends on the local growth rate of baroclinic instability.
-This specification is actually used when an ORCA key and both \key{traldf\_eiv} and \key{traldf\_c2d} are defined.
+\colorbox{yellow}{CASE \np{nn_aht_ijk_t}{nn\_aht\_ijk\_t} = 21 to be added}
+
+%% =================================================================================================
+\subsection[Mesh size and depth dependent mixing coefficients (\forcode{=30})]{Mesh size and depth dependent mixing coefficients (\protect\np[=30]{nn_aht_ijk_t}{nn\_aht\_ijk\_t} \& \protect\np[=30]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t})}
+
+The 3D space variation of the mixing coefficient is simply the combination of the 1D and 2D cases above,
+\ie\ a hyperbolic tangent variation with depth associated with a grid size dependence of
+the magnitude of the coefficient.
+
+%% =================================================================================================
+\subsection[Velocity dependent mixing coefficients (\forcode{=31})]{Flow dependent mixing coefficients (\protect\np[=31]{nn_aht_ijk_t}{nn\_aht\_ijk\_t} \& \protect\np[=31]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t})}
+In that case, the eddy coefficient is proportional to the local velocity magnitude so that the Reynolds number $Re =  \lvert U \rvert  e / A_l$ is constant (and here hardcoded to $12$):
+\colorbox{yellow}{JC comment: The Reynolds is effectively set to 12 in the code for both operators but shouldn't it be 2 for Laplacian ?}
+
+\begin{equation}
+  \label{eq:LDF_flowah}
+  A_l = \left\{
+    \begin{aligned}
+      & \frac{1}{12} \lvert U \rvert e  			& \text{for laplacian operator } \\
+      & \frac{1}{12} \lvert U \rvert e^3 		        & \text{for bilaplacian operator }
+    \end{aligned}
+  \right.
+\end{equation}
+
+%% =================================================================================================
+\subsection[Deformation rate dependent viscosities (\forcode{nn_ahm_ijk_t=32})]{Deformation rate dependent viscosities (\protect\np[=32]{nn_ahm_ijk_t}{nn\_ahm\_ijk\_t})}
+
+This option refers to the \citep{smagorinsky_MW63} scheme which is here implemented for momentum only. Smagorinsky chose as a
+characteristic time scale $T_{smag}$ the deformation rate and for the lengthscale $L_{smag}$ the maximum wavenumber possible on the horizontal grid, e.g.:
+
+\begin{equation}
+  \label{eq:LDF_smag1}
+  \begin{split}
+    T_{smag}^{-1} & = \sqrt{\left( \partial_x u - \partial_y v\right)^2 + \left( \partial_y u + \partial_x v\right)^2  } \\
+    L_{smag} & = \frac{1}{\pi}\frac{e_1 e_2}{e_1 + e_2}
+  \end{split}
+\end{equation}
+
+Introducing a user defined constant $C$ (given in the namelist as \np{rn_csmc}{rn\_csmc}), one can deduce the mixing coefficients as follows:
+
+\begin{equation}
+  \label{eq:LDF_smag2}
+  A_{smag} = \left\{
+    \begin{aligned}
+      & C^2  T_{smag}^{-1}  L_{smag}^2			& \text{for laplacian operator } \\
+      & \frac{C^2}{8} T_{smag}^{-1} L_{smag}^4     	& \text{for bilaplacian operator }
+    \end{aligned}
+  \right.
+\end{equation}
+
+For stability reasons, upper and lower limits are applied on the resulting coefficient (see \autoref{sec:TD_forward_imp}) so that:
+\begin{equation}
+  \label{eq:LDF_smag3}
+    \begin{aligned}
+      & C_{min} \frac{1}{2}   \lvert U \rvert  e    < A_{smag} < C_{max} \frac{e^2}{   8\rdt}                 & \text{for laplacian operator } \\
+      & C_{min} \frac{1}{12} \lvert U \rvert  e^3 < A_{smag} < C_{max} \frac{e^4}{64 \rdt}                 & \text{for bilaplacian operator }
+    \end{aligned}
+\end{equation}
+
+where $C_{min}$ and $C_{max}$ are adimensional namelist parameters given by \np{rn_minfac}{rn\_minfac} and \np{rn_maxfac}{rn\_maxfac} respectively.
+
+%% =================================================================================================
+\subsection{About space and time varying mixing coefficients}
 
 The following points are relevant when the eddy coefficient varies spatially:
 
 (1) the momentum diffusion operator acting along model level surfaces is written in terms of curl and
-divergent components of the horizontal current (see \autoref{subsec:PE_ldf}).
+divergent components of the horizontal current (see \autoref{subsec:MB_ldf}).
 Although the eddy coefficient could be set to different values in these two terms,
-this option is not currently available. 
+this option is not currently available.
 
 (2) with an horizontally varying viscosity, the quadratic integral constraints on enstrophy and on the square of
 the horizontal divergence for operators acting along model-surfaces are no longer satisfied
-(\autoref{sec:dynldf_properties}).
-
-(3) for isopycnal diffusion on momentum or tracers, an additional purely horizontal background diffusion with
-uniform coefficient can be added by setting a non zero value of \np{rn\_ahmb0} or \np{rn\_ahtb0},
-a background horizontal eddy viscosity or diffusivity coefficient
-(namelist parameters whose default values are $0$).
-However, the technique used to compute the isopycnal slopes is intended to get rid of such a background diffusion,
-since it introduces spurious diapycnal diffusion (see \autoref{sec:LDF_slp}).
-
-(4) when an eddy induced advection term is used (\key{traldf\_eiv}),
-$A^{eiv}$, the eddy induced coefficient has to be defined.
-Its space variations are controlled by the same CPP variable as for the eddy diffusivity coefficient
-(\ie \key{traldf\_cNd}). 
-
-(5) the eddy coefficient associated with a biharmonic operator must be set to a \emph{negative} value.
-
-(6) it is possible to use both the laplacian and biharmonic operators concurrently.
-
-(7) it is possible to run without explicit lateral diffusion on momentum
-(\np{ln\_dynldf\_lap}\forcode{ = .?.}\np{ln\_dynldf\_bilap}\forcode{ = .false.}).
-This is recommended when using the UBS advection scheme on momentum (\np{ln\_dynadv\_ubs}\forcode{ = .true.},
-see \autoref{subsec:DYN_adv_ubs}) and can be useful for testing purposes.
-
-% ================================================================
-% Eddy Induced Mixing
-% ================================================================
-\section[Eddy induced velocity (\textit{traadv\_eiv.F90}, \textit{ldfeiv.F90})]
-{Eddy induced velocity (\protect\mdl{traadv\_eiv}, \protect\mdl{ldfeiv})}
+(\autoref{sec:INVARIANTS_dynldf_properties}).
+
+%% =================================================================================================
+\section[Eddy induced velocity (\forcode{ln_ldfeiv})]{Eddy induced velocity (\protect\np{ln_ldfeiv}{ln\_ldfeiv})}
+
 \label{sec:LDF_eiv}
 
+\begin{listing}
+  \nlst{namtra_eiv}
+  \caption{\forcode{&namtra_eiv}}
+  \label{lst:namtra_eiv}
+\end{listing}
+
 %%gm  from Triad appendix  : to be incorporated....
-\gmcomment{
+\cmtgm{
   Values of iso-neutral diffusivity and GM coefficient are set as described in \autoref{sec:LDF_coef}.
   If none of the keys \key{traldf\_cNd}, N=1,2,3 is set (the default), spatially constant iso-neutral $A_l$ and
-  GM diffusivity $A_e$ are directly set by \np{rn\_aeih\_0} and \np{rn\_aeiv\_0}.
+  GM diffusivity $A_e$ are directly set by \np{rn_aeih_0}{rn\_aeih\_0} and \np{rn_aeiv_0}{rn\_aeiv\_0}.
   If 2D-varying coefficients are set with \key{traldf\_c2d} then $A_l$ is reduced in proportion with horizontal
   scale factor according to \autoref{eq:title}
@@ -457,16 +494,17 @@
     In this case, $A_e$ at low latitudes $|\theta|<20^{\circ}$ is further reduced by a factor $|f/f_{20}|$,
     where $f_{20}$ is the value of $f$ at $20^{\circ}$~N
-  } (\mdl{ldfeiv}) and \np{rn\_aeiv\_0} is ignored unless it is zero.
+  } (\mdl{ldfeiv}) and \np{rn_aeiv_0}{rn\_aeiv\_0} is ignored unless it is zero.
 }
 
-When Gent and McWilliams [1990] diffusion is used (\key{traldf\_eiv} defined),
+When  \citet{gent.mcwilliams_JPO90} diffusion is used (\np[=.true.]{ln_ldfeiv}{ln\_ldfeiv}),
 an eddy induced tracer advection term is added,
 the formulation of which depends on the slopes of iso-neutral surfaces.
 Contrary to the case of iso-neutral mixing, the slopes used here are referenced to the geopotential surfaces,
-\ie \autoref{eq:ldfslp_geo} is used in $z$-coordinates,
-and the sum \autoref{eq:ldfslp_geo} + \autoref{eq:ldfslp_iso} in $s$-coordinates.
-The eddy induced velocity is given by: 
-\begin{equation}
-  \label{eq:ldfeiv}
+\ie\ \autoref{eq:LDF_slp_geo} is used in $z$-coordinates,
+and the sum \autoref{eq:LDF_slp_geo} + \autoref{eq:LDF_slp_iso} in $s$-coordinates.
+
+If isopycnal mixing is used in the standard way, \ie\ \np[=.false.]{ln_traldf_triad}{ln\_traldf\_triad}, the eddy induced velocity is given by:
+\begin{equation}
+  \label{eq:LDF_eiv}
   \begin{split}
     u^* & = \frac{1}{e_{2u}e_{3u}}\; \delta_k \left[e_{2u} \, A_{uw}^{eiv} \; \overline{r_{1w}}^{\,i+1/2} \right]\\
@@ -475,8 +513,7 @@
   \end{split}
 \end{equation}
-where $A^{eiv}$ is the eddy induced velocity coefficient whose value is set through \np{rn\_aeiv},
-a \textit{nam\_traldf} namelist parameter.
-The three components of the eddy induced velocity are computed and
-add to the eulerian velocity in \mdl{traadv\_eiv}.
+where $A^{eiv}$ is the eddy induced velocity coefficient whose value is set through \np{nn_aei_ijk_t}{nn\_aei\_ijk\_t} \nam{tra_eiv}{tra\_eiv} namelist parameter.
+The three components of the eddy induced velocity are computed in \rou{ldf\_eiv\_trp} and
+added to the eulerian velocity in \rou{tra\_adv} where tracer advection is performed.
 This has been preferred to a separate computation of the advective trends associated with the eiv velocity,
 since it allows us to take advantage of all the advection schemes offered for the tracers
@@ -484,12 +521,28 @@
 previous releases of OPA \citep{madec.delecluse.ea_NPM98}.
 This is particularly useful for passive tracers where \emph{positivity} of the advection scheme is of
-paramount importance. 
+paramount importance.
 
 At the surface, lateral and bottom boundaries, the eddy induced velocity,
-and thus the advective eddy fluxes of heat and salt, are set to zero. 
-
-\biblio
-
-\pindex
+and thus the advective eddy fluxes of heat and salt, are set to zero.
+The value of the eddy induced mixing coefficient and its space variation is controlled in a similar way as for lateral mixing coefficient described in the preceding subsection (\np{nn_aei_ijk_t}{nn\_aei\_ijk\_t}, \np{rn_Ue}{rn\_Ue}, \np{rn_Le}{rn\_Le} namelist parameters).
+\colorbox{yellow}{CASE \np{nn_aei_ijk_t}{nn\_aei\_ijk\_t} = 21 to be added}
+
+In case of setting \np[=.true.]{ln_traldf_triad}{ln\_traldf\_triad}, a skew form of the eddy induced advective fluxes is used, which is described in \autoref{apdx:TRIADS}.
+
+%% =================================================================================================
+\section[Mixed layer eddies (\forcode{ln_mle})]{Mixed layer eddies (\protect\np{ln_mle}{ln\_mle})}
+\label{sec:LDF_mle}
+
+\begin{listing}
+  \nlst{namtra_mle}
+  \caption{\forcode{&namtra_mle}}
+  \label{lst:namtra_mle}
+\end{listing}
+
+If  \np[=.true.]{ln_mle}{ln\_mle} in \nam{tra_mle}{tra\_mle} namelist, a parameterization of the mixing due to unresolved mixed layer instabilities is activated (\citet{foxkemper.ferrari_JPO08}). Additional transport is computed in \rou{ldf\_mle\_trp} and added to the eulerian transport in \rou{tra\_adv} as done for eddy induced advection.
+
+\colorbox{yellow}{TBC}
+
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_OBS.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_OBS.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_OBS.tex	(revision 12143)
@@ -2,25 +2,45 @@
 
 \begin{document}
-% ================================================================
-% Chapter observation operator (OBS)
-% ================================================================
+
 \chapter{Observation and Model Comparison (OBS)}
 \label{chap:OBS}
 
-Authors: D. Lea, M. Martin, K. Mogensen, A. Vidard, A. Weaver, A. Ryan, ...   % do we keep that ?
-
-\minitoc
-
-\newpage
-
-The observation and model comparison code (OBS) reads in observation files
-(profile temperature and salinity, sea surface temperature, sea level anomaly, sea ice concentration, and velocity) and calculates an interpolated model equivalent value at the observation location and nearest model timestep.
+%\subsubsection*{Changes record}
+%\begin{tabular}{l||l|m{0.65\linewidth}}
+%    Release   & Author        & Modifications \\
+%    {\em 4.0} & {\em D. J. Lea} & {\em \NEMO\ 4.0 updates}  \\
+%    {\em 3.6} & {\em M. Martin, A. Ryan} & {\em Add averaging operator, standalone obs oper} \\
+%    {\em 3.4} & {\em D. J. Lea, M. Martin, ...} & {\em Initial version}  \\
+%    {\em --\texttt{"}--} & {\em ... K. Mogensen, A. Vidard, A. Weaver} & {\em ---\texttt{"}---}  \\
+%\end{tabular}
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+The observation and model comparison code, the observation operator (OBS), reads in observation files
+(profile temperature and salinity, sea surface temperature, sea level anomaly, sea ice concentration, and velocity) and calculates an interpolated model equivalent value at the observation location and nearest model time step.
 The resulting data are saved in a ``feedback'' file (or files).
 The code was originally developed for use with the NEMOVAR data assimilation code,
 but can be used for validation or verification of the model or with any other data assimilation system.
 
-The OBS code is called from \mdl{nemogcm} for model initialisation and to calculate the model equivalent values for observations on the 0th timestep.
-The code is then called again after each timestep from \mdl{step}.
-The code is only activated if the namelist logical \np{ln\_diaobs} is set to true.
+The OBS code is called from \mdl{nemogcm} for model initialisation and to calculate the model equivalent values for observations on the 0th time step.
+The code is then called again after each time step from \mdl{step}.
+The code is only activated if the \nam{obs}{obs} namelist logical \np{ln_diaobs}{ln\_diaobs} is set to true.
 
 For all data types a 2D horizontal interpolator or averager is needed to
@@ -28,92 +48,95 @@
 For {\em in situ} profiles, a 1D vertical interpolator is needed in addition to
 provide model fields at the observation depths.
-This now works in a generalised vertical coordinate system. 
-
-Some profile observation types (\eg tropical moored buoys) are made available as daily averaged quantities.
+This now works in a generalised vertical coordinate system.
+
+Some profile observation types (\eg\ tropical moored buoys) are made available as daily averaged quantities.
 The observation operator code can be set-up to calculate the equivalent daily average model temperature fields using
-the \np{nn\_profdavtypes} namelist array.
+the \np{nn_profdavtypes}{nn\_profdavtypes} namelist array.
 Some SST observations are equivalent to a night-time average value and
 the observation operator code can calculate equivalent night-time average model SST fields by
-setting the namelist value \np{ln\_sstnight} to true.
-Otherwise the model value from the nearest timestep to the observation time is used.
-
-The code is controlled by the namelist \textit{namobs}.
+setting the namelist value \np{ln_sstnight}{ln\_sstnight} to true.
+Otherwise (by default) the model value from the nearest time step to the observation time is used.
+
+The code is controlled by the namelist \nam{obs}{obs}.
 See the following sections for more details on setting up the namelist.
 
-\autoref{sec:OBS_example} introduces a test example of the observation operator code including
+In \autoref{sec:OBS_example} a test example of the observation operator code is introduced, including
 where to obtain data and how to setup the namelist.
-\autoref{sec:OBS_details} introduces some more technical details of the different observation types used and
-also shows a more complete namelist.
-\autoref{sec:OBS_theory} introduces some of the theoretical aspects of the observation operator including
+In \autoref{sec:OBS_details} some more technical details of the different observation types used are introduced, and we
+also show a more complete namelist.
+In \autoref{sec:OBS_theory} some of the theoretical aspects of the observation operator are described including
 interpolation methods and running on multiple processors.
-\autoref{sec:OBS_ooo} describes the offline observation operator code.
-\autoref{sec:OBS_obsutils} introduces some utilities to help working with the files produced by the OBS code.
-
-% ================================================================
-% Example
-% ================================================================
+In \autoref{sec:OBS_sao} the standalone observation operator code is described.
+In \autoref{sec:OBS_obsutils} we describe some utilities to help work with the files produced by the OBS code.
+
+%% =================================================================================================
 \section{Running the observation operator code example}
 \label{sec:OBS_example}
 
-This section describes an example of running the observation operator code using
-profile data which can be freely downloaded.
-It shows how to adapt an existing run and build of NEMO to run the observation operator.
+In this section an example of running the observation operator code is described using
+profile observation data which can be freely downloaded.
+It shows how to adapt an existing run and build of \NEMO\ to run the observation operator. Note also the observation operator and the assimilation increments code are run in the ORCA2\_ICE\_OBS SETTE test.
 
 \begin{enumerate}
-\item Compile NEMO.
+\item Compile \NEMO.
 
 \item Download some EN4 data from \href{http://www.metoffice.gov.uk/hadobs}{www.metoffice.gov.uk/hadobs}.
   Choose observations which are valid for the period of your test run because
-  the observation operator compares the model and observations for a matching date and time. 
-
-\item Compile the OBSTOOLS code using: 
+  the observation operator compares the model and observations for a matching date and time.
+
+\item Compile the OBSTOOLS code in the \path{tools} directory using:
 \begin{cmds}
-./maketools -n OBSTOOLS -m [ARCH].
+./maketools -n OBSTOOLS -m [ARCH]
 \end{cmds}
 
-\item Convert the EN4 data into feedback format: 
+replacing \texttt{[ARCH]} with the build architecture file for your machine. Note the tools are checked out from a separate location of the repository (under \path{/utils/tools}).
+
+\item Convert the EN4 data into feedback format:
 \begin{cmds}
 enact2fb.exe profiles_01.nc EN.4.1.1.f.profiles.g10.YYYYMM.nc
 \end{cmds}
 
-\item Include the following in the NEMO namelist to run the observation operator on this data:
+\item Include the following in the \NEMO\ namelist to run the observation operator on this data:
 \end{enumerate}
 
-Options are defined through the \ngn{namobs} namelist variables.
-The options \np{ln\_t3d} and \np{ln\_s3d} switch on the temperature and salinity profile observation operator code.
-The filename or array of filenames are specified using the \np{cn\_profbfiles} variable.
+Options are defined through the \nam{obs}{obs} namelist variables.
+The options \np{ln_t3d}{ln\_t3d} and \np{ln_s3d}{ln\_s3d} switch on the temperature and salinity profile observation operator code.
+The filename or array of filenames are specified using the \np{cn_profbfiles}{cn\_profbfiles} variable.
 The model grid points for a particular observation latitude and longitude are found using
 the grid searching part of the code.
 This can be expensive, particularly for large numbers of observations,
-setting \np{ln\_grid\_search\_lookup} allows the use of a lookup table which
-is saved into an ``xypos`` file (or files).
+setting \np{ln_grid_search_lookup}{ln\_grid\_search\_lookup} allows the use of a lookup table which
+is saved into an \np{cn_gridsearch}{cn\_gridsearch} file (or files).
 This will need to be generated the first time if it does not exist in the run directory.
 However, once produced it will significantly speed up future grid searches.
-Setting \np{ln\_grid\_global} means that the code distributes the observations evenly between processors.
+Setting \np{ln_grid_global}{ln\_grid\_global} means that the code distributes the observations evenly between processors.
 Alternatively each processor will work with observations located within the model subdomain
-(see section~\autoref{subsec:OBS_parallel}).
+(see \autoref{subsec:OBS_parallel}).
 
 A number of utilities are now provided to plot the feedback files, convert and recombine the files.
-These are explained in more detail in section~\autoref{sec:OBS_obsutils}.
-Utilites to convert other input data formats into the feedback format are also described in
-section~\autoref{sec:OBS_obsutils}.
-
+These are explained in more detail in \autoref{sec:OBS_obsutils}.
+Utilities to convert other input data formats into the feedback format are also described in
+\autoref{sec:OBS_obsutils}.
+
+%% =================================================================================================
 \section{Technical details (feedback type observation file headers)}
 \label{sec:OBS_details}
 
-Here we show a more complete example namelist \ngn{namobs} and also show the NetCDF headers of
+Here we show a more complete example namelist \nam{obs}{obs} and also show the NetCDF headers of
 the observation files that may be used with the observation operator.
 
-%------------------------------------------namobs--------------------------------------------------------
-
-\nlst{namobs}
-%-------------------------------------------------------------------------------------------------------------
-
-The observation operator code uses the "feedback" observation file format for all data types.
+\begin{listing}
+  \nlst{namobs}
+  \caption{\forcode{&namobs}}
+  \label{lst:namobs}
+\end{listing}
+
+The observation operator code uses the feedback observation file format for all data types.
 All the observation files must be in NetCDF format.
 Some example headers (produced using \mbox{\textit{ncdump~-h}}) for profile data, sea level anomaly and
 sea surface temperature are in the following subsections.
 
-\subsection{Profile feedback}
+%% =================================================================================================
+\subsection{Profile feedback file}
 
 \begin{clines}
@@ -271,5 +294,6 @@
 \end{clines}
 
-\subsection{Sea level anomaly feedback}
+%% =================================================================================================
+\subsection{Sea level anomaly feedback file}
 
 \begin{clines}
@@ -395,5 +419,5 @@
 \end{clines}
 
-The mean dynamic topography (MDT) must be provided in a separate file defined on
+To use Sea Level Anomaly (SLA) data the mean dynamic topography (MDT) must be provided in a separate file defined on
 the model grid called \ifile{slaReferenceLevel}.
 The MDT is required in order to produce the model equivalent sea level anomaly from the model sea surface height.
@@ -417,5 +441,6 @@
 \end{clines}
 
-\subsection{Sea surface temperature feedback}
+%% =================================================================================================
+\subsection{Sea surface temperature feedback file}
 
 \begin{clines}
@@ -534,7 +559,9 @@
 \end{clines}
 
+%% =================================================================================================
 \section{Theoretical details}
 \label{sec:OBS_theory}
 
+%% =================================================================================================
 \subsection{Horizontal interpolation and averaging methods}
 
@@ -542,47 +569,50 @@
 the model equivalent of the observation is calculated by interpolating from
 the four surrounding grid points to the observation location.
-Some satellite observations (\eg microwave satellite SST data, or satellite SSS data) have a footprint which
+Some satellite observations (\eg\ microwave satellite SST data, or satellite SSS data) have a footprint which
 is similar in size or larger than the model grid size (particularly when the grid size is small).
 In those cases the model counterpart should be calculated by averaging the model grid points over
 the same size as the footprint.
-NEMO therefore has the capability to specify either an interpolation or an averaging
-(for surface observation types only). 
-
-The main namelist option associated with the interpolation/averaging is \np{nn\_2dint}.
+\NEMO\ therefore has the capability to specify either an interpolation or an averaging
+(for surface observation types only).
+
+The main namelist option associated with the interpolation/averaging is \np{nn_2dint}{nn\_2dint}.
 This default option can be set to values from 0 to 6.
 Values between 0 to 4 are associated with interpolation while values 5 or 6 are associated with averaging.
 \begin{itemize}
-\item \np{nn\_2dint}\forcode{ = 0}: Distance-weighted interpolation
-\item \np{nn\_2dint}\forcode{ = 1}: Distance-weighted interpolation (small angle)
-\item \np{nn\_2dint}\forcode{ = 2}: Bilinear interpolation (geographical grid)
-\item \np{nn\_2dint}\forcode{ = 3}: Bilinear remapping interpolation (general grid)
-\item \np{nn\_2dint}\forcode{ = 4}: Polynomial interpolation
-\item \np{nn\_2dint}\forcode{ = 5}: Radial footprint averaging with diameter specified in the namelist as
-  \np{rn\_???\_avglamscl} in degrees or metres (set using \np{ln\_???\_fp\_indegs})
-\item \np{nn\_2dint}\forcode{ = 6}: Rectangular footprint averaging with E/W and N/S size specified in
-  the namelist as \np{rn\_???\_avglamscl} and \np{rn\_???\_avgphiscl} in degrees or metres
-  (set using \np{ln\_???\_fp\_indegs})
+\item \np[=0]{nn_2dint}{nn\_2dint}: Distance-weighted interpolation
+\item \np[=1]{nn_2dint}{nn\_2dint}: Distance-weighted interpolation (small angle)
+\item \np[=2]{nn_2dint}{nn\_2dint}: Bilinear interpolation (geographical grid)
+\item \np[=3]{nn_2dint}{nn\_2dint}: Bilinear remapping interpolation (general grid)
+\item \np[=4]{nn_2dint}{nn\_2dint}: Polynomial interpolation
+\item \np[=5]{nn_2dint}{nn\_2dint}: Radial footprint averaging with diameter specified in the namelist as
+  \texttt{rn\_[var]\_avglamscl} in degrees or metres (set using \texttt{ln\_[var]\_fp\_indegs})
+\item \np[=6]{nn_2dint}{nn\_2dint}: Rectangular footprint averaging with E/W and N/S size specified in
+  the namelist as \texttt{rn\_[var]\_avglamscl} and \texttt{rn\_[var]\_avgphiscl} in degrees or metres
+  (set using \texttt{ln\_[var]\_fp\_indegs})
 \end{itemize}
-The ??? in the last two options indicate these options should be specified for each observation type for
+Replace \texttt{[var]} in the last two options with the observation type (sla, sst, sss or sic) for
 which the averaging is to be performed (see namelist example above).
-The \np{nn\_2dint} default option can be overridden for surface observation types using
-namelist values \np{nn\_2dint\_???} where ??? is one of sla,sst,sss,sic.
-
-Below is some more detail on the various options for interpolation and averaging available in NEMO.
-
+The \np{nn_2dint}{nn\_2dint} default option can be overridden for surface observation types using
+namelist values \texttt{nn\_2dint\_[var]} where \texttt{[var]} is the observation type.
+
+Below is some more detail on the various options for interpolation and averaging available in \NEMO.
+
+%% =================================================================================================
 \subsubsection{Horizontal interpolation}
 
-Consider an observation point ${\mathrm P}$ with with longitude and latitude $({\lambda_{}}_{\mathrm P}, \phi_{\mathrm P})$ and
+Consider an observation point ${\mathrm P}$ with longitude and latitude (${\lambda_{}}_{\mathrm P}$, $\phi_{\mathrm P}$) and
 the four nearest neighbouring model grid points ${\mathrm A}$, ${\mathrm B}$, ${\mathrm C}$ and ${\mathrm D}$ with
 longitude and latitude ($\lambda_{\mathrm A}$, $\phi_{\mathrm A}$),($\lambda_{\mathrm B}$, $\phi_{\mathrm B}$) etc.
-All horizontal interpolation methods implemented in NEMO estimate the value of a model variable $x$ at point $P$ as
+All horizontal interpolation methods implemented in \NEMO\ estimate the value of a model variable $x$ at point $P$ as
 a weighted linear combination of the values of the model variables at the grid points ${\mathrm A}$, ${\mathrm B}$ etc.:
+
 \begin{align*}
-  {x_{}}_{\mathrm P} & \hspace{-2mm} = \hspace{-2mm} &
-                                                   \frac{1}{w} \left( {w_{}}_{\mathrm A} {x_{}}_{\mathrm A} +
-                                                   {w_{}}_{\mathrm B} {x_{}}_{\mathrm B} +
-                                                   {w_{}}_{\mathrm C} {x_{}}_{\mathrm C} +
-                                                   {w_{}}_{\mathrm D} {x_{}}_{\mathrm D} \right)
+  {x_{}}_{\mathrm P} =
+\frac{1}{w} \left( {w_{}}_{\mathrm A} {x_{}}_{\mathrm A} +
+{w_{}}_{\mathrm B} {x_{}}_{\mathrm B} +
+{w_{}}_{\mathrm C} {x_{}}_{\mathrm C} +
+{w_{}}_{\mathrm D} {x_{}}_{\mathrm D} \right)
 \end{align*}
+
 where ${w_{}}_{\mathrm A}$, ${w_{}}_{\mathrm B}$ etc. are the respective weights for the model field at
 points ${\mathrm A}$, ${\mathrm B}$ etc., and $w = {w_{}}_{\mathrm A} + {w_{}}_{\mathrm B} + {w_{}}_{\mathrm C} + {w_{}}_{\mathrm D}$.
@@ -591,65 +621,70 @@
 
 \begin{enumerate}
-
-\item[1.] {\bfseries Great-Circle distance-weighted interpolation.}
+\item {\bfseries Great-Circle distance-weighted interpolation.}
   The weights are computed as a function of the great-circle distance $s(P, \cdot)$ between $P$ and
   the model grid points $A$, $B$ etc.
   For example, the weight given to the field ${x_{}}_{\mathrm A}$ is specified as the product of the distances
   from ${\mathrm P}$ to the other points:
-  \begin{align*}
+
+  \begin{alignat*}{2}
     {w_{}}_{\mathrm A} = s({\mathrm P}, {\mathrm B}) \, s({\mathrm P}, {\mathrm C}) \, s({\mathrm P}, {\mathrm D})
-  \end{align*}
-  where 
-  \begin{align*}
-    s\left ({\mathrm P}, {\mathrm M} \right ) 
-     & \hspace{-2mm} = \hspace{-2mm} & 
-      \cos^{-1} \! \left\{ 
+  \end{alignat*}
+
+  where
+
+  \begin{alignat*}{2}
+    s\left({\mathrm P}, {\mathrm M} \right) & = & \hspace{0.25em} \cos^{-1} \! \left\{
                \sin {\phi_{}}_{\mathrm P} \sin {\phi_{}}_{\mathrm M}
-             + \cos {\phi_{}}_{\mathrm P} \cos {\phi_{}}_{\mathrm M} 
-               \cos ({\lambda_{}}_{\mathrm M} - {\lambda_{}}_{\mathrm P}) 
+             + \cos {\phi_{}}_{\mathrm P} \cos {\phi_{}}_{\mathrm M}
+               \cos ({\lambda_{}}_{\mathrm M} - {\lambda_{}}_{\mathrm P})
                    \right\}
-   \end{align*}
+   \end{alignat*}
+
    and $M$ corresponds to $B$, $C$ or $D$.
    A more stable form of the great-circle distance formula for small distances ($x$ near 1)
-   involves the arcsine function (\eg see p.~101 of \citet{daley.barker_bk01}:
-   \begin{align*}
-     s\left( {\mathrm P}, {\mathrm M} \right) & \hspace{-2mm} = \hspace{-2mm} & \sin^{-1} \! \left\{ \sqrt{ 1 - x^2 } \right\}
-   \end{align*}
+   involves the arcsine function (\eg\ see p.~101 of \citet{daley.barker_bk01}:
+
+   \begin{alignat*}{2}
+     s\left( {\mathrm P}, {\mathrm M} \right) = \sin^{-1} \! \left\{ \sqrt{ 1 - x^2 } \right\}
+   \end{alignat*}
+
    where
-   \begin{align*}
-     x & \hspace{-2mm} = \hspace{-2mm} &
-                                         {a_{}}_{\mathrm M} {a_{}}_{\mathrm P} + {b_{}}_{\mathrm M} {b_{}}_{\mathrm P} + {c_{}}_{\mathrm M} {c_{}}_{\mathrm P}
-   \end{align*}
-   and 
-   \begin{align*}
-      {a_{}}_{\mathrm M} & \hspace{-2mm} = \hspace{-2mm} & \sin {\phi_{}}_{\mathrm M}, \\
-      {a_{}}_{\mathrm P} & \hspace{-2mm} = \hspace{-2mm} & \sin {\phi_{}}_{\mathrm P}, \\
-      {b_{}}_{\mathrm M} & \hspace{-2mm} = \hspace{-2mm} & \cos {\phi_{}}_{\mathrm M} \cos {\phi_{}}_{\mathrm M}, \\
-      {b_{}}_{\mathrm P} & \hspace{-2mm} = \hspace{-2mm} & \cos {\phi_{}}_{\mathrm P} \cos {\phi_{}}_{\mathrm P}, \\
-      {c_{}}_{\mathrm M} & \hspace{-2mm} = \hspace{-2mm} & \cos {\phi_{}}_{\mathrm M} \sin {\phi_{}}_{\mathrm M}, \\
-      {c_{}}_{\mathrm P} & \hspace{-2mm} = \hspace{-2mm} & \cos {\phi_{}}_{\mathrm P} \sin {\phi_{}}_{\mathrm P}.
-  \end{align*}
-
-\item[2.] {\bfseries Great-Circle distance-weighted interpolation with small angle approximation.}
+
+   \begin{alignat*}{2}
+     x = {a_{}}_{\mathrm M} {a_{}}_{\mathrm P} + {b_{}}_{\mathrm M} {b_{}}_{\mathrm P} + {c_{}}_{\mathrm M} {c_{}}_{\mathrm P}
+   \end{alignat*}
+
+   and
+
+   \begin{alignat*}{3}
+   & {a_{}}_{\mathrm M} & = && \quad \sin {\phi_{}}_{\mathrm M}, \\
+   & {a_{}}_{\mathrm P} & = && \quad \sin {\phi_{}}_{\mathrm P}, \\
+   & {b_{}}_{\mathrm M} & = && \quad \cos {\phi_{}}_{\mathrm M} \cos {\phi_{}}_{\mathrm M}, \\
+   & {b_{}}_{\mathrm P} & = && \quad \cos {\phi_{}}_{\mathrm P} \cos {\phi_{}}_{\mathrm P}, \\
+   & {c_{}}_{\mathrm M} & = && \quad \cos {\phi_{}}_{\mathrm M} \sin {\phi_{}}_{\mathrm M}, \\
+   & {c_{}}_{\mathrm P} & = && \quad \cos {\phi_{}}_{\mathrm P} \sin {\phi_{}}_{\mathrm P}.
+   \end{alignat*}
+
+\item {\bfseries Great-Circle distance-weighted interpolation with small angle approximation.}
   Similar to the previous interpolation but with the distance $s$ computed as
-  \begin{align*}
+  \begin{alignat*}{2}
     s\left( {\mathrm P}, {\mathrm M} \right)
-    & \hspace{-2mm} = \hspace{-2mm} &
-                                      \sqrt{ \left( {\phi_{}}_{\mathrm M} - {\phi_{}}_{\mathrm P} \right)^{2}
+    & = & \sqrt{ \left( {\phi_{}}_{\mathrm M} - {\phi_{}}_{\mathrm P} \right)^{2}
                                       + \left( {\lambda_{}}_{\mathrm M} - {\lambda_{}}_{\mathrm P} \right)^{2}
                                       \cos^{2} {\phi_{}}_{\mathrm M} }
-  \end{align*}
+  \end{alignat*}
   where $M$ corresponds to $A$, $B$, $C$ or $D$.
 
-\item[3.] {\bfseries Bilinear interpolation for a regular spaced grid.}
+\item {\bfseries Bilinear interpolation for a regular spaced grid.}
   The interpolation is split into two 1D interpolations in the longitude and latitude directions, respectively.
 
-\item[4.] {\bfseries Bilinear remapping interpolation for a general grid.}
+\item {\bfseries Bilinear remapping interpolation for a general grid.}
   An iterative scheme that involves first mapping a quadrilateral cell into
   a cell with coordinates (0,0), (1,0), (0,1) and (1,1).
   This method is based on the \href{https://github.com/SCRIP-Project/SCRIP}{SCRIP interpolation package}.
-  
+
 \end{enumerate}
 
+%% =================================================================================================
 \subsubsection{Horizontal averaging}
 
@@ -658,8 +693,7 @@
 \item The standard grid-searching code is used to find the nearest model grid point to the observation location
   (see next subsection).
-\item The maximum number of grid points is calculated in the local grid domain for which
-  the averaging is likely need to cover.
-\item The lats/longs of the grid points surrounding the nearest model grid box are extracted using
-  existing mpi routines.
+\item The maximum number of grid points required for that observation in each local grid domain is calculated. Some of these points may later turn out to have zero weight depending on the shape of the footprint.
+\item The longitudes and latitudes of the grid points surrounding the nearest model grid box are extracted using
+  existing MPI routines.
 \item The weights for each grid point associated with each observation are calculated,
   either for radial or rectangular footprints.
@@ -673,46 +707,38 @@
 
 Examples of the weights calculated for an observation with rectangular and radial footprints are shown in
-Figs.~\autoref{fig:obsavgrec} and~\autoref{fig:obsavgrad}.
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\autoref{fig:OBS_avgrec} and~\autoref{fig:OBS_avgrad}.
+
 \begin{figure}
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_OBS_avg_rec}
-    \caption{
-      \protect\label{fig:obsavgrec}
-      Weights associated with each model grid box (blue lines and numbers)
-      for an observation at -170.5\deg{E}, 56.0\deg{N} with a rectangular footprint of 1\deg x 1\deg.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{OBS_avg_rec}
+  \caption[Observational weights with a rectangular footprint]{
+    Weights associated with each model grid box (blue lines and numbers)
+    for an observation at -170.5\deg{E}, 56.0\deg{N} with a rectangular footprint of 1\deg\ x 1\deg.}
+  \label{fig:OBS_avgrec}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
 \begin{figure}
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_OBS_avg_rad}
-    \caption{
-      \protect\label{fig:obsavgrad}
-      Weights associated with each model grid box (blue lines and numbers)
-      for an observation at -170.5\deg{E}, 56.0\deg{N} with a radial footprint with diameter 1\deg.
-    } 
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{OBS_avg_rad}
+  \caption[Observational weights with a radial footprint]{
+    Weights associated with each model grid box (blue lines and numbers)
+    for an observation at -170.5\deg{E}, 56.0\deg{N} with a radial footprint with diameter 1\deg.}
+  \label{fig:OBS_avgrad}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
+
+%% =================================================================================================
 \subsection{Grid search}
 
-For many grids used by the NEMO model, such as the ORCA family, the horizontal grid coordinates $i$ and $j$ are not simple functions of latitude and longitude.
+For many grids used by the \NEMO\ model, such as the ORCA family, the horizontal grid coordinates $i$ and $j$ are not simple functions of latitude and longitude.
 Therefore, it is not always straightforward to determine the grid points surrounding any given observational position.
-Before the interpolation can be performed, a search algorithm is then required to determine the corner points of 
+Before the interpolation can be performed, a search algorithm is then required to determine the corner points of
 the quadrilateral cell in which the observation is located.
-This is the most difficult and time consuming part of the 2D interpolation procedure. 
+This is the most difficult and time consuming part of the 2D interpolation procedure.
 A robust test for determining if an observation falls within a given quadrilateral cell is as follows.
 Let ${\mathrm P}({\lambda_{}}_{\mathrm P} ,{\phi_{}}_{\mathrm P} )$ denote the observation point,
 and let ${\mathrm A}({\lambda_{}}_{\mathrm A} ,{\phi_{}}_{\mathrm A} )$, ${\mathrm B}({\lambda_{}}_{\mathrm B} ,{\phi_{}}_{\mathrm B} )$,
 ${\mathrm C}({\lambda_{}}_{\mathrm C} ,{\phi_{}}_{\mathrm C} )$ and ${\mathrm D}({\lambda_{}}_{\mathrm D} ,{\phi_{}}_{\mathrm D} )$
-denote the bottom left, bottom right, top left and top right corner points of the cell, respectively. 
-To determine if P is inside the cell, we verify that the cross-products 
+denote the bottom left, bottom right, top left and top right corner points of the cell, respectively.
+To determine if P is inside the cell, we verify that the cross-products
 \begin{align*}
   \begin{array}{lllll}
@@ -738,8 +764,8 @@
           ({\phi_{}}_{\mathrm D}  \;  - \; {\phi_{}}_{\mathrm P} )] \; \widehat{\mathbf k} \\
   \end{array}
-  % \label{eq:cross}
+  % \label{eq:OBS_cross}
 \end{align*}
 point in the opposite direction to the unit normal $\widehat{\mathbf k}$
-(\ie that the coefficients of $\widehat{\mathbf k}$ are negative),
+(\ie\ that the coefficients of $\widehat{\mathbf k}$ are negative),
 where ${{\mathbf r}_{}}_{\mathrm PA}$, ${{\mathbf r}_{}}_{\mathrm PB}$, etc. correspond to
 the vectors between points P and A, P and B, etc..
@@ -750,6 +776,7 @@
 be searched for on a regular grid.
 For each observation position, the closest point on the regular grid of this position is computed and
-the $i$ and $j$ ranges of this point searched to determine the precise four points surrounding the observation. 
-
+the $i$ and $j$ ranges of this point searched to determine the precise four points surrounding the observation.
+
+%% =================================================================================================
 \subsection{Parallel aspects of horizontal interpolation}
 \label{subsec:OBS_parallel}
@@ -757,38 +784,35 @@
 For horizontal interpolation, there is the basic problem that
 the observations are unevenly distributed on the globe.
-In numerical models, it is common to divide the model grid into subgrids (or domains) where
+In \NEMO\ the model grid is divided into subgrids (or domains) where
 each subgrid is executed on a single processing element with explicit message passing for
 exchange of information along the domain boundaries when running on a massively parallel processor (MPP) system.
-This approach is used by \NEMO.
-
-For observations there is no natural distribution since the observations are not equally distributed on the globe. 
+
+For observations there is no natural distribution since the observations are not equally distributed on the globe.
 Two options have been made available:
 1) geographical distribution;
 and 2) round-robin.
 
+%% =================================================================================================
 \subsubsection{Geographical distribution of observations among processors}
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_ASM_obsdist_local}
-    \caption{
-      \protect\label{fig:obslocal}
-      Example of the distribution of observations with the geographical distribution of observational data.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{OBS_obsdist_local}
+  \caption[Observations with the geographical distribution]{
+    Example of the distribution of observations with
+    the geographical distribution of observational data}
+  \label{fig:OBS_local}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 This is the simplest option in which the observations are distributed according to
 the domain of the grid-point parallelization.
-\autoref{fig:obslocal} shows an example of the distribution of the {\em in situ} data on processors with
-a different colour for each observation on a given processor for a 4 $\times$ 2 decomposition with ORCA2. 
+\autoref{fig:OBS_local} shows an example of the distribution of the {\em in situ} data on processors with
+a different colour for each observation on a given processor for a 4 $\times$ 2 decomposition with ORCA2.
 The grid-point domain decomposition is clearly visible on the plot.
 
 The advantage of this approach is that all information needed for horizontal interpolation is available without
 any MPP communication.
-Of course, this is under the assumption that we are only using a $2 \times 2$ grid-point stencil for
-the interpolation (\eg bilinear interpolation).
+This is under the assumption that we are dealing with point observations and only using a $2 \times 2$ grid-point stencil for
+the interpolation (\eg\ bilinear interpolation).
 For higher order interpolation schemes this is no longer valid.
 A disadvantage with the above scheme is that the number of observations on each processor can be very different.
@@ -796,28 +820,27 @@
 this could lead to load imbalance.
 
+%% =================================================================================================
 \subsubsection{Round-robin distribution of observations among processors}
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_ASM_obsdist_global}
-    \caption{
-      \protect\label{fig:obsglobal}
-      Example of the distribution of observations with the round-robin distribution of observational data.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{OBS_obsdist_global}
+  \caption[Observations with the round-robin distribution]{
+    Example of the distribution of observations with
+    the round-robin distribution of observational data.}
+  \label{fig:OBS_global}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 An alternative approach is to distribute the observations equally among processors and
 use message passing in order to retrieve the stencil for interpolation.
 The simplest distribution of the observations is to distribute them using a round-robin scheme.
-\autoref{fig:obsglobal} shows the distribution of the {\em in situ} data on processors for
+\autoref{fig:OBS_global} shows the distribution of the {\em in situ} data on processors for
 the round-robin distribution of observations with a different colour for each observation on a given processor for
-a 4 $\times$ 2 decomposition with ORCA2 for the same input data as in \autoref{fig:obslocal}.
+a 4 $\times$ 2 decomposition with ORCA2 for the same input data as in \autoref{fig:OBS_local}.
 The observations are now clearly randomly distributed on the globe.
 In order to be able to perform horizontal interpolation in this case,
 a subroutine has been developed that retrieves any grid points in the global space.
 
+%% =================================================================================================
 \subsection{Vertical interpolation operator}
 
@@ -827,87 +850,65 @@
 At the bottom boundary, this is done using the land-ocean mask.
 
-\newpage
-
-% ================================================================
-% Offline observation operator documentation
-% ================================================================
+For profile observation types we do both vertical and horizontal interpolation. \NEMO\ has a generalised vertical coordinate system this means the vertical level depths can vary with location. Therefore, it is necessary first to perform vertical interpolation of the model value to the observation depths for each of the four surrounding grid points. After this the model values, at these points, at the observation depth, are horizontally interpolated to the observation location.
 
 %\usepackage{framed}
 
-\section{Offline observation operator}
-\label{sec:OBS_ooo}
-
+%% =================================================================================================
+\section{Standalone observation operator (\texttt{SAO})}
+\label{sec:OBS_sao}
+
+%% =================================================================================================
 \subsection{Concept}
 
-The obs oper maps model variables to observation space.
-It is possible to apply this mapping without running the model.
-The software which performs this functionality is known as the \textbf{offline obs oper}.
-The obs oper is divided into three stages.
-An initialisation phase, an interpolation phase and an output phase.
-The implementation of which is outlined in the previous sections.
-During the interpolation phase the offline obs oper populates the model arrays by
-reading saved model fields from disk.
-
-There are two ways of exploiting this offline capacity.
+The observation operator maps model variables to observation space. This is normally done while the model is running, i.e. online, it is possible to apply this mapping offline without running the model with the \textbf{standalone observation operator} (SAO). The process is divided into an initialisation phase, an interpolation phase and an output phase.
+During the interpolation phase the SAO populates the model arrays by
+reading saved model fields from disk. The interpolation and the output phases use the same OBS code described in the preceding sections.
+
+There are two ways of exploiting the standalone capacity.
 The first is to mimic the behaviour of the online system by supplying model fields at
 regular intervals between the start and the end of the run.
 This approach results in a single model counterpart per observation.
-This kind of usage produces feedback files the same file format as the online obs oper.
-The second is to take advantage of the offline setting in which
-multiple model counterparts can be calculated per observation.
+This kind of usage produces feedback files the same file format as the online observation operator.
+The second is to take advantage of the ability to run offline by calculating
+multiple model counterparts for each observation.
 In this case it is possible to consider all forecasts verifying at the same time.
-By forecast, I mean any method which produces an estimate of physical reality which is not an observed value.
-In the case of class 4 files this means forecasts, analyses, persisted analyses and
-climatological values verifying at the same time.
-Although the class 4 file format doesn't account for multiple ensemble members or
-multiple experiments per observation, it is possible to include these components in the same or multiple files.
-
-%--------------------------------------------------------------------------------------------------------
-% offline_oper.exe 
-%--------------------------------------------------------------------------------------------------------
-
-\subsection{Using the offline observation operator}
-
+By forecast, we mean any method which produces an estimate of physical reality which is not an observed value.
+
+% sao.exe
+
+%% =================================================================================================
+\subsection{Using the standalone observation operator}
+
+%% =================================================================================================
 \subsubsection{Building}
 
-In addition to \emph{OPA\_SRC} the offline obs oper requires the inclusion of the \emph{OOO\_SRC} directory.
-\emph{OOO\_SRC} contains a replacement \mdl{nemo} and \mdl{nemogcm} which
+In addition to \emph{OPA\_SRC} the SAO requires the inclusion of the \emph{SAO\_SRC} directory.
+\emph{SAO\_SRC} contains a replacement \mdl{nemo} and \mdl{nemogcm} which
 overwrites the resultant \textbf{nemo.exe}.
-This is the approach taken by \emph{SAS\_SRC} and \emph{OFF\_SRC}.
-
-%--------------------------------------------------------------------------------------------------------
-% Running 
-%--------------------------------------------------------------------------------------------------------
+Note this a similar approach to that taken by the standalone surface scheme \emph{SAS\_SRC} and the offline TOP model \emph{OFF\_SRC}.
+
+% Running
+%% =================================================================================================
 \subsubsection{Running}
 
-The simplest way to use the executable is to edit and append the \textbf{ooo.nml} namelist to
-a full NEMO namelist and then to run the executable as if it were nemo.exe. 
-
-\subsubsection{Quick script}
-
-A useful Python utility to control the namelist options can be found in \textbf{OBSTOOLS/OOO}.
-The functions which locate model fields and observation files can be manually specified.
-The package can be installed by appropriate use of the included setup.py script.
-
-Documentation can be auto-generated by Sphinx by running \emph{make html} in the \textbf{doc} directory.
-
-%--------------------------------------------------------------------------------------------------------
+The simplest way to use the executable is to edit and append the \textbf{sao.nml} namelist to
+a full \NEMO\ namelist and then to run the executable as if it were nemo.exe.
+
 % Configuration section
-%--------------------------------------------------------------------------------------------------------
-\subsection{Configuring the offline observation operator}
-The observation files and settings understood by \textbf{namobs} have been outlined in the online obs oper section.
-In addition there are two further namelists wich control the operation of the offline obs oper.
-\textbf{namooo} which controls the input model fields and \textbf{namcl4} which
-controls the production of class 4 files. 
-
+%% =================================================================================================
+\subsection{Configuring the standalone observation operator}
+The observation files and settings understood by \nam{obs}{obs} have been outlined in the online observation operator section.
+In addition is a further namelist \nam{sao}{sao} which used to set the input model fields for the SAO
+
+%% =================================================================================================
 \subsubsection{Single field}
 
-In offline mode model arrays are populated at appropriate time steps via input files.
-At present, \textbf{tsn} and \textbf{sshn} are populated by the default read routines. 
+In the SAO the model arrays are populated at appropriate time steps via input files.
+At present, \textbf{tsn} and \textbf{sshn} are populated by the default read routines.
 These routines will be expanded upon in future versions to allow the specification of any model variable.
 As such, input files must be global versions of the model domain with
 \textbf{votemper}, \textbf{vosaline} and optionally \textbf{sshn} present.
 
-For each field read there must be an entry in the \textbf{namooo} namelist specifying
+For each field read there must be an entry in the \nam{sao}{sao} namelist specifying
 the name of the file to read and the index along the \emph{time\_counter}.
 For example, to read the second time counter from a single file the namelist would be.
@@ -915,17 +916,18 @@
 \begin{forlines}
 !----------------------------------------------------------------------
-!       namooo Offline obs_oper namelist
+!       namsao Standalone obs_oper namelist
 !----------------------------------------------------------------------
-!   ooo_files    specifies the files containing the model counterpart
-!   nn_ooo_idx   specifies the time_counter index within the model file
-&namooo
-   ooo_files = "foo.nc"
-   nn_ooo_idx = 2
+!   sao_files    specifies the files containing the model counterpart
+!   nn_sao_idx   specifies the time_counter index within the model file
+&namsao
+   sao_files = "foo.nc"
+   nn_sao_idx = 2
 /
 \end{forlines}
 
+%% =================================================================================================
 \subsubsection{Multiple fields per run}
 
-Model field iteration is controlled via \textbf{nn\_ooo\_freq} which
+Model field iteration is controlled via \textbf{nn\_sao\_freq} which
 specifies the number of model steps at which the next field gets read.
 For example, if 12 hourly fields are to be interpolated in a setup where 288 steps equals 24 hours.
@@ -933,13 +935,13 @@
 \begin{forlines}
 !----------------------------------------------------------------------
-!       namooo Offline obs_oper namelist
+!       namsao Standalone obs_oper namelist
 !----------------------------------------------------------------------
-!   ooo_files    specifies the files containing the model counterpart
-!   nn_ooo_idx   specifies the time_counter index within the model file
-!   nn_ooo_freq  specifies number of time steps between read operations
-&namooo
-   ooo_files = "foo.nc" "foo.nc"
-   nn_ooo_idx = 1 2
-   nn_ooo_freq = 144
+!   sao_files    specifies the files containing the model counterpart
+!   nn_sao_idx   specifies the time_counter index within the model file
+!   nn_sao_freq  specifies number of time steps between read operations
+&namsao
+   sao_files = "foo.nc" "foo.nc"
+   nn_sao_idx = 1 2
+   nn_sao_freq = 144
 /
 \end{forlines}
@@ -952,289 +954,79 @@
 %\end{framed}
 
-It is easy to see how a collection of fields taken fron a number of files at different indices can be combined at
+A collection of fields taken from a number of files at different indices can be combined at
 a particular frequency in time to generate a pseudo model evolution.
-As long as all that is needed is a single model counterpart at a regular interval then
-namooo is all that needs to be edited.
-However, a far more interesting approach can be taken in which multiple forecasts, analyses, persisted analyses and
-climatologies are considered against the same set of observations.
-For this a slightly more complicated approach is needed.
-It is referred to as \emph{Class 4} since it is the fourth metric defined by the GODAE intercomparison project.
-
-%--------------------------------------------------------------------------------------------------------
-% Class 4 file section
-%--------------------------------------------------------------------------------------------------------
-\subsubsection{Multiple model counterparts per observation a.k.a Class 4}
-
-A generalisation of feedback files to allow multiple model components per observation.
-For a single observation, as well as previous forecasts verifying at the same time
-there are also analyses, persisted analyses and climatologies. 
-
-
-The above namelist performs two basic functions.
-It organises the fields given in \textbf{namooo} into groups so that observations can be matched up multiple times.
-It also controls the metadata and the output variable of the class 4 file when a write routine is called.
-
-%\begin{framed}
-\textbf{Note: ln\_cl4} must be set to \forcode{.true.} in \textbf{namobs} to use class 4 outputs.
-%\end{framed}
-
-\subsubsection{Class 4 naming convention}
-
-The standard class 4 file naming convention is as follows.
-
-\noindent
-\linebreak
-\textbf{\$\{prefix\}\_\$\{yyyymmdd\}\_\$\{sys\}\_\$\{cfg\}\_\$\{vn\}\_\$\{kind\}\_\$\{nproc\}}.nc
-
-\noindent
-\linebreak
-Much of the namelist is devoted to specifying this convention.
-The following namelist settings control the elements of the output file names.
-Each should be specified as a single string of character data.
-
-\begin{description}
-\item[cl4\_prefix]
-  Prefix for class 4 files \eg class4
-\item[cl4\_date]
-  YYYYMMDD validity date
-\item[cl4\_sys]
-  The name of the class 4 model system \eg FOAM
-\item[cl4\_cfg]
-  The name of the class 4 model configuration \eg orca025
-\item[cl4\_vn]
-  The name of the class 4 model version \eg 12.0
-\end{description}
-
-\noindent
-The kind is specified by the observation type internally to the obs oper.
-The processor number is specified internally in NEMO. 
-
-\subsubsection{Class 4 file global attributes}
-
-Global attributes necessary to fulfill the class 4 file definition.
-These are also useful pieces of information when collaborating with external partners.
-
-\begin{description}
-\item[cl4\_contact]
-  Contact email for class 4 files.
-\item[cl4\_inst]
-  The name of the producers institution.
-\item[cl4\_cfg]
-  The name of the class 4 model configuration \eg orca025
-\item[cl4\_vn]
-  The name of the class 4 model version \eg 12.0
-\end{description}
-
-\noindent
-The obs\_type, creation date and validity time are specified internally to the obs oper.
-
-\subsubsection{Class 4 model counterpart configuration}
-
-As seen previously it is possible to perform a single sweep of the obs oper and
-specify a collection of model fields equally spaced along that sweep.
-In the class 4 case the single sweep is replaced with multiple sweeps and
-a certain ammount of book keeping is needed to ensure each model counterpart makes its way to
-the correct piece of memory in the output files.
-
-\noindent
-\linebreak
-In terms of book keeping, the offline obs oper needs to know how many full sweeps need to be performed.
-This is specified via the \textbf{cl4\_match\_len} variable and
-is the total number of model counterparts per observation.
-For example, a 3 forecasts plus 3 persistence fields plus an analysis field would be 7 counterparts per observation.
-
-\begin{forlines}
-   cl4_match_len = 7
-\end{forlines}
-
-Then to correctly allocate a class 4 file the forecast axis must be defined.
-This is controlled via \textbf{cl4\_fcst\_len}, which in out above example would be 3.
-
-\begin{forlines}
-   cl4_fcst_len = 3
-\end{forlines}
-
-Then for each model field it is necessary to designate what class 4 variable and index along
-the forecast dimension the model counterpart should be stored in the output file.
-As well as a value for that lead time in hours, this will be useful when interpreting the data afterwards. 
-
-\begin{forlines}
-   cl4_vars = "forecast" "forecast" "forecast" "persistence" "persistence"
-              "persistence" "best_estimate"
-   cl4_fcst_idx = 1 2 3 1 2 3 1
-   cl4_leadtime = 12 36 60 
-\end{forlines}
-
-In terms of files and indices of fields inside each file the class 4 approach makes use of
-the \textbf{namooo} namelist.
-If our fields are in separate files with a single field per file our example inputs will be specified.
-
-\begin{forlines}
-   ooo_files = "F.1.nc" "F.2.nc" "F.3.nc" "P.1.nc" "P.2.nc" "P.3.nc" "A.1.nc"
-   nn_ooo_idx = 1 1 1 1 1 1 1
-\end{forlines}
-
-When we combine all of the naming conventions, global attributes and i/o instructions the class 4 namelist becomes.
-
-\begin{forlines}
-!----------------------------------------------------------------------
-!       namooo Offline obs_oper namelist
-!----------------------------------------------------------------------
-!   ooo_files    specifies the files containing the model counterpart
-!   nn_ooo_idx   specifies the time_counter index within the model file
-!   nn_ooo_freq  specifies number of time steps between read operations
-&namooo
-   ooo_files = "F.1.nc" "F.2.nc" "F.3.nc" "P.1.nc" "P.2.nc" "P.3.nc" "A.1.nc"
-   nn_ooo_idx = 1 1 1 1 1 1 1
-/
-!----------------------------------------------------------------------
-!       namcl4 Offline obs_oper class 4 namelist
-!----------------------------------------------------------------------
-!
-!  Naming convention
-!  -----------------
-!  cl4_prefix    specifies the output file prefix
-!  cl4_date      specifies the output file validity date
-!  cl4_sys       specifies the model counterpart system
-!  cl4_cfg       specifies the model counterpart configuration
-!  cl4_vn        specifies the model counterpart version
-!  cl4_inst      specifies the model counterpart institute
-!  cl4_contact   specifies the file producers contact details
-!
-!  I/O specification
-!  -----------------
-!  cl4_vars      specifies the names of the output file netcdf variable
-!  cl4_fcst_idx  specifies output file forecast index
-!  cl4_fcst_len  specifies forecast axis length
-!  cl4_match_len specifies number of unique matches per observation
-!  cl4_leadtime  specifies the forecast axis lead time 
-!
-&namcl4
-   cl4_match_len = 7
-   cl4_fcst_len = 3
-   cl4_fcst_idx = 1 2 3 1 2 3 1
-   cl4_vars = "forecast" "forecast" "forecast" "persistence" "persistence"
-              "persistence" "best_estimate"
-   cl4_leadtime = 12 36 60
-   cl4_prefix = "class4"
-   cl4_date = "20130101"
-   cl4_vn = "12.0"
-   cl4_sys = "FOAM"
-   cl4_cfg = "AMM7"
-   cl4_contact = "example@example.com"
-   cl4_inst = "UK Met Office"
-/
-\end{forlines}
-
-\subsubsection{Climatology interpolation}
-
-The climatological counterpart is generated at the start of the run by
-restarting the model from climatology through appropriate use of \textbf{namtsd}.
-To override the offline observation operator read routine and to take advantage of the restart settings,
-specify the first entry in \textbf{cl4\_vars} as "climatology".
-This will then pipe the restart from climatology into the output class 4 file.
-As in every other class 4 matchup the input file, input index and output index must be specified.
-These can be replaced with dummy data since they are not used but
-they must be present to cycle through the matchups correctly. 
-
-\subsection{Advanced usage}
-
-In certain cases it may be desirable to include both multiple model fields per observation window with
-multiple match ups per observation.
-This can be achieved by specifying \textbf{nn\_ooo\_freq} as well as the class 4 settings.
-Care must be taken in generating the ooo\_files list such that the files are arranged into
-consecutive blocks of single match ups.
-For example, 2 forecast fields of 12 hourly data would result in 4 separate read operations but
-only 2 write operations, 1 per forecast.
-
-\begin{forlines}
-   ooo_files = "F1.nc" "F1.nc" "F2.nc" "F2.nc"
-...
-   cl4_fcst_idx = 1 2
-\end{forlines}
-
-The above notation reveals the internal split between match up iterators and file iterators.
-This technique has not been used before so experimentation is needed before results can be trusted.
-
-\newpage
-
+If all that is needed is a single model counterpart at a regular interval then
+the standard SAO is all that is required.
+However, just to note, it is possible to extend this approach by comparing multiple forecasts, analyses, persisted analyses and
+climatologies with the same set of observations.
+This approach is referred to as \emph{Class 4} since it is the fourth metric defined by the GODAE intercomparison project. This requires multiple runs of the SAO and running an additional utility (not currently in the \NEMO\ repository) to combine the feedback files into one class 4 file.
+
+%% =================================================================================================
 \section{Observation utilities}
 \label{sec:OBS_obsutils}
 
-Some tools for viewing and processing of observation and feedback files are provided in
-the NEMO repository for convenience.
-These include OBSTOOLS which are a collection of \fortran programs which are helpful to deal with feedback files.
+For convenience some tools for viewing and processing of observation and feedback files are provided in
+the \NEMO\ repository.
+These tools include OBSTOOLS which are a collection of \fortran\ programs which are helpful to deal with feedback files.
 They do such tasks as observation file conversion, printing of file contents,
 some basic statistical analysis of feedback files.
-The other tool is an IDL program called dataplot which uses a graphical interface to
+The other main tool is an IDL program called dataplot which uses a graphical interface to
 visualise observations and feedback files.
 OBSTOOLS and dataplot are described in more detail below.
 
+%% =================================================================================================
 \subsection{Obstools}
 
-A series of \fortran utilities is provided with NEMO called OBSTOOLS.
-This are helpful in handling observation files and the feedback file output from the NEMO observation operator.
-The utilities are as follows
-
-\subsubsection{c4comb}
-
-The program c4comb combines multiple class 4 files produced by individual processors in
-an MPI run of NEMO offline obs\_oper into a single class 4 file.
-The program is called in the following way:
-
-
-\footnotesize
-\begin{cmds}
-c4comb.exe outputfile inputfile1 inputfile2 ...
-\end{cmds}
-
+A series of \fortran\ utilities is provided with \NEMO\ called OBSTOOLS.
+This are helpful in handling observation files and the feedback file output from the observation operator. A brief description of some of the utilities follows
+
+%% =================================================================================================
 \subsubsection{corio2fb}
 
 The program corio2fb converts profile observation files from the Coriolis format to the standard feedback format.
-The program is called in the following way:
-
-\footnotesize
+It is called in the following way:
+
 \begin{cmds}
 corio2fb.exe outputfile inputfile1 inputfile2 ...
 \end{cmds}
 
+%% =================================================================================================
 \subsubsection{enact2fb}
 
 The program enact2fb converts profile observation files from the ENACT format to the standard feedback format.
-The program is called in the following way:
-
-\footnotesize
+It is called in the following way:
+
 \begin{cmds}
 enact2fb.exe outputfile inputfile1 inputfile2 ...
 \end{cmds}
 
+%% =================================================================================================
 \subsubsection{fbcomb}
 
 The program fbcomb combines multiple feedback files produced by individual processors in
-an MPI run of NEMO into a single feedback file.
-The program is called in the following way:
-
-\footnotesize
+an MPI run of \NEMO\ into a single feedback file.
+It is called in the following way:
+
 \begin{cmds}
 fbcomb.exe outputfile inputfile1 inputfile2 ...
 \end{cmds}
 
+%% =================================================================================================
 \subsubsection{fbmatchup}
 
 The program fbmatchup will match observations from two feedback files.
-The program is called in the following way:
-
-\footnotesize
+It is called in the following way:
+
 \begin{cmds}
 fbmatchup.exe outputfile inputfile1 varname1 inputfile2 varname2 ...
 \end{cmds}
 
+%% =================================================================================================
 \subsubsection{fbprint}
 
 The program fbprint will print the contents of a feedback file or files to standard output.
 Selected information can be output using optional arguments.
-The program is called in the following way:
-
-\footnotesize
+It is called in the following way:
+
 \begin{cmds}
 fbprint.exe [options] inputfile
@@ -1246,11 +1038,11 @@
      -B            Select observations based on QC flags
      -u            unsorted
-     -s ID         select station ID  
+     -s ID         select station ID
      -t TYPE       select observation type
-     -v NUM1-NUM2  select variable range to print by number 
+     -v NUM1-NUM2  select variable range to print by number
                       (default all)
-     -a NUM1-NUM2  select additional variable range to print by number 
+     -a NUM1-NUM2  select additional variable range to print by number
                       (default all)
-     -e NUM1-NUM2  select extra variable range to print by number 
+     -e NUM1-NUM2  select extra variable range to print by number
                       (default all)
      -d            output date range
@@ -1259,41 +1051,41 @@
 \end{cmds}
 
+%% =================================================================================================
 \subsubsection{fbsel}
 
 The program fbsel will select or subsample observations.
-The program is called in the following way:
-
-\footnotesize
+It is called in the following way:
+
 \begin{cmds}
 fbsel.exe <input filename> <output filename>
 \end{cmds}
 
+%% =================================================================================================
 \subsubsection{fbstat}
 
 The program fbstat will output summary statistics in different global areas into a number of files.
-The program is called in the following way:
-
-\footnotesize
+It is called in the following way:
+
 \begin{cmds}
 fbstat.exe [-nmlev] <filenames>
 \end{cmds}
 
+%% =================================================================================================
 \subsubsection{fbthin}
 
 The program fbthin will thin the data to 1 degree resolution.
 The code could easily be modified to thin to a different resolution.
-The program is called in the following way:
-
-\footnotesize
+It is called in the following way:
+
 \begin{cmds}
 fbthin.exe inputfile outputfile
 \end{cmds}
 
+%% =================================================================================================
 \subsubsection{sla2fb}
 
 The program sla2fb will convert an AVISO SLA format file to feedback format.
-The program is called in the following way:
-
-\footnotesize
+It is called in the following way:
+
 \begin{cmds}
 sla2fb.exe [-s type] outputfile inputfile1 inputfile2 ...
@@ -1303,25 +1095,28 @@
 \end{cmds}
 
+%% =================================================================================================
 \subsubsection{vel2fb}
 
 The program vel2fb will convert TAO/PIRATA/RAMA currents files to feedback format.
-The program is called in the following way:
-
-\footnotesize
+It is called in the following way:
+
 \begin{cmds}
 vel2fb.exe outputfile inputfile1 inputfile2 ...
 \end{cmds}
 
+%% =================================================================================================
 \subsection{Building the obstools}
 
 To build the obstools use in the tools directory use ./maketools -n OBSTOOLS -m [ARCH].
 
+%% =================================================================================================
 \subsection{Dataplot}
 
 An IDL program called dataplot is included which uses a graphical interface to
-visualise observations and feedback files.
+visualise observations and feedback files. Note a similar package has recently developed in python (also called dataplot) which does some of the same things that the IDL dataplot does. Please contact the authors of the this chapter if you are interested in this.
+
 It is possible to zoom in, plot individual profiles and calculate some basic statistics.
 To plot some data run IDL and then:
-\footnotesize
+
 \begin{minted}{idl}
 IDL> dataplot, "filename"
@@ -1331,5 +1126,5 @@
 for example multiple feedback files from different processors or from different days,
 the easiest method is to use the spawn command to generate a list of files which can then be passed to dataplot.
-\footnotesize
+
 \begin{minted}{idl}
 IDL> spawn, 'ls profb*.nc', files
@@ -1337,5 +1132,5 @@
 \end{minted}
 
-\autoref{fig:obsdataplotmain} shows the main window which is launched when dataplot starts.
+\autoref{fig:OBS_dataplotmain} shows the main window which is launched when dataplot starts.
 This is split into three parts.
 At the top there is a menu bar which contains a variety of drop down menus.
@@ -1350,5 +1145,5 @@
 The plotting colour range can be changed by clicking on the colour bar.
 The title of the plot gives some basic information about the date range and depth range shown,
-the extreme values, and the mean and rms values.
+the extreme values, and the mean and RMS values.
 It is possible to zoom in using a drag-box.
 You may also zoom in or out using the mouse wheel.
@@ -1362,41 +1157,28 @@
 observation minus background value.
 The next group of radio buttons selects the map projection.
-This can either be regular latitude longitude grid, or north or south polar stereographic.
+This can either be regular longitude latitude grid, or north or south polar stereographic.
 The next group of radio buttons will plot bad observations, switch to salinity and
 plot density for profile observations.
 The rightmost group of buttons will print the plot window as a postscript, save it as png, or exit from dataplot.
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}
-  \begin{center}
-    % \includegraphics[width=\textwidth]{Fig_OBS_dataplot_main}
-    \includegraphics[width=\textwidth]{Fig_OBS_dataplot_main}
-    \caption{
-      \protect\label{fig:obsdataplotmain}
-      Main window of dataplot.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{OBS_dataplot_main}
+  \caption{Main window of dataplot}
+  \label{fig:OBS_dataplotmain}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 If a profile point is clicked with the mouse button a plot of the observation and background values as
-a function of depth (\autoref{fig:obsdataplotprofile}).
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+a function of depth (\autoref{fig:OBS_dataplotprofile}).
+
 \begin{figure}
-  \begin{center}
-    % \includegraphics[width=\textwidth]{Fig_OBS_dataplot_prof}
-    \includegraphics[width=\textwidth]{Fig_OBS_dataplot_prof}
-    \caption{
-      \protect\label{fig:obsdataplotprofile}
-      Profile plot from dataplot produced by right clicking on a point in the main window.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{OBS_dataplot_prof}
+  \caption[Profile plot from dataplot]{
+    Profile plot from dataplot produced by right clicking on a point in the main window}
+  \label{fig:OBS_dataplotprofile}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-\biblio
-
-\pindex
+
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_SBC.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_SBC.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_SBC.tex	(revision 12143)
@@ -2,299 +2,272 @@
 
 \begin{document}
-% ================================================================
-% Chapter —— Surface Boundary Condition (SBC, ISF, ICB) 
-% ================================================================
-\chapter{Surface Boundary Condition (SBC, ISF, ICB)}
+
+\chapter{Surface Boundary Condition (SBC, SAS, ISF, ICB)}
 \label{chap:SBC}
-\minitoc
-
-\newpage
-
-%---------------------------------------namsbc--------------------------------------------------
-
-\nlst{namsbc}
-%--------------------------------------------------------------------------------------------------------------
-
-The ocean needs six fields as surface boundary condition:
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+\begin{listing}
+  \nlst{namsbc}
+  \caption{\forcode{&namsbc}}
+  \label{lst:namsbc}
+\end{listing}
+
+The ocean needs seven fields as surface boundary condition:
+
 \begin{itemize}
-\item
-  the two components of the surface ocean stress $\left( {\tau_u \;,\;\tau_v} \right)$
-\item
-  the incoming solar and non solar heat fluxes $\left( {Q_{ns} \;,\;Q_{sr} } \right)$
-\item
-  the surface freshwater budget $\left( {\textit{emp}} \right)$
-\item
-  the surface salt flux associated with freezing/melting of seawater $\left( {\textit{sfx}} \right)$
+\item the two components of the surface ocean stress $\left( {\tau_u \;,\;\tau_v} \right)$
+\item the incoming solar and non solar heat fluxes $\left( {Q_{ns} \;,\;Q_{sr} } \right)$
+\item the surface freshwater budget $\left( {\textit{emp}} \right)$
+\item the surface salt flux associated with freezing/melting of seawater $\left( {\textit{sfx}} \right)$
+\item the atmospheric pressure at the ocean surface $\left( p_a \right)$
 \end{itemize}
-plus an optional field:
+
+Four different ways are available to provide the seven fields to the ocean. They are controlled by
+namelist \nam{sbc}{sbc} variables:
+
 \begin{itemize}
-	\item the atmospheric pressure at the ocean surface $\left( p_a \right)$
+\item a bulk formulation (\np[=.true.]{ln_blk}{ln\_blk} with four possible bulk algorithms),
+\item a flux formulation (\np[=.true.]{ln_flx}{ln\_flx}),
+\item a coupled or mixed forced/coupled formulation (exchanges with a atmospheric model via the OASIS coupler),
+(\np{ln_cpl}{ln\_cpl} or \np[=.true.]{ln_mixcpl}{ln\_mixcpl}),
+\item a user defined formulation (\np[=.true.]{ln_usr}{ln\_usr}).
 \end{itemize}
 
-Four different ways to provide the first six fields to the ocean are available which are controlled by
-namelist \ngn{namsbc} variables:
-an analytical formulation (\np{ln\_ana}\forcode{ = .true.}),
-a flux formulation (\np{ln\_flx}\forcode{ = .true.}),
-a bulk formulae formulation (CORE (\np{ln\_blk\_core}\forcode{ = .true.}),
-CLIO (\np{ln\_blk\_clio}\forcode{ = .true.}) bulk formulae) and
-a coupled or mixed forced/coupled formulation (exchanges with a atmospheric model via the OASIS coupler)
-(\np{ln\_cpl} or \np{ln\_mixcpl}\forcode{ = .true.}). 
-When used (\ie \np{ln\_apr\_dyn}\forcode{ = .true.}),
-the atmospheric pressure forces both ocean and ice dynamics.
-
-The frequency at which the forcing fields have to be updated is given by the \np{nn\_fsbc} namelist parameter.
-When the fields are supplied from data files (flux and bulk formulations),
-the input fields need not be supplied on the model grid.
-Instead a file of coordinates and weights can be supplied which maps the data from the supplied grid to
+The frequency at which the forcing fields have to be updated is given by the \np{nn_fsbc}{nn\_fsbc} namelist parameter.
+
+When the fields are supplied from data files (bulk, flux and mixed formulations),
+the input fields do not need to be supplied on the model grid.
+Instead, a file of coordinates and weights can be supplied to map the data from the input fields grid to
 the model points (so called "Interpolation on the Fly", see \autoref{subsec:SBC_iof}).
-If the Interpolation on the Fly option is used, input data belonging to land points (in the native grid),
-can be masked to avoid spurious results in proximity of the coasts as
+If the "Interpolation on the Fly" option is used, input data belonging to land points (in the native grid)
+should be masked or filled to avoid spurious results in proximity of the coasts, as
 large sea-land gradients characterize most of the atmospheric variables.
 
 In addition, the resulting fields can be further modified using several namelist options.
-These options control 
+These options control:
+
 \begin{itemize}
-\item
-  the rotation of vector components supplied relative to an east-north coordinate system onto
-  the local grid directions in the model;
-\item
-  the addition of a surface restoring term to observed SST and/or SSS (\np{ln\_ssr}\forcode{ = .true.});
-\item
-  the modification of fluxes below ice-covered areas (using observed ice-cover or a sea-ice model)
-  (\np{nn\_ice}\forcode{ = 0..3});
-\item
-  the addition of river runoffs as surface freshwater fluxes or lateral inflow (\np{ln\_rnf}\forcode{ = .true.});
-\item
-  the addition of isf melting as lateral inflow (parameterisation) or
-  as fluxes applied at the land-ice ocean interface (\np{ln\_isf}) ; 
-\item
-  the addition of a freshwater flux adjustment in order to avoid a mean sea-level drift
-  (\np{nn\_fwb}\forcode{ = 0..2});
-\item
-  the transformation of the solar radiation (if provided as daily mean) into a diurnal cycle
-  (\np{ln\_dm2dc}\forcode{ = .true.});
-\item
-  a neutral drag coefficient can be read from an external wave model (\np{ln\_cdgw}\forcode{ = .true.});
-\item
-  the Stokes drift rom an external wave model can be accounted (\np{ln\_sdw}\forcode{ = .true.}); 
-\item
-  the Stokes-Coriolis term can be included (\np{ln\_stcor}\forcode{ = .true.});
-\item
-  the surface stress felt by the ocean can be modified by surface waves (\np{ln\_tauwoc}\forcode{ = .true.}).
+\item the rotation of vector components supplied relative to an east-north coordinate system onto
+  the local grid directions in the model,
+\item the use of a land/sea mask for input fields (\np[=.true.]{nn_lsm}{nn\_lsm}),
+\item the addition of a surface restoring term to observed SST and/or SSS (\np[=.true.]{ln_ssr}{ln\_ssr}),
+\item the modification of fluxes below ice-covered areas (using climatological ice-cover or a sea-ice model)
+  (\np[=0..3]{nn_ice}{nn\_ice}),
+\item the addition of river runoffs as surface freshwater fluxes or lateral inflow (\np[=.true.]{ln_rnf}{ln\_rnf}),
+\item the addition of ice-shelf melting as lateral inflow (parameterisation) or
+  as fluxes applied at the land-ice ocean interface (\np[=.true.]{ln_isf}{ln\_isf}),
+\item the addition of a freshwater flux adjustment in order to avoid a mean sea-level drift
+  (\np[=0..2]{nn_fwb}{nn\_fwb}),
+\item the transformation of the solar radiation (if provided as daily mean) into an analytical diurnal cycle
+  (\np[=.true.]{ln_dm2dc}{ln\_dm2dc}),
+\item the activation of wave effects from an external wave model  (\np[=.true.]{ln_wave}{ln\_wave}),
+\item a neutral drag coefficient is read from an external wave model (\np[=.true.]{ln_cdgw}{ln\_cdgw}),
+\item the Stokes drift from an external wave model is accounted for (\np[=.true.]{ln_sdw}{ln\_sdw}),
+\item the choice of the Stokes drift profile parameterization (\np[=0..2]{nn_sdrift}{nn\_sdrift}),
+\item the surface stress given to the ocean is modified by surface waves (\np[=.true.]{ln_tauwoc}{ln\_tauwoc}),
+\item the surface stress given to the ocean is read from an external wave model (\np[=.true.]{ln_tauw}{ln\_tauw}),
+\item the Stokes-Coriolis term is included (\np[=.true.]{ln_stcor}{ln\_stcor}),
+\item the light penetration in the ocean (\np[=.true.]{ln_traqsr}{ln\_traqsr} with namelist \nam{tra_qsr}{tra\_qsr}),
+\item the atmospheric surface pressure gradient effect on ocean and ice dynamics (\np[=.true.]{ln_apr_dyn}{ln\_apr\_dyn} with namelist \nam{sbc_apr}{sbc\_apr}),
+\item the effect of sea-ice pressure on the ocean (\np[=.true.]{ln_ice_embd}{ln\_ice\_embd}).
 \end{itemize}
 
-In this chapter, we first discuss where the surface boundary condition appears in the model equations.
-Then we present the five ways of providing the surface boundary condition, 
-followed by the description of the atmospheric pressure and the river runoff. 
-Next the scheme for interpolation on the fly is described.
+In this chapter, we first discuss where the surface boundary conditions appear in the model equations.
+Then we present the three ways of providing the surface boundary conditions,
+followed by the description of the atmospheric pressure and the river runoff.
+Next, the scheme for interpolation on the fly is described.
 Finally, the different options that further modify the fluxes applied to the ocean are discussed.
-One of these is modification by icebergs (see \autoref{sec:ICB_icebergs}),
+One of these is modification by icebergs (see \autoref{sec:SBC_ICB_icebergs}),
 which act as drifting sources of fresh water.
-Another example of modification is that due to the ice shelf melting/freezing (see \autoref{sec:SBC_isf}), 
+Another example of modification is that due to the ice shelf melting/freezing (see \autoref{sec:SBC_isf}),
 which provides additional sources of fresh water.
 
-
-% ================================================================
-% Surface boundary condition for the ocean
-% ================================================================
+%% =================================================================================================
 \section{Surface boundary condition for the ocean}
-\label{sec:SBC_general}
+\label{sec:SBC_ocean}
 
 The surface ocean stress is the stress exerted by the wind and the sea-ice on the ocean.
 It is applied in \mdl{dynzdf} module as a surface boundary condition of the computation of
-the momentum vertical mixing trend (see \autoref{eq:dynzdf_sbc} in \autoref{sec:DYN_zdf}).
+the momentum vertical mixing trend (see \autoref{eq:DYN_zdf_sbc} in \autoref{sec:DYN_zdf}).
 As such, it has to be provided as a 2D vector interpolated onto the horizontal velocity ocean mesh,
-\ie resolved onto the model (\textbf{i},\textbf{j}) direction at $u$- and $v$-points.
+\ie\ resolved onto the model (\textbf{i},\textbf{j}) direction at $u$- and $v$-points.
 
 The surface heat flux is decomposed into two parts, a non solar and a solar heat flux,
 $Q_{ns}$ and $Q_{sr}$, respectively.
 The former is the non penetrative part of the heat flux
-(\ie the sum of sensible, latent and long wave heat fluxes plus
-the heat content of the mass exchange with the atmosphere and sea-ice).
+(\ie\ the sum of sensible, latent and long wave heat fluxes plus
+the heat content of the mass exchange between the ocean and sea-ice).
 It is applied in \mdl{trasbc} module as a surface boundary condition trend of
 the first level temperature time evolution equation
-(see \autoref{eq:tra_sbc} and \autoref{eq:tra_sbc_lin} in \autoref{subsec:TRA_sbc}). 
+(see \autoref{eq:TRA_sbc} and \autoref{eq:TRA_sbc_lin} in \autoref{subsec:TRA_sbc}).
 The latter is the penetrative part of the heat flux.
-It is applied as a 3D trends of the temperature equation (\mdl{traqsr} module) when
-\np{ln\_traqsr}\forcode{ = .true.}.
+It is applied as a 3D trend of the temperature equation (\mdl{traqsr} module) when
+\np[=.true.]{ln_traqsr}{ln\_traqsr}.
 The way the light penetrates inside the water column is generally a sum of decreasing exponentials
-(see \autoref{subsec:TRA_qsr}). 
+(see \autoref{subsec:TRA_qsr}).
 
 The surface freshwater budget is provided by the \textit{emp} field.
 It represents the mass flux exchanged with the atmosphere (evaporation minus precipitation) and
 possibly with the sea-ice and ice shelves (freezing minus melting of ice).
-It affects both the ocean in two different ways:
-$(i)$  it changes the volume of the ocean and therefore appears in the sea surface height equation as
-a volume flux, and 
+It affects the ocean in two different ways:
+$(i)$  it changes the volume of the ocean, and therefore appears in the sea surface height equation as		%GS: autoref ssh equation to be added
+a volume flux, and
 $(ii)$ it changes the surface temperature and salinity through the heat and salt contents of
-the mass exchanged with the atmosphere, the sea-ice and the ice shelves. 
-
+the mass exchanged with atmosphere, sea-ice and ice shelves.
 
 %\colorbox{yellow}{Miss: }
-%
-%A extensive description of all namsbc namelist (parameter that have to be 
+%A extensive description of all namsbc namelist (parameter that have to be
 %created!)
-%
-%Especially the \np{nn\_fsbc}, the \mdl{sbc\_oce} module (fluxes + mean sst sss ssu 
-%ssv) \ie information required by flux computation or sea-ice
-%
-%\mdl{sbc\_oce} containt the definition in memory of the 7 fields (6+runoff), add 
+%Especially the \np{nn_fsbc}{nn\_fsbc}, the \mdl{sbc\_oce} module (fluxes + mean sst sss ssu
+%ssv) \ie\ information required by flux computation or sea-ice
+%\mdl{sbc\_oce} containt the definition in memory of the 7 fields (6+runoff), add
 %a word on runoff: included in surface bc or add as lateral obc{\ldots}.
-%
 %Sbcmod manage the ``providing'' (fourniture) to the ocean the 7 fields
-%
-%Fluxes update only each nf{\_}sbc time step (namsbc) explain relation 
-%between nf{\_}sbc and nf{\_}ice, do we define nf{\_}blk??? ? only one 
-%nf{\_}sbc
-%
+%Fluxes update only each nf\_sbc time step (namsbc) explain relation
+%between nf\_sbc and nf\_ice, do we define nf\_blk??? ? only one
+%nf\_sbc
 %Explain here all the namlist namsbc variable{\ldots}.
-% 
 % explain : use or not of surface currents
-%
 %\colorbox{yellow}{End Miss }
 
 The ocean model provides, at each time step, to the surface module (\mdl{sbcmod})
-the surface currents, temperature and salinity.  
-These variables are averaged over \np{nn\_fsbc} time-step (\autoref{tab:ssm}), and
-it is these averaged fields which are used to computes the surface fluxes at a frequency of \np{nn\_fsbc} time-step.
-
-
-%-------------------------------------------------TABLE---------------------------------------------------
+the surface currents, temperature and salinity.
+These variables are averaged over \np{nn_fsbc}{nn\_fsbc} time-step (\autoref{tab:SBC_ssm}), and
+these averaged fields are used to compute the surface fluxes at the frequency of \np{nn_fsbc}{nn\_fsbc} time-steps.
+
 \begin{table}[tb]
-  \begin{center}
-    \begin{tabular}{|l|l|l|l|}
-      \hline
-      Variable description					& Model variable	& Units	& point \\	\hline
-      i-component of the surface current	& ssu\_m	& $m.s^{-1}$	& U \\	\hline
-      j-component of the surface current	& ssv\_m	& $m.s^{-1}$	& V \\	\hline
-      Sea surface temperature				& sst\_m	& \r{}$K$		& T \\	\hline
-      Sea surface salinty					& sss\_m	& $psu$			& T \\	\hline
-    \end{tabular}
-    \caption{
-      \protect\label{tab:ssm}
-      Ocean variables provided by the ocean to the surface module (SBC).
-      The variable are averaged over nn{\_}fsbc time step,
-      \ie the frequency of computation of surface fluxes.
-    }
-  \end{center}
+  \centering
+  \begin{tabular}{|l|l|l|l|}
+    \hline
+    Variable description			                  & Model variable	& Units	& point                 \\
+    \hline
+    i-component of the surface current	& ssu\_m	              & $m.s^{-1}$	    & U     \\
+    \hline
+    j-component of the surface current	& ssv\_m	              & $m.s^{-1}$	    & V     \\
+    \hline
+    Sea surface temperature			         & sst\_m	              & \r{}$K$	             & T     \\\hline
+    Sea surface salinty			                  & sss\_m	              & $psu$		        & T     \\	\hline
+  \end{tabular}
+  \caption[Ocean variables provided to the surface module)]{
+    Ocean variables provided to the surface module (\texttt{SBC}).
+    The variable are averaged over \protect\np{nn_fsbc}{nn\_fsbc} time-step,
+    \ie\ the frequency of computation of surface fluxes.}
+  \label{tab:SBC_ssm}
 \end{table}
-%--------------------------------------------------------------------------------------------------------------
-
-%\colorbox{yellow}{Penser a} mettre dans le restant l'info nn{\_}fsbc ET nn{\_}fsbc*rdt de sorte de reinitialiser la moyenne si on change la frequence ou le pdt
-
-
-% ================================================================
-%       Input Data 
-% ================================================================
+
+%\colorbox{yellow}{Penser a} mettre dans le restant l'info nn\_fsbc ET nn\_fsbc*rdt de sorte de reinitialiser la moyenne si on change la frequence ou le pdt
+
+%% =================================================================================================
 \section{Input data generic interface}
 \label{sec:SBC_input}
 
 A generic interface has been introduced to manage the way input data
-(2D or 3D fields, like surface forcing or ocean T and S) are specify in \NEMO.
-This task is archieved by \mdl{fldread}.
-The module was design with four main objectives in mind: 
+(2D or 3D fields, like surface forcing or ocean T and S) are specified in \NEMO.
+This task is achieved by \mdl{fldread}.
+The module is designed with four main objectives in mind:
 \begin{enumerate}
-\item
-  optionally provide a time interpolation of the input data at model time-step, whatever their input frequency is,
+\item optionally provide a time interpolation of the input data every specified model time-step, whatever their input frequency is,
   and according to the different calendars available in the model.
-\item
-  optionally provide an on-the-fly space interpolation from the native input data grid to the model grid.
-\item
-  make the run duration independent from the period cover by the input files.
-\item
-  provide a simple user interface and a rather simple developer interface by
-  limiting the number of prerequisite information. 
-\end{enumerate}  
-
-As a results the user have only to fill in for each variable a structure in the namelist file to
+\item optionally provide an on-the-fly space interpolation from the native input data grid to the model grid.
+\item make the run duration independent from the period cover by the input files.
+\item provide a simple user interface and a rather simple developer interface by
+  limiting the number of prerequisite informations.
+\end{enumerate}
+
+As a result, the user has only to fill in for each variable a structure in the namelist file to
 define the input data file and variable names, the frequency of the data (in hours or months),
 whether its is climatological data or not, the period covered by the input file (one year, month, week or day),
-and three additional parameters for on-the-fly interpolation.
+and three additional parameters for the on-the-fly interpolation.
 When adding a new input variable, the developer has to add the associated structure in the namelist,
 read this information by mirroring the namelist read in \rou{sbc\_blk\_init} for example,
 and simply call \rou{fld\_read} to obtain the desired input field at the model time-step and grid points.
 
-The only constraints are that the input file is a NetCDF file, the file name follows a nomenclature 
+The only constraints are that the input file is a NetCDF file, the file name follows a nomenclature
 (see \autoref{subsec:SBC_fldread}), the period it cover is one year, month, week or day, and,
 if on-the-fly interpolation is used, a file of weights must be supplied (see \autoref{subsec:SBC_iof}).
 
 Note that when an input data is archived on a disc which is accessible directly from the workspace where
-the code is executed, then the use can set the \np{cn\_dir} to the pathway leading to the data.
-By default, the data are assumed to have been copied so that cn\_dir='./'.
-
-% -------------------------------------------------------------------------------------------------------------
-% Input Data specification (\mdl{fldread})
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Input data specification (\textit{fldread.F90})]
-{Input data specification (\protect\mdl{fldread})}
+the code is executed, then the user can set the \np{cn_dir}{cn\_dir} to the pathway leading to the data.
+By default, the data are assumed to be in the same directory as the executable, so that cn\_dir='./'.
+
+%% =================================================================================================
+\subsection[Input data specification (\textit{fldread.F90})]{Input data specification (\protect\mdl{fldread})}
 \label{subsec:SBC_fldread}
 
 The structure associated with an input variable contains the following information:
 \begin{forlines}
-!  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask ! 
+!  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
 \end{forlines}
-where 
-\begin{description}  
-\item[File name]:
-  the stem name of the NetCDF file to be open.
+where
+\begin{description}
+\item [File name]: the stem name of the NetCDF file to be opened.
   This stem will be completed automatically by the model, with the addition of a '.nc' at its end and
   by date information and possibly a prefix (when using AGRIF).
-  Tab.\autoref{tab:fldread} provides the resulting file name in all possible cases according to
+  \autoref{tab:SBC_fldread} provides the resulting file name in all possible cases according to
   whether it is a climatological file or not, and to the open/close frequency (see below for definition).
-
-%--------------------------------------------------TABLE--------------------------------------------------
   \begin{table}[htbp]
-    \begin{center}
-      \begin{tabular}{|l|c|c|c|}
-        \hline
-        & daily or weekLLL	        & monthly                   &   yearly          \\   \hline
-        \np{clim}\forcode{ = .false.}	& fn\_yYYYYmMMdDD.nc  &   fn\_yYYYYmMM.nc   &   fn\_yYYYY.nc  \\   \hline
-        \np{clim}\forcode{ = .true.}	 	   & not possible 	              &  fn\_m??.nc             &   fn                \\   \hline
-      \end{tabular}
-    \end{center}
-    \caption{
-      \protect\label{tab:fldread}
-      naming nomenclature for climatological or interannual input file, as a function of the Open/close frequency.
+    \centering
+    \begin{tabular}{|l|c|c|c|}
+      \hline
+                                  &  daily or weekLL     &  monthly           &  yearly        \\
+      \hline
+      \np[=.false.]{clim}{clim} &  fn\_yYYYYmMMdDD.nc  &  fn\_yYYYYmMM.nc   &  fn\_yYYYY.nc  \\
+      \hline
+      \np[=.true.]{clim}{clim}  &  not possible        &  fn\_m??.nc        &  fn            \\
+      \hline
+    \end{tabular}
+    \caption[Naming nomenclature for climatological or interannual input file]{
+      Naming nomenclature for climatological or interannual input file,
+      as a function of the open/close frequency.
       The stem name is assumed to be 'fn'.
       For weekly files, the 'LLL' corresponds to the first three letters of the first day of the week
-      (\ie 'sun','sat','fri','thu','wed','tue','mon').
-      The 'YYYY', 'MM' and 'DD' should be replaced by the actual year/month/day, always coded with 4 or 2 digits.
-      Note that (1) in mpp, if the file is split over each subdomain, the suffix '.nc' is replaced by '\_PPPP.nc',
+      (\ie\ 'sun','sat','fri','thu','wed','tue','mon').
+      The 'YYYY', 'MM' and 'DD' should be replaced by the actual year/month/day,
+      always coded with 4 or 2 digits.
+      Note that (1) in mpp, if the file is split over each subdomain,
+      the suffix '.nc' is replaced by '\_PPPP.nc',
       where 'PPPP' is the process number coded with 4 digits;
-      (2) when using AGRIF, the prefix '\_N' is added to files, where 'N'  is the child grid number.
+      (2) when using AGRIF, the prefix '\_N' is added to files, where 'N' is the child grid number.
     }
+    \label{tab:SBC_fldread}
   \end{table}
-%--------------------------------------------------------------------------------------------------------------
-  
-
-\item[Record frequency]:
-  the frequency of the records contained in the input file.
+\item [Record frequency]: the frequency of the records contained in the input file.
   Its unit is in hours if it is positive (for example 24 for daily forcing) or in months if negative
   (for example -1 for monthly forcing or -12 for annual forcing).
-  Note that this frequency must really be an integer and not a real.
-  On some computers, seting it to '24.' can be interpreted as 240!
-
-\item[Variable name]:
-  the name of the variable to be read in the input NetCDF file.
-
-\item[Time interpolation]:
-  a logical to activate, or not, the time interpolation.
+  Note that this frequency must REALLY be an integer and not a real.
+  On some computers, setting it to '24.' can be interpreted as 240!
+\item [Variable name]: the name of the variable to be read in the input NetCDF file.
+\item [Time interpolation]: a logical to activate, or not, the time interpolation.
   If set to 'false', the forcing will have a steplike shape remaining constant during each forcing period.
   For example, when using a daily forcing without time interpolation, the forcing remaining constant from
   00h00'00'' to 23h59'59".
   If set to 'true', the forcing will have a broken line shape.
-  Records are assumed to be dated the middle of the forcing period.
+  Records are assumed to be dated at the middle of the forcing period.
   For example, when using a daily forcing with time interpolation,
-  linear interpolation will be performed between mid-day of two consecutive days. 
-
-\item[Climatological forcing]:
-  a logical to specify if a input file contains climatological forcing which can be cycle in time,
+  linear interpolation will be performed between mid-day of two consecutive days.
+\item [Climatological forcing]: a logical to specify if a input file contains climatological forcing which can be cycle in time,
   or an interannual forcing which will requires additional files if
-  the period covered by the simulation exceed the one of the file.
-  See the above the file naming strategy which impacts the expected name of the file to be opened. 
-
-\item[Open/close frequency]:
-  the frequency at which forcing files must be opened/closed.
+  the period covered by the simulation exceeds the one of the file.
+  See the above file naming strategy which impacts the expected name of the file to be opened.
+\item [Open/close frequency]: the frequency at which forcing files must be opened/closed.
   Four cases are coded:
   'daily', 'weekLLL' (with 'LLL' the first 3 letters of the first day of the week), 'monthly' and 'yearly' which
@@ -302,10 +275,7 @@
   Files are assumed to contain data from the beginning of the open/close period.
   For example, the first record of a yearly file containing daily data is Jan 1st even if
-  the experiment is not starting at the beginning of the year. 
-
-\item[Others]:
-  'weights filename', 'pairing rotation' and 'land/sea mask' are associated with
+  the experiment is not starting at the beginning of the year.
+\item [Others]:  'weights filename', 'pairing rotation' and 'land/sea mask' are associated with
   on-the-fly interpolation which is described in \autoref{subsec:SBC_iof}.
-
 \end{description}
 
@@ -315,38 +285,35 @@
 the date of the records read in the input files.
 Following \citet{leclair.madec_OM09}, the date of a time step is set at the middle of the time step.
-For example, for an experiment starting at 0h00'00" with a one hour time-step,
+For example, for an experiment starting at 0h00'00" with a one-hour time-step,
 a time interpolation will be performed at the following time: 0h30'00", 1h30'00", 2h30'00", etc.
 However, for forcing data related to the surface module,
-values are not needed at every time-step but at every \np{nn\_fsbc} time-step.
-For example with \np{nn\_fsbc}\forcode{ = 3}, the surface module will be called at time-steps 1, 4, 7, etc.
-The date used for the time interpolation is thus redefined to be at the middle of \np{nn\_fsbc} time-step period.
-In the previous example, this leads to: 1h30'00", 4h30'00", 7h30'00", etc. \\ 
+values are not needed at every time-step but at every \np{nn_fsbc}{nn\_fsbc} time-step.
+For example with \np[=3]{nn_fsbc}{nn\_fsbc}, the surface module will be called at time-steps 1, 4, 7, etc.
+The date used for the time interpolation is thus redefined to the middle of \np{nn_fsbc}{nn\_fsbc} time-step period.
+In the previous example, this leads to: 1h30'00", 4h30'00", 7h30'00", etc. \\
 (2) For code readablility and maintenance issues, we don't take into account the NetCDF input file calendar.
 The calendar associated with the forcing field is build according to the information provided by
 user in the record frequency, the open/close frequency and the type of temporal interpolation.
 For example, the first record of a yearly file containing daily data that will be interpolated in time is assumed to
-be start Jan 1st at 12h00'00" and end Dec 31st at 12h00'00". \\
+start Jan 1st at 12h00'00" and end Dec 31st at 12h00'00". \\
 (3) If a time interpolation is requested, the code will pick up the needed data in the previous (next) file when
 interpolating data with the first (last) record of the open/close period.
-For example, if the input file specifications are ''yearly, containing daily data to be interpolated in time'', 
+For example, if the input file specifications are ''yearly, containing daily data to be interpolated in time'',
 the values given by the code between 00h00'00" and 11h59'59" on Jan 1st will be interpolated values between
 Dec 31st 12h00'00" and Jan 1st 12h00'00".
 If the forcing is climatological, Dec and Jan will be keep-up from the same year.
 However, if the forcing is not climatological, at the end of
-the open/close period the code will automatically close the current file and open the next one.
+the open/close period, the code will automatically close the current file and open the next one.
 Note that, if the experiment is starting (ending) at the beginning (end) of
-an open/close period we do accept that the previous (next) file is not existing.
+an open/close period, we do accept that the previous (next) file is not existing.
 In this case, the time interpolation will be performed between two identical values.
 For example, when starting an experiment on Jan 1st of year Y with yearly files and daily data to be interpolated,
 we do accept that the file related to year Y-1 is not existing.
 The value of Jan 1st will be used as the missing one for Dec 31st of year Y-1.
-If the file of year Y-1 exists, the code will read its last record. 
+If the file of year Y-1 exists, the code will read its last record.
 Therefore, this file can contain only one record corresponding to Dec 31st,
 a useful feature for user considering that it is too heavy to manipulate the complete file for year Y-1.
 
-
-% -------------------------------------------------------------------------------------------------------------
-% Interpolation on the Fly
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \subsection{Interpolation on-the-fly}
 \label{subsec:SBC_iof}
@@ -354,11 +321,11 @@
 Interpolation on the Fly allows the user to supply input files required for the surface forcing on
 grids other than the model grid.
-To do this he or she must supply, in addition to the source data file, a file of weights to be used to
+To do this, he or she must supply, in addition to the source data file(s), a file of weights to be used to
 interpolate from the data grid to the model grid.
 The original development of this code used the SCRIP package
 (freely available \href{http://climate.lanl.gov/Software/SCRIP}{here} under a copyright agreement).
-In principle, any package can be used to generate the weights, but the variables in
+In principle, any package such as CDO can be used to generate the weights, but the variables in
 the input weights file must have the same names and meanings as assumed by the model.
-Two methods are currently available: bilinear and bicubic interpolation.
+Two methods are currently available: bilinear and bicubic interpolations.
 Prior to the interpolation, providing a land/sea mask file, the user can decide to remove land points from
 the input file and substitute the corresponding values with the average of the 8 neighbouring points in
@@ -366,9 +333,10 @@
 Only "sea points" are considered for the averaging.
 The land/sea mask file must be provided in the structure associated with the input variable.
-The netcdf land/sea mask variable name must be 'LSM' it must have the same horizontal and vertical dimensions of
-the associated variable and should be equal to 1 over land and 0 elsewhere.
-The procedure can be recursively applied setting nn\_lsm > 1 in namsbc namelist.
-Note that nn\_lsm=0 forces the code to not apply the procedure even if a file for land/sea mask is supplied.
-
+The netcdf land/sea mask variable name must be 'LSM' and must have the same horizontal and vertical dimensions as
+the associated variables and should be equal to 1 over land and 0 elsewhere.
+The procedure can be recursively applied by setting nn\_lsm > 1 in namsbc namelist.
+Note that nn\_lsm=0 forces the code to not apply the procedure, even if a land/sea mask file is supplied.
+
+%% =================================================================================================
 \subsubsection{Bilinear interpolation}
 \label{subsec:SBC_iof_bilinear}
@@ -376,5 +344,5 @@
 The input weights file in this case has two sets of variables:
 src01, src02, src03, src04 and wgt01, wgt02, wgt03, wgt04.
-The "src" variables correspond to the point in the input grid to which the weight "wgt" is to be applied.
+The "src" variables correspond to the point in the input grid to which the weight "wgt" is applied.
 Each src value is an integer corresponding to the index of a point in the input grid when
 written as a one dimensional array.
@@ -392,9 +360,10 @@
 and wgt(1) corresponds to variable "wgt01" for example.
 
+%% =================================================================================================
 \subsubsection{Bicubic interpolation}
 \label{subsec:SBC_iof_bicubic}
 
-Again there are two sets of variables: "src" and "wgt".
-But in this case there are 16 of each.
+Again, there are two sets of variables: "src" and "wgt".
+But in this case, there are 16 of each.
 The symbolic algorithm used to calculate values on the model grid is now:
 
@@ -402,12 +371,13 @@
   \begin{split}
     f_{m}(i,j) =  f_{m}(i,j) +& \sum_{k=1}^{4} {wgt(k)f(idx(src(k)))}
-    +   \sum_{k=5}^{8} {wgt(k)\left.\frac{\partial f}{\partial i}\right| _{idx(src(k))} }    \\
-    +& \sum_{k=9}^{12} {wgt(k)\left.\frac{\partial f}{\partial j}\right| _{idx(src(k))} }
-    +   \sum_{k=13}^{16} {wgt(k)\left.\frac{\partial ^2 f}{\partial i \partial j}\right| _{idx(src(k))} }
+    +  \sum_{k=5 }^{8 } {wgt(k)\left.\frac{\partial f}{\partial i}\right| _{idx(src(k))} }    \\
+    +& \sum_{k=9 }^{12} {wgt(k)\left.\frac{\partial f}{\partial j}\right| _{idx(src(k))} }
+    +  \sum_{k=13}^{16} {wgt(k)\left.\frac{\partial ^2 f}{\partial i \partial j}\right| _{idx(src(k))} }
   \end{split}
 \]
 The gradients here are taken with respect to the horizontal indices and not distances since
-the spatial dependency has been absorbed into the weights.
-
+the spatial dependency has been included into the weights.
+
+%% =================================================================================================
 \subsubsection{Implementation}
 \label{subsec:SBC_iof_imp}
@@ -421,12 +391,12 @@
 inspecting a global attribute stored in the weights input file.
 This attribute must be called "ew\_wrap" and be of integer type.
-If it is negative, the input non-model grid is assumed not to be cyclic.
+If it is negative, the input non-model grid is assumed to be not cyclic.
 If zero or greater, then the value represents the number of columns that overlap.
 $E.g.$ if the input grid has columns at longitudes 0, 1, 2, .... , 359, then ew\_wrap should be set to 0;
 if longitudes are 0.5, 2.5, .... , 358.5, 360.5, 362.5, ew\_wrap should be 2.
 If the model does not find attribute ew\_wrap, then a value of -999 is assumed.
-In this case the \rou{fld\_read} routine defaults ew\_wrap to value 0 and
+In this case, the \rou{fld\_read} routine defaults ew\_wrap to value 0 and
 therefore the grid is assumed to be cyclic with no overlapping columns.
-(In fact this only matters when bicubic interpolation is required.)
+(In fact, this only matters when bicubic interpolation is required.)
 Note that no testing is done to check the validity in the model,
 since there is no way of knowing the name used for the longitude variable,
@@ -445,23 +415,20 @@
 or is a copy of one from the first few columns on the opposite side of the grid (cyclical case).
 
+%% =================================================================================================
 \subsubsection{Limitations}
 \label{subsec:SBC_iof_lim}
 
-\begin{enumerate}  
-\item
-  The case where input data grids are not logically rectangular has not been tested.
-\item
-  This code is not guaranteed to produce positive definite answers from positive definite inputs when
+\begin{enumerate}
+\item The case where input data grids are not logically rectangular (irregular grid case) has not been tested.
+\item This code is not guaranteed to produce positive definite answers from positive definite inputs when
   a bicubic interpolation method is used.
-\item
-  The cyclic condition is only applied on left and right columns, and not to top and bottom rows.
-\item
-  The gradients across the ends of a cyclical grid assume that the grid spacing between
+\item The cyclic condition is only applied on left and right columns, and not to top and bottom rows.
+\item The gradients across the ends of a cyclical grid assume that the grid spacing between
   the two columns involved are consistent with the weights used.
-\item
-  Neither interpolation scheme is conservative. (There is a conservative scheme available in SCRIP,
+\item Neither interpolation scheme is conservative. (There is a conservative scheme available in SCRIP,
   but this has not been implemented.)
 \end{enumerate}
 
+%% =================================================================================================
 \subsubsection{Utilities}
 \label{subsec:SBC_iof_util}
@@ -471,65 +438,47 @@
 (see the directory NEMOGCM/TOOLS/WEIGHTS).
 
-% -------------------------------------------------------------------------------------------------------------
-% Standalone Surface Boundary Condition Scheme
-% -------------------------------------------------------------------------------------------------------------
-\subsection{Standalone surface boundary condition scheme}
-\label{subsec:SAS_iof}
-
-%---------------------------------------namsbc_ana--------------------------------------------------
-
-\nlst{namsbc_sas}
-%--------------------------------------------------------------------------------------------------------------
-
-In some circumstances it may be useful to avoid calculating the 3D temperature,
-salinity and velocity fields and simply read them in from a previous run or receive them from OASIS.  
+%% =================================================================================================
+\subsection{Standalone surface boundary condition scheme (SAS)}
+\label{subsec:SBC_SAS}
+
+\begin{listing}
+  \nlst{namsbc_sas}
+  \caption{\forcode{&namsbc_sas}}
+  \label{lst:namsbc_sas}
+\end{listing}
+
+In some circumstances, it may be useful to avoid calculating the 3D temperature,
+salinity and velocity fields and simply read them in from a previous run or receive them from OASIS.
 For example:
 
 \begin{itemize}
-\item
-  Multiple runs of the model are required in code development to
+\item Multiple runs of the model are required in code development to
   see the effect of different algorithms in the bulk formulae.
-\item
-  The effect of different parameter sets in the ice model is to be examined.
-\item
-  Development of sea-ice algorithms or parameterizations.
-\item
-  Spinup of the iceberg floats
-\item
-  Ocean/sea-ice simulation with both media running in parallel (\np{ln\_mixcpl}\forcode{ = .true.})
+\item The effect of different parameter sets in the ice model is to be examined.
+\item Development of sea-ice algorithms or parameterizations.
+\item Spinup of the iceberg floats
+\item Ocean/sea-ice simulation with both models running in parallel (\np[=.true.]{ln_mixcpl}{ln\_mixcpl})
 \end{itemize}
 
-The StandAlone Surface scheme provides this utility.
-Its options are defined through the \ngn{namsbc\_sas} namelist variables.
+The Standalone Surface scheme provides this capacity.
+Its options are defined through the \nam{sbc_sas}{sbc\_sas} namelist variables.
 A new copy of the model has to be compiled with a configuration based on ORCA2\_SAS\_LIM.
-However no namelist parameters need be changed from the settings of the previous run (except perhaps nn{\_}date0).
+However, no namelist parameters need be changed from the settings of the previous run (except perhaps nn\_date0).
 In this configuration, a few routines in the standard model are overriden by new versions.
 Routines replaced are:
 
 \begin{itemize}
-\item
-  \mdl{nemogcm}:
-  This routine initialises the rest of the model and repeatedly calls the stp time stepping routine (\mdl{step}).
+\item \mdl{nemogcm}: This routine initialises the rest of the model and repeatedly calls the stp time stepping routine (\mdl{step}).
   Since the ocean state is not calculated all associated initialisations have been removed.
-\item
-  \mdl{step}:
-  The main time stepping routine now only needs to call the sbc routine (and a few utility functions).
-\item
-  \mdl{sbcmod}:
-  This has been cut down and now only calculates surface forcing and the ice model required.
+\item \mdl{step}: The main time stepping routine now only needs to call the sbc routine (and a few utility functions).
+\item \mdl{sbcmod}: This has been cut down and now only calculates surface forcing and the ice model required.
   New surface modules that can function when only the surface level of the ocean state is defined can also be added
-  (\eg icebergs).
-\item
-  \mdl{daymod}:
-  No ocean restarts are read or written (though the ice model restarts are retained),
+  (\eg\ icebergs).
+\item \mdl{daymod}: No ocean restarts are read or written (though the ice model restarts are retained),
   so calls to restart functions have been removed.
   This also means that the calendar cannot be controlled by time in a restart file,
-  so the user must make sure that nn{\_}date0 in the model namelist is correct for his or her purposes.
-\item
-  \mdl{stpctl}:
-  Since there is no free surface solver, references to it have been removed from \rou{stp\_ctl} module.
-\item
-  \mdl{diawri}:
-  All 3D data have been removed from the output.
+  so the user must check that nn\_date0 in the model namelist is correct for his or her purposes.
+\item \mdl{stpctl}: Since there is no free surface solver, references to it have been removed from \rou{stp\_ctl} module.
+\item \mdl{diawri}: All 3D data have been removed from the output.
   The surface temperature, salinity and velocity components (which have been read in) are written along with
   relevant forcing and ice data.
@@ -539,10 +488,8 @@
 
 \begin{itemize}
-\item
-  \mdl{sbcsas}:
-  This module initialises the input files needed for reading temperature, salinity and
+\item \mdl{sbcsas}: This module initialises the input files needed for reading temperature, salinity and
   velocity arrays at the surface.
-  These filenames are supplied in namelist namsbc{\_}sas.
-  Unfortunately because of limitations with the \mdl{iom} module,
+  These filenames are supplied in namelist namsbc\_sas.
+  Unfortunately, because of limitations with the \mdl{iom} module,
   the full 3D fields from the mean files have to be read in and interpolated in time,
   before using just the top level.
@@ -550,51 +497,20 @@
 \end{itemize}
 
-
-% Missing the description of the 2 following variables:
-%   ln_3d_uve   = .true.    !  specify whether we are supplying a 3D u,v and e3 field
-%   ln_read_frq = .false.    !  specify whether we must read frq or not
-
-
-
-% ================================================================
-% Analytical formulation (sbcana module) 
-% ================================================================
-\section[Analytical formulation (\textit{sbcana.F90})]
-{Analytical formulation (\protect\mdl{sbcana})}
-\label{sec:SBC_ana}
-
-%---------------------------------------namsbc_ana--------------------------------------------------
-%
-%\nlst{namsbc_ana}
-%--------------------------------------------------------------------------------------------------------------
-
-The analytical formulation of the surface boundary condition is the default scheme.
-In this case, all the six fluxes needed by the ocean are assumed to be uniform in space.
-They take constant values given in the namelist \ngn{namsbc{\_}ana} by
-the variables \np{rn\_utau0}, \np{rn\_vtau0}, \np{rn\_qns0}, \np{rn\_qsr0}, and \np{rn\_emp0}
-($\textit{emp}=\textit{emp}_S$).
-The runoff is set to zero.
-In addition, the wind is allowed to reach its nominal value within a given number of time steps (\np{nn\_tau000}).
-
-If a user wants to apply a different analytical forcing,
-the \mdl{sbcana} module can be modified to use another scheme.
-As an example, the \mdl{sbc\_ana\_gyre} routine provides the analytical forcing for the GYRE configuration
-(see GYRE configuration manual, in preparation).
-
-
-% ================================================================
-% Flux formulation 
-% ================================================================
-\section[Flux formulation (\textit{sbcflx.F90})]
-{Flux formulation (\protect\mdl{sbcflx})}
+The user can also choose in the \nam{sbc_sas}{sbc\_sas} namelist to read the mean (nn\_fsbc time-step) fraction of solar net radiation absorbed in the 1st T level using
+ (\np[=.true.]{ln_flx}{ln\_flx}) and to provide 3D oceanic velocities instead of 2D ones (\np{ln_flx}{ln\_flx}\forcode{=.true.}). In that last case, only the 1st level will be read in.
+
+%% =================================================================================================
+\section[Flux formulation (\textit{sbcflx.F90})]{Flux formulation (\protect\mdl{sbcflx})}
 \label{sec:SBC_flx}
-%------------------------------------------namsbc_flx----------------------------------------------------
-
-\nlst{namsbc_flx} 
-%-------------------------------------------------------------------------------------------------------------
-
-In the flux formulation (\np{ln\_flx}\forcode{ = .true.}),
+
+\begin{listing}
+  \nlst{namsbc_flx}
+  \caption{\forcode{&namsbc_flx}}
+  \label{lst:namsbc_flx}
+\end{listing}
+
+In the flux formulation (\np[=.true.]{ln_flx}{ln\_flx}),
 the surface boundary condition fields are directly read from input files.
-The user has to define in the namelist \ngn{namsbc{\_}flx} the name of the file,
+The user has to define in the namelist \nam{sbc_flx}{sbc\_flx} the name of the file,
 the name of the variable read in the file, the time frequency at which it is given (in hours),
 and a logical setting whether a time interpolation to the model time step is required for this field.
@@ -604,68 +520,58 @@
 See \autoref{subsec:SBC_ssr} for its specification.
 
-
-% ================================================================
-% Bulk formulation
-% ================================================================
-\section[Bulk formulation {(\textit{sbcblk\{\_core,\_clio\}.F90})}]
-{Bulk formulation {(\protect\mdl{sbcblk\_core}, \protect\mdl{sbcblk\_clio})}}
+%% =================================================================================================
+\section[Bulk formulation (\textit{sbcblk.F90})]{Bulk formulation (\protect\mdl{sbcblk})}
 \label{sec:SBC_blk}
 
-In the bulk formulation, the surface boundary condition fields are computed using bulk formulae and atmospheric fields and ocean (and ice) variables.
+\begin{listing}
+  \nlst{namsbc_blk}
+  \caption{\forcode{&namsbc_blk}}
+  \label{lst:namsbc_blk}
+\end{listing}
+
+In the bulk formulation, the surface boundary condition fields are computed with bulk formulae using atmospheric fields
+and ocean (and sea-ice) variables averaged over \np{nn_fsbc}{nn\_fsbc} time-step.
 
 The atmospheric fields used depend on the bulk formulae used.
-Two bulk formulations are available:
-the CORE and the CLIO bulk formulea.
+In forced mode, when a sea-ice model is used, a specific bulk formulation is used.
+Therefore, different bulk formulae are used for the turbulent fluxes computation
+over the ocean and over sea-ice surface.
+For the ocean, four bulk formulations are available thanks to the \href{https://brodeau.github.io/aerobulk/}{Aerobulk} package (\citet{brodeau.barnier.ea_JPO16}):
+the NCAR (formerly named CORE), COARE 3.0, COARE 3.5 and ECMWF bulk formulae.
 The choice is made by setting to true one of the following namelist variable:
-\np{ln\_core} or \np{ln\_clio}.
-
-Note:
-in forced mode, when a sea-ice model is used, a bulk formulation (CLIO or CORE) have to be used.
-Therefore the two bulk (CLIO and CORE) formulea include the computation of the fluxes over
-both an ocean and an ice surface. 
-
-% -------------------------------------------------------------------------------------------------------------
-%        CORE Bulk formulea
-% -------------------------------------------------------------------------------------------------------------
-\subsection[CORE formulea (\textit{sbcblk\_core.F90}, \forcode{ln_core = .true.})]
-{CORE formulea (\protect\mdl{sbcblk\_core}, \protect\np{ln\_core}\forcode{ = .true.})}
-\label{subsec:SBC_blk_core}
-%------------------------------------------namsbc_core----------------------------------------------------
-%
-%\nlst{namsbc_core}
-%-------------------------------------------------------------------------------------------------------------
-
-The CORE bulk formulae have been developed by \citet{large.yeager_rpt04}.
-They have been designed to handle the CORE forcing, a mixture of NCEP reanalysis and satellite data.
-They use an inertial dissipative method to compute the turbulent transfer coefficients
-(momentum, sensible heat and evaporation) from the 10 metre wind speed, air temperature and specific humidity.
-This \citet{large.yeager_rpt04} dataset is available through
-the \href{http://nomads.gfdl.noaa.gov/nomads/forms/mom4/CORE.html}{GFDL web site}.
-
-Note that substituting ERA40 to NCEP reanalysis fields does not require changes in the bulk formulea themself.
-This is the so-called DRAKKAR Forcing Set (DFS) \citep{brodeau.barnier.ea_OM10}.
-
-Options are defined through the  \ngn{namsbc\_core} namelist variables.
-The required 8 input fields are:
-
-%--------------------------------------------------TABLE--------------------------------------------------
+ \np{ln_NCAR}{ln\_NCAR}, \np{ln_COARE_3p0}{ln\_COARE\_3p0},  \np{ln_COARE_3p5}{ln\_COARE\_3p5} and  \np{ln_ECMWF}{ln\_ECMWF}.
+For sea-ice, three possibilities can be selected:
+a constant transfer coefficient (1.4e-3; default value), \citet{lupkes.gryanik.ea_JGR12} (\np{ln_Cd_L12}{ln\_Cd\_L12}), and \citet{lupkes.gryanik_JGR15} (\np{ln_Cd_L15}{ln\_Cd\_L15}) parameterizations
+
+Common options are defined through the \nam{sbc_blk}{sbc\_blk} namelist variables.
+The required 9 input fields are:
+
 \begin{table}[htbp]
-  \label{tab:CORE}
-  \begin{center}
-    \begin{tabular}{|l|c|c|c|}
-      \hline
-      Variable desciption					& Model variable	& Units	 & point \\		\hline
-      i-component of the 10m air velocity	& utau		& $m.s^{-1}$			& T  \\ 	\hline
-      j-component of the 10m air velocity	& vtau		& $m.s^{-1}$			& T  \\	\hline
-      10m air temperature					& tair		& \r{}$K$				& T 	\\	\hline
-      Specific humidity					& humi		& \%					& T \\		\hline
-      Incoming long wave radiation		& qlw		& $W.m^{-2}$			& T \\		\hline
-      Incoming short wave radiation		& qsr		& $W.m^{-2}$			& T \\		\hline
-      Total precipitation (liquid + solid)	& precip	& $Kg.m^{-2}.s^{-1}$	& T \\ 	\hline
-      Solid precipitation					& snow		& $Kg.m^{-2}.s^{-1}$	& T \\	\hline
+  \centering
+  \begin{tabular}{|l|c|c|c|}
+    \hline
+    Variable description                 & Model variable & Units              & point \\
+    \hline
+    i-component of the 10m air velocity  & utau           & $m.s^{-1}$         & T     \\
+    \hline
+    j-component of the 10m air velocity  & vtau           & $m.s^{-1}$         & T     \\
+    \hline
+    10m air temperature                  & tair           & \r{}$K$            & T     \\
+    \hline
+    Specific humidity                    & humi           & \%                 & T     \\
+    \hline
+    Incoming long wave radiation         & qlw            & $W.m^{-2}$         & T     \\
+    \hline
+    Incoming short wave radiation        & qsr            & $W.m^{-2}$         & T     \\
+    \hline
+    Total precipitation (liquid + solid) & precip         & $Kg.m^{-2}.s^{-1}$ & T     \\
+    \hline
+    Solid precipitation                  & snow           & $Kg.m^{-2}.s^{-1}$ & T     \\
+    \hline
+    Mean sea-level pressure              & slp            & $hPa$              & T     \\
+    \hline
     \end{tabular}
-  \end{center}
+  \label{tab:SBC_BULK}
 \end{table}
-%--------------------------------------------------------------------------------------------------------------
 
 Note that the air velocity is provided at a tracer ocean point, not at a velocity ocean point ($u$- and $v$-points).
@@ -673,118 +579,120 @@
 the ocean grid size is the same or larger than the one of the input atmospheric fields.
 
-The \np{sn\_wndi}, \np{sn\_wndj}, \np{sn\_qsr}, \np{sn\_qlw}, \np{sn\_tair}, \np{sn\_humi}, \np{sn\_prec},
-\np{sn\_snow}, \np{sn\_tdif} parameters describe the fields and the way they have to be used
-(spatial and temporal interpolations). 
-
-\np{cn\_dir} is the directory of location of bulk files
-\np{ln\_taudif} is the flag to specify if we use Hight Frequency (HF) tau information (.true.) or not (.false.)
-\np{rn\_zqt}: is the height of humidity and temperature measurements (m)
-\np{rn\_zu}: is the height of wind measurements (m)
-
-Three multiplicative factors are availables: 
-\np{rn\_pfac} and \np{rn\_efac} allows to adjust (if necessary) the global freshwater budget by
+The \np{sn_wndi}{sn\_wndi}, \np{sn_wndj}{sn\_wndj}, \np{sn_qsr}{sn\_qsr}, \np{sn_qlw}{sn\_qlw}, \np{sn_tair}{sn\_tair}, \np{sn_humi}{sn\_humi}, \np{sn_prec}{sn\_prec},
+\np{sn_snow}{sn\_snow}, \np{sn_tdif}{sn\_tdif} parameters describe the fields and the way they have to be used
+(spatial and temporal interpolations).
+
+\np{cn_dir}{cn\_dir} is the directory of location of bulk files
+\np{ln_taudif}{ln\_taudif} is the flag to specify if we use Hight Frequency (HF) tau information (.true.) or not (.false.)
+\np{rn_zqt}{rn\_zqt}: is the height of humidity and temperature measurements (m)
+\np{rn_zu}{rn\_zu}: is the height of wind measurements (m)
+
+Three multiplicative factors are available:
+\np{rn_pfac}{rn\_pfac} and \np{rn_efac}{rn\_efac} allow to adjust (if necessary) the global freshwater budget by
 increasing/reducing the precipitations (total and snow) and or evaporation, respectively.
-The third one,\np{rn\_vfac}, control to which extend the ice/ocean velocities are taken into account in
+The third one,\np{rn_vfac}{rn\_vfac}, control to which extend the ice/ocean velocities are taken into account in
 the calculation of surface wind stress.
-Its range should be between zero and one, and it is recommended to set it to 0.
-
-% -------------------------------------------------------------------------------------------------------------
-%        CLIO Bulk formulea
-% -------------------------------------------------------------------------------------------------------------
-\subsection[CLIO formulea (\textit{sbcblk\_clio.F90}, \forcode{ln_clio = .true.})]
-{CLIO formulea (\protect\mdl{sbcblk\_clio}, \protect\np{ln\_clio}\forcode{ = .true.})}
-\label{subsec:SBC_blk_clio}
-%------------------------------------------namsbc_clio----------------------------------------------------
-%
-%\nlst{namsbc_clio}
-%-------------------------------------------------------------------------------------------------------------
-
-The CLIO bulk formulae were developed several years ago for the Louvain-la-neuve coupled ice-ocean model
-(CLIO, \cite{goosse.deleersnijder.ea_JGR99}). 
-They are simpler bulk formulae.
-They assume the stress to be known and compute the radiative fluxes from a climatological cloud cover. 
-
-Options are defined through the  \ngn{namsbc\_clio} namelist variables.
-The required 7 input fields are:
-
-%--------------------------------------------------TABLE--------------------------------------------------
-\begin{table}[htbp]
-  \label{tab:CLIO}
-  \begin{center}
-    \begin{tabular}{|l|l|l|l|}
-      \hline
-      Variable desciption				& Model variable	& Units				& point \\	\hline
-      i-component of the ocean stress		& utau			& $N.m^{-2}$			& U \\	\hline
-      j-component of the ocean stress		& vtau			& $N.m^{-2}$			& V \\	\hline
-      Wind speed module					& vatm			& $m.s^{-1}$			& T \\	\hline
-      10m air temperature					& tair			& \r{}$K$				& T \\	\hline
-      Specific humidity						& humi			& \%					& T \\	\hline
-      Cloud cover							& 				& \%					& T \\	\hline
-      Total precipitation (liquid + solid)	& precip		& $Kg.m^{-2}.s^{-1}$	& T \\	\hline
-      Solid precipitation 					& snow			& $Kg.m^{-2}.s^{-1}$	& T \\	\hline
-    \end{tabular}
-  \end{center}
-\end{table}
-%--------------------------------------------------------------------------------------------------------------
+Its range must be between zero and one, and it is recommended to set it to 0 at low-resolution (ORCA2 configuration).
 
 As for the flux formulation, information about the input data required by the model is provided in
-the namsbc\_blk\_core or namsbc\_blk\_clio namelist (see \autoref{subsec:SBC_fldread}). 
-
-% ================================================================
-% Coupled formulation
-% ================================================================
-\section[Coupled formulation (\textit{sbccpl.F90})]
-{Coupled formulation (\protect\mdl{sbccpl})}
+the namsbc\_blk namelist (see \autoref{subsec:SBC_fldread}).
+
+%% =================================================================================================
+\subsection[Ocean-Atmosphere Bulk formulae (\textit{sbcblk\_algo\_coare.F90, sbcblk\_algo\_coare3p5.F90, sbcblk\_algo\_ecmwf.F90, sbcblk\_algo\_ncar.F90})]{Ocean-Atmosphere Bulk formulae (\mdl{sbcblk\_algo\_coare}, \mdl{sbcblk\_algo\_coare3p5}, \mdl{sbcblk\_algo\_ecmwf}, \mdl{sbcblk\_algo\_ncar})}
+\label{subsec:SBC_blk_ocean}
+
+Four different bulk algorithms are available to compute surface turbulent momentum and heat fluxes over the ocean.
+COARE 3.0, COARE 3.5 and ECMWF schemes mainly differ by their roughness lenghts computation and consequently
+their neutral transfer coefficients relationships with neutral wind.
+\begin{itemize}
+\item NCAR (\np[=.true.]{ln_NCAR}{ln\_NCAR}): The NCAR bulk formulae have been developed by \citet{large.yeager_rpt04}.
+  They have been designed to handle the NCAR forcing, a mixture of NCEP reanalysis and satellite data.
+  They use an inertial dissipative method to compute the turbulent transfer coefficients
+  (momentum, sensible heat and evaporation) from the 10m wind speed, air temperature and specific humidity.
+  This \citet{large.yeager_rpt04} dataset is available through
+  the \href{http://nomads.gfdl.noaa.gov/nomads/forms/mom4/NCAR.html}{GFDL web site}.
+  Note that substituting ERA40 to NCEP reanalysis fields does not require changes in the bulk formulea themself.
+  This is the so-called DRAKKAR Forcing Set (DFS) \citep{brodeau.barnier.ea_OM10}.
+\item COARE 3.0 (\np[=.true.]{ln_COARE_3p0}{ln\_COARE\_3p0}): See \citet{fairall.bradley.ea_JC03} for more details
+\item COARE 3.5 (\np[=.true.]{ln_COARE_3p5}{ln\_COARE\_3p5}): See \citet{edson.jampana.ea_JPO13} for more details
+\item ECMWF (\np[=.true.]{ln_ECMWF}{ln\_ECMWF}): Based on \href{https://www.ecmwf.int/node/9221}{IFS (Cy31)} implementation and documentation.
+  Surface roughness lengths needed for the Obukhov length are computed following \citet{beljaars_QJRMS95}.
+\end{itemize}
+
+%% =================================================================================================
+\subsection{Ice-Atmosphere Bulk formulae}
+\label{subsec:SBC_blk_ice}
+
+Surface turbulent fluxes between sea-ice and the atmosphere can be computed in three different ways:
+
+\begin{itemize}
+\item Constant value (\np[ Cd_ice=1.4e-3 ]{constant value}{constant\ value}):
+  default constant value used for momentum and heat neutral transfer coefficients
+\item \citet{lupkes.gryanik.ea_JGR12} (\np[=.true.]{ln_Cd_L12}{ln\_Cd\_L12}):
+  This scheme adds a dependency on edges at leads, melt ponds and flows
+  of the constant neutral air-ice drag. After some approximations,
+  this can be resumed to a dependency on ice concentration (A).
+  This drag coefficient has a parabolic shape (as a function of ice concentration)
+  starting at 1.5e-3 for A=0, reaching 1.97e-3 for A=0.5 and going down 1.4e-3 for A=1.
+  It is theoretically applicable to all ice conditions (not only MIZ).
+\item \citet{lupkes.gryanik_JGR15} (\np[=.true.]{ln_Cd_L15}{ln\_Cd\_L15}):
+  Alternative turbulent transfer coefficients formulation between sea-ice
+  and atmosphere with distinct momentum and heat coefficients depending
+  on sea-ice concentration and atmospheric stability (no melt-ponds effect for now).
+  The parameterization is adapted from ECHAM6 atmospheric model.
+  Compared to Lupkes2012 scheme, it considers specific skin and form drags
+  to compute neutral transfer coefficients for both heat and momentum fluxes.
+  Atmospheric stability effect on transfer coefficient is also taken into account.
+\end{itemize}
+
+%% =================================================================================================
+\section[Coupled formulation (\textit{sbccpl.F90})]{Coupled formulation (\protect\mdl{sbccpl})}
 \label{sec:SBC_cpl}
-%------------------------------------------namsbc_cpl----------------------------------------------------
-
-\nlst{namsbc_cpl} 
-%-------------------------------------------------------------------------------------------------------------
+
+\begin{listing}
+  \nlst{namsbc_cpl}
+  \caption{\forcode{&namsbc_cpl}}
+  \label{lst:namsbc_cpl}
+\end{listing}
 
 In the coupled formulation of the surface boundary condition,
-the fluxes are provided by the OASIS coupler at a frequency which is defined in the OASIS coupler,
+the fluxes are provided by the OASIS coupler at a frequency which is defined in the OASIS coupler namelist,
 while sea and ice surface temperature, ocean and ice albedo, and ocean currents are sent to
 the atmospheric component.
 
 A generalised coupled interface has been developed.
-It is currently interfaced with OASIS-3-MCT (\key{oasis3}).
-It has been successfully used to interface \NEMO to most of the European atmospheric GCM
+It is currently interfaced with OASIS-3-MCT versions 1 to 4 (\key{oasis3}).
+An additional specific CPP key (\key{oa3mct\_v1v2}) is needed for OASIS-3-MCT versions 1 and 2.
+It has been successfully used to interface \NEMO\ to most of the European atmospheric GCM
 (ARPEGE, ECHAM, ECMWF, HadAM, HadGAM, LMDz), as well as to \href{http://wrf-model.org/}{WRF}
 (Weather Research and Forecasting Model).
 
-Note that in addition to the setting of \np{ln\_cpl} to true, the \key{coupled} have to be defined.
-The CPP key is mainly used in sea-ice to ensure that the atmospheric fluxes are actually received by
-the ice-ocean system (no calculation of ice sublimation in coupled mode).
-When PISCES biogeochemical model (\key{top} and \key{pisces}) is also used in the coupled system, 
-the whole carbon cycle is computed by defining \key{cpl\_carbon\_cycle}.
+When PISCES biogeochemical model (\key{top}) is also used in the coupled system,
+the whole carbon cycle is computed.
 In this case, CO$_2$ fluxes will be exchanged between the atmosphere and the ice-ocean system
-(and need to be activated in \ngn{namsbc{\_}cpl} ).
+(and need to be activated in \nam{sbc_cpl}{sbc\_cpl} ).
 
 The namelist above allows control of various aspects of the coupling fields (particularly for vectors) and
 now allows for any coupling fields to have multiple sea ice categories (as required by LIM3 and CICE).
-When indicating a multi-category coupling field in namsbc{\_}cpl the number of categories will be determined by
+When indicating a multi-category coupling field in \nam{sbc_cpl}{sbc\_cpl}, the number of categories will be determined by
 the number used in the sea ice model.
-In some limited cases it may be possible to specify single category coupling fields even when
+In some limited cases, it may be possible to specify single category coupling fields even when
 the sea ice model is running with multiple categories -
-in this case the user should examine the code to be sure the assumptions made are satisfactory.
-In cases where this is definitely not possible the model should abort with an error message.
-The new code has been tested using ECHAM with LIM2, and HadGAM3 with CICE but
-although it will compile with \key{lim3} additional minor code changes may be required to run using LIM3.
-
-
-% ================================================================
-%        Atmospheric pressure
-% ================================================================
-\section[Atmospheric pressure (\textit{sbcapr.F90})]
-{Atmospheric pressure (\protect\mdl{sbcapr})}
+in this case, the user should examine the code to be sure the assumptions made are satisfactory.
+In cases where this is definitely not possible, the model should abort with an error message.
+
+%% =================================================================================================
+\section[Atmospheric pressure (\textit{sbcapr.F90})]{Atmospheric pressure (\protect\mdl{sbcapr})}
 \label{sec:SBC_apr}
-%------------------------------------------namsbc_apr----------------------------------------------------
-
-\nlst{namsbc_apr} 
-%-------------------------------------------------------------------------------------------------------------
+
+\begin{listing}
+  \nlst{namsbc_apr}
+  \caption{\forcode{&namsbc_apr}}
+  \label{lst:namsbc_apr}
+\end{listing}
 
 The optional atmospheric pressure can be used to force ocean and ice dynamics
-(\np{ln\_apr\_dyn}\forcode{ = .true.}, \textit{\ngn{namsbc}} namelist).
-The input atmospheric forcing defined via \np{sn\_apr} structure (\textit{namsbc\_apr} namelist)
+(\np[=.true.]{ln_apr_dyn}{ln\_apr\_dyn}, \nam{sbc}{sbc} namelist).
+The input atmospheric forcing defined via \np{sn_apr}{sn\_apr} structure (\nam{sbc_apr}{sbc\_apr} namelist)
 can be interpolated in time to the model time step, and even in space when the interpolation on-the-fly is used.
 When used to force the dynamics, the atmospheric pressure is further transformed into
@@ -795,36 +703,34 @@
 \]
 where $P_{atm}$ is the atmospheric pressure and $P_o$ a reference atmospheric pressure.
-A value of $101,000~N/m^2$ is used unless \np{ln\_ref\_apr} is set to true.
-In this case $P_o$ is set to the value of $P_{atm}$ averaged over the ocean domain,
-\ie the mean value of $\eta_{ib}$ is kept to zero at all time step.
+A value of $101,000~N/m^2$ is used unless \np{ln_ref_apr}{ln\_ref\_apr} is set to true.
+In this case, $P_o$ is set to the value of $P_{atm}$ averaged over the ocean domain,
+\ie\ the mean value of $\eta_{ib}$ is kept to zero at all time steps.
 
 The gradient of $\eta_{ib}$ is added to the RHS of the ocean momentum equation (see \mdl{dynspg} for the ocean).
 For sea-ice, the sea surface height, $\eta_m$, which is provided to the sea ice model is set to $\eta - \eta_{ib}$
 (see \mdl{sbcssr} module).
-$\eta_{ib}$ can be set in the output.
+$\eta_{ib}$ can be written in the output.
 This can simplify altimetry data and model comparison as
 inverse barometer sea surface height is usually removed from these date prior to their distribution.
 
 When using time-splitting and BDY package for open boundaries conditions,
-the equivalent inverse barometer sea surface height $\eta_{ib}$ can be added to BDY ssh data: 
-\np{ln\_apr\_obc}  might be set to true.
-
-% ================================================================
-%        Surface Tides Forcing
-% ================================================================
-\section[Surface tides (\textit{sbctide.F90})]
-{Surface tides (\protect\mdl{sbctide})}
+the equivalent inverse barometer sea surface height $\eta_{ib}$ can be added to BDY ssh data:
+\np{ln_apr_obc}{ln\_apr\_obc}  might be set to true.
+
+%% =================================================================================================
+\section[Surface tides (\textit{sbctide.F90})]{Surface tides (\protect\mdl{sbctide})}
 \label{sec:SBC_tide}
 
-%------------------------------------------nam_tide---------------------------------------
-
-\nlst{nam_tide}
-%-----------------------------------------------------------------------------------------
+\begin{listing}
+  \nlst{nam_tide}
+  \caption{\forcode{&nam_tide}}
+  \label{lst:nam_tide}
+\end{listing}
 
 The tidal forcing, generated by the gravity forces of the Earth-Moon and Earth-Sun sytems,
-is activated if \np{ln\_tide} and \np{ln\_tide\_pot} are both set to \forcode{.true.} in \ngn{nam\_tide}.
-This translates as an additional barotropic force in the momentum equations \ref{eq:PE_dyn} such that:
+is activated if \np{ln_tide}{ln\_tide} and \np{ln_tide_pot}{ln\_tide\_pot} are both set to \forcode{.true.} in \nam{_tide}{\_tide}.
+This translates as an additional barotropic force in the momentum \autoref{eq:MB_PE_dyn} such that:
 \[
-  % \label{eq:PE_dyn_tides}
+  % \label{eq:SBC_PE_dyn_tides}
   \frac{\partial {\mathrm {\mathbf U}}_h }{\partial t}= ...
   +g\nabla (\Pi_{eq} + \Pi_{sal})
@@ -832,16 +738,16 @@
 where $\Pi_{eq}$ stands for the equilibrium tidal forcing and
 $\Pi_{sal}$ is a self-attraction and loading term (SAL).
- 
+
 The equilibrium tidal forcing is expressed as a sum over a subset of
 constituents chosen from the set of available tidal constituents
-defined in file \rou{SBC/tide.h90} (this comprises the tidal
+defined in file \hf{SBC/tide} (this comprises the tidal
 constituents \textit{M2, N2, 2N2, S2, K2, K1, O1, Q1, P1, M4, Mf, Mm,
   Msqm, Mtm, S1, MU2, NU2, L2}, and \textit{T2}). Individual
 constituents are selected by including their names in the array
-\np{clname} in \ngn{nam\_tide} (e.g., \np{clname(1) = 'M2',
-  clname(2)='S2'} to select solely the tidal consituents \textit{M2}
-and \textit{S2}). Optionally, when \np{ln\_tide\_ramp} is set to
+\np{clname}{clname} in \nam{_tide}{\_tide} (e.g., \np{clname}{clname}\forcode{(1)='M2', }
+\np{clname}{clname}\forcode{(2)='S2'} to select solely the tidal consituents \textit{M2}
+and \textit{S2}). Optionally, when \np{ln_tide_ramp}{ln\_tide\_ramp} is set to
 \forcode{.true.}, the equilibrium tidal forcing can be ramped up
-linearly from zero during the initial \np{rdttideramp} days of the
+linearly from zero during the initial \np{rdttideramp}{rdttideramp} days of the
 model run.
 
@@ -850,53 +756,50 @@
 discussion about the practical implementation of this term).
 Nevertheless, the complex calculations involved would make this
-computationally too expensive.  Here, two options are available:
+computationally too expensive. Here, two options are available:
 $\Pi_{sal}$ generated by an external model can be read in
-(\np{ln\_read\_load=.true.}), or a ``scalar approximation'' can be
-used (\np{ln\_scal\_load=.true.}). In the latter case
+(\np[=.true.]{ln_read_load}{ln\_read\_load}), or a ``scalar approximation'' can be
+used (\np[=.true.]{ln_scal_load}{ln\_scal\_load}). In the latter case
 \[
   \Pi_{sal} = \beta \eta,
 \]
-where $\beta$ (\np{rn\_scal\_load} with a default value of 0.094) is a
+where $\beta$ (\np{rn_scal_load}{rn\_scal\_load} with a default value of 0.094) is a
 spatially constant scalar, often chosen to minimize tidal prediction
-errors. Setting both \np{ln\_read\_load} and \np{ln\_scal\_load} to
+errors. Setting both \np{ln_read_load}{ln\_read\_load} and \np{ln_scal_load}{ln\_scal\_load} to
 \forcode{.false.} removes the SAL contribution.
 
-% ================================================================
-%        River runoffs
-% ================================================================
-\section[River runoffs (\textit{sbcrnf.F90})]
-{River runoffs (\protect\mdl{sbcrnf})}
+%% =================================================================================================
+\section[River runoffs (\textit{sbcrnf.F90})]{River runoffs (\protect\mdl{sbcrnf})}
 \label{sec:SBC_rnf}
-%------------------------------------------namsbc_rnf----------------------------------------------------
-
-\nlst{namsbc_rnf} 
-%-------------------------------------------------------------------------------------------------------------
-
-%River runoff generally enters the ocean at a nonzero depth rather than through the surface. 
+
+\begin{listing}
+  \nlst{namsbc_rnf}
+  \caption{\forcode{&namsbc_rnf}}
+  \label{lst:namsbc_rnf}
+\end{listing}
+
+%River runoff generally enters the ocean at a nonzero depth rather than through the surface.
 %Many models, however, have traditionally inserted river runoff to the top model cell.
-%This was the case in \NEMO prior to the version 3.3. The switch toward a input of runoff 
-%throughout a nonzero depth has been motivated by the numerical and physical problems 
-%that arise when the top grid cells are of the order of one meter. This situation is common in 
-%coastal modelling and becomes more and more often open ocean and climate modelling 
+%This was the case in \NEMO\ prior to the version 3.3. The switch toward a input of runoff
+%throughout a nonzero depth has been motivated by the numerical and physical problems
+%that arise when the top grid cells are of the order of one meter. This situation is common in
+%coastal modelling and becomes more and more often open ocean and climate modelling
 %\footnote{At least a top cells thickness of 1~meter and a 3 hours forcing frequency are
 %required to properly represent the diurnal cycle \citep{bernie.woolnough.ea_JC05}. see also \autoref{fig:SBC_dcy}.}.
 
-
-%To do this we need to treat evaporation/precipitation fluxes and river runoff differently in the 
-%\mdl{tra\_sbc} module.  We decided to separate them throughout the code, so that the variable 
-%\textit{emp} represented solely evaporation minus precipitation fluxes, and a new 2d variable 
-%rnf was added which represents the volume flux of river runoff (in kg/m2s to remain consistent with 
-%emp).  This meant many uses of emp and emps needed to be changed, a list of all modules which use 
+%To do this we need to treat evaporation/precipitation fluxes and river runoff differently in the
+%\mdl{tra\_sbc} module.  We decided to separate them throughout the code, so that the variable
+%\textit{emp} represented solely evaporation minus precipitation fluxes, and a new 2d variable
+%rnf was added which represents the volume flux of river runoff (in kg/m2s to remain consistent with
+%emp).  This meant many uses of emp and emps needed to be changed, a list of all modules which use
 %emp or emps and the changes made are below:
-
 
 %Rachel:
 River runoff generally enters the ocean at a nonzero depth rather than through the surface.
 Many models, however, have traditionally inserted river runoff to the top model cell.
-This was the case in \NEMO prior to the version 3.3,
+This was the case in \NEMO\ prior to the version 3.3,
 and was combined with an option to increase vertical mixing near the river mouth.
 
 However, with this method numerical and physical problems arise when the top grid cells are of the order of one meter.
-This situation is common in coastal modelling and is becoming more common in open ocean and climate modelling 
+This situation is common in coastal modelling and is becoming more common in open ocean and climate modelling
 \footnote{
   At least a top cells thickness of 1~meter and a 3 hours forcing frequency are required to
@@ -909,21 +812,21 @@
 along with the depth (in metres) which the river should be added to.
 
-Namelist variables in \ngn{namsbc\_rnf}, \np{ln\_rnf\_depth}, \np{ln\_rnf\_sal} and
-\np{ln\_rnf\_temp} control whether the river attributes (depth, salinity and temperature) are read in and used.
+Namelist variables in \nam{sbc_rnf}{sbc\_rnf}, \np{ln_rnf_depth}{ln\_rnf\_depth}, \np{ln_rnf_sal}{ln\_rnf\_sal} and
+\np{ln_rnf_temp}{ln\_rnf\_temp} control whether the river attributes (depth, salinity and temperature) are read in and used.
 If these are set as false the river is added to the surface box only, assumed to be fresh (0~psu),
 and/or taken as surface temperature respectively.
 
-The runoff value and attributes are read in in sbcrnf.  
+The runoff value and attributes are read in in sbcrnf.
 For temperature -999 is taken as missing data and the river temperature is taken to
 be the surface temperatue at the river point.
-For the depth parameter a value of -1 means the river is added to the surface box only, 
-and a value of -999 means the river is added through the entire water column. 
+For the depth parameter a value of -1 means the river is added to the surface box only,
+and a value of -999 means the river is added through the entire water column.
 After being read in the temperature and salinity variables are multiplied by the amount of runoff
 (converted into m/s) to give the heat and salt content of the river runoff.
 After the user specified depth is read ini,
-the number of grid boxes this corresponds to is calculated and stored in the variable \np{nz\_rnf}.
+the number of grid boxes this corresponds to is calculated and stored in the variable \np{nz_rnf}{nz\_rnf}.
 The variable \textit{h\_dep} is then calculated to be the depth (in metres) of
 the bottom of the lowest box the river water is being added to
-(\ie the total depth that river water is being added to in the model).
+(\ie\ the total depth that river water is being added to in the model).
 
 The mass/volume addition due to the river runoff is, at each relevant depth level, added to
@@ -931,5 +834,5 @@
 This increases the diffusion term in the vicinity of the river, thereby simulating a momentum flux.
 The sea surface height is calculated using the sum of the horizontal divergence terms,
-and so the river runoff indirectly forces an increase in sea surface height. 
+and so the river runoff indirectly forces an increase in sea surface height.
 
 The \textit{hdivn} terms are used in the tracer advection modules to force vertical velocities.
@@ -944,5 +847,5 @@
 As such the volume of water does not change, but the water is diluted.
 
-For the non-linear free surface case (\key{vvl}), no flux is allowed through the surface.
+For the non-linear free surface case, no flux is allowed through the surface.
 Instead in the surface box (as well as water moving up from the boxes below) a volume of runoff water is added with
 no corresponding heat and salt addition and so as happens in the lower boxes there is a dilution effect.
@@ -953,5 +856,5 @@
 This is done in the same way for both vvl and non-vvl.
 The temperature and salinity are increased through the specified depth according to
-the heat and salt content of the river. 
+the heat and salt content of the river.
 
 In the non-linear free surface case (vvl),
@@ -962,11 +865,10 @@
 
 It is also possible for runnoff to be specified as a negative value for modelling flow through straits,
-\ie modelling the Baltic flow in and out of the North Sea.
+\ie\ modelling the Baltic flow in and out of the North Sea.
 When the flow is out of the domain there is no change in temperature and salinity,
 regardless of the namelist options used,
-as the ocean water leaving the domain removes heat and salt (at the same concentration) with it. 
-
-
-%\colorbox{yellow}{Nevertheless, Pb of vertical resolution and 3D input : increase vertical mixing near river mouths to mimic a 3D river 
+as the ocean water leaving the domain removes heat and salt (at the same concentration) with it.
+
+%\colorbox{yellow}{Nevertheless, Pb of vertical resolution and 3D input : increase vertical mixing near river mouths to mimic a 3D river
 
 %All river runoff and emp fluxes are assumed to be fresh water (zero salinity) and at the same temperature as the sea surface.}
@@ -978,116 +880,120 @@
 %ENDIF
 
-%\gmcomment{  word doc of runoffs:
-%
-%In the current \NEMO setup river runoff is added to emp fluxes, these are then applied at just the sea surface as a volume change (in the variable volume case this is a literal volume change, and in the linear free surface case the free surface is moved) and a salt flux due to the concentration/dilution effect.  There is also an option to increase vertical mixing near river mouths; this gives the effect of having a 3d river.  All river runoff and emp fluxes are assumed to be fresh water (zero salinity) and at the same temperature as the sea surface.
-%Our aim was to code the option to specify the temperature and salinity of river runoff, (as well as the amount), along with the depth that the river water will affect.  This would make it possible to model low salinity outflow, such as the Baltic, and would allow the ocean temperature to be affected by river runoff.  
-
-%The depth option makes it possible to have the river water affecting just the surface layer, throughout depth, or some specified point in between.
-
-%To do this we need to treat evaporation/precipitation fluxes and river runoff differently in the tra_sbc module.  We decided to separate them throughout the code, so that the variable emp represented solely evaporation minus precipitation fluxes, and a new 2d variable rnf was added which represents the volume flux of river runoff (in kg/m2s to remain consistent with emp).  This meant many uses of emp and emps needed to be changed, a list of all modules which use emp or emps and the changes made are below:
-
-%}
-% ================================================================
-%        Ice shelf melting
-% ================================================================
-\section[Ice shelf melting (\textit{sbcisf.F90})]
-{Ice shelf melting (\protect\mdl{sbcisf})}
+\cmtgm{  word doc of runoffs:
+In the current \NEMO\ setup river runoff is added to emp fluxes,
+these are then applied at just the sea surface as a volume change (in the variable volume case
+this is a literal volume change, and in the linear free surface case the free surface is moved)
+and a salt flux due to the concentration/dilution effect.
+There is also an option to increase vertical mixing near river mouths;
+this gives the effect of having a 3d river.
+All river runoff and emp fluxes are assumed to be fresh water (zero salinity) and
+at the same temperature as the sea surface.
+Our aim was to code the option to specify the temperature and salinity of river runoff,
+(as well as the amount), along with the depth that the river water will affect.
+This would make it possible to model low salinity outflow, such as the Baltic,
+and would allow the ocean temperature to be affected by river runoff.
+
+The depth option makes it possible to have the river water affecting just the surface layer,
+throughout depth, or some specified point in between.
+
+To do this we need to treat evaporation/precipitation fluxes and river runoff differently in
+the \mdl{tra_sbc} module.
+We decided to separate them throughout the code,
+so that the variable emp represented solely evaporation minus precipitation fluxes,
+and a new 2d variable rnf was added which represents the volume flux of river runoff
+(in $kg/m^2s$ to remain consistent with $emp$).
+This meant many uses of emp and emps needed to be changed,
+a list of all modules which use $emp$ or $emps$ and the changes made are below:}
+
+%% =================================================================================================
+\section[Ice shelf melting (\textit{sbcisf.F90})]{Ice shelf melting (\protect\mdl{sbcisf})}
 \label{sec:SBC_isf}
-%------------------------------------------namsbc_isf----------------------------------------------------
-
-\nlst{namsbc_isf}
-%--------------------------------------------------------------------------------------------------------
-The namelist variable in \ngn{namsbc}, \np{nn\_isf}, controls the ice shelf representation.
-Description and result of sensitivity test to \np{nn\_isf} are presented in \citet{mathiot.jenkins.ea_GMD17}. 
+
+\begin{listing}
+  \nlst{namsbc_isf}
+  \caption{\forcode{&namsbc_isf}}
+  \label{lst:namsbc_isf}
+\end{listing}
+
+The namelist variable in \nam{sbc}{sbc}, \np{nn_isf}{nn\_isf}, controls the ice shelf representation.
+Description and result of sensitivity test to \np{nn_isf}{nn\_isf} are presented in \citet{mathiot.jenkins.ea_GMD17}.
 The different options are illustrated in \autoref{fig:SBC_isf}.
 
 \begin{description}
-\item[\np{nn\_isf}\forcode{ = 1}]:
-  The ice shelf cavity is represented (\np{ln\_isfcav}\forcode{ = .true.} needed).
+  \item [{\np[=1]{nn_isf}{nn\_isf}}]: The ice shelf cavity is represented (\np[=.true.]{ln_isfcav}{ln\_isfcav} needed).
   The fwf and heat flux are depending of the local water properties.
+
   Two different bulk formulae are available:
 
-	\begin{description}
-	\item[\np{nn\_isfblk}\forcode{ = 1}]:
-     The melt rate is based on a balance between the upward ocean heat flux and
-     the latent heat flux at the ice shelf base. A complete description is available in \citet{hunter_rpt06}.
-	\item[\np{nn\_isfblk}\forcode{ = 2}]:
-     The melt rate and the heat flux are based on a 3 equations formulation
-     (a heat flux budget at the ice base, a salt flux budget at the ice base and a linearised freezing point temperature equation). 
-     A complete description is available in \citet{jenkins_JGR91}.
-	\end{description}
-
-     Temperature and salinity used to compute the melt are the average temperature in the top boundary layer \citet{losch_JGR08}. 
-     Its thickness is defined by \np{rn\_hisf\_tbl}.
-     The fluxes and friction velocity are computed using the mean temperature, salinity and velocity in the the first \np{rn\_hisf\_tbl} m.
-     Then, the fluxes are spread over the same thickness (ie over one or several cells).
-     If \np{rn\_hisf\_tbl} larger than top $e_{3}t$, there is no more feedback between the freezing point at the interface and the the top cell temperature.
-     This can lead to super-cool temperature in the top cell under melting condition.
-     If \np{rn\_hisf\_tbl} smaller than top $e_{3}t$, the top boundary layer thickness is set to the top cell thickness.\\
-
-     Each melt bulk formula depends on a exchange coeficient ($\Gamma^{T,S}$) between the ocean and the ice. 
-     There are 3 different ways to compute the exchange coeficient:
-	\begin{description}
-        \item[\np{nn\_gammablk}\forcode{ = 0}]:
-     The salt and heat exchange coefficients are constant and defined by \np{rn\_gammas0} and \np{rn\_gammat0}. 
-\[
-  % \label{eq:sbc_isf_gamma_iso}
-\gamma^{T} = \np{rn\_gammat0}
-\]
-\[
-\gamma^{S} = \np{rn\_gammas0}
-\]
-     This is the recommended formulation for ISOMIP.
-	\item[\np{nn\_gammablk}\forcode{ = 1}]:
-     The salt and heat exchange coefficients are velocity dependent and defined as
-\[
-\gamma^{T} = \np{rn\_gammat0} \times u_{*} 
-\]
-\[
-\gamma^{S} = \np{rn\_gammas0} \times u_{*}
-\]
-     where $u_{*}$ is the friction velocity in the top boundary layer (ie first \np{rn\_hisf\_tbl} meters).
-     See \citet{jenkins.nicholls.ea_JPO10} for all the details on this formulation. It is the recommended formulation for realistic application.
-	\item[\np{nn\_gammablk}\forcode{ = 2}]:
-     The salt and heat exchange coefficients are velocity and stability dependent and defined as:
-\[
-\gamma^{T,S} = \frac{u_{*}}{\Gamma_{Turb} + \Gamma^{T,S}_{Mole}} 
-\]
-     where $u_{*}$ is the friction velocity in the top boundary layer (ie first \np{rn\_hisf\_tbl} meters),
-     $\Gamma_{Turb}$ the contribution of the ocean stability and
-     $\Gamma^{T,S}_{Mole}$ the contribution of the molecular diffusion.
-     See \citet{holland.jenkins_JPO99} for all the details on this formulation. 
-     This formulation has not been extensively tested in NEMO (not recommended).
-   \end{description}
- \item[\np{nn\_isf}\forcode{ = 2}]:
-   The ice shelf cavity is not represented.
-   The fwf and heat flux are computed using the \citet{beckmann.goosse_OM03} parameterisation of isf melting.
-   The fluxes are distributed along the ice shelf edge between the depth of the average grounding line (GL)
-   (\np{sn\_depmax\_isf}) and the base of the ice shelf along the calving front
-   (\np{sn\_depmin\_isf}) as in (\np{nn\_isf}\forcode{ = 3}).
-   The effective melting length (\np{sn\_Leff\_isf}) is read from a file.
- \item[\np{nn\_isf}\forcode{ = 3}]:
-   The ice shelf cavity is not represented.
-   The fwf (\np{sn\_rnfisf}) is prescribed and distributed along the ice shelf edge between
-   the depth of the average grounding line (GL) (\np{sn\_depmax\_isf}) and
-   the base of the ice shelf along the calving front (\np{sn\_depmin\_isf}).
-   The heat flux ($Q_h$) is computed as $Q_h = fwf \times L_f$.
- \item[\np{nn\_isf}\forcode{ = 4}]:
-   The ice shelf cavity is opened (\np{ln\_isfcav}\forcode{ = .true.} needed).
-   However, the fwf is not computed but specified from file \np{sn\_fwfisf}).
-   The heat flux ($Q_h$) is computed as $Q_h = fwf \times L_f$.
-   As in \np{nn\_isf}\forcode{ = 1}, the fluxes are spread over the top boundary layer thickness (\np{rn\_hisf\_tbl})\\
+  \begin{description}
+  \item [{\np[=1]{nn_isfblk}{nn\_isfblk}}]: The melt rate is based on a balance between the upward ocean heat flux and
+    the latent heat flux at the ice shelf base. A complete description is available in \citet{hunter_rpt06}.
+  \item [{\np[=2]{nn_isfblk}{nn\_isfblk}}]: The melt rate and the heat flux are based on a 3 equations formulation
+    (a heat flux budget at the ice base, a salt flux budget at the ice base and a linearised freezing point temperature equation).
+    A complete description is available in \citet{jenkins_JGR91}.
+  \end{description}
+
+  Temperature and salinity used to compute the melt are the average temperature in the top boundary layer \citet{losch_JGR08}.
+  Its thickness is defined by \np{rn_hisf_tbl}{rn\_hisf\_tbl}.
+  The fluxes and friction velocity are computed using the mean temperature, salinity and velocity in the the first \np{rn_hisf_tbl}{rn\_hisf\_tbl} m.
+  Then, the fluxes are spread over the same thickness (ie over one or several cells).
+  If \np{rn_hisf_tbl}{rn\_hisf\_tbl} larger than top $e_{3}t$, there is no more feedback between the freezing point at the interface and the the top cell temperature.
+  This can lead to super-cool temperature in the top cell under melting condition.
+  If \np{rn_hisf_tbl}{rn\_hisf\_tbl} smaller than top $e_{3}t$, the top boundary layer thickness is set to the top cell thickness.\\
+
+  Each melt bulk formula depends on a exchange coeficient ($\Gamma^{T,S}$) between the ocean and the ice.
+  There are 3 different ways to compute the exchange coeficient:
+  \begin{description}
+  \item [{\np[=0]{nn_gammablk}{nn\_gammablk}}]: The salt and heat exchange coefficients are constant and defined by \np{rn_gammas0}{rn\_gammas0} and \np{rn_gammat0}{rn\_gammat0}.
+    \begin{gather*}
+       % \label{eq:SBC_isf_gamma_iso}
+      \gamma^{T} = rn\_gammat0 \\
+      \gamma^{S} = rn\_gammas0
+    \end{gather*}
+    This is the recommended formulation for ISOMIP.
+  \item [{\np[=1]{nn_gammablk}{nn\_gammablk}}]: The salt and heat exchange coefficients are velocity dependent and defined as
+    \begin{gather*}
+      \gamma^{T} = rn\_gammat0 \times u_{*} \\
+      \gamma^{S} = rn\_gammas0 \times u_{*}
+    \end{gather*}
+    where $u_{*}$ is the friction velocity in the top boundary layer (ie first \np{rn_hisf_tbl}{rn\_hisf\_tbl} meters).
+    See \citet{jenkins.nicholls.ea_JPO10} for all the details on this formulation. It is the recommended formulation for realistic application.
+  \item [{\np[=2]{nn_gammablk}{nn\_gammablk}}]: The salt and heat exchange coefficients are velocity and stability dependent and defined as:
+    \[
+      \gamma^{T,S} = \frac{u_{*}}{\Gamma_{Turb} + \Gamma^{T,S}_{Mole}}
+    \]
+    where $u_{*}$ is the friction velocity in the top boundary layer (ie first \np{rn_hisf_tbl}{rn\_hisf\_tbl} meters),
+    $\Gamma_{Turb}$ the contribution of the ocean stability and
+    $\Gamma^{T,S}_{Mole}$ the contribution of the molecular diffusion.
+    See \citet{holland.jenkins_JPO99} for all the details on this formulation.
+    This formulation has not been extensively tested in \NEMO\ (not recommended).
+  \end{description}
+\item [{\np[=2]{nn_isf}{nn\_isf}}]: The ice shelf cavity is not represented.
+  The fwf and heat flux are computed using the \citet{beckmann.goosse_OM03} parameterisation of isf melting.
+  The fluxes are distributed along the ice shelf edge between the depth of the average grounding line (GL)
+  (\np{sn_depmax_isf}{sn\_depmax\_isf}) and the base of the ice shelf along the calving front
+  (\np{sn_depmin_isf}{sn\_depmin\_isf}) as in (\np[=3]{nn_isf}{nn\_isf}).
+  The effective melting length (\np{sn_Leff_isf}{sn\_Leff\_isf}) is read from a file.
+\item [{\np[=3]{nn_isf}{nn\_isf}}]: The ice shelf cavity is not represented.
+  The fwf (\np{sn_rnfisf}{sn\_rnfisf}) is prescribed and distributed along the ice shelf edge between
+  the depth of the average grounding line (GL) (\np{sn_depmax_isf}{sn\_depmax\_isf}) and
+  the base of the ice shelf along the calving front (\np{sn_depmin_isf}{sn\_depmin\_isf}).
+  The heat flux ($Q_h$) is computed as $Q_h = fwf \times L_f$.
+\item [{\np[=4]{nn_isf}{nn\_isf}}]: The ice shelf cavity is opened (\np[=.true.]{ln_isfcav}{ln\_isfcav} needed).
+  However, the fwf is not computed but specified from file \np{sn_fwfisf}{sn\_fwfisf}).
+  The heat flux ($Q_h$) is computed as $Q_h = fwf \times L_f$.
+  As in \np[=1]{nn_isf}{nn\_isf}, the fluxes are spread over the top boundary layer thickness (\np{rn_hisf_tbl}{rn\_hisf\_tbl})
 \end{description}
 
-$\bullet$ \np{nn\_isf}\forcode{ = 1} and \np{nn\_isf}\forcode{ = 2} compute a melt rate based on
+$\bullet$ \np[=1]{nn_isf}{nn\_isf} and \np[=2]{nn_isf}{nn\_isf} compute a melt rate based on
 the water mass properties, ocean velocities and depth.
 This flux is thus highly dependent of the model resolution (horizontal and vertical),
 realism of the water masses onto the shelf ...\\
 
-$\bullet$ \np{nn\_isf}\forcode{ = 3} and \np{nn\_isf}\forcode{ = 4} read the melt rate from a file.
+$\bullet$ \np[=3]{nn_isf}{nn\_isf} and \np[=4]{nn_isf}{nn\_isf} read the melt rate from a file.
 You have total control of the fwf forcing.
 This can be useful if the water masses on the shelf are not realistic or
 the resolution (horizontal/vertical) are too coarse to have realistic melting or
-for studies where you need to control your heat and fw input.\\ 
+for studies where you need to control your heat and fw input.\\
 
 The ice shelf melt is implemented as a volume flux as for the runoff.
@@ -1096,52 +1002,49 @@
 See the runoff section \autoref{sec:SBC_rnf} for all the details about the divergence correction.\\
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_SBC_isf}
-    \caption{
-      \protect\label{fig:SBC_isf}
-      Illustration the location where the fwf is injected and whether or not the fwf is interactif or not depending of \np{nn\_isf}.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{SBC_isf}
+  \caption[Ice shelf location and fresh water flux definition]{
+    Illustration of the location where the fwf is injected and
+    whether or not the fwf is interactif or not depending of \protect\np{nn_isf}{nn\_isf}.}
+  \label{fig:SBC_isf}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
+
+%% =================================================================================================
 \section{Ice sheet coupling}
 \label{sec:SBC_iscpl}
-%------------------------------------------namsbc_iscpl----------------------------------------------------
-
-\nlst{namsbc_iscpl}
-%--------------------------------------------------------------------------------------------------------
+
+\begin{listing}
+  \nlst{namsbc_iscpl}
+  \caption{\forcode{&namsbc_iscpl}}
+  \label{lst:namsbc_iscpl}
+\end{listing}
+
 Ice sheet/ocean coupling is done through file exchange at the restart step.
 At each restart step:
-\begin{description}
-\item[Step 1]: the ice sheet model send a new bathymetry and ice shelf draft netcdf file.
-\item[Step 2]: a new domcfg.nc file is built using the DOMAINcfg tools.
-\item[Step 3]: NEMO run for a specific period and output the average melt rate over the period.
-\item[Step 4]: the ice sheet model run using the melt rate outputed in step 4.
-\item[Step 5]: go back to 1.
-\end{description}
-
-If \np{ln\_iscpl}\forcode{ = .true.}, the isf draft is assume to be different at each restart step with
+
+\begin{enumerate}
+\item the ice sheet model send a new bathymetry and ice shelf draft netcdf file.
+\item a new domcfg.nc file is built using the DOMAINcfg tools.
+\item \NEMO\ run for a specific period and output the average melt rate over the period.
+\item the ice sheet model run using the melt rate outputed in step 4.
+\item go back to 1.
+\end{enumerate}
+
+If \np[=.true.]{ln_iscpl}{ln\_iscpl}, the isf draft is assume to be different at each restart step with
 potentially some new wet/dry cells due to the ice sheet dynamics/thermodynamics.
 The wetting and drying scheme applied on the restart is very simple and described below for the 6 different possible cases:
+
 \begin{description}
-\item[Thin a cell down]:
-  T/S/ssh are unchanged and U/V in the top cell are corrected to keep the barotropic transport (bt) constant
+\item [Thin a cell down]: T/S/ssh are unchanged and U/V in the top cell are corrected to keep the barotropic transport (bt) constant
   ($bt_b=bt_n$).
-\item[Enlarge  a cell]:
-  See case "Thin a cell down"
-\item[Dry a cell]:
-  mask, T/S, U/V and ssh are set to 0.
+\item [Enlarge  a cell]: See case "Thin a cell down"
+\item [Dry a cell]: mask, T/S, U/V and ssh are set to 0.
   Furthermore, U/V into the water column are modified to satisfy ($bt_b=bt_n$).
-\item[Wet a cell]: 
-  mask is set to 1, T/S is extrapolated from neighbours, $ssh_n = ssh_b$ and U/V set to 0.
-  If no neighbours, T/S is extrapolated from old top cell value. 
+\item [Wet a cell]: mask is set to 1, T/S is extrapolated from neighbours, $ssh_n = ssh_b$ and U/V set to 0.
+  If no neighbours, T/S is extrapolated from old top cell value.
   If no neighbours along i,j and k (both previous test failed), T/S/U/V/ssh and mask are set to 0.
-\item[Dry a column]:
-	mask, T/S, U/V are set to 0 everywhere in the column and ssh set to 0.
-\item[Wet a column]:
-  set mask to 1, T/S is extrapolated from neighbours, ssh is extrapolated from neighbours and U/V set to 0.
+\item [Dry a column]: mask, T/S, U/V are set to 0 everywhere in the column and ssh set to 0.
+\item [Wet a column]: set mask to 1, T/S is extrapolated from neighbours, ssh is extrapolated from neighbours and U/V set to 0.
   If no neighbour, T/S/U/V and mask set to 0.
 \end{description}
@@ -1150,51 +1053,48 @@
 the restart time step is prescribed to be an euler time step instead of a leap frog and $fields_b = fields_n$.\\
 
-The horizontal extrapolation to fill new cell with realistic value is called \np{nn\_drown} times.
-It means that if the grounding line retreat by more than \np{nn\_drown} cells between 2 coupling steps,
+The horizontal extrapolation to fill new cell with realistic value is called \np{nn_drown}{nn\_drown} times.
+It means that if the grounding line retreat by more than \np{nn_drown}{nn\_drown} cells between 2 coupling steps,
 the code will be unable to fill all the new wet cells properly.
 The default number is set up for the MISOMIP idealised experiments.
 This coupling procedure is able to take into account grounding line and calving front migration.
-However, it is a non-conservative processe. 
+However, it is a non-conservative processe.
 This could lead to a trend in heat/salt content and volume.\\
 
 In order to remove the trend and keep the conservation level as close to 0 as possible,
-a simple conservation scheme is available with \np{ln\_hsb}\forcode{ = .true.}.
+a simple conservation scheme is available with \np[=.true.]{ln_hsb}{ln\_hsb}.
 The heat/salt/vol. gain/loss is diagnosed, as well as the location.
-A correction increment is computed and apply each time step during the next \np{rn\_fiscpl} time steps. 
-For safety, it is advised to set \np{rn\_fiscpl} equal to the coupling period (smallest increment possible).
+A correction increment is computed and apply each time step during the next \np{rn_fiscpl}{rn\_fiscpl} time steps.
+For safety, it is advised to set \np{rn_fiscpl}{rn\_fiscpl} equal to the coupling period (smallest increment possible).
 The corrective increment is apply into the cell itself (if it is a wet cell), the neigbouring cells or the closest wet cell (if the cell is now dry).
 
-%
-% ================================================================
-%        Handling of icebergs
-% ================================================================
+%% =================================================================================================
 \section{Handling of icebergs (ICB)}
-\label{sec:ICB_icebergs}
-%------------------------------------------namberg----------------------------------------------------
-
-\nlst{namberg}
-%-------------------------------------------------------------------------------------------------------------
-
-Icebergs are modelled as lagrangian particles in NEMO \citep{marsh.ivchenko.ea_GMD15}.
+\label{sec:SBC_ICB_icebergs}
+
+\begin{listing}
+  \nlst{namberg}
+  \caption{\forcode{&namberg}}
+  \label{lst:namberg}
+\end{listing}
+
+Icebergs are modelled as lagrangian particles in \NEMO\ \citep{marsh.ivchenko.ea_GMD15}.
 Their physical behaviour is controlled by equations as described in \citet{martin.adcroft_OM10} ).
-(Note that the authors kindly provided a copy of their code to act as a basis for implementation in NEMO).
+(Note that the authors kindly provided a copy of their code to act as a basis for implementation in \NEMO).
 Icebergs are initially spawned into one of ten classes which have specific mass and thickness as
-described in the \ngn{namberg} namelist: \np{rn\_initial\_mass} and \np{rn\_initial\_thickness}.
-Each class has an associated scaling (\np{rn\_mass\_scaling}),
+described in the \nam{berg}{berg} namelist: \np{rn_initial_mass}{rn\_initial\_mass} and \np{rn_initial_thickness}{rn\_initial\_thickness}.
+Each class has an associated scaling (\np{rn_mass_scaling}{rn\_mass\_scaling}),
 which is an integer representing how many icebergs of this class are being described as one lagrangian point
 (this reduces the numerical problem of tracking every single iceberg).
-They are enabled by setting \np{ln\_icebergs}\forcode{ = .true.}.
+They are enabled by setting \np[=.true.]{ln_icebergs}{ln\_icebergs}.
 
 Two initialisation schemes are possible.
 \begin{description}
-\item[\np{nn\_test\_icebergs}~$>$~0]
-  In this scheme, the value of \np{nn\_test\_icebergs} represents the class of iceberg to generate
-  (so between 1 and 10), and \np{nn\_test\_icebergs} provides a lon/lat box in the domain at each grid point of
+\item [{\np{nn_test_icebergs}{nn\_test\_icebergs}~$>$~0}] In this scheme, the value of \np{nn_test_icebergs}{nn\_test\_icebergs} represents the class of iceberg to generate
+  (so between 1 and 10), and \np{nn_test_icebergs}{nn\_test\_icebergs} provides a lon/lat box in the domain at each grid point of
   which an iceberg is generated at the beginning of the run.
-  (Note that this happens each time the timestep equals \np{nn\_nit000}.)
-  \np{nn\_test\_icebergs} is defined by four numbers in \np{nn\_test\_box} representing the corners of
+  (Note that this happens each time the timestep equals \np{nn_nit000}{nn\_nit000}.)
+  \np{nn_test_icebergs}{nn\_test\_icebergs} is defined by four numbers in \np{nn_test_box}{nn\_test\_box} representing the corners of
   the geographical box: lonmin,lonmax,latmin,latmax
-\item[\np{nn\_test\_icebergs}\forcode{ = -1}]
-  In this scheme the model reads a calving file supplied in the \np{sn\_icb} parameter.
+\item [{\np[=-1]{nn_test_icebergs}{nn\_test\_icebergs}}] In this scheme, the model reads a calving file supplied in the \np{sn_icb}{sn\_icb} parameter.
   This should be a file with a field on the configuration grid (typically ORCA)
   representing ice accumulation rate at each model point.
@@ -1204,5 +1104,5 @@
   At each time step, a test is performed to see if there is enough ice mass to
   calve an iceberg of each class in order (1 to 10).
-  Note that this is the initial mass multiplied by the number each particle represents (\ie the scaling).
+  Note that this is the initial mass multiplied by the number each particle represents (\ie\ the scaling).
   If there is enough ice, a new iceberg is spawned and the total available ice reduced accordingly.
 \end{description}
@@ -1211,20 +1111,20 @@
 The latter act to disintegrate the iceberg.
 This is either all melted freshwater,
-or (if \np{rn\_bits\_erosion\_fraction}~$>$~0) into melt and additionally small ice bits
+or (if \np{rn_bits_erosion_fraction}{rn\_bits\_erosion\_fraction}~$>$~0) into melt and additionally small ice bits
 which are assumed to propagate with their larger parent and thus delay fluxing into the ocean.
-Melt water (and other variables on the configuration grid) are written into the main NEMO model output files.
+Melt water (and other variables on the configuration grid) are written into the main \NEMO\ model output files.
 
 Extensive diagnostics can be produced.
 Separate output files are maintained for human-readable iceberg information.
-A separate file is produced for each processor (independent of \np{ln\_ctl}).
+A separate file is produced for each processor (independent of \np{ln_ctl}{ln\_ctl}).
 The amount of information is controlled by two integer parameters:
 \begin{description}
-\item[\np{nn\_verbose\_level}] takes a value between one and four and
+\item [{\np{nn_verbose_level}{nn\_verbose\_level}}] takes a value between one and four and
   represents an increasing number of points in the code at which variables are written,
   and an increasing level of obscurity.
-\item[\np{nn\_verbose\_write}] is the number of timesteps between writes
+\item [{\np{nn_verbose_write}{nn\_verbose\_write}}] is the number of timesteps between writes
 \end{description}
 
-Iceberg trajectories can also be written out and this is enabled by setting \np{nn\_sample\_rate}~$>$~0.
+Iceberg trajectories can also be written out and this is enabled by setting \np{nn_sample_rate}{nn\_sample\_rate}~$>$~0.
 A non-zero value represents how many timesteps between writes of information into the output file.
 These output files are in NETCDF format.
@@ -1234,69 +1134,59 @@
 since its trajectory data may be spread across multiple files.
 
-% -------------------------------------------------------------------------------------------------------------
-%        Interactions with waves (sbcwave.F90, ln_wave)
-% -------------------------------------------------------------------------------------------------------------
-\section[Interactions with waves (\textit{sbcwave.F90}, \texttt{ln\_wave})]
-{Interactions with waves (\protect\mdl{sbcwave}, \protect\np{ln\_wave})}
+%% =================================================================================================
+\section[Interactions with waves (\textit{sbcwave.F90}, \forcode{ln_wave})]{Interactions with waves (\protect\mdl{sbcwave}, \protect\np{ln_wave}{ln\_wave})}
 \label{sec:SBC_wave}
-%------------------------------------------namsbc_wave--------------------------------------------------------
-
-\nlst{namsbc_wave}
-%-------------------------------------------------------------------------------------------------------------
-
-Ocean waves represent the interface between the ocean and the atmosphere, so NEMO is extended to incorporate 
-physical processes related to ocean surface waves, namely the surface stress modified by growth and 
-dissipation of the oceanic wave field, the Stokes-Coriolis force and the Stokes drift impact on mass and 
-tracer advection; moreover the neutral surface drag coefficient from a wave model can be used to evaluate 
+
+\begin{listing}
+  \nlst{namsbc_wave}
+  \caption{\forcode{&namsbc_wave}}
+  \label{lst:namsbc_wave}
+\end{listing}
+
+Ocean waves represent the interface between the ocean and the atmosphere, so \NEMO\ is extended to incorporate
+physical processes related to ocean surface waves, namely the surface stress modified by growth and
+dissipation of the oceanic wave field, the Stokes-Coriolis force and the Stokes drift impact on mass and
+tracer advection; moreover the neutral surface drag coefficient from a wave model can be used to evaluate
 the wind stress.
 
-Physical processes related to ocean surface waves can be accounted by setting the logical variable 
-\np{ln\_wave}\forcode{= .true.} in \ngn{namsbc} namelist. In addition, specific flags accounting for 
-different porcesses should be activated as explained in the following sections.
+Physical processes related to ocean surface waves can be accounted by setting the logical variable
+\np[=.true.]{ln_wave}{ln\_wave} in \nam{sbc}{sbc} namelist. In addition, specific flags accounting for
+different processes should be activated as explained in the following sections.
 
 Wave fields can be provided either in forced or coupled mode:
 \begin{description}
-\item[forced mode]: wave fields should be defined through the \ngn{namsbc\_wave} namelist 
-for external data names, locations, frequency, interpolation and all the miscellanous options allowed by 
-Input Data generic Interface (see \autoref{sec:SBC_input}). 
-\item[coupled mode]: NEMO and an external wave model can be coupled by setting \np{ln\_cpl} \forcode{= .true.} 
-in \ngn{namsbc} namelist and filling the \ngn{namsbc\_cpl} namelist.
+\item [forced mode]: wave fields should be defined through the \nam{sbc_wave}{sbc\_wave} namelist
+for external data names, locations, frequency, interpolation and all the miscellanous options allowed by
+Input Data generic Interface (see \autoref{sec:SBC_input}).
+\item [coupled mode]: \NEMO\ and an external wave model can be coupled by setting \np[=.true.]{ln_cpl}{ln\_cpl}
+in \nam{sbc}{sbc} namelist and filling the \nam{sbc_cpl}{sbc\_cpl} namelist.
 \end{description}
 
-
-% ================================================================
-% Neutral drag coefficient from wave model (ln_cdgw)
-
-% ================================================================
-\subsection[Neutral drag coefficient from wave model (\texttt{ln\_cdgw})]
-{Neutral drag coefficient from wave model (\protect\np{ln\_cdgw})}
+%% =================================================================================================
+\subsection[Neutral drag coefficient from wave model (\forcode{ln_cdgw})]{Neutral drag coefficient from wave model (\protect\np{ln_cdgw}{ln\_cdgw})}
 \label{subsec:SBC_wave_cdgw}
 
-The neutral surface drag coefficient provided from an external data source (\ie a wave model), 
-can be used by setting the logical variable \np{ln\_cdgw} \forcode{= .true.} in \ngn{namsbc} namelist. 
-Then using the routine \rou{turb\_ncar} and starting from the neutral drag coefficent provided, 
-the drag coefficient is computed according to the stable/unstable conditions of the 
-air-sea interface following \citet{large.yeager_rpt04}. 
-
-
-% ================================================================
-% 3D Stokes Drift (ln_sdw, nn_sdrift)
-% ================================================================
-\subsection[3D Stokes Drift (\texttt{ln\_sdw}, \texttt{nn\_sdrift})]
-{3D Stokes Drift (\protect\np{ln\_sdw, nn\_sdrift})}
+The neutral surface drag coefficient provided from an external data source (\ie\ a wave model),
+can be used by setting the logical variable \np[=.true.]{ln_cdgw}{ln\_cdgw} in \nam{sbc}{sbc} namelist.
+Then using the routine \rou{sbcblk\_algo\_ncar} and starting from the neutral drag coefficent provided,
+the drag coefficient is computed according to the stable/unstable conditions of the
+air-sea interface following \citet{large.yeager_rpt04}.
+
+%% =================================================================================================
+\subsection[3D Stokes Drift (\forcode{ln_sdw} \& \forcode{nn_sdrift})]{3D Stokes Drift (\protect\np{ln_sdw}{ln\_sdw} \& \np{nn_sdrift}{nn\_sdrift})}
 \label{subsec:SBC_wave_sdw}
 
-The Stokes drift is a wave driven mechanism of mass and momentum transport \citep{stokes_ibk09}. 
-It is defined as the difference between the average velocity of a fluid parcel (Lagrangian velocity) 
-and the current measured at a fixed point (Eulerian velocity). 
-As waves travel, the water particles that make up the waves travel in orbital motions but 
-without a closed path. Their movement is enhanced at the top of the orbit and slowed slightly 
-at the bottom so the result is a net forward motion of water particles, referred to as the Stokes drift. 
-An accurate evaluation of the Stokes drift and the inclusion of related processes may lead to improved 
-representation of surface physics in ocean general circulation models.
-The Stokes drift velocity $\mathbf{U}_{st}$ in deep water can be computed from the wave spectrum and may be written as: 
+The Stokes drift is a wave driven mechanism of mass and momentum transport \citep{stokes_ibk09}.
+It is defined as the difference between the average velocity of a fluid parcel (Lagrangian velocity)
+and the current measured at a fixed point (Eulerian velocity).
+As waves travel, the water particles that make up the waves travel in orbital motions but
+without a closed path. Their movement is enhanced at the top of the orbit and slowed slightly
+at the bottom, so the result is a net forward motion of water particles, referred to as the Stokes drift.
+An accurate evaluation of the Stokes drift and the inclusion of related processes may lead to improved
+representation of surface physics in ocean general circulation models. %GS: reference needed
+The Stokes drift velocity $\mathbf{U}_{st}$ in deep water can be computed from the wave spectrum and may be written as:
 
 \[
-  % \label{eq:sbc_wave_sdw}
+  % \label{eq:SBC_wave_sdw}
   \mathbf{U}_{st} = \frac{16{\pi^3}} {g}
   \int_0^\infty \int_{-\pi}^{\pi} (cos{\theta},sin{\theta}) {f^3}
@@ -1304,25 +1194,25 @@
 \]
 
-where: ${\theta}$ is the wave direction, $f$ is the wave intrinsic frequency, 
-$\mathrm{S}($f$,\theta)$ is the 2D frequency-direction spectrum, 
-$k$ is the mean wavenumber defined as: 
+where: ${\theta}$ is the wave direction, $f$ is the wave intrinsic frequency,
+$\mathrm{S}($f$,\theta)$ is the 2D frequency-direction spectrum,
+$k$ is the mean wavenumber defined as:
 $k=\frac{2\pi}{\lambda}$ (being $\lambda$ the wavelength). \\
 
-In order to evaluate the Stokes drift in a realistic ocean wave field the wave spectral shape is required 
-and its computation quickly becomes expensive as the 2D spectrum must be integrated for each vertical level. 
+In order to evaluate the Stokes drift in a realistic ocean wave field, the wave spectral shape is required
+and its computation quickly becomes expensive as the 2D spectrum must be integrated for each vertical level.
 To simplify, it is customary to use approximations to the full Stokes profile.
-Three possible parameterizations for the calculation for the approximate Stokes drift velocity profile 
-are included in the code through the \np{nn\_sdrift} parameter once provided the surface Stokes drift 
-$\mathbf{U}_{st |_{z=0}}$ which is evaluated by an external wave model that accurately reproduces the wave spectra 
-and makes possible the estimation of the surface Stokes drift for random directional waves in 
+Three possible parameterizations for the calculation for the approximate Stokes drift velocity profile
+are included in the code through the \np{nn_sdrift}{nn\_sdrift} parameter once provided the surface Stokes drift
+$\mathbf{U}_{st |_{z=0}}$ which is evaluated by an external wave model that accurately reproduces the wave spectra
+and makes possible the estimation of the surface Stokes drift for random directional waves in
 realistic wave conditions:
 
 \begin{description}
-\item[\np{nn\_sdrift} = 0]: exponential integral profile parameterization proposed by 
+\item [{\np{nn_sdrift}{nn\_sdrift} = 0}]: exponential integral profile parameterization proposed by
 \citet{breivik.janssen.ea_JPO14}:
 
 \[
-  % \label{eq:sbc_wave_sdw_0a}
-  \mathbf{U}_{st} \cong \mathbf{U}_{st |_{z=0}} \frac{\mathrm{e}^{-2k_ez}} {1-8k_ez} 
+  % \label{eq:SBC_wave_sdw_0a}
+  \mathbf{U}_{st} \cong \mathbf{U}_{st |_{z=0}} \frac{\mathrm{e}^{-2k_ez}} {1-8k_ez}
 \]
 
@@ -1330,18 +1220,18 @@
 
 \[
-  % \label{eq:sbc_wave_sdw_0b}
+  % \label{eq:SBC_wave_sdw_0b}
   k_e = \frac{|\mathbf{U}_{\left.st\right|_{z=0}}|} {|T_{st}|}
   \quad \text{and }\
-  T_{st} = \frac{1}{16} \bar{\omega} H_s^2 
+  T_{st} = \frac{1}{16} \bar{\omega} H_s^2
 \]
 
 where $H_s$ is the significant wave height and $\omega$ is the wave frequency.
 
-\item[\np{nn\_sdrift} = 1]: velocity profile based on the Phillips spectrum which is considered to be a 
-reasonable estimate of the part of the spectrum most contributing to the Stokes drift velocity near the surface
+\item [{\np{nn_sdrift}{nn\_sdrift} = 1}]: velocity profile based on the Phillips spectrum which is considered to be a
+reasonable estimate of the part of the spectrum mostly contributing to the Stokes drift velocity near the surface
 \citep{breivik.bidlot.ea_OM16}:
 
 \[
-  % \label{eq:sbc_wave_sdw_1}
+  % \label{eq:SBC_wave_sdw_1}
   \mathbf{U}_{st} \cong \mathbf{U}_{st |_{z=0}} \Big[exp(2k_pz)-\beta \sqrt{-2 \pi k_pz}
   \textit{ erf } \Big(\sqrt{-2 k_pz}\Big)\Big]
@@ -1350,63 +1240,55 @@
 where $erf$ is the complementary error function and $k_p$ is the peak wavenumber.
 
-\item[\np{nn\_sdrift} = 2]: velocity profile based on the Phillips spectrum as for \np{nn\_sdrift} = 1 
+\item [{\np{nn_sdrift}{nn\_sdrift} = 2}]: velocity profile based on the Phillips spectrum as for \np{nn_sdrift}{nn\_sdrift} = 1
 but using the wave frequency from a wave model.
 
 \end{description}
 
-The Stokes drift enters the wave-averaged momentum equation, as well as the tracer advection equations 
-and its effect on the evolution of the sea-surface height ${\eta}$ is considered as follows: 
+The Stokes drift enters the wave-averaged momentum equation, as well as the tracer advection equations
+and its effect on the evolution of the sea-surface height ${\eta}$ is considered as follows:
 
 \[
-  % \label{eq:sbc_wave_eta_sdw}
+  % \label{eq:SBC_wave_eta_sdw}
   \frac{\partial{\eta}}{\partial{t}} =
   -\nabla_h \int_{-H}^{\eta} (\mathbf{U} + \mathbf{U}_{st}) dz
 \]
 
-The tracer advection equation is also modified in order for Eulerian ocean models to properly account 
-for unresolved wave effect. The divergence of the wave tracer flux equals the mean tracer advection 
-that is induced by the three-dimensional Stokes velocity. 
-The advective equation for a tracer $c$ combining the effects of the mean current and sea surface waves 
-can be formulated as follows: 
+The tracer advection equation is also modified in order for Eulerian ocean models to properly account
+for unresolved wave effect. The divergence of the wave tracer flux equals the mean tracer advection
+that is induced by the three-dimensional Stokes velocity.
+The advective equation for a tracer $c$ combining the effects of the mean current and sea surface waves
+can be formulated as follows:
 
 \[
-  % \label{eq:sbc_wave_tra_sdw}
+  % \label{eq:SBC_wave_tra_sdw}
   \frac{\partial{c}}{\partial{t}} =
   - (\mathbf{U} + \mathbf{U}_{st}) \cdot \nabla{c}
 \]
 
-
-% ================================================================
-% Stokes-Coriolis term (ln_stcor)
-% ================================================================
-\subsection[Stokes-Coriolis term (\texttt{ln\_stcor})]
-{Stokes-Coriolis term (\protect\np{ln\_stcor})}
+%% =================================================================================================
+\subsection[Stokes-Coriolis term (\forcode{ln_stcor})]{Stokes-Coriolis term (\protect\np{ln_stcor}{ln\_stcor})}
 \label{subsec:SBC_wave_stcor}
 
-In a rotating ocean, waves exert a wave-induced stress on the mean ocean circulation which results 
-in a force equal to $\mathbf{U}_{st}$×$f$, where $f$ is the Coriolis parameter. 
-This additional force may have impact on the Ekman turning of the surface current. 
-In order to include this term, once evaluated the Stokes drift (using one of the 3 possible 
-approximations described in \autoref{subsec:SBC_wave_sdw}), 
-\np{ln\_stcor}\forcode{ = .true.} has to be set.
-
-
-% ================================================================
-% Waves modified stress (ln_tauwoc, ln_tauw)
-% ================================================================
-\subsection[Wave modified sress (\texttt{ln\_tauwoc}, \texttt{ln\_tauw})]
-{Wave modified sress (\protect\np{ln\_tauwoc, ln\_tauw})}
+In a rotating ocean, waves exert a wave-induced stress on the mean ocean circulation which results
+in a force equal to $\mathbf{U}_{st}$×$f$, where $f$ is the Coriolis parameter.
+This additional force may have impact on the Ekman turning of the surface current.
+In order to include this term, once evaluated the Stokes drift (using one of the 3 possible
+approximations described in \autoref{subsec:SBC_wave_sdw}),
+\np[=.true.]{ln_stcor}{ln\_stcor} has to be set.
+
+%% =================================================================================================
+\subsection[Wave modified stress (\forcode{ln_tauwoc} \& \forcode{ln_tauw})]{Wave modified sress (\protect\np{ln_tauwoc}{ln\_tauwoc} \& \np{ln_tauw}{ln\_tauw})}
 \label{subsec:SBC_wave_tauw}
 
-The surface stress felt by the ocean is the atmospheric stress minus the net stress going 
-into the waves \citep{janssen.breivik.ea_rpt13}. Therefore, when waves are growing, momentum and energy is spent and is not 
-available for forcing the mean circulation, while in the opposite case of a decaying sea 
-state more momentum is available for forcing the ocean. 
-Only when the sea state is in equilibrium the ocean is forced by the atmospheric stress, 
-but in practice an equilibrium sea state is a fairly rare event. 
-So the atmospheric stress felt by the ocean circulation $\tau_{oc,a}$ can be expressed as: 
+The surface stress felt by the ocean is the atmospheric stress minus the net stress going
+into the waves \citep{janssen.breivik.ea_rpt13}. Therefore, when waves are growing, momentum and energy is spent and is not
+available for forcing the mean circulation, while in the opposite case of a decaying sea
+state, more momentum is available for forcing the ocean.
+Only when the sea state is in equilibrium, the ocean is forced by the atmospheric stress,
+but in practice, an equilibrium sea state is a fairly rare event.
+So the atmospheric stress felt by the ocean circulation $\tau_{oc,a}$ can be expressed as:
 
 \[
-  % \label{eq:sbc_wave_tauoc}
+  % \label{eq:SBC_wave_tauoc}
   \tau_{oc,a} = \tau_a - \tau_w
 \]
@@ -1416,90 +1298,72 @@
 
 \[
-  % \label{eq:sbc_wave_tauw}
+  % \label{eq:SBC_wave_tauw}
   \tau_w = \rho g \int {\frac{dk}{c_p} (S_{in}+S_{nl}+S_{diss})}
 \]
 
 where: $c_p$ is the phase speed of the gravity waves,
-$S_{in}$, $S_{nl}$ and $S_{diss}$ are three source terms that represent 
-the physics of ocean waves. The first one, $S_{in}$, describes the generation 
-of ocean waves by wind and therefore represents the momentum and energy transfer 
-from air to ocean waves; the second term $S_{nl}$ denotes 
-the nonlinear transfer by resonant four-wave interactions; while the third term $S_{diss}$ 
-describes the dissipation of waves by processes such as white-capping, large scale breaking 
+$S_{in}$, $S_{nl}$ and $S_{diss}$ are three source terms that represent
+the physics of ocean waves. The first one, $S_{in}$, describes the generation
+of ocean waves by wind and therefore represents the momentum and energy transfer
+from air to ocean waves; the second term $S_{nl}$ denotes
+the nonlinear transfer by resonant four-wave interactions; while the third term $S_{diss}$
+describes the dissipation of waves by processes such as white-capping, large scale breaking
 eddy-induced damping.
 
-The wave stress derived from an external wave model can be provided either through the normalized 
-wave stress into the ocean by setting \np{ln\_tauwoc}\forcode{ = .true.}, or through the zonal and 
-meridional stress components by setting \np{ln\_tauw}\forcode{ = .true.}.
-
-
-% ================================================================
-% Miscellanea options
-% ================================================================
+The wave stress derived from an external wave model can be provided either through the normalized
+wave stress into the ocean by setting \np[=.true.]{ln_tauwoc}{ln\_tauwoc}, or through the zonal and
+meridional stress components by setting \np[=.true.]{ln_tauw}{ln\_tauw}.
+
+%% =================================================================================================
 \section{Miscellaneous options}
 \label{sec:SBC_misc}
 
-% -------------------------------------------------------------------------------------------------------------
-%        Diurnal cycle
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Diurnal cycle (\textit{sbcdcy.F90})]
-{Diurnal cycle (\protect\mdl{sbcdcy})}
+%% =================================================================================================
+\subsection[Diurnal cycle (\textit{sbcdcy.F90})]{Diurnal cycle (\protect\mdl{sbcdcy})}
 \label{subsec:SBC_dcy}
-%------------------------------------------namsbc_rnf----------------------------------------------------
-%
-\nlst{namsbc} 
-%-------------------------------------------------------------------------------------------------------------
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_SBC_diurnal}
-    \caption{
-      \protect\label{fig:SBC_diurnal}
-      Example of recontruction of the diurnal cycle variation of short wave flux from daily mean values.
-      The reconstructed diurnal cycle (black line) is chosen as
-      the mean value of the analytical cycle (blue line) over a time step,
-      not as the mid time step value of the analytically cycle (red square).
-      From \citet{bernie.guilyardi.ea_CD07}.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{SBC_diurnal}
+  \caption[Reconstruction of the diurnal cycle variation of short wave flux]{
+    Example of reconstruction of the diurnal cycle variation of short wave flux from
+    daily mean values.
+    The reconstructed diurnal cycle (black line) is chosen as
+    the mean value of the analytical cycle (blue line) over a time step,
+    not as the mid time step value of the analytically cycle (red square).
+    From \citet{bernie.guilyardi.ea_CD07}.}
+  \label{fig:SBC_diurnal}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 \cite{bernie.woolnough.ea_JC05} have shown that to capture 90$\%$ of the diurnal variability of SST requires a vertical resolution in upper ocean of 1~m or better and a temporal resolution of the surface fluxes of 3~h or less.
-Unfortunately high frequency forcing fields are rare, not to say inexistent.
-Nevertheless, it is possible to obtain a reasonable diurnal cycle of the SST knowning only short wave flux (SWF) at
-high frequency \citep{bernie.guilyardi.ea_CD07}.
+%Unfortunately high frequency forcing fields are rare, not to say inexistent. GS: not true anymore !
+Nevertheless, it is possible to obtain a reasonable diurnal cycle of the SST knowning only short wave flux (SWF) at high frequency \citep{bernie.guilyardi.ea_CD07}.
 Furthermore, only the knowledge of daily mean value of SWF is needed,
 as higher frequency variations can be reconstructed from them,
 assuming that the diurnal cycle of SWF is a scaling of the top of the atmosphere diurnal cycle of incident SWF.
-The \cite{bernie.guilyardi.ea_CD07} reconstruction algorithm is available in \NEMO by
-setting \np{ln\_dm2dc}\forcode{ = .true.} (a \textit{\ngn{namsbc}} namelist variable) when
-using CORE bulk formulea (\np{ln\_blk\_core}\forcode{ = .true.}) or
-the flux formulation (\np{ln\_flx}\forcode{ = .true.}).
+The \cite{bernie.guilyardi.ea_CD07} reconstruction algorithm is available in \NEMO\ by
+setting \np[=.true.]{ln_dm2dc}{ln\_dm2dc} (a \textit{\nam{sbc}{sbc}} namelist variable) when
+using a bulk formulation (\np[=.true.]{ln_blk}{ln\_blk}) or
+the flux formulation (\np[=.true.]{ln_flx}{ln\_flx}).
 The reconstruction is performed in the \mdl{sbcdcy} module.
 The detail of the algoritm used can be found in the appendix~A of \cite{bernie.guilyardi.ea_CD07}.
-The algorithm preserve the daily mean incoming SWF as the reconstructed SWF at
+The algorithm preserves the daily mean incoming SWF as the reconstructed SWF at
 a given time step is the mean value of the analytical cycle over this time step (\autoref{fig:SBC_diurnal}).
 The use of diurnal cycle reconstruction requires the input SWF to be daily
-(\ie a frequency of 24 and a time interpolation set to true in \np{sn\_qsr} namelist parameter).
-Furthermore, it is recommended to have a least 8 surface module time step per day,
+(\ie\ a frequency of 24 hours and a time interpolation set to true in \np{sn_qsr}{sn\_qsr} namelist parameter).
+Furthermore, it is recommended to have a least 8 surface module time steps per day,
 that is  $\rdt \ nn\_fsbc < 10,800~s = 3~h$.
 An example of recontructed SWF is given in \autoref{fig:SBC_dcy} for a 12 reconstructed diurnal cycle,
 one every 2~hours (from 1am to 11pm).
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_SBC_dcy}
-    \caption{
-      \protect\label{fig:SBC_dcy}
-      Example of recontruction of the diurnal cycle variation of short wave flux from
-      daily mean values on an ORCA2 grid with a time sampling of 2~hours (from 1am to 11pm).
-      The display is on (i,j) plane.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{SBC_dcy}
+  \caption[Reconstruction of the diurnal cycle variation of short wave flux on an ORCA2 grid]{
+    Example of reconstruction of the diurnal cycle variation of short wave flux from
+    daily mean values on an ORCA2 grid with a time sampling of 2~hours (from 1am to 11pm).
+    The display is on (i,j) plane.}
+  \label{fig:SBC_dcy}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 Note also that the setting a diurnal cycle in SWF is highly recommended when
@@ -1507,17 +1371,14 @@
 an inconsistency between the scale of the vertical resolution and the forcing acting on that scale.
 
-% -------------------------------------------------------------------------------------------------------------
-%        Rotation of vector pairs onto the model grid directions
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \subsection{Rotation of vector pairs onto the model grid directions}
 \label{subsec:SBC_rotation}
 
-When using a flux (\np{ln\_flx}\forcode{ = .true.}) or
-bulk (\np{ln\_clio}\forcode{ = .true.} or \np{ln\_core}\forcode{ = .true.}) formulation,
+When using a flux (\np[=.true.]{ln_flx}{ln\_flx}) or bulk (\np[=.true.]{ln_blk}{ln\_blk}) formulation,
 pairs of vector components can be rotated from east-north directions onto the local grid directions.
 This is particularly useful when interpolation on the fly is used since here any vectors are likely to
 be defined relative to a rectilinear grid.
-To activate this option a non-empty string is supplied in the rotation pair column of the relevant namelist.
-The eastward component must start with "U" and the northward component with "V".  
+To activate this option, a non-empty string is supplied in the rotation pair column of the relevant namelist.
+The eastward component must start with "U" and the northward component with "V".
 The remaining characters in the strings are used to identify which pair of components go together.
 So for example, strings "U1" and "V1" next to "utau" and "vtau" would pair the wind stress components together and
@@ -1527,20 +1388,19 @@
 The rot\_rep routine from the \mdl{geo2ocean} module is used to perform the rotation.
 
-% -------------------------------------------------------------------------------------------------------------
-%        Surface restoring to observed SST and/or SSS
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Surface restoring to observed SST and/or SSS (\textit{sbcssr.F90})]
-{Surface restoring to observed SST and/or SSS (\protect\mdl{sbcssr})}
+%% =================================================================================================
+\subsection[Surface restoring to observed SST and/or SSS (\textit{sbcssr.F90})]{Surface restoring to observed SST and/or SSS (\protect\mdl{sbcssr})}
 \label{subsec:SBC_ssr}
-%------------------------------------------namsbc_ssr----------------------------------------------------
-
-\nlst{namsbc_ssr} 
-%-------------------------------------------------------------------------------------------------------------
-
-IOptions are defined through the \ngn{namsbc\_ssr} namelist variables.
-On forced mode using a flux formulation (\np{ln\_flx}\forcode{ = .true.}),
+
+\begin{listing}
+  \nlst{namsbc_ssr}
+  \caption{\forcode{&namsbc_ssr}}
+  \label{lst:namsbc_ssr}
+\end{listing}
+
+Options are defined through the \nam{sbc_ssr}{sbc\_ssr} namelist variables.
+On forced mode using a flux formulation (\np[=.true.]{ln_flx}{ln\_flx}),
 a feedback term \emph{must} be added to the surface heat flux $Q_{ns}^o$:
 \[
-  % \label{eq:sbc_dmp_q}
+  % \label{eq:SBC_dmp_q}
   Q_{ns} = Q_{ns}^o + \frac{dQ}{dT} \left( \left. T \right|_{k=1} - SST_{Obs} \right)
 \]
@@ -1548,6 +1408,6 @@
 $T$ is the model surface layer temperature and
 $\frac{dQ}{dT}$ is a negative feedback coefficient usually taken equal to $-40~W/m^2/K$.
-For a $50~m$ mixed-layer depth, this value corresponds to a relaxation time scale of two months. 
-This term ensures that if $T$ perfectly matches the supplied SST, then $Q$ is equal to $Q_o$. 
+For a $50~m$ mixed-layer depth, this value corresponds to a relaxation time scale of two months.
+This term ensures that if $T$ perfectly matches the supplied SST, then $Q$ is equal to $Q_o$.
 
 In the fresh water budget, a feedback term can also be added.
@@ -1555,5 +1415,5 @@
 
 \begin{equation}
-  \label{eq:sbc_dmp_emp}
+  \label{eq:SBC_dmp_emp}
   \textit{emp} = \textit{emp}_o + \gamma_s^{-1} e_{3t}  \frac{  \left(\left.S\right|_{k=1}-SSS_{Obs}\right)}
   {\left.S\right|_{k=1}}
@@ -1566,12 +1426,10 @@
 $\left.S\right|_{k=1}$ is the model surface layer salinity and
 $\gamma_s$ is a negative feedback coefficient which is provided as a namelist parameter.
-Unlike heat flux, there is no physical justification for the feedback term in \autoref{eq:sbc_dmp_emp} as
+Unlike heat flux, there is no physical justification for the feedback term in \autoref{eq:SBC_dmp_emp} as
 the atmosphere does not care about ocean surface salinity \citep{madec.delecluse_IWN97}.
 The SSS restoring term should be viewed as a flux correction on freshwater fluxes to
 reduce the uncertainties we have on the observed freshwater budget.
 
-% -------------------------------------------------------------------------------------------------------------
-%        Handling of ice-covered area
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \subsection{Handling of ice-covered area  (\textit{sbcice\_...})}
 \label{subsec:SBC_ice-cover}
@@ -1579,13 +1437,11 @@
 The presence at the sea surface of an ice covered area modifies all the fluxes transmitted to the ocean.
 There are several way to handle sea-ice in the system depending on
-the value of the \np{nn\_ice} namelist parameter found in \ngn{namsbc} namelist.
+the value of the \np{nn_ice}{nn\_ice} namelist parameter found in \nam{sbc}{sbc} namelist.
 \begin{description}
-\item[nn{\_}ice = 0]
-  there will never be sea-ice in the computational domain.
+\item [nn\_ice = 0] there will never be sea-ice in the computational domain.
   This is a typical namelist value used for tropical ocean domain.
   The surface fluxes are simply specified for an ice-free ocean.
   No specific things is done for sea-ice.
-\item[nn{\_}ice = 1]
-  sea-ice can exist in the computational domain, but no sea-ice model is used.
+\item [nn\_ice = 1] sea-ice can exist in the computational domain, but no sea-ice model is used.
   An observed ice covered area is read in a file.
   Below this area, the SST is restored to the freezing point and
@@ -1595,44 +1451,44 @@
   This prevents deep convection to occur when trying to reach the freezing point
   (and so ice covered area condition) while the SSS is too large.
-  This manner of managing sea-ice area, just by using si IF case,
+  This manner of managing sea-ice area, just by using a IF case,
   is usually referred as the \textit{ice-if} model.
-  It can be found in the \mdl{sbcice{\_}if} module.
-\item[nn{\_}ice = 2 or more]
-  A full sea ice model is used.
+  It can be found in the \mdl{sbcice\_if} module.
+\item [nn\_ice = 2 or more] A full sea ice model is used.
   This model computes the ice-ocean fluxes,
   that are combined with the air-sea fluxes using the ice fraction of each model cell to
-  provide the surface ocean fluxes.
-  Note that the activation of a sea-ice model is is done by defining a CPP key (\key{lim3} or \key{cice}).
-  The activation automatically overwrites the read value of nn{\_}ice to its appropriate value
-  (\ie $2$ for LIM-3 or $3$ for CICE).
+  provide the surface averaged ocean fluxes.
+  Note that the activation of a sea-ice model is done by defining a CPP key (\key{si3} or \key{cice}).
+  The activation automatically overwrites the read value of nn\_ice to its appropriate value
+  (\ie\ $2$ for SI3 or $3$ for CICE).
 \end{description}
 
 % {Description of Ice-ocean interface to be added here or in LIM 2 and 3 doc ?}
-
-\subsection[Interface to CICE (\textit{sbcice\_cice.F90})]
-{Interface to CICE (\protect\mdl{sbcice\_cice})}
+%GS: ocean-ice (SI3) interface is not located in SBC directory anymore, so it should be included in SI3 doc
+
+%% =================================================================================================
+\subsection[Interface to CICE (\textit{sbcice\_cice.F90})]{Interface to CICE (\protect\mdl{sbcice\_cice})}
 \label{subsec:SBC_cice}
 
-It is now possible to couple a regional or global NEMO configuration (without AGRIF)
+It is possible to couple a regional or global \NEMO\ configuration (without AGRIF)
 to the CICE sea-ice model by using \key{cice}.
 The CICE code can be obtained from \href{http://oceans11.lanl.gov/trac/CICE/}{LANL} and
 the additional 'hadgem3' drivers will be required, even with the latest code release.
-Input grid files consistent with those used in NEMO will also be needed,
+Input grid files consistent with those used in \NEMO\ will also be needed,
 and CICE CPP keys \textbf{ORCA\_GRID}, \textbf{CICE\_IN\_NEMO} and \textbf{coupled} should be used
 (seek advice from UKMO if necessary).
-Currently the code is only designed to work when using the CORE forcing option for NEMO
-(with \textit{calc\_strair}\forcode{ = .true.} and \textit{calc\_Tsfc}\forcode{ = .true.} in the CICE name-list),
-or alternatively when NEMO is coupled to the HadGAM3 atmosphere model
-(with \textit{calc\_strair}\forcode{ = .false.} and \textit{calc\_Tsfc}\forcode{ = false}).
-The code is intended to be used with \np{nn\_fsbc} set to 1
+Currently, the code is only designed to work when using the NCAR forcing option for \NEMO\ %GS: still true ?
+(with \textit{calc\_strair}\forcode{=.true.} and \textit{calc\_Tsfc}\forcode{=.true.} in the CICE name-list),
+or alternatively when \NEMO\ is coupled to the HadGAM3 atmosphere model
+(with \textit{calc\_strair}\forcode{=.false.} and \textit{calc\_Tsfc}\forcode{=false}).
+The code is intended to be used with \np{nn_fsbc}{nn\_fsbc} set to 1
 (although coupling ocean and ice less frequently should work,
 it is possible the calculation of some of the ocean-ice fluxes needs to be modified slightly -
 the user should check that results are not significantly different to the standard case).
 
-There are two options for the technical coupling between NEMO and CICE.
+There are two options for the technical coupling between \NEMO\ and CICE.
 The standard version allows complete flexibility for the domain decompositions in the individual models,
 but this is at the expense of global gather and scatter operations in the coupling which
 become very expensive on larger numbers of processors.
-The alternative option (using \key{nemocice\_decomp} for both NEMO and CICE) ensures that
+The alternative option (using \key{nemocice\_decomp} for both \NEMO\ and CICE) ensures that
 the domain decomposition is identical in both models (provided domain parameters are set appropriately,
 and \textit{processor\_shape~=~square-ice} and \textit{distribution\_wght~=~block} in the CICE name-list) and
@@ -1641,55 +1497,47 @@
 there is no sea ice.
 
-% -------------------------------------------------------------------------------------------------------------
-%        Freshwater budget control 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Freshwater budget control (\textit{sbcfwb.F90})]
-{Freshwater budget control (\protect\mdl{sbcfwb})}
+%% =================================================================================================
+\subsection[Freshwater budget control (\textit{sbcfwb.F90})]{Freshwater budget control (\protect\mdl{sbcfwb})}
 \label{subsec:SBC_fwb}
 
-For global ocean simulation it can be useful to introduce a control of the mean sea level in order to
+For global ocean simulation, it can be useful to introduce a control of the mean sea level in order to
 prevent unrealistic drift of the sea surface height due to inaccuracy in the freshwater fluxes.
-In \NEMO, two way of controlling the the freshwater budget. 
+In \NEMO, two way of controlling the freshwater budget are proposed:
+
 \begin{description}
-\item[\np{nn\_fwb}\forcode{ = 0}]
-  no control at all.
+\item [{\np[=0]{nn_fwb}{nn\_fwb}}] no control at all.
   The mean sea level is free to drift, and will certainly do so.
-\item[\np{nn\_fwb}\forcode{ = 1}]
-  global mean \textit{emp} set to zero at each model time step. 
-%Note that with a sea-ice model, this technique only control the mean sea level with linear free surface (\key{vvl} not defined) and no mass flux between ocean and ice (as it is implemented in the current ice-ocean coupling). 
-\item[\np{nn\_fwb}\forcode{ = 2}]
-  freshwater budget is adjusted from the previous year annual mean budget which
+\item [{\np[=1]{nn_fwb}{nn\_fwb}}] global mean \textit{emp} set to zero at each model time step.
+  %GS: comment below still relevant ?
+  %Note that with a sea-ice model, this technique only controls the mean sea level with linear free surface and no mass flux between ocean and ice (as it is implemented in the current ice-ocean coupling).
+\item [{\np[=2]{nn_fwb}{nn\_fwb}}] freshwater budget is adjusted from the previous year annual mean budget which
   is read in the \textit{EMPave\_old.dat} file.
   As the model uses the Boussinesq approximation, the annual mean fresh water budget is simply evaluated from
-  the change in the mean sea level at January the first and saved in the \textit{EMPav.dat} file. 
+  the change in the mean sea level at January the first and saved in the \textit{EMPav.dat} file.
 \end{description}
 
-
-
 % Griffies doc:
-% When running ocean-ice simulations, we are not explicitly representing land processes, 
-% such as rivers, catchment areas, snow accumulation, etc. However, to reduce model drift, 
-% it is important to balance the hydrological cycle in ocean-ice models. 
-% We thus need to prescribe some form of global normalization to the precipitation minus evaporation plus river runoff. 
-% The result of the normalization should be a global integrated zero net water input to the ocean-ice system over 
-% a chosen time scale. 
-%How often the normalization is done is a matter of choice. In mom4p1, we choose to do so at each model time step, 
-% so that there is always a zero net input of water to the ocean-ice system. 
-% Others choose to normalize over an annual cycle, in which case the net imbalance over an annual cycle is used 
-% to alter the subsequent year�s water budget in an attempt to damp the annual water imbalance. 
-% Note that the annual budget approach may be inappropriate with interannually varying precipitation forcing. 
-% When running ocean-ice coupled models, it is incorrect to include the water transport between the ocean 
-% and ice models when aiming to balance the hydrological cycle. 
-% The reason is that it is the sum of the water in the ocean plus ice that should be balanced when running ocean-ice models, 
-% not the water in any one sub-component. As an extreme example to illustrate the issue, 
-% consider an ocean-ice model with zero initial sea ice. As the ocean-ice model spins up, 
-% there should be a net accumulation of water in the growing sea ice, and thus a net loss of water from the ocean. 
-% The total water contained in the ocean plus ice system is constant, but there is an exchange of water between 
-% the subcomponents. This exchange should not be part of the normalization used to balance the hydrological cycle 
-% in ocean-ice models. 
-
-\biblio
-
-\pindex
+% When running ocean-ice simulations, we are not explicitly representing land processes,
+% such as rivers, catchment areas, snow accumulation, etc. However, to reduce model drift,
+% it is important to balance the hydrological cycle in ocean-ice models.
+% We thus need to prescribe some form of global normalization to the precipitation minus evaporation plus river runoff.
+% The result of the normalization should be a global integrated zero net water input to the ocean-ice system over
+% a chosen time scale.
+% How often the normalization is done is a matter of choice. In mom4p1, we choose to do so at each model time step,
+% so that there is always a zero net input of water to the ocean-ice system.
+% Others choose to normalize over an annual cycle, in which case the net imbalance over an annual cycle is used
+% to alter the subsequent year�s water budget in an attempt to damp the annual water imbalance.
+% Note that the annual budget approach may be inappropriate with interannually varying precipitation forcing.
+% When running ocean-ice coupled models, it is incorrect to include the water transport between the ocean
+% and ice models when aiming to balance the hydrological cycle.
+% The reason is that it is the sum of the water in the ocean plus ice that should be balanced when running ocean-ice models,
+% not the water in any one sub-component. As an extreme example to illustrate the issue,
+% consider an ocean-ice model with zero initial sea ice. As the ocean-ice model spins up,
+% there should be a net accumulation of water in the growing sea ice, and thus a net loss of water from the ocean.
+% The total water contained in the ocean plus ice system is constant, but there is an exchange of water between
+% the subcomponents. This exchange should not be part of the normalization used to balance the hydrological cycle
+% in ocean-ice models.
+
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_STO.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_STO.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_STO.tex	(revision 12143)
@@ -2,56 +2,72 @@
 
 \begin{document}
-% ================================================================
-% Chapter stochastic parametrization of EOS (STO)
-% ================================================================
+
 \chapter{Stochastic Parametrization of EOS (STO)}
 \label{chap:STO}
 
-Authors: P.-A. Bouttier
-
-\minitoc
-
-\newpage
-
-The stochastic parametrization module aims to explicitly simulate uncertainties in the model.
-More particularly, \cite{brankart_OM13} has shown that,
-because of the nonlinearity of the seawater equation of state, unresolved scales represent a major source of
-uncertainties in the computation of the large scale horizontal density gradient (from T/S large scale fields),
-and that the impact of these uncertainties can be simulated by
-random processes representing unresolved T/S fluctuations.
-
-The stochastic formulation of the equation of state can be written as:
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+% \vfill
+% \begin{figure}[b]
+%% =================================================================================================
+% \subsubsection*{Changes record}
+% \begin{tabular}{l||l|m{0.65\linewidth}}
+%    Release   & Author        & Modifications \\
+%    {\em 4.0.1} & {\em C. Levy} & {\em 4.0.1 update}  \\
+%    {\em 3.6} & {\em P.-A. Bouttier} & {\em initial version}  \\
+% \end{tabular}
+% \end{figure}
+
+\clearpage
+
+As a result of the nonlinearity of the seawater equation of state, unresolved scales represent a major source of uncertainties in the computation of the large-scale horizontal density gradient from the large-scale temperature and salinity fields. Following  \cite{brankart_OM13}, the impact of these uncertainties can be simulated by random processes representing unresolved T/S fluctuations. The Stochastic Parametrization of EOS (STO) module implements this parametrization.
+
+As detailed in \cite{brankart_OM13}, the stochastic formulation of the equation of state can be written as:
 \begin{equation}
-  \label{eq:eos_sto}
+  \label{eq:STO_eos_sto}
   \rho = \frac{1}{2} \sum_{i=1}^m\{ \rho[T+\Delta T_i,S+\Delta S_i,p_o(z)] + \rho[T-\Delta T_i,S-\Delta S_i,p_o(z)] \}
 \end{equation}
 where $p_o(z)$ is the reference pressure depending on the depth and,
-$\Delta T_i$ and $\Delta S_i$ are a set of T/S perturbations defined as
+$\Delta T_i$ and $\Delta S_i$ (i=1,m) is a set of T/S perturbations defined as
 the scalar product of the respective local T/S gradients with random walks $\mathbf{\xi}$:
 \begin{equation}
-  \label{eq:sto_pert}
+  \label{eq:STO_sto_pert}
   \Delta T_i = \mathbf{\xi}_i \cdot \nabla T \qquad \hbox{and} \qquad \Delta S_i = \mathbf{\xi}_i \cdot \nabla S
 \end{equation}
-$\mathbf{\xi}_i$ are produced by a first-order autoregressive processes (AR-1) with
+$\mathbf{\xi}_i$ are produced by a first-order autoregressive process (AR-1) with
 a parametrized decorrelation time scale, and horizontal and vertical standard deviations $\sigma_s$.
 $\mathbf{\xi}$ are uncorrelated over the horizontal and fully correlated along the vertical.
 
-
+%% =================================================================================================
 \section{Stochastic processes}
 \label{sec:STO_the_details}
 
-The starting point of our implementation of stochastic parameterizations in NEMO is to observe that
-many existing parameterizations are based on autoregressive processes,
+There are many existing parameterizations based on autoregressive processes,
 which are used as a basic source of randomness to transform a deterministic model into a probabilistic model.
-A generic approach is thus to add one single new module in NEMO,
-generating processes with appropriate statistics to simulate each kind of uncertainty in the model
+The generic approach here is to a new STO module,
+generating processes features with appropriate statistics to simulate these uncertainties in the model
 (see \cite{brankart.candille.ea_GMD15} for more details).
 
-In practice, at every model grid point,
+In practice, at each model grid point,
 independent Gaussian autoregressive processes~$\xi^{(i)},\,i=1,\ldots,m$ are first generated using
 the same basic equation:
 
 \begin{equation}
-  \label{eq:autoreg}
+  \label{eq:STO_autoreg}
   \xi^{(i)}_{k+1} = a^{(i)} \xi^{(i)}_k + b^{(i)} w^{(i)} + c^{(i)}
 \end{equation}
@@ -63,10 +79,9 @@
 
 \begin{itemize}
-\item
-  for order~1 processes, $w^{(i)}$ is a Gaussian white noise, with zero mean and standard deviation equal to~1,
+\item for order~1 processes, $w^{(i)}$ is a Gaussian white noise, with zero mean and standard deviation equal to~1,
   and the parameters $a^{(i)}$, $b^{(i)}$, $c^{(i)}$ are given by:
 
   \[
-    % \label{eq:ord1}
+    % \label{eq:STO_ord1}
     \left\{
       \begin{array}{l}
@@ -78,6 +93,5 @@
   \]
 
-\item
-  for order~$n>1$ processes, $w^{(i)}$ is an order~$n-1$ autoregressive process, with zero mean,
+\item for order~$n>1$ processes, $w^{(i)}$ is an order~$n-1$ autoregressive process, with zero mean,
   standard deviation equal to~$\sigma^{(i)}$;
   correlation timescale equal to~$\tau^{(i)}$;
@@ -85,5 +99,5 @@
 
   \begin{equation}
-    \label{eq:ord2}
+    \label{eq:STO_ord2}
     \left\{
       \begin{array}{l}
@@ -101,41 +115,39 @@
 \noindent
 In this way, higher order processes can be easily generated recursively using the same piece of code implementing
-(\autoref{eq:autoreg}), and using succesively processes from order $0$ to~$n-1$ as~$w^{(i)}$.
-The parameters in (\autoref{eq:ord2}) are computed so that this recursive application of
-(\autoref{eq:autoreg}) leads to processes with the required standard deviation and correlation timescale,
+\autoref{eq:STO_autoreg}, and using successive processes from order $0$ to~$n-1$ as~$w^{(i)}$.
+The parameters in \autoref{eq:STO_ord2} are computed so that this recursive application of
+\autoref{eq:STO_autoreg} leads to processes with the required standard deviation and correlation timescale,
 with the additional condition that the $n-1$ first derivatives of the autocorrelation function are equal to
-zero at~$t=0$, so that the resulting processes become smoother and smoother as $n$ is increased.
+zero at~$t=0$, so that the resulting processes become smoother and smoother as $n$ increases.
 
 Overall, this method provides quite a simple and generic way of generating a wide class of stochastic processes.
 However, this also means that new model parameters are needed to specify each of these stochastic processes.
-As in any parameterization of lacking physics, a very important issues then to tune these new parameters using
+As in any parameterization, the main issue is to tune the parameters using
 either first principles, model simulations, or real-world observations.
-
+The parameters are set by default as described in \cite{brankart_OM13}, which has been shown in the paper
+to give good results for a global low resolution (2°) \NEMO\ configuration. where this parametrization produces a major effect on the average large-scale circulation, especilally in regions of intense mesoscale activity.
+The set of parameters will need further investigation to find appropriate values
+for any other configuration or resolution of the model.
+
+%% =================================================================================================
 \section{Implementation details}
 \label{sec:STO_thech_details}
 
-%---------------------------------------namsbc--------------------------------------------------
-
-\nlst{namsto}
-%--------------------------------------------------------------------------------------------------------------
-
-The computer code implementing stochastic parametrisations can be found in the STO directory.
-It involves three modules : 
-\begin{description}
-\item[\mdl{stopar}:]
-  define the Stochastic parameters and their time evolution.
-\item[\mdl{storng}:]
-  a random number generator based on (and includes) the 64-bit KISS (Keep It Simple Stupid) random number generator
-  distributed by George Marsaglia
-  (see \href{https://groups.google.com/forum/#!searchin/comp.lang.fortran/64-bit$20KISS$20RNGs}{here})
-\item[\mdl{stopts}:]
-  stochastic parametrisation associated with the non-linearity of the equation of seawater,
-  implementing \autoref{eq:sto_pert} and specific piece of code in
-  the equation of state implementing \autoref{eq:eos_sto}.
-\end{description}
-
-The \mdl{stopar} module has 3 public routines to be called by the model (in our case, NEMO):
-
-The first routine (\rou{sto\_par}) is a direct implementation of (\autoref{eq:autoreg}),
+The code implementing stochastic parametrisation is located in the src/OCE/STO directory.
+It contains three modules :
+% \begin{description}
+
+\mdl{stopar} : define the Stochastic parameters and their time evolution
+
+\mdl{storng} : random number generator based on and including the 64-bit KISS (Keep It Simple Stupid) random number generator distributed by George Marsaglia
+
+\mdl{stopts} : stochastic parametrisation associated with the non-linearity of the equation of
+ seawater, implementing \autoref{eq:STO_sto_pert} so as specifics in the equation of state
+ implementing \autoref{eq:STO_eos_sto}.
+% \end{description}
+
+The \mdl{stopar} module includes three public routines called in the model:
+
+(\rou{sto\_par}) is a direct implementation of \autoref{eq:STO_autoreg},
 applied at each model grid point (in 2D or 3D), and called at each model time step ($k$) to
 update every autoregressive process ($i=1,\ldots,m$).
@@ -143,35 +155,55 @@
 to introduce a spatial correlation between the stochastic processes.
 
-The second routine (\rou{sto\_par\_init}) is an initialization routine mainly dedicated to
-the computation of parameters $a^{(i)}, b^{(i)}, c^{(i)}$ for each autoregressive process,
+(\rou{sto\_par\_init}) is the initialization routine computing
+the values $a^{(i)}, b^{(i)}, c^{(i)}$ for each autoregressive process,
 as a function of the statistical properties required by the model user
-(mean, standard deviation, time correlation, order of the process,\ldots). 
-
-Parameters for the processes can be specified through the following \ngn{namsto} namelist parameters:
-\begin{description}
-\item[\np{nn\_sto\_eos}:]   number of independent random walks
-\item[\np{rn\_eos\_stdxy}:] random walk horz. standard deviation (in grid points)
-\item[\np{rn\_eos\_stdz}:]  random walk vert. standard deviation (in grid points)
-\item[\np{rn\_eos\_tcor}:]  random walk time correlation (in timesteps)
-\item[\np{nn\_eos\_ord}:]   order of autoregressive processes
-\item[\np{nn\_eos\_flt}:]   passes of Laplacian filter
-\item[\np{rn\_eos\_lim}:]   limitation factor (default = 3.0)
-\end{description}
+(mean, standard deviation, time correlation, order of the process,\ldots).
 This routine also includes the initialization (seeding) of the random number generator.
 
-The third routine (\rou{sto\_rst\_write}) writes a restart file
-(which suffix name is given by \np{cn\_storst\_out} namelist parameter) containing the current value of
-all autoregressive processes to allow restarting a simulation from where it has been interrupted.
-This file also contains the current state of the random number generator.
-When \np{ln\_rststo} is set to \forcode{.true.}),
-the restart file (which suffix name is given by \np{cn\_storst\_in} namelist parameter) is read by
+(\rou{sto\_rst\_write}) writes a restart file
+(which suffix name is given by \np{cn_storst_out}{cn\_storst\_out} namelist parameter) containing the current value of
+all autoregressive processes to allow creating the file needed for a restart.
+This restart file also contains the current state of the random number generator.
+When \np{ln_rststo}{ln\_rststo} is set to \forcode{.true.}),
+the restart file (which suffix name is given by \np{cn_storst_in}{cn\_storst\_in} namelist parameter) is read by
 the initialization routine (\rou{sto\_par\_init}).
 The simulation will continue exactly as if it was not interrupted only
-when \np{ln\_rstseed} is set to \forcode{.true.},
-\ie when the state of the random number generator is read in the restart file.
-
-\biblio
-
-\pindex
+when \np{ln_rstseed}{ln\_rstseed} is set to \forcode{.true.},
+\ie\ when the state of the random number generator is read in the restart file.\\
+
+The implementation includes the basics for a few possible stochastic parametrisations including equation of state,
+lateral diffusion, horizontal pressure gradient, ice strength, trend, tracers dynamics.
+As for this release, only the stochastic parametrisation of equation of state is fully available and tested. \\
+
+Options and parameters \\
+
+The \np{ln_sto_eos}{ln\_sto\_eos} namelist variable activates stochastic parametrisation of equation of state.
+By default it set to \forcode{.false.}) and not active.
+The set of parameters is available in \nam{sto}{sto} namelist
+(only the subset for equation of state stochastic parametrisation is listed below):
+
+\begin{listing}
+  \nlst{namsto}
+  \caption{\forcode{&namsto}}
+  \label{lst:namsto}
+\end{listing}
+
+The variables of stochastic paramtetrisation itself (based on the global 2° experiments as in \cite{brankart_OM13} are:
+
+\begin{description}
+\item [{\np{nn_sto_eos}{nn\_sto\_eos}:}]     number of independent random walks
+\item [{\np{rn_eos_stdxy}{rn\_eos\_stdxy}:}] random walk horizontal standard deviation
+  (in grid points)
+\item [{\np{rn_eos_stdz}{rn\_eos\_stdz}:}]   random walk vertical standard deviation
+  (in grid points)
+\item [{\np{rn_eos_tcor}{rn\_eos\_tcor}:}]   random walk time correlation (in timesteps)
+\item [{\np{nn_eos_ord}{nn\_eos\_ord}:}]     order of autoregressive processes
+\item [{\np{nn_eos_flt}{nn\_eos\_flt}:}]     passes of Laplacian filter
+\item [{\np{rn_eos_lim}{rn\_eos\_lim}:}]     limitation factor (default = 3.0)
+\end{description}
+
+The first four parameters define the stochastic part of equation of state.
+
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_TRA.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_TRA.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_TRA.tex	(revision 12143)
@@ -2,22 +2,37 @@
 
 \begin{document}
-% ================================================================
-% Chapter 1 ——— Ocean Tracers (TRA)
-% ================================================================
+
 \chapter{Ocean Tracers (TRA)}
 \label{chap:TRA}
 
-\minitoc
-
-% missing/update 
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release          & Author(s)                                   & Modifications       \\
+    \hline
+    {\em        4.0} & {\em Christian \'{E}th\'{e}               } & {\em Review       } \\
+    {\em        3.6} & {\em Gurvan Madec                         } & {\em Update       } \\
+    {\em $\leq$ 3.4} & {\em Gurvan Madec and S\'{e}bastien Masson} & {\em First version} \\
+  \end{tabularx}
+}
+
+\clearpage
+
+% missing/update
 % traqsr: need to coordinate with SBC module
 
-%STEVEN :  is the use of the word "positive" to describe a scheme enough, or should it be "positive definite"? I added a comment to this effect on some instances of this below
+%STEVEN :  is the use of the word "positive" to describe a scheme enough, or should it be "positive definite"?
+%I added a comment to this effect on some instances of this below
 
 Using the representation described in \autoref{chap:DOM}, several semi -discrete space forms of
 the tracer equations are available depending on the vertical coordinate used and on the physics used.
 In all the equations presented here, the masking has been omitted for simplicity.
-One must be aware that all the quantities are masked fields and that each time a mean or
-difference operator is used, the resulting field is multiplied by a mask.
+One must be aware that all the quantities are masked fields and that
+each time a mean or difference operator is used, the resulting field is multiplied by a mask.
 
 The two active tracers are potential temperature and salinity.
@@ -30,48 +45,49 @@
 NXT stands for next, referring to the time-stepping.
 From left to right, the terms on the rhs of the tracer equations are the advection (ADV),
-the lateral diffusion (LDF), the vertical diffusion (ZDF), the contributions from the external forcings
-(SBC: Surface Boundary Condition, QSR: penetrative Solar Radiation, and BBC: Bottom Boundary Condition),
-the contribution from the bottom boundary Layer (BBL) parametrisation, and an internal damping (DMP) term.
+the lateral diffusion (LDF), the vertical diffusion (ZDF),
+the contributions from the external forcings (SBC: Surface Boundary Condition,
+QSR: penetrative Solar Radiation, and BBC: Bottom Boundary Condition),
+the contribution from the bottom boundary Layer (BBL) parametrisation,
+and an internal damping (DMP) term.
 The terms QSR, BBC, BBL and DMP are optional.
 The external forcings and parameterisations require complex inputs and complex calculations
-(\eg bulk formulae, estimation of mixing coefficients) that are carried out in the SBC,
+(\eg\ bulk formulae, estimation of mixing coefficients) that are carried out in the SBC,
 LDF and ZDF modules and described in \autoref{chap:SBC}, \autoref{chap:LDF} and
 \autoref{chap:ZDF}, respectively.
-Note that \mdl{tranpc}, the non-penetrative convection module, although located in
-the \path{./src/OCE/TRA} directory as it directly modifies the tracer fields,
+Note that \mdl{tranpc}, the non-penetrative convection module,
+although located in the \path{./src/OCE/TRA} directory as it directly modifies the tracer fields,
 is described with the model vertical physics (ZDF) together with
 other available parameterization of convection.
 
-In the present chapter we also describe the diagnostic equations used to compute the sea-water properties
-(density, Brunt-V\"{a}is\"{a}l\"{a} frequency, specific heat and freezing point with
-associated modules \mdl{eosbn2} and \mdl{phycst}).
-
-The different options available to the user are managed by namelist logicals or CPP keys.
+In the present chapter we also describe the diagnostic equations used to
+compute the sea-water properties (density, Brunt-V\"{a}is\"{a}l\"{a} frequency, specific heat and
+freezing point with associated modules \mdl{eosbn2} and \mdl{phycst}).
+
+The different options available to the user are managed by namelist logicals.
 For each equation term \textit{TTT}, the namelist logicals are \textit{ln\_traTTT\_xxx},
 where \textit{xxx} is a 3 or 4 letter acronym corresponding to each optional scheme.
-The CPP key (when it exists) is \key{traTTT}.
 The equivalent code can be found in the \textit{traTTT} or \textit{traTTT\_xxx} module,
 in the \path{./src/OCE/TRA} directory.
 
 The user has the option of extracting each tendency term on the RHS of the tracer equation for output
-(\np{ln\_tra\_trd} or \np{ln\_tra\_mxl}\forcode{ = .true.}), as described in \autoref{chap:DIA}.
-
-% ================================================================
-% Tracer Advection
-% ================================================================
-\section[Tracer advection (\textit{traadv.F90})]
-{Tracer advection (\protect\mdl{traadv})}
+(\np{ln_tra_trd}{ln\_tra\_trd} or \np[=.true.]{ln_tra_mxl}{ln\_tra\_mxl}),
+as described in \autoref{chap:DIA}.
+
+%% =================================================================================================
+\section[Tracer advection (\textit{traadv.F90})]{Tracer advection (\protect\mdl{traadv})}
 \label{sec:TRA_adv}
-%------------------------------------------namtra_adv-----------------------------------------------------
-
-\nlst{namtra_adv}
-%-------------------------------------------------------------------------------------------------------------
-
-When considered (\ie when \np{ln\_traadv\_NONE} is not set to \forcode{.true.}),
+
+\begin{listing}
+  \nlst{namtra_adv}
+  \caption{\forcode{&namtra_adv}}
+  \label{lst:namtra_adv}
+\end{listing}
+
+When considered (\ie\ when \np{ln_traadv_OFF}{ln\_traadv\_OFF} is not set to \forcode{.true.}),
 the advection tendency of a tracer is expressed in flux form,
-\ie as the divergence of the advective fluxes.
-Its discrete expression is given by :
-\begin{equation}
-  \label{eq:tra_adv}
+\ie\ as the divergence of the advective fluxes.
+Its discrete expression is given by:
+\begin{equation}
+  \label{eq:TRA_adv}
   ADV_\tau = - \frac{1}{b_t} \Big(   \delta_i [ e_{2u} \, e_{3u} \; u \; \tau_u]
                                    + \delta_j [ e_{1v} \, e_{3v} \; v \; \tau_v] \Big)
@@ -79,38 +95,38 @@
 \end{equation}
 where $\tau$ is either T or S, and $b_t = e_{1t} \, e_{2t} \, e_{3t}$ is the volume of $T$-cells.
-The flux form in \autoref{eq:tra_adv} implicitly requires the use of the continuity equation.
-Indeed, it is obtained by using the following equality: $\nabla \cdot (\vect U \, T) = \vect U \cdot \nabla T$ which
-results from the use of the continuity equation, $\partial_t e_3 + e_3 \; \nabla \cdot \vect U = 0$
-(which reduces to $\nabla \cdot \vect U = 0$ in linear free surface, \ie \np{ln\_linssh}\forcode{ = .true.}).
-Therefore it is of paramount importance to design the discrete analogue of the advection tendency so that
-it is consistent with the continuity equation in order to enforce the conservation properties of
-the continuous equations.
-In other words, by setting $\tau = 1$ in (\autoref{eq:tra_adv}) we recover the discrete form of
-the continuity equation which is used to calculate the vertical velocity.
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_adv_scheme}
-    \caption{
-      \protect\label{fig:adv_scheme}
-      Schematic representation of some ways used to evaluate the tracer value at $u$-point and
-      the amount of tracer exchanged between two neighbouring grid points.
-      Upsteam biased scheme (ups):
-      the upstream value is used and the black area is exchanged.
-      Piecewise parabolic method (ppm):
-      a parabolic interpolation is used and the black and dark grey areas are exchanged.
-      Monotonic upstream scheme for conservative laws (muscl):
-      a parabolic interpolation is used and black, dark grey and grey areas are exchanged.
-      Second order scheme (cen2):
-      the mean value is used and black, dark grey, grey and light grey areas are exchanged.
-      Note that this illustration does not include the flux limiter used in ppm and muscl schemes.
-    }
-  \end{center}
+The flux form in \autoref{eq:TRA_adv} implicitly requires the use of the continuity equation.
+Indeed, it is obtained by using the following equality:
+$\nabla \cdot (\vect U \, T) = \vect U \cdot \nabla T$ which
+results from the use of the continuity equation,
+$\partial_t e_3 + e_3 \; \nabla \cdot \vect U = 0$
+(which reduces to $\nabla \cdot \vect U = 0$ in linear free surface,
+\ie\ \np[=.true.]{ln_linssh}{ln\_linssh}).
+Therefore it is of paramount importance to
+design the discrete analogue of the advection tendency so that
+it is consistent with the continuity equation in order to
+enforce the conservation properties of the continuous equations.
+In other words, by setting $\tau = 1$ in (\autoref{eq:TRA_adv}) we recover
+the discrete form of the continuity equation which is used to calculate the vertical velocity.
+\begin{figure}
+  \centering
+  \includegraphics[width=0.66\textwidth]{TRA_adv_scheme}
+  \caption[Ways to evaluate the tracer value and the amount of tracer exchanged]{
+    Schematic representation of some ways used to evaluate the tracer value at $u$-point and
+    the amount of tracer exchanged between two neighbouring grid points.
+    Upsteam biased scheme (ups):
+    the upstream value is used and the black area is exchanged.
+    Piecewise parabolic method (ppm):
+    a parabolic interpolation is used and the black and dark grey areas are exchanged.
+    Monotonic upstream scheme for conservative laws (muscl):
+    a parabolic interpolation is used and black, dark grey and grey areas are exchanged.
+    Second order scheme (cen2):
+    the mean value is used and black, dark grey, grey and light grey areas are exchanged.
+    Note that this illustration does not include the flux limiter used in ppm and muscl schemes.}
+  \label{fig:TRA_adv_scheme}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-The key difference between the advection schemes available in \NEMO is the choice made in space and
-time interpolation to define the value of the tracer at the velocity points
-(\autoref{fig:adv_scheme}).
+
+The key difference between the advection schemes available in \NEMO\ is the choice made in
+space and time interpolation to define the value of the tracer at the velocity points
+(\autoref{fig:TRA_adv_scheme}).
 
 Along solid lateral and bottom boundaries a zero tracer flux is automatically specified,
@@ -119,126 +135,136 @@
 
 \begin{description}
-\item[linear free surface:]
-  (\np{ln\_linssh}\forcode{ = .true.})
+\item [linear free surface] (\np[=.true.]{ln_linssh}{ln\_linssh})
   the first level thickness is constant in time:
-  the vertical boundary condition is applied at the fixed surface $z = 0$ rather than on
-  the moving surface $z = \eta$.
-  There is a non-zero advective flux which is set for all advection schemes as
-  $\tau_w|_{k = 1/2} = T_{k = 1}$, \ie the product of surface velocity (at $z = 0$) by
-  the first level tracer value.
-\item[non-linear free surface:]
-  (\np{ln\_linssh}\forcode{ = .false.})
+  the vertical boundary condition is applied at the fixed surface $z = 0$ rather than
+  on the moving surface $z = \eta$.
+  There is a non-zero advective flux which is set for
+  all advection schemes as $\tau_w|_{k = 1/2} = T_{k = 1}$,
+  \ie\ the product of surface velocity (at $z = 0$) by the first level tracer value.
+\item [non-linear free surface] (\np[=.false.]{ln_linssh}{ln\_linssh})
   convergence/divergence in the first ocean level moves the free surface up/down.
-  There is no tracer advection through it so that the advective fluxes through the surface are also zero.
+  There is no tracer advection through it so that
+  the advective fluxes through the surface are also zero.
 \end{description}
 
 In all cases, this boundary condition retains local conservation of tracer.
-Global conservation is obtained in non-linear free surface case, but \textit{not} in the linear free surface case.
-Nevertheless, in the latter case, it is achieved to a good approximation since
-the non-conservative term is the product of the time derivative of the tracer and the free surface height,
-two quantities that are not correlated \citep{roullet.madec_JGR00, griffies.pacanowski.ea_MWR01, campin.adcroft.ea_OM04}.
-
-The velocity field that appears in (\autoref{eq:tra_adv} and \autoref{eq:tra_adv_zco?}) is
-the centred (\textit{now}) \textit{effective} ocean velocity, \ie the \textit{eulerian} velocity
+Global conservation is obtained in non-linear free surface case,
+but \textit{not} in the linear free surface case.
+Nevertheless, in the latter case,
+it is achieved to a good approximation since the non-conservative term is
+the product of the time derivative of the tracer and the free surface height,
+two quantities that are not correlated
+\citep{roullet.madec_JGR00, griffies.pacanowski.ea_MWR01, campin.adcroft.ea_OM04}.
+
+The velocity field that appears in (\autoref{eq:TRA_adv} is
+the centred (\textit{now}) \textit{effective} ocean velocity, \ie\ the \textit{eulerian} velocity
 (see \autoref{chap:DYN}) plus the eddy induced velocity (\textit{eiv}) and/or
 the mixed layer eddy induced velocity (\textit{eiv}) when those parameterisations are used
 (see \autoref{chap:LDF}).
 
-Several tracer advection scheme are proposed, namely a $2^{nd}$ or $4^{th}$ order centred schemes (CEN),
-a $2^{nd}$ or $4^{th}$ order Flux Corrected Transport scheme (FCT), a Monotone Upstream Scheme for
-Conservative Laws scheme (MUSCL), a $3^{rd}$ Upstream Biased Scheme (UBS, also often called UP3),
-and a Quadratic Upstream Interpolation for Convective Kinematics with Estimated Streaming Terms scheme (QUICKEST).
-The choice is made in the \ngn{namtra\_adv} namelist, by setting to \forcode{.true.} one of
-the logicals \textit{ln\_traadv\_xxx}.
-The corresponding code can be found in the \textit{traadv\_xxx.F90} module, where
-\textit{xxx} is a 3 or 4 letter acronym corresponding to each scheme.
-By default (\ie in the reference namelist, \textit{namelist\_ref}), all the logicals are set to \forcode{.false.}.
-If the user does not select an advection scheme in the configuration namelist (\textit{namelist\_cfg}),
-the tracers will \textit{not} be advected!
+Several tracer advection scheme are proposed,
+namely a $2^{nd}$ or $4^{th}$ order \textbf{CEN}tred schemes (CEN),
+a $2^{nd}$ or $4^{th}$ order \textbf{F}lux \textbf{C}orrected \textbf{T}ransport scheme (FCT),
+a \textbf{M}onotone \textbf{U}pstream \textbf{S}cheme for
+\textbf{C}onservative \textbf{L}aws scheme (MUSCL),
+a $3^{rd}$ \textbf{U}pstream \textbf{B}iased \textbf{S}cheme (UBS, also often called UP3),
+and a \textbf{Q}uadratic \textbf{U}pstream \textbf{I}nterpolation for
+\textbf{C}onvective \textbf{K}inematics with
+\textbf{E}stimated \textbf{S}treaming \textbf{T}erms scheme (QUICKEST).
+The choice is made in the \nam{tra_adv}{tra\_adv} namelist,
+by setting to \forcode{.true.} one of the logicals \textit{ln\_traadv\_xxx}.
+The corresponding code can be found in the \textit{traadv\_xxx.F90} module,
+where \textit{xxx} is a 3 or 4 letter acronym corresponding to each scheme.
+By default (\ie\ in the reference namelist, \textit{namelist\_ref}),
+all the logicals are set to \forcode{.false.}.
+If the user does not select an advection scheme in the configuration namelist
+(\textit{namelist\_cfg}), the tracers will \textit{not} be advected!
 
 Details of the advection schemes are given below.
-The choosing an advection scheme is a complex matter which depends on the model physics, model resolution,
-type of tracer, as well as the issue of numerical cost. In particular, we note that
+The choosing an advection scheme is a complex matter which depends on the
+model physics, model resolution, type of tracer, as well as the issue of numerical cost.
+In particular, we note that
 
 \begin{enumerate}
-\item
-  CEN and FCT schemes require an explicit diffusion operator while the other schemes are diffusive enough so that
-  they do not necessarily need additional diffusion;
-\item
-  CEN and UBS are not \textit{positive} schemes
-  \footnote{negative values can appear in an initially strictly positive tracer field which is advected},
+\item CEN and FCT schemes require an explicit diffusion operator while
+  the other schemes are diffusive enough so that they do not necessarily need additional diffusion;
+\item CEN and UBS are not \textit{positive} schemes \footnote{negative values can appear in
+    an initially strictly positive tracer field which is advected},
   implying that false extrema are permitted.
   Their use is not recommended on passive tracers;
-\item
-  It is recommended that the same advection-diffusion scheme is used on both active and passive tracers.
+\item It is recommended that the same advection-diffusion scheme is used on
+  both active and passive tracers.
 \end{enumerate}
 
-Indeed, if a source or sink of a passive tracer depends on an active one, the difference of treatment of active and
-passive tracers can create very nice-looking frontal structures that are pure numerical artefacts.
+Indeed, if a source or sink of a passive tracer depends on an active one,
+the difference of treatment of active and passive tracers can create
+very nice-looking frontal structures that are pure numerical artefacts.
 Nevertheless, most of our users set a different treatment on passive and active tracers,
 that's the reason why this possibility is offered.
-We strongly suggest them to perform a sensitivity experiment using a same treatment to assess the robustness of
-their results.
-
-% -------------------------------------------------------------------------------------------------------------
-%        2nd and 4th order centred schemes
-% -------------------------------------------------------------------------------------------------------------
-\subsection[CEN: Centred scheme (\forcode{ln_traadv_cen = .true.})]
-{CEN: Centred scheme (\protect\np{ln\_traadv\_cen}\forcode{ = .true.})}
+We strongly suggest them to perform a sensitivity experiment using a same treatment to
+assess the robustness of their results.
+
+%% =================================================================================================
+\subsection[CEN: Centred scheme (\forcode{ln_traadv_cen})]{CEN: Centred scheme (\protect\np{ln_traadv_cen}{ln\_traadv\_cen})}
 \label{subsec:TRA_adv_cen}
 
-%        2nd order centred scheme  
-
-The centred advection scheme (CEN) is used when \np{ln\_traadv\_cen}\forcode{ = .true.}.
-Its order ($2^{nd}$ or $4^{th}$) can be chosen independently on horizontal (iso-level) and vertical direction by
-setting \np{nn\_cen\_h} and \np{nn\_cen\_v} to $2$ or $4$.
+%        2nd order centred scheme
+
+The \textbf{CEN}tred advection scheme (CEN) is used when \np[=.true.]{ln_traadv_cen}{ln\_traadv\_cen}.
+Its order ($2^{nd}$ or $4^{th}$) can be chosen independently on
+horizontal (iso-level) and vertical direction by
+setting \np{nn_cen_h}{nn\_cen\_h} and \np{nn_cen_v}{nn\_cen\_v} to $2$ or $4$.
 CEN implementation can be found in the \mdl{traadv\_cen} module.
 
-In the $2^{nd}$ order centred formulation (CEN2), the tracer at velocity points is evaluated as the mean of
-the two neighbouring $T$-point values.
+In the $2^{nd}$ order centred formulation (CEN2), the tracer at velocity points is evaluated as
+the mean of the two neighbouring $T$-point values.
 For example, in the $i$-direction :
 \begin{equation}
-  \label{eq:tra_adv_cen2}
+  \label{eq:TRA_adv_cen2}
   \tau_u^{cen2} = \overline T ^{i + 1/2}
 \end{equation}
 
-CEN2 is non diffusive (\ie it conserves the tracer variance, $\tau^2$) but dispersive
-(\ie it may create false extrema).
-It is therefore notoriously noisy and must be used in conjunction with an explicit diffusion operator to
-produce a sensible solution.
-The associated time-stepping is performed using a leapfrog scheme in conjunction with an Asselin time-filter,
-so $T$ in (\autoref{eq:tra_adv_cen2}) is the \textit{now} tracer value.
+CEN2 is non diffusive (\ie\ it conserves the tracer variance, $\tau^2$) but
+dispersive (\ie\ it may create false extrema).
+It is therefore notoriously noisy and must be used in conjunction with
+an explicit diffusion operator to produce a sensible solution.
+The associated time-stepping is performed using
+a leapfrog scheme in conjunction with an Asselin time-filter,
+so $T$ in (\autoref{eq:TRA_adv_cen2}) is the \textit{now} tracer value.
 
 Note that using the CEN2, the overall tracer advection is of second order accuracy since
-both (\autoref{eq:tra_adv}) and (\autoref{eq:tra_adv_cen2}) have this order of accuracy.
-
-%        4nd order centred scheme  
-
-In the $4^{th}$ order formulation (CEN4), tracer values are evaluated at u- and v-points as
-a $4^{th}$ order interpolation, and thus depend on the four neighbouring $T$-points.
+both (\autoref{eq:TRA_adv}) and (\autoref{eq:TRA_adv_cen2}) have this order of accuracy.
+
+%        4nd order centred scheme
+
+In the $4^{th}$ order formulation (CEN4),
+tracer values are evaluated at u- and v-points as a $4^{th}$ order interpolation,
+and thus depend on the four neighbouring $T$-points.
 For example, in the $i$-direction:
 \begin{equation}
-  \label{eq:tra_adv_cen4}
+  \label{eq:TRA_adv_cen4}
   \tau_u^{cen4} = \overline{T - \frac{1}{6} \, \delta_i \Big[ \delta_{i + 1/2}[T] \, \Big]}^{\,i + 1/2}
 \end{equation}
-In the vertical direction (\np{nn\_cen\_v}\forcode{ = 4}),
+In the vertical direction (\np[=4]{nn_cen_v}{nn\_cen\_v}),
 a $4^{th}$ COMPACT interpolation has been prefered \citep{demange_phd14}.
-In the COMPACT scheme, both the field and its derivative are interpolated, which leads, after a matrix inversion,
-spectral characteristics similar to schemes of higher order \citep{lele_JCP92}. 
+In the COMPACT scheme, both the field and its derivative are interpolated,
+which leads, after a matrix inversion, spectral characteristics similar to schemes of higher order
+\citep{lele_JCP92}.
 
 Strictly speaking, the CEN4 scheme is not a $4^{th}$ order advection scheme but
 a $4^{th}$ order evaluation of advective fluxes,
-since the divergence of advective fluxes \autoref{eq:tra_adv} is kept at $2^{nd}$ order.
-The expression \textit{$4^{th}$ order scheme} used in oceanographic literature is usually associated with
-the scheme presented here.
-Introducing a \forcode{.true.} $4^{th}$ order advection scheme is feasible but, for consistency reasons,
-it requires changes in the discretisation of the tracer advection together with changes in the continuity equation,
-and the momentum advection and pressure terms.
+since the divergence of advective fluxes \autoref{eq:TRA_adv} is kept at $2^{nd}$ order.
+The expression \textit{$4^{th}$ order scheme} used in oceanographic literature is
+usually associated with the scheme presented here.
+Introducing a ``true'' $4^{th}$ order advection scheme is feasible but, for consistency reasons,
+it requires changes in the discretisation of the tracer advection together with
+changes in the continuity equation, and the momentum advection and pressure terms.
 
 A direct consequence of the pseudo-fourth order nature of the scheme is that it is not non-diffusive,
-\ie the global variance of a tracer is not preserved using CEN4.
-Furthermore, it must be used in conjunction with an explicit diffusion operator to produce a sensible solution.
-As in CEN2 case, the time-stepping is performed using a leapfrog scheme in conjunction with an Asselin time-filter,
-so $T$ in (\autoref{eq:tra_adv_cen4}) is the \textit{now} tracer.
+\ie\ the global variance of a tracer is not preserved using CEN4.
+Furthermore, it must be used in conjunction with an explicit diffusion operator to
+produce a sensible solution.
+As in CEN2 case, the time-stepping is performed using a leapfrog scheme in conjunction with
+an Asselin time-filter, so $T$ in (\autoref{eq:TRA_adv_cen4}) is the \textit{now} tracer.
 
 At a $T$-grid cell adjacent to a boundary (coastline, bottom and surface),
@@ -246,24 +272,23 @@
 This hypothesis usually reduces the order of the scheme.
 Here we choose to set the gradient of $T$ across the boundary to zero.
-Alternative conditions can be specified, such as a reduction to a second order scheme for
-these near boundary grid points.
-
-% -------------------------------------------------------------------------------------------------------------
-%        FCT scheme  
-% -------------------------------------------------------------------------------------------------------------
-\subsection[FCT: Flux Corrected Transport scheme (\forcode{ln_traadv_fct = .true.})]
-{FCT: Flux Corrected Transport scheme (\protect\np{ln\_traadv\_fct}\forcode{ = .true.})}
+Alternative conditions can be specified,
+such as a reduction to a second order scheme for these near boundary grid points.
+
+%% =================================================================================================
+\subsection[FCT: Flux Corrected Transport scheme (\forcode{ln_traadv_fct})]{FCT: Flux Corrected Transport scheme (\protect\np{ln_traadv_fct}{ln\_traadv\_fct})}
 \label{subsec:TRA_adv_tvd}
 
-The Flux Corrected Transport schemes (FCT) is used when \np{ln\_traadv\_fct}\forcode{ = .true.}.
-Its order ($2^{nd}$ or $4^{th}$) can be chosen independently on horizontal (iso-level) and vertical direction by
-setting \np{nn\_fct\_h} and \np{nn\_fct\_v} to $2$ or $4$.
+The \textbf{F}lux \textbf{C}orrected \textbf{T}ransport schemes (FCT) is used when
+\np[=.true.]{ln_traadv_fct}{ln\_traadv\_fct}.
+Its order ($2^{nd}$ or $4^{th}$) can be chosen independently on
+horizontal (iso-level) and vertical direction by
+setting \np{nn_fct_h}{nn\_fct\_h} and \np{nn_fct_v}{nn\_fct\_v} to $2$ or $4$.
 FCT implementation can be found in the \mdl{traadv\_fct} module.
 
-In FCT formulation, the tracer at velocity points is evaluated using a combination of an upstream and
-a centred scheme.
+In FCT formulation, the tracer at velocity points is evaluated using
+a combination of an upstream and a centred scheme.
 For example, in the $i$-direction :
 \begin{equation}
-  \label{eq:tra_adv_fct}
+  \label{eq:TRA_adv_fct}
   \begin{split}
     \tau_u^{ups} &=
@@ -271,6 +296,5 @@
                      T_{i + 1} & \text{if~} u_{i + 1/2} <    0 \\
                      T_i       & \text{if~} u_{i + 1/2} \geq 0 \\
-    \end{cases}
-    \\
+    \end{cases} \\
     \tau_u^{fct} &= \tau_u^{ups} + c_u \, \big( \tau_u^{cen} - \tau_u^{ups} \big)
   \end{split}
@@ -278,7 +302,7 @@
 where $c_u$ is a flux limiter function taking values between 0 and 1.
 The FCT order is the one of the centred scheme used
-(\ie it depends on the setting of \np{nn\_fct\_h} and \np{nn\_fct\_v}).
+(\ie\ it depends on the setting of \np{nn_fct_h}{nn\_fct\_h} and \np{nn_fct_v}{nn\_fct\_v}).
 There exist many ways to define $c_u$, each corresponding to a different FCT scheme.
-The one chosen in \NEMO is described in \citet{zalesak_JCP79}.
+The one chosen in \NEMO\ is described in \citet{zalesak_JCP79}.
 $c_u$ only departs from $1$ when the advective term produces a local extremum in the tracer field.
 The resulting scheme is quite expensive but \textit{positive}.
@@ -286,108 +310,101 @@
 A comparison of FCT-2 with MUSCL and a MPDATA scheme can be found in \citet{levy.estublier.ea_GRL01}.
 
-An additional option has been added controlled by \np{nn\_fct\_zts}.
-By setting this integer to a value larger than zero,
-a $2^{nd}$ order FCT scheme is used on both horizontal and vertical direction, but on the latter,
-a split-explicit time stepping is used, with a number of sub-timestep equals to \np{nn\_fct\_zts}.
-This option can be useful when the size of the timestep is limited by vertical advection \citep{lemarie.debreu.ea_OM15}.
-Note that in this case, a similar split-explicit time stepping should be used on vertical advection of momentum to
-insure a better stability (see \autoref{subsec:DYN_zad}).
-
-For stability reasons (see \autoref{chap:STP}),
-$\tau_u^{cen}$ is evaluated in (\autoref{eq:tra_adv_fct}) using the \textit{now} tracer while
+For stability reasons (see \autoref{chap:TD}),
+$\tau_u^{cen}$ is evaluated in (\autoref{eq:TRA_adv_fct}) using the \textit{now} tracer while
 $\tau_u^{ups}$ is evaluated using the \textit{before} tracer.
-In other words, the advective part of the scheme is time stepped with a leap-frog scheme
-while a forward scheme is used for the diffusive part.
-
-% -------------------------------------------------------------------------------------------------------------
-%        MUSCL scheme  
-% -------------------------------------------------------------------------------------------------------------
-\subsection[MUSCL: Monotone Upstream Scheme for Conservative Laws (\forcode{ln_traadv_mus = .true.})]
-{MUSCL: Monotone Upstream Scheme for Conservative Laws (\protect\np{ln\_traadv\_mus}\forcode{ = .true.})}
+In other words, the advective part of the scheme is time stepped with a leap-frog scheme while
+a forward scheme is used for the diffusive part.
+
+%% =================================================================================================
+\subsection[MUSCL: Monotone Upstream Scheme for Conservative Laws (\forcode{ln_traadv_mus})]{MUSCL: Monotone Upstream Scheme for Conservative Laws (\protect\np{ln_traadv_mus}{ln\_traadv\_mus})}
 \label{subsec:TRA_adv_mus}
 
-The Monotone Upstream Scheme for Conservative Laws (MUSCL) is used when \np{ln\_traadv\_mus}\forcode{ = .true.}.
+The \textbf{M}onotone \textbf{U}pstream \textbf{S}cheme for \textbf{C}onservative \textbf{L}aws
+(MUSCL) is used when \np[=.true.]{ln_traadv_mus}{ln\_traadv\_mus}.
 MUSCL implementation can be found in the \mdl{traadv\_mus} module.
 
-MUSCL has been first implemented in \NEMO by \citet{levy.estublier.ea_GRL01}.
-In its formulation, the tracer at velocity points is evaluated assuming a linear tracer variation between
-two $T$-points (\autoref{fig:adv_scheme}).
+MUSCL has been first implemented in \NEMO\ by \citet{levy.estublier.ea_GRL01}.
+In its formulation, the tracer at velocity points is evaluated assuming
+a linear tracer variation between two $T$-points (\autoref{fig:TRA_adv_scheme}).
 For example, in the $i$-direction :
-\begin{equation}
-  % \label{eq:tra_adv_mus}
+\[
+  % \label{eq:TRA_adv_mus}
   \tau_u^{mus} = \lt\{
   \begin{split}
-                       \tau_i         &+ \frac{1}{2} \lt( 1 - \frac{u_{i + 1/2} \, \rdt}{e_{1u}} \rt)
-                       \widetilde{\partial_i         \tau} & \text{if~} u_{i + 1/2} \geqslant 0 \\
-                       \tau_{i + 1/2} &+ \frac{1}{2} \lt( 1 + \frac{u_{i + 1/2} \, \rdt}{e_{1u}} \rt)
-                       \widetilde{\partial_{i + 1/2} \tau} & \text{if~} u_{i + 1/2} <         0
+    \tau_i        &+ \frac{1}{2} \lt( 1 - \frac{u_{i + 1/2} \, \rdt}{e_{1u}} \rt)
+    \widetilde{\partial_i        \tau} & \text{if~} u_{i + 1/2} \geqslant 0 \\
+    \tau_{i + 1/2} &+ \frac{1}{2} \lt( 1 + \frac{u_{i + 1/2} \, \rdt}{e_{1u}} \rt)
+    \widetilde{\partial_{i + 1/2} \tau} & \text{if~} u_{i + 1/2} <         0
   \end{split}
                                                                                                       \rt.
-\end{equation}
-where $\widetilde{\partial_i \tau}$ is the slope of the tracer on which a limitation is imposed to
-ensure the \textit{positive} character of the scheme.
-
-The time stepping is performed using a forward scheme, that is the \textit{before} tracer field is used to
-evaluate $\tau_u^{mus}$.
+\]
+where $\widetilde{\partial_i \tau}$ is the slope of the tracer on which
+a limitation is imposed to ensure the \textit{positive} character of the scheme.
+
+The time stepping is performed using a forward scheme,
+that is the \textit{before} tracer field is used to evaluate $\tau_u^{mus}$.
 
 For an ocean grid point adjacent to land and where the ocean velocity is directed toward land,
 an upstream flux is used.
 This choice ensure the \textit{positive} character of the scheme.
-In addition, fluxes round a grid-point where a runoff is applied can optionally be computed using upstream fluxes
-(\np{ln\_mus\_ups}\forcode{ = .true.}).
-
-% -------------------------------------------------------------------------------------------------------------
-%        UBS scheme  
-% -------------------------------------------------------------------------------------------------------------
-\subsection[UBS a.k.a. UP3: Upstream-Biased Scheme (\forcode{ln_traadv_ubs = .true.})]
-{UBS a.k.a. UP3: Upstream-Biased Scheme (\protect\np{ln\_traadv\_ubs}\forcode{ = .true.})}
+In addition, fluxes round a grid-point where a runoff is applied can optionally be computed using
+upstream fluxes (\np[=.true.]{ln_mus_ups}{ln\_mus\_ups}).
+
+%% =================================================================================================
+\subsection[UBS a.k.a. UP3: Upstream-Biased Scheme (\forcode{ln_traadv_ubs})]{UBS a.k.a. UP3: Upstream-Biased Scheme (\protect\np{ln_traadv_ubs}{ln\_traadv\_ubs})}
 \label{subsec:TRA_adv_ubs}
 
-The Upstream-Biased Scheme (UBS) is used when \np{ln\_traadv\_ubs}\forcode{ = .true.}.
+The \textbf{U}pstream-\textbf{B}iased \textbf{S}cheme (UBS) is used when
+\np[=.true.]{ln_traadv_ubs}{ln\_traadv\_ubs}.
 UBS implementation can be found in the \mdl{traadv\_mus} module.
 
 The UBS scheme, often called UP3, is also known as the Cell Averaged QUICK scheme
-(Quadratic Upstream Interpolation for Convective Kinematics).
+(\textbf{Q}uadratic \textbf{U}pstream \textbf{I}nterpolation for
+\textbf{C}onvective \textbf{K}inematics).
 It is an upstream-biased third order scheme based on an upstream-biased parabolic interpolation.
 For example, in the $i$-direction:
 \begin{equation}
-  \label{eq:tra_adv_ubs}
+  \label{eq:TRA_adv_ubs}
   \tau_u^{ubs} = \overline T ^{i + 1/2} - \frac{1}{6}
     \begin{cases}
-                                                      \tau"_i       & \text{if~} u_{i + 1/2} \geqslant 0 \\
-                                                      \tau"_{i + 1} & \text{if~} u_{i + 1/2} <         0
+      \tau"_i       & \text{if~} u_{i + 1/2} \geqslant 0 \\
+      \tau"_{i + 1} & \text{if~} u_{i + 1/2} <         0
     \end{cases}
-  \quad
-  \text{where~} \tau"_i = \delta_i \lt[ \delta_{i + 1/2} [\tau] \rt]
+  \quad \text{where~} \tau"_i = \delta_i \lt[ \delta_{i + 1/2} [\tau] \rt]
 \end{equation}
 
 This results in a dissipatively dominant (i.e. hyper-diffusive) truncation error
 \citep{shchepetkin.mcwilliams_OM05}.
-The overall performance of the advection scheme is similar to that reported in \cite{farrow.stevens_JPO95}.
+The overall performance of the advection scheme is similar to that reported in
+\cite{farrow.stevens_JPO95}.
 It is a relatively good compromise between accuracy and smoothness.
 Nevertheless the scheme is not \textit{positive}, meaning that false extrema are permitted,
 but the amplitude of such are significantly reduced over the centred second or fourth order method.
-Therefore it is not recommended that it should be applied to a passive tracer that requires positivity.
+Therefore it is not recommended that it should be applied to
+a passive tracer that requires positivity.
 
 The intrinsic diffusion of UBS makes its use risky in the vertical direction where
 the control of artificial diapycnal fluxes is of paramount importance
 \citep{shchepetkin.mcwilliams_OM05, demange_phd14}.
-Therefore the vertical flux is evaluated using either a $2^nd$ order FCT scheme or a $4^th$ order COMPACT scheme
-(\np{nn\_cen\_v}\forcode{ = 2 or 4}).
-
-For stability reasons (see \autoref{chap:STP}), the first term  in \autoref{eq:tra_adv_ubs}
-(which corresponds to a second order centred scheme)
-is evaluated using the \textit{now} tracer (centred in time) while the second term
-(which is the diffusive part of the scheme),
+Therefore the vertical flux is evaluated using either a $2^nd$ order FCT scheme or
+a $4^th$ order COMPACT scheme (\np[=2 or 4]{nn_ubs_v}{nn\_ubs\_v}).
+
+For stability reasons (see \autoref{chap:TD}),
+the first term  in \autoref{eq:TRA_adv_ubs} (which corresponds to a second order centred scheme)
+is evaluated using the \textit{now}    tracer (centred in time) while
+the second term (which is the diffusive part of the scheme),
 is evaluated using the \textit{before} tracer (forward in time).
-This choice is discussed by \citet{webb.de-cuevas.ea_JAOT98} in the context of the QUICK advection scheme.
+This choice is discussed by \citet{webb.de-cuevas.ea_JAOT98} in
+the context of the QUICK advection scheme.
 UBS and QUICK schemes only differ by one coefficient.
-Replacing 1/6 with 1/8 in \autoref{eq:tra_adv_ubs} leads to the QUICK advection scheme \citep{webb.de-cuevas.ea_JAOT98}.
+Replacing 1/6 with 1/8 in \autoref{eq:TRA_adv_ubs} leads to the QUICK advection scheme
+\citep{webb.de-cuevas.ea_JAOT98}.
 This option is not available through a namelist parameter, since the 1/6 coefficient is hard coded.
-Nevertheless it is quite easy to make the substitution in the \mdl{traadv\_ubs} module and obtain a QUICK scheme.
-
-Note that it is straightforward to rewrite \autoref{eq:tra_adv_ubs} as follows:
+Nevertheless it is quite easy to make the substitution in the \mdl{traadv\_ubs} module and
+obtain a QUICK scheme.
+
+Note that it is straightforward to rewrite \autoref{eq:TRA_adv_ubs} as follows:
 \begin{gather}
-  \label{eq:traadv_ubs2}
+  \label{eq:TRA_adv_ubs2}
   \tau_u^{ubs} = \tau_u^{cen4} + \frac{1}{12}
     \begin{cases}
@@ -396,32 +413,34 @@
     \end{cases}
   \intertext{or equivalently}
-  % \label{eq:traadv_ubs2b}
+  % \label{eq:TRA_adv_ubs2b}
   u_{i + 1/2} \ \tau_u^{ubs} = u_{i + 1/2} \, \overline{T - \frac{1}{6} \, \delta_i \Big[ \delta_{i + 1/2}[T] \Big]}^{\,i + 1/2}
                              - \frac{1}{2} |u|_{i + 1/2} \, \frac{1}{6} \, \delta_{i + 1/2} [\tau"_i] \nonumber
 \end{gather}
 
-\autoref{eq:traadv_ubs2} has several advantages.
+\autoref{eq:TRA_adv_ubs2} has several advantages.
 Firstly, it clearly reveals that the UBS scheme is based on the fourth order scheme to which
 an upstream-biased diffusion term is added.
-Secondly, this emphasises that the $4^{th}$ order part (as well as the $2^{nd}$ order part as stated above) has to
-be evaluated at the \textit{now} time step using \autoref{eq:tra_adv_ubs}.
-Thirdly, the diffusion term is in fact a biharmonic operator with an eddy coefficient which
-is simply proportional to the velocity: $A_u^{lm} = \frac{1}{12} \, {e_{1u}}^3 \, |u|$.
-Note the current version of NEMO uses the computationally more efficient formulation \autoref{eq:tra_adv_ubs}.
-
-% -------------------------------------------------------------------------------------------------------------
-%        QCK scheme  
-% -------------------------------------------------------------------------------------------------------------
-\subsection[QCK: QuiCKest scheme (\forcode{ln_traadv_qck = .true.})]
-{QCK: QuiCKest scheme (\protect\np{ln\_traadv\_qck}\forcode{ = .true.})}
+Secondly,
+this emphasises that the $4^{th}$ order part (as well as the $2^{nd}$ order part as stated above) has to be evaluated at the \textit{now} time step using \autoref{eq:TRA_adv_ubs}.
+Thirdly, the diffusion term is in fact a biharmonic operator with
+an eddy coefficient which is simply proportional to the velocity:
+$A_u^{lm} = \frac{1}{12} \, {e_{1u}}^3 \, |u|$.
+Note the current version of \NEMO\ uses the computationally more efficient formulation
+\autoref{eq:TRA_adv_ubs}.
+
+%% =================================================================================================
+\subsection[QCK: QuiCKest scheme (\forcode{ln_traadv_qck})]{QCK: QuiCKest scheme (\protect\np{ln_traadv_qck}{ln\_traadv\_qck})}
 \label{subsec:TRA_adv_qck}
 
-The Quadratic Upstream Interpolation for Convective Kinematics with Estimated Streaming Terms (QUICKEST) scheme
-proposed by \citet{leonard_CMAME79} is used when \np{ln\_traadv\_qck}\forcode{ = .true.}.
+The \textbf{Q}uadratic \textbf{U}pstream \textbf{I}nterpolation for
+\textbf{C}onvective \textbf{K}inematics with \textbf{E}stimated \textbf{S}treaming \textbf{T}erms
+(QUICKEST) scheme proposed by \citet{leonard_CMAME79} is used when
+\np[=.true.]{ln_traadv_qck}{ln\_traadv\_qck}.
 QUICKEST implementation can be found in the \mdl{traadv\_qck} module.
 
 QUICKEST is the third order Godunov scheme which is associated with the ULTIMATE QUICKEST limiter
 \citep{leonard_CMAME91}.
-It has been implemented in NEMO by G. Reffray (MERCATOR-ocean) and can be found in the \mdl{traadv\_qck} module.
+It has been implemented in \NEMO\ by G. Reffray (Mercator Ocean) and
+can be found in the \mdl{traadv\_qck} module.
 The resulting scheme is quite expensive but \textit{positive}.
 It can be used on both active and passive tracers.
@@ -430,26 +449,29 @@
 Therefore the vertical flux is evaluated using the CEN2 scheme.
 This no longer guarantees the positivity of the scheme.
-The use of FCT in the vertical direction (as for the UBS case) should be implemented to restore this property.
-
-%%%gmcomment   :  Cross term are missing in the current implementation....
-
-% ================================================================
-% Tracer Lateral Diffusion
-% ================================================================
-\section[Tracer lateral diffusion (\textit{traldf.F90})]
-{Tracer lateral diffusion (\protect\mdl{traldf})}
+The use of FCT in the vertical direction (as for the UBS case) should be implemented to
+restore this property.
+
+\cmtgm{Cross term are missing in the current implementation....}
+
+%% =================================================================================================
+\section[Tracer lateral diffusion (\textit{traldf.F90})]{Tracer lateral diffusion (\protect\mdl{traldf})}
 \label{sec:TRA_ldf}
-%-----------------------------------------nam_traldf------------------------------------------------------
-
-\nlst{namtra_ldf}
-%-------------------------------------------------------------------------------------------------------------
- 
-Options are defined through the \ngn{namtra\_ldf} namelist variables.
-They are regrouped in four items, allowing to specify 
-$(i)$   the type of operator used (none, laplacian, bilaplacian),
-$(ii)$  the direction along which the operator acts (iso-level, horizontal, iso-neutral),
-$(iii)$ some specific options related to the rotated operators (\ie non-iso-level operator), and
-$(iv)$  the specification of eddy diffusivity coefficient (either constant or variable in space and time).
-Item $(iv)$ will be described in \autoref{chap:LDF}.
+
+\begin{listing}
+  \nlst{namtra_ldf}
+  \caption{\forcode{&namtra_ldf}}
+  \label{lst:namtra_ldf}
+\end{listing}
+
+Options are defined through the \nam{tra_ldf}{tra\_ldf} namelist variables.
+They are regrouped in four items, allowing to specify
+\begin{enumerate*}[label=(\textit{\roman*})]
+\item the type of operator used (none, laplacian, bilaplacian),
+\item the direction along which the operator acts (iso-level, horizontal, iso-neutral),
+\item some specific options related to the rotated operators (\ie\ non-iso-level operator), and
+\item the specification of eddy diffusivity coefficient
+  (either constant or variable in space and time).
+\end{enumerate*}
+Item (iv) will be described in \autoref{chap:LDF}.
 The direction along which the operators act is defined through the slope between
 this direction and the iso-level surfaces.
@@ -457,15 +479,14 @@
 
 The lateral diffusion of tracers is evaluated using a forward scheme,
-\ie the tracers appearing in its expression are the \textit{before} tracers in time,
+\ie\ the tracers appearing in its expression are the \textit{before} tracers in time,
 except for the pure vertical component that appears when a rotation tensor is used.
-This latter component is solved implicitly together with the vertical diffusion term (see \autoref{chap:STP}).
-When \np{ln\_traldf\_msc}\forcode{ = .true.}, a Method of Stabilizing Correction is used in which
-the pure vertical component is split into an explicit and an implicit part \citep{lemarie.debreu.ea_OM12}.
-
-% -------------------------------------------------------------------------------------------------------------
-%        Type of operator
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Type of operator (\texttt{ln\_traldf}\{\texttt{\_NONE,\_lap,\_blp}\})]
-{Type of operator (\protect\np{ln\_traldf\_NONE}, \protect\np{ln\_traldf\_lap}, or \protect\np{ln\_traldf\_blp}) } 
+This latter component is solved implicitly together with the vertical diffusion term
+(see \autoref{chap:TD}).
+When \np[=.true.]{ln_traldf_msc}{ln\_traldf\_msc},
+a Method of Stabilizing Correction is used in which the pure vertical component is split into
+an explicit and an implicit part \citep{lemarie.debreu.ea_OM12}.
+
+%% =================================================================================================
+\subsection[Type of operator (\forcode{ln_traldf_}\{\forcode{OFF,lap,blp}\})]{Type of operator (\protect\np{ln_traldf_OFF}{ln\_traldf\_OFF}, \protect\np{ln_traldf_lap}{ln\_traldf\_lap}, or \protect\np{ln_traldf_blp}{ln\_traldf\_blp})}
 \label{subsec:TRA_ldf_op}
 
@@ -473,18 +494,19 @@
 
 \begin{description}
-\item[\np{ln\_traldf\_NONE}\forcode{ = .true.}:]
-  no operator selected, the lateral diffusive tendency will not be applied to the tracer equation.
-  This option can be used when the selected advection scheme is diffusive enough (MUSCL scheme for example).
-\item[\np{ln\_traldf\_lap}\forcode{ = .true.}:]
-  a laplacian operator is selected.
-  This harmonic operator takes the following expression:  $\mathpzc{L}(T) = \nabla \cdot A_{ht} \; \nabla T $,
+\item [{\np[=.true.]{ln_traldf_OFF}{ln\_traldf\_OFF}}] no operator selected,
+  the lateral diffusive tendency will not be applied to the tracer equation.
+  This option can be used when the selected advection scheme is diffusive enough
+  (MUSCL scheme for example).
+\item [{\np[=.true.]{ln_traldf_lap}{ln\_traldf\_lap}}] a laplacian operator is selected.
+  This harmonic operator takes the following expression:
+  $\mathcal{L}(T) = \nabla \cdot A_{ht} \; \nabla T $,
   where the gradient operates along the selected direction (see \autoref{subsec:TRA_ldf_dir}),
   and $A_{ht}$ is the eddy diffusivity coefficient expressed in $m^2/s$ (see \autoref{chap:LDF}).
-\item[\np{ln\_traldf\_blp}\forcode{ = .true.}]:
-  a bilaplacian operator is selected.
+\item [{\np[=.true.]{ln_traldf_blp}{ln\_traldf\_blp}}] a bilaplacian operator is selected.
   This biharmonic operator takes the following expression:
-  $\mathpzc{B} = - \mathpzc{L}(\mathpzc{L}(T)) = - \nabla \cdot b \nabla (\nabla \cdot b \nabla T)$
+  $\mathcal{B} = - \mathcal{L}(\mathcal{L}(T)) = - \nabla \cdot b \nabla (\nabla \cdot b \nabla T)$
   where the gradient operats along the selected direction,
-  and $b^2 = B_{ht}$ is the eddy diffusivity coefficient expressed in $m^4/s$ (see \autoref{chap:LDF}).
+  and $b^2 = B_{ht}$ is the eddy diffusivity coefficient expressed in $m^4/s$
+  (see \autoref{chap:LDF}).
   In the code, the bilaplacian operator is obtained by calling the laplacian twice.
 \end{description}
@@ -494,29 +516,27 @@
 minimizing the impact on the larger scale features.
 The main difference between the two operators is the scale selectiveness.
-The bilaplacian damping time (\ie its spin down time) scales like $\lambda^{-4}$ for
-disturbances of wavelength $\lambda$ (so that short waves damped more rapidelly than long ones),
+The bilaplacian damping time (\ie\ its spin down time) scales like
+$\lambda^{-4}$ for disturbances of wavelength $\lambda$
+(so that short waves damped more rapidelly than long ones),
 whereas the laplacian damping time scales only like $\lambda^{-2}$.
 
-% -------------------------------------------------------------------------------------------------------------
-%        Direction of action
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Action direction (\texttt{ln\_traldf}\{\texttt{\_lev,\_hor,\_iso,\_triad}\})]
-{Direction of action (\protect\np{ln\_traldf\_lev}, \protect\np{ln\_traldf\_hor}, \protect\np{ln\_traldf\_iso}, or \protect\np{ln\_traldf\_triad}) } 
+%% =================================================================================================
+\subsection[Action direction (\forcode{ln_traldf_}\{\forcode{lev,hor,iso,triad}\})]{Direction of action (\protect\np{ln_traldf_lev}{ln\_traldf\_lev}, \protect\np{ln_traldf_hor}{ln\_traldf\_hor}, \protect\np{ln_traldf_iso}{ln\_traldf\_iso}, or \protect\np{ln_traldf_triad}{ln\_traldf\_triad})}
 \label{subsec:TRA_ldf_dir}
 
 The choice of a direction of action determines the form of operator used.
 The operator is a simple (re-entrant) laplacian acting in the (\textbf{i},\textbf{j}) plane when
-iso-level option is used (\np{ln\_traldf\_lev}\forcode{ = .true.}) or
-when a horizontal (\ie geopotential) operator is demanded in \textit{z}-coordinate
-(\np{ln\_traldf\_hor} and \np{ln\_zco} equal \forcode{.true.}).
+iso-level option is used (\np[=.true.]{ln_traldf_lev}{ln\_traldf\_lev}) or when
+a horizontal (\ie\ geopotential) operator is demanded in \textit{z}-coordinate
+(\np{ln_traldf_hor}{ln\_traldf\_hor} and \np[=.true.]{ln_zco}{ln\_zco}).
 The associated code can be found in the \mdl{traldf\_lap\_blp} module.
 The operator is a rotated (re-entrant) laplacian when
 the direction along which it acts does not coincide with the iso-level surfaces,
 that is when standard or triad iso-neutral option is used
-(\np{ln\_traldf\_iso} or \np{ln\_traldf\_triad} equals \forcode{.true.},
+(\np{ln_traldf_iso}{ln\_traldf\_iso} or \np{ln_traldf_triad}{ln\_traldf\_triad} = \forcode{.true.},
 see \mdl{traldf\_iso} or \mdl{traldf\_triad} module, resp.), or
-when a horizontal (\ie geopotential) operator is demanded in \textit{s}-coordinate
-(\np{ln\_traldf\_hor} and \np{ln\_sco} equal \forcode{.true.})
-\footnote{In this case, the standard iso-neutral operator will be automatically selected}.
+when a horizontal (\ie\ geopotential) operator is demanded in \textit{s}-coordinate
+(\np{ln_traldf_hor}{ln\_traldf\_hor} and \np{ln_sco}{ln\_sco} = \forcode{.true.}) \footnote{
+  In this case, the standard iso-neutral operator will be automatically selected}.
 In that case, a rotation is applied to the gradient(s) that appears in the operator so that
 diffusive fluxes acts on the three spatial direction.
@@ -525,14 +545,11 @@
 the next two sub-sections.
 
-% -------------------------------------------------------------------------------------------------------------
-%       iso-level operator
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Iso-level (bi-)laplacian operator (\texttt{ln\_traldf\_iso})]
-{Iso-level (bi-)laplacian operator ( \protect\np{ln\_traldf\_iso})}
+%% =================================================================================================
+\subsection[Iso-level (bi-)laplacian operator (\forcode{ln_traldf_iso})]{Iso-level (bi-)laplacian operator ( \protect\np{ln_traldf_iso}{ln\_traldf\_iso})}
 \label{subsec:TRA_ldf_lev}
 
-The laplacian diffusion operator acting along the model (\textit{i,j})-surfaces is given by: 
-\begin{equation}
-  \label{eq:tra_ldf_lap}
+The laplacian diffusion operator acting along the model (\textit{i,j})-surfaces is given by:
+\begin{equation}
+  \label{eq:TRA_ldf_lap}
   D_t^{lT} = \frac{1}{b_t} \Bigg(   \delta_{i} \lt[ A_u^{lT} \; \frac{e_{2u} \, e_{3u}}{e_{1u}} \; \delta_{i + 1/2} [T] \rt]
                                   + \delta_{j} \lt[ A_v^{lT} \; \frac{e_{1v} \, e_{3v}}{e_{2v}} \; \delta_{j + 1/2} [T] \rt] \Bigg)
@@ -541,35 +558,37 @@
 where zero diffusive fluxes is assumed across solid boundaries,
 first (and third in bilaplacian case) horizontal tracer derivative are masked.
-It is implemented in the \rou{traldf\_lap} subroutine found in the \mdl{traldf\_lap} module.
-The module also contains \rou{traldf\_blp}, the subroutine calling twice \rou{traldf\_lap} in order to
+It is implemented in the \rou{tra\_ldf\_lap} subroutine found in the \mdl{traldf\_lap\_blp} module.
+The module also contains \rou{tra\_ldf\_blp},
+the subroutine calling twice \rou{tra\_ldf\_lap} in order to
 compute the iso-level bilaplacian operator.
 
 It is a \textit{horizontal} operator (\ie acting along geopotential surfaces) in
-the $z$-coordinate with or without partial steps, but is simply an iso-level operator in the $s$-coordinate.
-It is thus used when, in addition to \np{ln\_traldf\_lap} or \np{ln\_traldf\_blp}\forcode{ = .true.},
-we have \np{ln\_traldf\_lev}\forcode{ = .true.} or \np{ln\_traldf\_hor}~=~\np{ln\_zco}\forcode{ = .true.}.
+the $z$-coordinate with or without partial steps,
+but is simply an iso-level operator in the $s$-coordinate.
+It is thus used when,
+in addition to \np{ln_traldf_lap}{ln\_traldf\_lap} or \np[=.true.]{ln_traldf_blp}{ln\_traldf\_blp},
+we have \np[=.true.]{ln_traldf_lev}{ln\_traldf\_lev} or
+\np[=]{ln_traldf_hor}{ln\_traldf\_hor}\np[=.true.]{ln_zco}{ln\_zco}.
 In both cases, it significantly contributes to diapycnal mixing.
 It is therefore never recommended, even when using it in the bilaplacian case.
 
-Note that in the partial step $z$-coordinate (\np{ln\_zps}\forcode{ = .true.}),
+Note that in the partial step $z$-coordinate (\np[=.true.]{ln_zps}{ln\_zps}),
 tracers in horizontally adjacent cells are located at different depths in the vicinity of the bottom.
-In this case, horizontal derivatives in (\autoref{eq:tra_ldf_lap}) at the bottom level require a specific treatment.
+In this case,
+horizontal derivatives in (\autoref{eq:TRA_ldf_lap}) at the bottom level require a specific treatment.
 They are calculated in the \mdl{zpshde} module, described in \autoref{sec:TRA_zpshde}.
 
-% -------------------------------------------------------------------------------------------------------------
-%         Rotated laplacian operator
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \subsection{Standard and triad (bi-)laplacian operator}
 \label{subsec:TRA_ldf_iso_triad}
 
-%&&    Standard rotated (bi-)laplacian operator
-%&& ----------------------------------------------
-\subsubsection[Standard rotated (bi-)laplacian operator (\textit{traldf\_iso.F90})]
-{Standard rotated (bi-)laplacian operator (\protect\mdl{traldf\_iso})}
+%% =================================================================================================
+\subsubsection[Standard rotated (bi-)laplacian operator (\textit{traldf\_iso.F90})]{Standard rotated (bi-)laplacian operator (\protect\mdl{traldf\_iso})}
 \label{subsec:TRA_ldf_iso}
-The general form of the second order lateral tracer subgrid scale physics (\autoref{eq:PE_zdf})
-takes the following semi -discrete space form in $z$- and $s$-coordinates:
-\begin{equation}
-  \label{eq:tra_ldf_iso}
+
+The general form of the second order lateral tracer subgrid scale physics (\autoref{eq:MB_zdf})
+takes the following semi-discrete space form in $z$- and $s$-coordinates:
+\begin{equation}
+  \label{eq:TRA_ldf_iso}
   \begin{split}
     D_T^{lT} = \frac{1}{b_t} \Bigg[ \quad &\delta_i A_u^{lT} \lt( \frac{e_{2u} e_{3u}}{e_{1u}}                      \, \delta_{i + 1/2} [T]
@@ -584,89 +603,85 @@
 where $b_t = e_{1t} \, e_{2t} \, e_{3t}$  is the volume of $T$-cells,
 $r_1$ and $r_2$ are the slopes between the surface of computation ($z$- or $s$-surfaces) and
-the surface along which the diffusion operator acts (\ie horizontal or iso-neutral surfaces).
-It is thus used when, in addition to \np{ln\_traldf\_lap}\forcode{ = .true.},
-we have \np{ln\_traldf\_iso}\forcode{ = .true.},
-or both \np{ln\_traldf\_hor}\forcode{ = .true.} and \np{ln\_zco}\forcode{ = .true.}.
+the surface along which the diffusion operator acts (\ie\ horizontal or iso-neutral surfaces).
+It is thus used when, in addition to \np[=.true.]{ln_traldf_lap}{ln\_traldf\_lap},
+we have \np[=.true.]{ln_traldf_iso}{ln\_traldf\_iso},
+or both \np[=.true.]{ln_traldf_hor}{ln\_traldf\_hor} and \np[=.true.]{ln_zco}{ln\_zco}.
 The way these slopes are evaluated is given in \autoref{sec:LDF_slp}.
-At the surface, bottom and lateral boundaries, the turbulent fluxes of heat and salt are set to zero using
-the mask technique (see \autoref{sec:LBC_coast}).
-
-The operator in \autoref{eq:tra_ldf_iso} involves both lateral and vertical derivatives.
-For numerical stability, the vertical second derivative must be solved using the same implicit time scheme as that
-used in the vertical physics (see \autoref{sec:TRA_zdf}).
+At the surface, bottom and lateral boundaries,
+the turbulent fluxes of heat and salt are set to zero using the mask technique
+(see \autoref{sec:LBC_coast}).
+
+The operator in \autoref{eq:TRA_ldf_iso} involves both lateral and vertical derivatives.
+For numerical stability, the vertical second derivative must be solved using
+the same implicit time scheme as that used in the vertical physics (see \autoref{sec:TRA_zdf}).
 For computer efficiency reasons, this term is not computed in the \mdl{traldf\_iso} module,
 but in the \mdl{trazdf} module where, if iso-neutral mixing is used,
-the vertical mixing coefficient is simply increased by $\frac{e_{1w} e_{2w}}{e_{3w}}(r_{1w}^2 + r_{2w}^2)$.
+the vertical mixing coefficient is simply increased by
+$\frac{e_{1w} e_{2w}}{e_{3w}}(r_{1w}^2 + r_{2w}^2)$.
 
 This formulation conserves the tracer but does not ensure the decrease of the tracer variance.
-Nevertheless the treatment performed on the slopes (see \autoref{chap:LDF}) allows the model to run safely without
-any additional background horizontal diffusion \citep{guilyardi.madec.ea_CD01}.
-
-Note that in the partial step $z$-coordinate (\np{ln\_zps}\forcode{ = .true.}),
-the horizontal derivatives at the bottom level in \autoref{eq:tra_ldf_iso} require a specific treatment.
+Nevertheless the treatment performed on the slopes (see \autoref{chap:LDF}) allows the model to
+run safely without any additional background horizontal diffusion \citep{guilyardi.madec.ea_CD01}.
+
+Note that in the partial step $z$-coordinate (\np[=.true.]{ln_zps}{ln\_zps}),
+the horizontal derivatives at the bottom level in \autoref{eq:TRA_ldf_iso} require
+a specific treatment.
 They are calculated in module zpshde, described in \autoref{sec:TRA_zpshde}.
 
-%&&     Triad rotated (bi-)laplacian operator
-%&&  -------------------------------------------
-\subsubsection[Triad rotated (bi-)laplacian operator (\textit{ln\_traldf\_triad})]
-{Triad rotated (bi-)laplacian operator (\protect\np{ln\_traldf\_triad})}
+%% =================================================================================================
+\subsubsection[Triad rotated (bi-)laplacian operator (\forcode{ln_traldf_triad})]{Triad rotated (bi-)laplacian operator (\protect\np{ln_traldf_triad}{ln\_traldf\_triad})}
 \label{subsec:TRA_ldf_triad}
 
-If the Griffies triad scheme is employed (\np{ln\_traldf\_triad}\forcode{ = .true.}; see \autoref{apdx:triad})
-
-An alternative scheme developed by \cite{griffies.gnanadesikan.ea_JPO98} which ensures tracer variance decreases
-is also available in \NEMO (\np{ln\_traldf\_grif}\forcode{ = .true.}).
-A complete description of the algorithm is given in \autoref{apdx:triad}.
-
-The lateral fourth order bilaplacian operator on tracers is obtained by applying (\autoref{eq:tra_ldf_lap}) twice.
+An alternative scheme developed by \cite{griffies.gnanadesikan.ea_JPO98} which
+ensures tracer variance decreases is also available in \NEMO\
+(\np[=.true.]{ln_traldf_triad}{ln\_traldf\_triad}).
+A complete description of the algorithm is given in \autoref{apdx:TRIADS}.
+
+The lateral fourth order bilaplacian operator on tracers is obtained by
+applying (\autoref{eq:TRA_ldf_lap}) twice.
 The operator requires an additional assumption on boundary conditions:
 both first and third derivative terms normal to the coast are set to zero.
 
-The lateral fourth order operator formulation on tracers is obtained by applying (\autoref{eq:tra_ldf_iso}) twice.
+The lateral fourth order operator formulation on tracers is obtained by
+applying (\autoref{eq:TRA_ldf_iso}) twice.
 It requires an additional assumption on boundary conditions:
 first and third derivative terms normal to the coast,
 normal to the bottom and normal to the surface are set to zero.
 
-%&&    Option for the rotated operators
-%&& ----------------------------------------------
+%% =================================================================================================
 \subsubsection{Option for the rotated operators}
 \label{subsec:TRA_ldf_options}
 
-\begin{itemize}
-\item \np{ln\_traldf\_msc} = Method of Stabilizing Correction (both operators)
-\item \np{rn\_slpmax} = slope limit (both operators)
-\item \np{ln\_triad\_iso} = pure horizontal mixing in ML (triad only)
-\item \np{rn\_sw\_triad} $= 1$ switching triad; $= 0$ all 4 triads used (triad only) 
-\item \np{ln\_botmix\_triad} = lateral mixing on bottom (triad only)
-\end{itemize}
-
-% ================================================================
-% Tracer Vertical Diffusion
-% ================================================================
-\section[Tracer vertical diffusion (\textit{trazdf.F90})]
-{Tracer vertical diffusion (\protect\mdl{trazdf})}
+\begin{labeling}{{\np{ln_botmix_triad}{ln\_botmix\_triad}}}
+\item [{\np{ln_traldf_msc}{ln\_traldf\_msc}    }] Method of Stabilizing Correction (both operators)
+\item [{\np{rn_slpmax}{rn\_slpmax}             }] Slope limit (both operators)
+\item [{\np{ln_triad_iso}{ln\_triad\_iso}      }] Pure horizontal mixing in ML (triad only)
+\item [{\np{rn_sw_triad}{rn\_sw\_triad}        }] \forcode{=1} switching triad;
+  \forcode{= 0} all 4 triads used (triad only)
+\item [{\np{ln_botmix_triad}{ln\_botmix\_triad}}] Lateral mixing on bottom (triad only)
+\end{labeling}
+
+%% =================================================================================================
+\section[Tracer vertical diffusion (\textit{trazdf.F90})]{Tracer vertical diffusion (\protect\mdl{trazdf})}
 \label{sec:TRA_zdf}
-%--------------------------------------------namzdf---------------------------------------------------------
-
-\nlst{namzdf}
-%--------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{namzdf} namelist variables.
-The formulation of the vertical subgrid scale tracer physics is the same for all the vertical coordinates,
-and is based on a laplacian operator.
-The vertical diffusion operator given by (\autoref{eq:PE_zdf}) takes the following semi -discrete space form:
-\begin{gather*}
-  % \label{eq:tra_zdf}
-    D^{vT}_T = \frac{1}{e_{3t}} \, \delta_k \lt[ \, \frac{A^{vT}_w}{e_{3w}} \delta_{k + 1/2}[T] \, \rt] \\
-    D^{vS}_T = \frac{1}{e_{3t}} \; \delta_k \lt[ \, \frac{A^{vS}_w}{e_{3w}} \delta_{k + 1/2}[S] \, \rt]
-\end{gather*}
-where $A_w^{vT}$ and $A_w^{vS}$ are the vertical eddy diffusivity coefficients on temperature and salinity,
-respectively.
+
+Options are defined through the \nam{zdf}{zdf} namelist variables.
+The formulation of the vertical subgrid scale tracer physics is the same for
+all the vertical coordinates, and is based on a laplacian operator.
+The vertical diffusion operator given by (\autoref{eq:MB_zdf}) takes
+the following semi-discrete space form:
+\[
+  % \label{eq:TRA_zdf}
+  D^{vT}_T = \frac{1}{e_{3t}} \, \delta_k \lt[ \, \frac{A^{vT}_w}{e_{3w}} \delta_{k + 1/2}[T] \, \rt] \quad
+  D^{vS}_T = \frac{1}{e_{3t}} \; \delta_k \lt[ \, \frac{A^{vS}_w}{e_{3w}} \delta_{k + 1/2}[S] \, \rt]
+\]
+where $A_w^{vT}$ and $A_w^{vS}$ are the vertical eddy diffusivity coefficients on
+temperature and salinity, respectively.
 Generally, $A_w^{vT} = A_w^{vS}$ except when double diffusive mixing is parameterised
-(\ie \key{zdfddm} is defined).
+(\ie\ \np[=.true.]{ln_zdfddm}{ln\_zdfddm},).
 The way these coefficients are evaluated is given in \autoref{chap:ZDF} (ZDF).
-Furthermore, when iso-neutral mixing is used, both mixing coefficients are increased by
-$\frac{e_{1w} e_{2w}}{e_{3w} }({r_{1w}^2 + r_{2w}^2})$ to account for the vertical second derivative of
-\autoref{eq:tra_ldf_iso}.
+Furthermore, when iso-neutral mixing is used,
+both mixing coefficients are increased by $\frac{e_{1w} e_{2w}}{e_{3w} }({r_{1w}^2 + r_{2w}^2})$ to
+account for the vertical second derivative of \autoref{eq:TRA_ldf_iso}.
 
 At the surface and bottom boundaries, the turbulent fluxes of heat and salt must be specified.
@@ -675,24 +690,15 @@
 a geothermal flux forcing is prescribed as a bottom boundary condition (see \autoref{subsec:TRA_bbc}).
 
-The large eddy coefficient found in the mixed layer together with high vertical resolution implies that
-in the case of explicit time stepping (\np{ln\_zdfexp}\forcode{ = .true.})
-there would be too restrictive a constraint on the time step.
-Therefore, the default implicit time stepping is preferred for the vertical diffusion since
+The large eddy coefficient found in the mixed layer together with high vertical resolution implies
+that there would be too restrictive constraint on the time step if we use explicit time stepping.
+Therefore an implicit time stepping is preferred for the vertical diffusion since
 it overcomes the stability constraint.
-A forward time differencing scheme (\np{ln\_zdfexp}\forcode{ = .true.}) using
-a time splitting technique (\np{nn\_zdfexp} $> 1$) is provided as an alternative.
-Namelist variables \np{ln\_zdfexp} and \np{nn\_zdfexp} apply to both tracers and dynamics.
-
-% ================================================================
-% External Forcing
-% ================================================================
+
+%% =================================================================================================
 \section{External forcing}
 \label{sec:TRA_sbc_qsr_bbc}
 
-% -------------------------------------------------------------------------------------------------------------
-%        surface boundary condition
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Surface boundary condition (\textit{trasbc.F90})]
-{Surface boundary condition (\protect\mdl{trasbc})}
+%% =================================================================================================
+\subsection[Surface boundary condition (\textit{trasbc.F90})]{Surface boundary condition (\protect\mdl{trasbc})}
 \label{subsec:TRA_sbc}
 
@@ -704,84 +710,84 @@
 
 Due to interactions and mass exchange of water ($F_{mass}$) with other Earth system components
-(\ie atmosphere, sea-ice, land), the change in the heat and salt content of the surface layer of the ocean is due
-both to the heat and salt fluxes crossing the sea surface (not linked with $F_{mass}$) and
+(\ie\ atmosphere, sea-ice, land),
+the change in the heat and salt content of the surface layer of the ocean is due both to
+the heat and salt fluxes crossing the sea surface (not linked with $F_{mass}$) and
 to the heat and salt content of the mass exchange.
 They are both included directly in $Q_{ns}$, the surface heat flux,
 and $F_{salt}$, the surface salt flux (see \autoref{chap:SBC} for further details).
-By doing this, the forcing formulation is the same for any tracer (including temperature and salinity).
-
-The surface module (\mdl{sbcmod}, see \autoref{chap:SBC}) provides the following forcing fields (used on tracers):
-
-\begin{itemize}
-\item
-  $Q_{ns}$, the non-solar part of the net surface heat flux that crosses the sea surface
-  (\ie the difference between the total surface heat flux and the fraction of the short wave flux that
-  penetrates into the water column, see \autoref{subsec:TRA_qsr})
+By doing this, the forcing formulation is the same for any tracer
+(including temperature and salinity).
+
+The surface module (\mdl{sbcmod}, see \autoref{chap:SBC}) provides the following forcing fields
+(used on tracers):
+
+\begin{labeling}{\textit{fwfisf}}
+\item [$Q_{ns}$] The non-solar part of the net surface heat flux that crosses the sea surface
+  (\ie\ the difference between the total surface heat flux and
+  the fraction of the short wave flux that penetrates into the water column,
+  see \autoref{subsec:TRA_qsr})
   plus the heat content associated with of the mass exchange with the atmosphere and lands.
-\item
-  $\textit{sfx}$, the salt flux resulting from ice-ocean mass exchange (freezing, melting, ridging...)
-\item
-  \textit{emp}, the mass flux exchanged with the atmosphere (evaporation minus precipitation) and
+\item [\textit{sfx}] The salt flux resulting from ice-ocean mass exchange
+  (freezing, melting, ridging...)
+\item [\textit{emp}] The mass flux exchanged with the atmosphere (evaporation minus precipitation) and
   possibly with the sea-ice and ice-shelves.
-\item
-  \textit{rnf}, the mass flux associated with runoff
+\item [\textit{rnf}] The mass flux associated with runoff
   (see \autoref{sec:SBC_rnf} for further detail of how it acts on temperature and salinity tendencies)
-\item
-  \textit{fwfisf}, the mass flux associated with ice shelf melt,
+\item [\textit{fwfisf}] The mass flux associated with ice shelf melt,
   (see \autoref{sec:SBC_isf} for further details on how the ice shelf melt is computed and applied).
-\end{itemize}
+\end{labeling}
 
 The surface boundary condition on temperature and salinity is applied as follows:
 \begin{equation}
-  \label{eq:tra_sbc}
-  \begin{alignedat}{2}
-    F^T &= \frac{1}{C_p} &\frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}} &\overline{Q_{ns}      }^t \\
-    F^S &=               &\frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}} &\overline{\textit{sfx}}^t
-  \end{alignedat}
+  \label{eq:TRA_sbc}
+    F^T = \frac{1}{C_p} \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}} \overline{Q_{ns}      }^t \qquad
+    F^S =               \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}} \overline{\textit{sfx}}^t
 \end{equation}
 where $\overline x^t$ means that $x$ is averaged over two consecutive time steps
 ($t - \rdt / 2$ and $t + \rdt / 2$).
-Such time averaging prevents the divergence of odd and even time step (see \autoref{chap:STP}).
-
-In the linear free surface case (\np{ln\_linssh}\forcode{ = .true.}), an additional term has to be added on
-both temperature and salinity.
-On temperature, this term remove the heat content associated with mass exchange that has been added to $Q_{ns}$.
-On salinity, this term mimics the concentration/dilution effect that would have resulted from a change in
-the volume of the first level.
+Such time averaging prevents the divergence of odd and even time step (see \autoref{chap:TD}).
+
+In the linear free surface case (\np[=.true.]{ln_linssh}{ln\_linssh}),
+an additional term has to be added on both temperature and salinity.
+On temperature, this term remove the heat content associated with
+mass exchange that has been added to $Q_{ns}$.
+On salinity, this term mimics the concentration/dilution effect that would have resulted from
+a change in the volume of the first level.
 The resulting surface boundary condition is applied as follows:
 \begin{equation}
-  \label{eq:tra_sbc_lin}
-  \begin{alignedat}{2}
-    F^T &= \frac{1}{C_p} &\frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}}
-          &\overline{(Q_{ns}       - C_p \, \textit{emp} \lt. T \rt|_{k = 1})}^t \\
-    F^S &=               &\frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}}
-          &\overline{(\textit{sfx} -        \textit{emp} \lt. S \rt|_{k = 1})}^t
-  \end{alignedat}
-\end{equation} 
-Note that an exact conservation of heat and salt content is only achieved with non-linear free surface.
+  \label{eq:TRA_sbc_lin}
+    F^T = \frac{1}{C_p} \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}}
+          \overline{(Q_{ns}       - C_p \, \textit{emp} \lt. T \rt|_{k = 1})}^t \qquad
+    F^S =               \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}}
+          \overline{(\textit{sfx} -        \textit{emp} \lt. S \rt|_{k = 1})}^t
+\end{equation}
+Note that an exact conservation of heat and salt content is only achieved with
+non-linear free surface.
 In the linear free surface case, there is a small imbalance.
-The imbalance is larger than the imbalance associated with the Asselin time filter \citep{leclair.madec_OM09}.
-This is the reason why the modified filter is not applied in the linear free surface case (see \autoref{chap:STP}).
-
-% -------------------------------------------------------------------------------------------------------------
-%        Solar Radiation Penetration 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Solar radiation penetration (\textit{traqsr.F90})]
-{Solar radiation penetration (\protect\mdl{traqsr})}
+The imbalance is larger than the imbalance associated with the Asselin time filter
+\citep{leclair.madec_OM09}.
+This is the reason why the modified filter is not applied in the linear free surface case
+(see \autoref{chap:TD}).
+
+%% =================================================================================================
+\subsection[Solar radiation penetration (\textit{traqsr.F90})]{Solar radiation penetration (\protect\mdl{traqsr})}
 \label{subsec:TRA_qsr}
-%--------------------------------------------namqsr--------------------------------------------------------
-
-\nlst{namtra_qsr}
-%--------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{namtra\_qsr} namelist variables.
-When the penetrative solar radiation option is used (\np{ln\_flxqsr}\forcode{ = .true.}),
+
+\begin{listing}
+  \nlst{namtra_qsr}
+  \caption{\forcode{&namtra_qsr}}
+  \label{lst:namtra_qsr}
+\end{listing}
+
+Options are defined through the \nam{tra_qsr}{tra\_qsr} namelist variables.
+When the penetrative solar radiation option is used (\np[=.true.]{ln_traqsr}{ln\_traqsr}),
 the solar radiation penetrates the top few tens of meters of the ocean.
-If it is not used (\np{ln\_flxqsr}\forcode{ = .false.}) all the heat flux is absorbed in the first ocean level.
-Thus, in the former case a term is added to the time evolution equation of temperature \autoref{eq:PE_tra_T} and
-the surface boundary condition is modified to take into account only the non-penetrative part of the surface 
-heat flux:
-\begin{equation}
-  \label{eq:PE_qsr}
+If it is not used (\np[=.false.]{ln_traqsr}{ln\_traqsr}) all the heat flux is absorbed in
+the first ocean level.
+Thus, in the former case a term is added to the time evolution equation of temperature
+\autoref{eq:MB_PE_tra_T} and the surface boundary condition is modified to
+take into account only the non-penetrative part of the surface heat flux:
+\begin{equation}
+  \label{eq:TRA_PE_qsr}
   \begin{gathered}
     \pd[T]{t} = \ldots + \frac{1}{\rho_o \, C_p \, e_3} \; \pd[I]{k} \\
@@ -789,72 +795,75 @@
   \end{gathered}
 \end{equation}
-where $Q_{sr}$ is the penetrative part of the surface heat flux (\ie the shortwave radiation) and
+where $Q_{sr}$ is the penetrative part of the surface heat flux (\ie\ the shortwave radiation) and
 $I$ is the downward irradiance ($\lt. I \rt|_{z = \eta} = Q_{sr}$).
-The additional term in \autoref{eq:PE_qsr} is discretized as follows:
-\begin{equation}
-  \label{eq:tra_qsr}
+The additional term in \autoref{eq:TRA_PE_qsr} is discretized as follows:
+\begin{equation}
+  \label{eq:TRA_qsr}
   \frac{1}{\rho_o \, C_p \, e_3} \, \pd[I]{k} \equiv \frac{1}{\rho_o \, C_p \, e_{3t}} \delta_k [I_w]
 \end{equation}
 
 The shortwave radiation, $Q_{sr}$, consists of energy distributed across a wide spectral range.
-The ocean is strongly absorbing for wavelengths longer than 700~nm and these wavelengths contribute to
-heating the upper few tens of centimetres.
-The fraction of $Q_{sr}$ that resides in these almost non-penetrative wavebands, $R$, is $\sim 58\%$
-(specified through namelist parameter \np{rn\_abs}).
-It is assumed to penetrate the ocean with a decreasing exponential profile, with an e-folding depth scale, $\xi_0$,
-of a few tens of centimetres (typically $\xi_0 = 0.35~m$ set as \np{rn\_si0} in the \ngn{namtra\_qsr} namelist).
-For shorter wavelengths (400-700~nm), the ocean is more transparent, and solar energy propagates to
-larger depths where it contributes to local heating.
-The way this second part of the solar energy penetrates into the ocean depends on which formulation is chosen.
-In the simple 2-waveband light penetration scheme (\np{ln\_qsr\_2bd}\forcode{ = .true.})
+The ocean is strongly absorbing for wavelengths longer than 700 $nm$ and
+these wavelengths contribute to heat the upper few tens of centimetres.
+The fraction of $Q_{sr}$ that resides in these almost non-penetrative wavebands, $R$, is $\sim$ 58\%
+(specified through namelist parameter \np{rn_abs}{rn\_abs}).
+It is assumed to penetrate the ocean with a decreasing exponential profile,
+with an e-folding depth scale, $\xi_0$, of a few tens of centimetres
+(typically $\xi_0 = 0.35~m$ set as \np{rn_si0}{rn\_si0} in the \nam{tra_qsr}{tra\_qsr} namelist).
+For shorter wavelengths (400-700 $nm$), the ocean is more transparent,
+and solar energy propagates to larger depths where it contributes to local heating.
+The way this second part of the solar energy penetrates into
+the ocean depends on which formulation is chosen.
+In the simple 2-waveband light penetration scheme (\np[=.true.]{ln_qsr_2bd}{ln\_qsr\_2bd})
 a chlorophyll-independent monochromatic formulation is chosen for the shorter wavelengths,
 leading to the following expression \citep{paulson.simpson_JPO77}:
 \[
-  % \label{eq:traqsr_iradiance}
+  % \label{eq:TRA_qsr_iradiance}
   I(z) = Q_{sr} \lt[ Re^{- z / \xi_0} + (1 - R) e^{- z / \xi_1} \rt]
 \]
 where $\xi_1$ is the second extinction length scale associated with the shorter wavelengths.
-It is usually chosen to be 23~m by setting the \np{rn\_si0} namelist parameter.
-The set of default values ($\xi_0, \xi_1, R$) corresponds to a Type I water in Jerlov's (1968) classification
-(oligotrophic waters).
+It is usually chosen to be 23~m by setting the \np{rn_si0}{rn\_si0} namelist parameter.
+The set of default values ($\xi_0, \xi_1, R$) corresponds to
+a Type I water in Jerlov's (1968) classification (oligotrophic waters).
 
 Such assumptions have been shown to provide a very crude and simplistic representation of
-observed light penetration profiles (\cite{morel_JGR88}, see also \autoref{fig:traqsr_irradiance}).
+observed light penetration profiles (\cite{morel_JGR88}, see also \autoref{fig:TRA_qsr_irradiance}).
 Light absorption in the ocean depends on particle concentration and is spectrally selective.
 \cite{morel_JGR88} has shown that an accurate representation of light penetration can be provided by
 a 61 waveband formulation.
 Unfortunately, such a model is very computationally expensive.
-Thus, \cite{lengaigne.menkes.ea_CD07} have constructed a simplified version of this formulation in which
-visible light is split into three wavebands: blue (400-500 nm), green (500-600 nm) and red (600-700nm).
-For each wave-band, the chlorophyll-dependent attenuation coefficient is fitted to the coefficients computed from
-the full spectral model of \cite{morel_JGR88} (as modified by \cite{morel.maritorena_JGR01}),
-assuming the same power-law relationship.
-As shown in \autoref{fig:traqsr_irradiance}, this formulation, called RGB (Red-Green-Blue),
+Thus, \cite{lengaigne.menkes.ea_CD07} have constructed a simplified version of
+this formulation in which visible light is split into three wavebands:
+blue (400-500 $nm$), green (500-600 $nm$) and red (600-700 $nm$).
+For each wave-band, the chlorophyll-dependent attenuation coefficient is fitted to
+the coefficients computed from the full spectral model of \cite{morel_JGR88}
+(as modified by \cite{morel.maritorena_JGR01}), assuming the same power-law relationship.
+As shown in \autoref{fig:TRA_qsr_irradiance}, this formulation,
+called RGB (\textbf{R}ed-\textbf{G}reen-\textbf{B}lue),
 reproduces quite closely the light penetration profiles predicted by the full spectal model,
 but with much greater computational efficiency.
 The 2-bands formulation does not reproduce the full model very well.
 
-The RGB formulation is used when \np{ln\_qsr\_rgb}\forcode{ = .true.}.
-The RGB attenuation coefficients (\ie the inverses of the extinction length scales) are tabulated over
-61 nonuniform chlorophyll classes ranging from 0.01 to 10 g.Chl/L
+The RGB formulation is used when \np[=.true.]{ln_qsr_rgb}{ln\_qsr\_rgb}.
+The RGB attenuation coefficients (\ie\ the inverses of the extinction length scales) are
+tabulated over 61 nonuniform chlorophyll classes ranging from 0.01 to 10 $g.Chl/L$
 (see the routine \rou{trc\_oce\_rgb} in \mdl{trc\_oce} module).
 Four types of chlorophyll can be chosen in the RGB formulation:
 
 \begin{description}
-\item[\np{nn\_chdta}\forcode{ = 0}]
-  a constant 0.05 g.Chl/L value everywhere ; 
-\item[\np{nn\_chdta}\forcode{ = 1}]
-  an observed time varying chlorophyll deduced from satellite surface ocean color measurement spread uniformly in
-  the vertical direction;
-\item[\np{nn\_chdta}\forcode{ = 2}]
-  same as previous case except that a vertical profile of chlorophyl is used.
-  Following \cite{morel.berthon_LO89}, the profile is computed from the local surface chlorophyll value;
-\item[\np{ln\_qsr\_bio}\forcode{ = .true.}]
-  simulated time varying chlorophyll by TOP biogeochemical model.
-  In this case, the RGB formulation is used to calculate both the phytoplankton light limitation in
-  PISCES or LOBSTER and the oceanic heating rate.
-\end{description} 
-
-The trend in \autoref{eq:tra_qsr} associated with the penetration of the solar radiation is added to
+\item [{\np[=0]{nn_chldta}{nn\_chldta}}] a constant 0.05 $g.Chl/L$ value everywhere;
+\item [{\np[=1]{nn_chldta}{nn\_chldta}}] an observed time varying chlorophyll deduced from
+  satellite surface ocean color measurement spread uniformly in the vertical direction;
+\item [{\np[=2]{nn_chldta}{nn\_chldta}}] same as previous case except that
+  a vertical profile of chlorophyl is used.
+  Following \cite{morel.berthon_LO89},
+  the profile is computed from the local surface chlorophyll value;
+\item [{\np[=.true.]{ln_qsr_bio}{ln\_qsr\_bio}}] simulated time varying chlorophyll by
+  \TOP\ biogeochemical model.
+  In this case, the RGB formulation is used to calculate both
+  the phytoplankton light limitation in \PISCES\ and the oceanic heating rate.
+\end{description}
+
+The trend in \autoref{eq:TRA_qsr} associated with the penetration of the solar radiation is added to
 the temperature trend, and the surface heat flux is modified in routine \mdl{traqsr}.
 
@@ -862,79 +871,77 @@
 the depth of $w-$levels does not significantly vary with location.
 The level at which the light has been totally absorbed
-(\ie it is less than the computer precision) is computed once,
+(\ie\ it is less than the computer precision) is computed once,
 and the trend associated with the penetration of the solar radiation is only added down to that level.
-Finally, note that when the ocean is shallow ($<$ 200~m), part of the solar radiation can reach the ocean floor.
+Finally, note that when the ocean is shallow ($<$ 200~m),
+part of the solar radiation can reach the ocean floor.
 In this case, we have chosen that all remaining radiation is absorbed in the last ocean level
-(\ie $I$ is masked).
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_TRA_Irradiance}
-    \caption{
-      \protect\label{fig:traqsr_irradiance}
-      Penetration profile of the downward solar irradiance calculated by four models.
-      Two waveband chlorophyll-independent formulation (blue),
-      a chlorophyll-dependent monochromatic formulation (green),
-      4 waveband RGB formulation (red),
-      61 waveband Morel (1988) formulation (black) for a chlorophyll concentration of
-      (a) Chl=0.05 mg/m$^3$ and (b) Chl=0.5 mg/m$^3$.
-      From \citet{lengaigne.menkes.ea_CD07}.
-    }
-  \end{center}
+(\ie\ $I$ is masked).
+
+\begin{figure}
+  \centering
+  \includegraphics[width=0.66\textwidth]{TRA_Irradiance}
+  \caption[Penetration profile of the downward solar irradiance calculated by four models]{
+    Penetration profile of the downward solar irradiance calculated by four models.
+    Two waveband chlorophyll-independent formulation (blue),
+    a chlorophyll-dependent monochromatic formulation (green),
+    4 waveband RGB formulation (red),
+    61 waveband Morel (1988) formulation (black) for a chlorophyll concentration of
+    (a) Chl=0.05 $mg/m^3$ and (b) Chl=0.5 $mg/m^3$.
+    From \citet{lengaigne.menkes.ea_CD07}.}
+  \label{fig:TRA_qsr_irradiance}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -------------------------------------------------------------------------------------------------------------
-%        Bottom Boundary Condition
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Bottom boundary condition (\textit{trabbc.F90})]
-{Bottom boundary condition (\protect\mdl{trabbc})}
+
+%% =================================================================================================
+\subsection[Bottom boundary condition (\textit{trabbc.F90}) - \forcode{ln_trabbc})]{Bottom boundary condition (\protect\mdl{trabbc} - \protect\np{ln_trabbc}{ln\_trabbc})}
 \label{subsec:TRA_bbc}
-%--------------------------------------------nambbc--------------------------------------------------------
-
-\nlst{nambbc}
-%--------------------------------------------------------------------------------------------------------------
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_TRA_geoth}
-    \caption{
-      \protect\label{fig:geothermal}
-      Geothermal Heat flux (in $mW.m^{-2}$) used by \cite{emile-geay.madec_OS09}.
-      It is inferred from the age of the sea floor and the formulae of \citet{stein.stein_N92}.
-    }
-  \end{center}
+
+\begin{listing}
+  \nlst{nambbc}
+  \caption{\forcode{&nambbc}}
+  \label{lst:nambbc}
+\end{listing}
+
+\begin{figure}
+  \centering
+  \includegraphics[width=0.66\textwidth]{TRA_geoth}
+  \caption[Geothermal heat flux]{
+    Geothermal Heat flux (in $mW.m^{-2}$) used by \cite{emile-geay.madec_OS09}.
+    It is inferred from the age of the sea floor and the formulae of \citet{stein.stein_N92}.}
+  \label{fig:TRA_geothermal}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 Usually it is assumed that there is no exchange of heat or salt through the ocean bottom,
-\ie a no flux boundary condition is applied on active tracers at the bottom.
+\ie\ a no flux boundary condition is applied on active tracers at the bottom.
 This is the default option in \NEMO, and it is implemented using the masking technique.
-However, there is a non-zero heat flux across the seafloor that is associated with solid earth cooling.
-This flux is weak compared to surface fluxes (a mean global value of $\sim 0.1 \, W/m^2$ \citep{stein.stein_N92}),
+However, there is a non-zero heat flux across the seafloor that
+is associated with solid earth cooling.
+This flux is weak compared to surface fluxes
+(a mean global value of $\sim 0.1 \, W/m^2$ \citep{stein.stein_N92}),
 but it warms systematically the ocean and acts on the densest water masses.
 Taking this flux into account in a global ocean model increases the deepest overturning cell
-(\ie the one associated with the Antarctic Bottom Water) by a few Sverdrups \citep{emile-geay.madec_OS09}.
-
-Options are defined through the  \ngn{namtra\_bbc} namelist variables.
-The presence of geothermal heating is controlled by setting the namelist parameter \np{ln\_trabbc} to true.
-Then, when \np{nn\_geoflx} is set to 1, a constant geothermal heating is introduced whose value is given by
-the \np{nn\_geoflx\_cst}, which is also a namelist parameter.
-When \np{nn\_geoflx} is set to 2, a spatially varying geothermal heat flux is introduced which is provided in
-the \ifile{geothermal\_heating} NetCDF file (\autoref{fig:geothermal}) \citep{emile-geay.madec_OS09}.
-
-% ================================================================
-% Bottom Boundary Layer
-% ================================================================
-\section[Bottom boundary layer (\textit{trabbl.F90} - \texttt{\textbf{key\_trabbl}})]
-{Bottom boundary layer (\protect\mdl{trabbl} - \protect\key{trabbl})}
+(\ie\ the one associated with the Antarctic Bottom Water) by
+a few Sverdrups \citep{emile-geay.madec_OS09}.
+
+Options are defined through the \nam{bbc}{bbc} namelist variables.
+The presence of geothermal heating is controlled by
+setting the namelist parameter \np{ln_trabbc}{ln\_trabbc} to true.
+Then, when \np{nn_geoflx}{nn\_geoflx} is set to 1, a constant geothermal heating is introduced whose
+value is given by the \np{rn_geoflx_cst}{rn\_geoflx\_cst}, which is also a namelist parameter.
+When \np{nn_geoflx}{nn\_geoflx} is set to 2,
+a spatially varying geothermal heat flux is introduced which is provided in
+the \ifile{geothermal\_heating} NetCDF file
+(\autoref{fig:TRA_geothermal}) \citep{emile-geay.madec_OS09}.
+
+%% =================================================================================================
+\section[Bottom boundary layer (\textit{trabbl.F90} - \forcode{ln_trabbl})]{Bottom boundary layer (\protect\mdl{trabbl} - \protect\np{ln_trabbl}{ln\_trabbl})}
 \label{sec:TRA_bbl}
-%--------------------------------------------nambbl---------------------------------------------------------
-
-\nlst{nambbl}
-%--------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{nambbl} namelist variables.
+
+\begin{listing}
+  \nlst{nambbl}
+  \caption{\forcode{&nambbl}}
+  \label{lst:nambbl}
+\end{listing}
+
+Options are defined through the \nam{bbl}{bbl} namelist variables.
 In a $z$-coordinate configuration, the bottom topography is represented by a series of discrete steps.
 This is not adequate to represent gravity driven downslope flows.
@@ -942,65 +949,66 @@
 where dense water formed in marginal seas flows into a basin filled with less dense water,
 or along the continental slope when dense water masses are formed on a continental shelf.
-The amount of entrainment that occurs in these gravity plumes is critical in determining the density and
-volume flux of the densest waters of the ocean, such as Antarctic Bottom Water, or North Atlantic Deep Water.
+The amount of entrainment that occurs in these gravity plumes is critical in
+determining the density and volume flux of the densest waters of the ocean,
+such as Antarctic Bottom Water, or North Atlantic Deep Water.
 $z$-coordinate models tend to overestimate the entrainment,
-because the gravity flow is mixed vertically by convection as it goes ''downstairs'' following the step topography,
+because the gravity flow is mixed vertically by convection as
+it goes ''downstairs'' following the step topography,
 sometimes over a thickness much larger than the thickness of the observed gravity plume.
-A similar problem occurs in the $s$-coordinate when the thickness of the bottom level varies rapidly downstream of
-a sill \citep{willebrand.barnier.ea_PO01}, and the thickness of the plume is not resolved.
-
-The idea of the bottom boundary layer (BBL) parameterisation, first introduced by \citet{beckmann.doscher_JPO97},
+A similar problem occurs in the $s$-coordinate when
+the thickness of the bottom level varies rapidly downstream of a sill
+\citep{willebrand.barnier.ea_PO01}, and the thickness of the plume is not resolved.
+
+The idea of the bottom boundary layer (BBL) parameterisation, first introduced by
+\citet{beckmann.doscher_JPO97},
 is to allow a direct communication between two adjacent bottom cells at different levels,
 whenever the densest water is located above the less dense water.
-The communication can be by a diffusive flux (diffusive BBL), an advective flux (advective BBL), or both.
+The communication can be by a diffusive flux (diffusive BBL),
+an advective flux (advective BBL), or both.
 In the current implementation of the BBL, only the tracers are modified, not the velocities.
-Furthermore, it only connects ocean bottom cells, and therefore does not include all the improvements introduced by
-\citet{campin.goosse_T99}.
-
-% -------------------------------------------------------------------------------------------------------------
-%        Diffusive BBL
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Diffusive bottom boundary layer (\forcode{nn_bbl_ldf = 1})]
-{Diffusive bottom boundary layer (\protect\np{nn\_bbl\_ldf}\forcode{ = 1})}
+Furthermore, it only connects ocean bottom cells,
+and therefore does not include all the improvements introduced by \citet{campin.goosse_T99}.
+
+%% =================================================================================================
+\subsection[Diffusive bottom boundary layer (\forcode{nn_bbl_ldf=1})]{Diffusive bottom boundary layer (\protect\np[=1]{nn_bbl_ldf}{nn\_bbl\_ldf})}
 \label{subsec:TRA_bbl_diff}
 
-When applying sigma-diffusion (\key{trabbl} defined and \np{nn\_bbl\_ldf} set to 1),
-the diffusive flux between two adjacent cells at the ocean floor is given by 
+When applying sigma-diffusion
+(\np[=.true.]{ln_trabbl}{ln\_trabbl} and \np{nn_bbl_ldf}{nn\_bbl\_ldf} set to 1),
+the diffusive flux between two adjacent cells at the ocean floor is given by
 \[
-  % \label{eq:tra_bbl_diff}
+  % \label{eq:TRA_bbl_diff}
   \vect F_\sigma = A_l^\sigma \, \nabla_\sigma T
 \]
-with $\nabla_\sigma$ the lateral gradient operator taken between bottom cells, and
-$A_l^\sigma$ the lateral diffusivity in the BBL.
+with $\nabla_\sigma$ the lateral gradient operator taken between bottom cells,
+and $A_l^\sigma$ the lateral diffusivity in the BBL.
 Following \citet{beckmann.doscher_JPO97}, the latter is prescribed with a spatial dependence,
-\ie in the conditional form
-\begin{equation}
-  \label{eq:tra_bbl_coef}
+\ie\ in the conditional form
+\begin{equation}
+  \label{eq:TRA_bbl_coef}
   A_l^\sigma (i,j,t) =
       \begin{cases}
         A_{bbl} & \text{if~} \nabla_\sigma \rho \cdot \nabla H < 0 \\
-        \\
-        0      & \text{otherwise} \\
+        0      & \text{otherwise}
       \end{cases}
 \end{equation}
-where $A_{bbl}$ is the BBL diffusivity coefficient, given by the namelist parameter \np{rn\_ahtbbl} and
+where $A_{bbl}$ is the BBL diffusivity coefficient,
+given by the namelist parameter \np{rn_ahtbbl}{rn\_ahtbbl} and
 usually set to a value much larger than the one used for lateral mixing in the open ocean.
-The constraint in \autoref{eq:tra_bbl_coef} implies that sigma-like diffusion only occurs when
+The constraint in \autoref{eq:TRA_bbl_coef} implies that sigma-like diffusion only occurs when
 the density above the sea floor, at the top of the slope, is larger than in the deeper ocean
-(see green arrow in \autoref{fig:bbl}).
+(see green arrow in \autoref{fig:TRA_bbl}).
 In practice, this constraint is applied separately in the two horizontal directions,
-and the density gradient in \autoref{eq:tra_bbl_coef} is evaluated with the log gradient formulation: 
+and the density gradient in \autoref{eq:TRA_bbl_coef} is evaluated with the log gradient formulation:
 \[
-  % \label{eq:tra_bbl_Drho}
+  % \label{eq:TRA_bbl_Drho}
   \nabla_\sigma \rho / \rho = \alpha \, \nabla_\sigma T + \beta \, \nabla_\sigma S
 \]
-where $\rho$, $\alpha$ and $\beta$ are functions of $\overline T^\sigma$, $\overline S^\sigma$ and
-$\overline H^\sigma$, the along bottom mean temperature, salinity and depth, respectively.
-
-% -------------------------------------------------------------------------------------------------------------
-%        Advective BBL
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Advective bottom boundary layer (\forcode{nn_bbl_adv = [12]})]
-{Advective bottom boundary layer (\protect\np{nn\_bbl\_adv}\forcode{ = [12]})}
+where $\rho$, $\alpha$ and $\beta$ are functions of
+$\overline T^\sigma$, $\overline S^\sigma$ and $\overline H^\sigma$,
+the along bottom mean temperature, salinity and depth, respectively.
+
+%% =================================================================================================
+\subsection[Advective bottom boundary layer (\forcode{nn_bbl_adv=1,2})]{Advective bottom boundary layer (\protect\np[=1,2]{nn_bbl_adv}{nn\_bbl\_adv})}
 \label{subsec:TRA_bbl_adv}
 
@@ -1010,20 +1018,18 @@
 %}
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_BBL_adv}
-    \caption{
-      \protect\label{fig:bbl}
-      Advective/diffusive Bottom Boundary Layer.
-      The BBL parameterisation is activated when $\rho^i_{kup}$ is larger than $\rho^{i + 1}_{kdnw}$.
-      Red arrows indicate the additional overturning circulation due to the advective BBL.
-      The transport of the downslope flow is defined either as the transport of the bottom ocean cell (black arrow),
-      or as a function of the along slope density gradient.
-      The green arrow indicates the diffusive BBL flux directly connecting $kup$ and $kdwn$ ocean bottom cells.
-    }
-  \end{center}
+\begin{figure}
+  \centering
+  \includegraphics[width=0.33\textwidth]{TRA_BBL_adv}
+  \caption[Advective/diffusive bottom boundary layer]{
+    Advective/diffusive Bottom Boundary Layer.
+    The BBL parameterisation is activated when $\rho^i_{kup}$ is larger than $\rho^{i + 1}_{kdnw}$.
+    Red arrows indicate the additional overturning circulation due to the advective BBL.
+    The transport of the downslope flow is defined either
+    as the transport of the bottom ocean cell (black arrow),
+    or as a function of the along slope density gradient.
+    The green arrow indicates the diffusive BBL flux directly connecting
+    $kup$ and $kdwn$ ocean bottom cells.}
+  \label{fig:TRA_bbl}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 %!!      nn_bbl_adv = 1   use of the ocean velocity as bbl velocity
@@ -1031,57 +1037,56 @@
 %!!        i.e. transport proportional to the along-slope density gradient
 
-%%%gmcomment   :  this section has to be really written
-
-When applying an advective BBL (\np{nn\_bbl\_adv}\forcode{ = 1..2}), an overturning circulation is added which
-connects two adjacent bottom grid-points only if dense water overlies less dense water on the slope.
+\cmtgm{This section has to be really written}
+
+When applying an advective BBL (\np[=1..2]{nn_bbl_adv}{nn\_bbl\_adv}),
+an overturning circulation is added which connects two adjacent bottom grid-points only if
+dense water overlies less dense water on the slope.
 The density difference causes dense water to move down the slope.
 
-\np{nn\_bbl\_adv}\forcode{ = 1}:
-the downslope velocity is chosen to be the Eulerian ocean velocity just above the topographic step
-(see black arrow in \autoref{fig:bbl}) \citep{beckmann.doscher_JPO97}.
-It is a \textit{conditional advection}, that is, advection is allowed only
-if dense water overlies less dense water on the slope (\ie $\nabla_\sigma \rho \cdot \nabla H < 0$) and
-if the velocity is directed towards greater depth (\ie $\vect U \cdot \nabla H > 0$).
-
-\np{nn\_bbl\_adv}\forcode{ = 2}:
-the downslope velocity is chosen to be proportional to $\Delta \rho$,
-the density difference between the higher cell and lower cell densities \citep{campin.goosse_T99}.
-The advection is allowed only  if dense water overlies less dense water on the slope
-(\ie $\nabla_\sigma \rho \cdot \nabla H < 0$).
-For example, the resulting transport of the downslope flow, here in the $i$-direction (\autoref{fig:bbl}),
-is simply given by the following expression:
-\[
-  % \label{eq:bbl_Utr}
-  u^{tr}_{bbl} = \gamma g \frac{\Delta \rho}{\rho_o} e_{1u} \, min ({e_{3u}}_{kup},{e_{3u}}_{kdwn})
-\]
-where $\gamma$, expressed in seconds, is the coefficient of proportionality provided as \np{rn\_gambbl},
-a namelist parameter, and \textit{kup} and \textit{kdwn} are the vertical index of the higher and lower cells,
-respectively.
-The parameter $\gamma$ should take a different value for each bathymetric step, but for simplicity,
-and because no direct estimation of this parameter is available, a uniform value has been assumed.
-The possible values for $\gamma$ range between 1 and $10~s$ \citep{campin.goosse_T99}.
-
-Scalar properties are advected by this additional transport $(u^{tr}_{bbl},v^{tr}_{bbl})$ using the upwind scheme.
-Such a diffusive advective scheme has been chosen to mimic the entrainment between the downslope plume and
-the surrounding water at intermediate depths.
+\begin{description}
+\item [{\np[=1]{nn_bbl_adv}{nn\_bbl\_adv}}] the downslope velocity is chosen to
+  be the Eulerian ocean velocity just above the topographic step
+  (see black arrow in \autoref{fig:TRA_bbl}) \citep{beckmann.doscher_JPO97}.
+  It is a \textit{conditional advection}, that is,
+  advection is allowed only if dense water overlies less dense water on the slope
+  (\ie\ $\nabla_\sigma \rho \cdot \nabla H < 0$) and if the velocity is directed towards greater depth
+  (\ie\ $\vect U \cdot \nabla H > 0$).
+\item [{\np[=2]{nn_bbl_adv}{nn\_bbl\_adv}}] the downslope velocity is chosen to be proportional to
+  $\Delta \rho$, the density difference between the higher cell and lower cell densities
+  \citep{campin.goosse_T99}.
+  The advection is allowed only  if dense water overlies less dense water on the slope
+  (\ie\ $\nabla_\sigma \rho \cdot \nabla H < 0$).
+  For example, the resulting transport of the downslope flow, here in the $i$-direction
+  (\autoref{fig:TRA_bbl}), is simply given by the following expression:
+  \[
+    % \label{eq:TRA_bbl_Utr}
+    u^{tr}_{bbl} = \gamma g \frac{\Delta \rho}{\rho_o} e_{1u} \, min ({e_{3u}}_{kup},{e_{3u}}_{kdwn})
+  \]
+  where $\gamma$, expressed in seconds, is the coefficient of proportionality provided as
+  \np{rn_gambbl}{rn\_gambbl}, a namelist parameter, and
+  \textit{kup} and \textit{kdwn} are the vertical index of the higher and lower cells, respectively.
+  The parameter $\gamma$ should take a different value for each bathymetric step, but for simplicity,
+  and because no direct estimation of this parameter is available, a uniform value has been assumed.
+  The possible values for $\gamma$ range between 1 and $10~s$ \citep{campin.goosse_T99}.
+\end{description}
+
+Scalar properties are advected by this additional transport $(u^{tr}_{bbl},v^{tr}_{bbl})$ using
+the upwind scheme.
+Such a diffusive advective scheme has been chosen to mimic the entrainment between
+the downslope plume and the surrounding water at intermediate depths.
 The entrainment is replaced by the vertical mixing implicit in the advection scheme.
-Let us consider as an example the case displayed in \autoref{fig:bbl} where
+Let us consider as an example the case displayed in \autoref{fig:TRA_bbl} where
 the density at level $(i,kup)$ is larger than the one at level $(i,kdwn)$.
-The advective BBL scheme modifies the tracer time tendency of the ocean cells near the topographic step by
-the downslope flow \autoref{eq:bbl_dw}, the horizontal \autoref{eq:bbl_hor} and
-the upward \autoref{eq:bbl_up} return flows as follows: 
-\begin{alignat}{3}
-  \label{eq:bbl_dw}
-  \partial_t T^{do}_{kdw} &\equiv \partial_t T^{do}_{kdw}
-                                &&+ \frac{u^{tr}_{bbl}}{{b_t}^{do}_{kdw}} &&\lt( T^{sh}_{kup} - T^{do}_{kdw} \rt) \\
-  \label{eq:bbl_hor}
-  \partial_t T^{sh}_{kup} &\equiv \partial_t T^{sh}_{kup}
-                                &&+ \frac{u^{tr}_{bbl}}{{b_t}^{sh}_{kup}} &&\lt( T^{do}_{kup} - T^{sh}_{kup} \rt) \\
-  %
-  \intertext{and for $k =kdw-1,\;..., \; kup$ :}
-  %
-  \label{eq:bbl_up}
-  \partial_t T^{do}_{k} &\equiv \partial_t S^{do}_{k}
-                                &&+ \frac{u^{tr}_{bbl}}{{b_t}^{do}_{k}}   &&\lt( T^{do}_{k +1} - T^{sh}_{k}   \rt)
+The advective BBL scheme modifies the tracer time tendency of
+the ocean cells near the topographic step by the downslope flow \autoref{eq:TRA_bbl_dw},
+the horizontal \autoref{eq:TRA_bbl_hor} and the upward \autoref{eq:TRA_bbl_up} return flows as follows:
+\begin{alignat}{5}
+  \label{eq:TRA_bbl_dw}
+  \partial_t T^{do}_{kdw} &\equiv \partial_t T^{do}_{kdw} &&+ \frac{u^{tr}_{bbl}}{{b_t}^{do}_{kdw}} &&\lt( T^{sh}_{kup} - T^{do}_{kdw} \rt) \\
+  \label{eq:TRA_bbl_hor}
+  \partial_t T^{sh}_{kup} &\equiv \partial_t T^{sh}_{kup} &&+ \frac{u^{tr}_{bbl}}{{b_t}^{sh}_{kup}} &&\lt( T^{do}_{kup} - T^{sh}_{kup} \rt) \\
+  \shortintertext{and for $k =kdw-1,\;..., \; kup$ :}
+  \label{eq:TRA_bbl_up}
+  \partial_t T^{do}_{k}   &\equiv \partial_t S^{do}_{k}   &&+ \frac{u^{tr}_{bbl}}{{b_t}^{do}_{k}}   &&\lt( T^{do}_{k +1} - T^{sh}_{k}   \rt)
 \end{alignat}
 where $b_t$ is the $T$-cell volume.
@@ -1090,264 +1095,255 @@
 It has to be used to compute the effective velocity as well as the effective overturning circulation.
 
-% ================================================================
-% Tracer damping
-% ================================================================
-\section[Tracer damping (\textit{tradmp.F90})]
-{Tracer damping (\protect\mdl{tradmp})}
+%% =================================================================================================
+\section[Tracer damping (\textit{tradmp.F90})]{Tracer damping (\protect\mdl{tradmp})}
 \label{sec:TRA_dmp}
-%--------------------------------------------namtra_dmp-------------------------------------------------
-
-\nlst{namtra_dmp}
-%--------------------------------------------------------------------------------------------------------------
-
-In some applications it can be useful to add a Newtonian damping term into the temperature and salinity equations:
-\begin{equation}
-  \label{eq:tra_dmp}
-  \begin{gathered}
-    \pd[T]{t} = \cdots - \gamma (T - T_o) \\
-    \pd[S]{t} = \cdots - \gamma (S - S_o)
-  \end{gathered}
-\end{equation} 
-where $\gamma$ is the inverse of a time scale, and $T_o$ and $S_o$ are given temperature and salinity fields
-(usually a climatology).
-Options are defined through the  \ngn{namtra\_dmp} namelist variables.
-The restoring term is added when the namelist parameter \np{ln\_tradmp} is set to true.
-It also requires that both \np{ln\_tsd\_init} and \np{ln\_tsd\_tradmp} are set to true in
-\ngn{namtsd} namelist as well as \np{sn\_tem} and \np{sn\_sal} structures are correctly set
-(\ie that $T_o$ and $S_o$ are provided in input files and read using \mdl{fldread},
+
+\begin{listing}
+  \nlst{namtra_dmp}
+  \caption{\forcode{&namtra_dmp}}
+  \label{lst:namtra_dmp}
+\end{listing}
+
+In some applications it can be useful to add a Newtonian damping term into
+the temperature and salinity equations:
+\begin{equation}
+  \label{eq:TRA_dmp}
+    \pd[T]{t} = \cdots - \gamma (T - T_o) \qquad \pd[S]{t} = \cdots - \gamma (S - S_o)
+\end{equation}
+where $\gamma$ is the inverse of a time scale,
+and $T_o$ and $S_o$ are given temperature and salinity fields (usually a climatology).
+Options are defined through the \nam{tra_dmp}{tra\_dmp} namelist variables.
+The restoring term is added when the namelist parameter \np{ln_tradmp}{ln\_tradmp} is set to true.
+It also requires that both \np{ln_tsd_init}{ln\_tsd\_init} and
+\np{ln_tsd_dmp}{ln\_tsd\_dmp} are set to true in \nam{tsd}{tsd} namelist as well as
+\np{sn_tem}{sn\_tem} and \np{sn_sal}{sn\_sal} structures are correctly set
+(\ie\ that $T_o$ and $S_o$ are provided in input files and read using \mdl{fldread},
 see \autoref{subsec:SBC_fldread}).
-The restoring coefficient $\gamma$ is a three-dimensional array read in during the \rou{tra\_dmp\_init} routine.
-The file name is specified by the namelist variable \np{cn\_resto}.
-The DMP\_TOOLS tool is provided to allow users to generate the netcdf file.
-
-The two main cases in which \autoref{eq:tra_dmp} is used are
-\textit{(a)} the specification of the boundary conditions along artificial walls of a limited domain basin and
-\textit{(b)} the computation of the velocity field associated with a given $T$-$S$ field
-(for example to build the initial state of a prognostic simulation,
-or to use the resulting velocity field for a passive tracer study).
+The restoring coefficient $\gamma$ is a three-dimensional array read in during
+the \rou{tra\_dmp\_init} routine.
+The file name is specified by the namelist variable \np{cn_resto}{cn\_resto}.
+The \texttt{DMP\_TOOLS} are provided to allow users to generate the netcdf file.
+
+The two main cases in which \autoref{eq:TRA_dmp} is used are
+\begin{enumerate*}[label=(\textit{\alph*})]
+\item the specification of the boundary conditions along
+  artificial walls of a limited domain basin and
+\item the computation of the velocity field associated with a given $T$-$S$ field
+  (for example to build the initial state of a prognostic simulation,
+  or to use the resulting velocity field for a passive tracer study).
+\end{enumerate*}
 The first case applies to regional models that have artificial walls instead of open boundaries.
-In the vicinity of these walls, $\gamma$ takes large values (equivalent to a time scale of a few days) whereas
-it is zero in the interior of the model domain.
+In the vicinity of these walls, $\gamma$ takes large values (equivalent to a time scale of a few days)
+whereas it is zero in the interior of the model domain.
 The second case corresponds to the use of the robust diagnostic method \citep{sarmiento.bryan_JGR82}.
 It allows us to find the velocity field consistent with the model dynamics whilst
 having a $T$, $S$ field close to a given climatological field ($T_o$, $S_o$).
 
-The robust diagnostic method is very efficient in preventing temperature drift in intermediate waters but
-it produces artificial sources of heat and salt within the ocean.
+The robust diagnostic method is very efficient in preventing temperature drift in
+intermediate waters but it produces artificial sources of heat and salt within the ocean.
 It also has undesirable effects on the ocean convection.
-It tends to prevent deep convection and subsequent deep-water formation, by stabilising the water column too much.
-
-The namelist parameter \np{nn\_zdmp} sets whether the damping should be applied in the whole water column or
-only below the mixed layer (defined either on a density or $S_o$ criterion).
+It tends to prevent deep convection and subsequent deep-water formation,
+by stabilising the water column too much.
+
+The namelist parameter \np{nn_zdmp}{nn\_zdmp} sets whether the damping should be applied in
+the whole water column or only below the mixed layer (defined either on a density or $S_o$ criterion).
 It is common to set the damping to zero in the mixed layer as the adjustment time scale is short here
 \citep{madec.delecluse.ea_JPO96}.
 
-For generating \ifile{resto}, see the documentation for the DMP tool provided with the source code under
-\path{./tools/DMP_TOOLS}.
-
-% ================================================================
-% Tracer time evolution
-% ================================================================
-\section[Tracer time evolution (\textit{tranxt.F90})]
-{Tracer time evolution (\protect\mdl{tranxt})}
+For generating \ifile{resto},
+see the documentation for the DMP tools provided with the source code under \path{./tools/DMP_TOOLS}.
+
+%% =================================================================================================
+\section[Tracer time evolution (\textit{tranxt.F90})]{Tracer time evolution (\protect\mdl{tranxt})}
 \label{sec:TRA_nxt}
-%--------------------------------------------namdom-----------------------------------------------------
-
-\nlst{namdom}
-%--------------------------------------------------------------------------------------------------------------
-
-Options are defined through the \ngn{namdom} namelist variables.
-The general framework for tracer time stepping is a modified leap-frog scheme \citep{leclair.madec_OM09},
-\ie a three level centred time scheme associated with a Asselin time filter (cf. \autoref{sec:STP_mLF}):
-\begin{equation}
-  \label{eq:tra_nxt}
-  \begin{alignedat}{3}
+
+Options are defined through the \nam{dom}{dom} namelist variables.
+The general framework for tracer time stepping is a modified leap-frog scheme
+\citep{leclair.madec_OM09}, \ie\ a three level centred time scheme associated with
+a Asselin time filter (cf. \autoref{sec:TD_mLF}):
+\begin{equation}
+  \label{eq:TRA_nxt}
+  \begin{alignedat}{5}
     &(e_{3t}T)^{t + \rdt} &&= (e_{3t}T)_f^{t - \rdt} &&+ 2 \, \rdt \,e_{3t}^t \ \text{RHS}^t \\
     &(e_{3t}T)_f^t        &&= (e_{3t}T)^t            &&+ \, \gamma \, \lt[ (e_{3t}T)_f^{t - \rdt} - 2(e_{3t}T)^t + (e_{3t}T)^{t + \rdt} \rt] \\
-    &                     &&                         &&- \, \gamma \, \rdt \, \lt[ Q^{t + \rdt/2} - Q^{t - \rdt/2} \rt]  
+    &                     &&                         &&- \, \gamma \, \rdt \, \lt[ Q^{t + \rdt/2} - Q^{t - \rdt/2} \rt]
   \end{alignedat}
-\end{equation} 
-where RHS is the right hand side of the temperature equation, the subscript $f$ denotes filtered values,
-$\gamma$ is the Asselin coefficient, and $S$ is the total forcing applied on $T$
-(\ie fluxes plus content in mass exchanges).
-$\gamma$ is initialized as \np{rn\_atfp} (\textbf{namelist} parameter).
-Its default value is \np{rn\_atfp}\forcode{ = 10.e-3}.
+\end{equation}
+where RHS is the right hand side of the temperature equation,
+the subscript $f$ denotes filtered values, $\gamma$ is the Asselin coefficient,
+and $S$ is the total forcing applied on $T$ (\ie\ fluxes plus content in mass exchanges).
+$\gamma$ is initialized as \np{rn_atfp}{rn\_atfp}, its default value is \forcode{10.e-3}.
 Note that the forcing correction term in the filter is not applied in linear free surface
-(\jp{lk\_vvl}\forcode{ = .false.}) (see \autoref{subsec:TRA_sbc}).
-Not also that in constant volume case, the time stepping is performed on $T$, not on its content, $e_{3t}T$.
-
-When the vertical mixing is solved implicitly, the update of the \textit{next} tracer fields is done in
-\mdl{trazdf} module.
+(\jp{ln\_linssh}\forcode{=.true.}) (see \autoref{subsec:TRA_sbc}).
+Not also that in constant volume case, the time stepping is performed on $T$,
+not on its content, $e_{3t}T$.
+
+When the vertical mixing is solved implicitly,
+the update of the \textit{next} tracer fields is done in \mdl{trazdf} module.
 In this case only the swapping of arrays and the Asselin filtering is done in the \mdl{tranxt} module.
 
-In order to prepare for the computation of the \textit{next} time step, a swap of tracer arrays is performed:
-$T^{t - \rdt} = T^t$ and $T^t = T_f$.
-
-% ================================================================
-% Equation of State (eosbn2) 
-% ================================================================
-\section[Equation of state (\textit{eosbn2.F90})]
-{Equation of state (\protect\mdl{eosbn2})}
+In order to prepare for the computation of the \textit{next} time step,
+a swap of tracer arrays is performed: $T^{t - \rdt} = T^t$ and $T^t = T_f$.
+
+%% =================================================================================================
+\section[Equation of state (\textit{eosbn2.F90})]{Equation of state (\protect\mdl{eosbn2})}
 \label{sec:TRA_eosbn2}
-%--------------------------------------------nameos-----------------------------------------------------
-
-\nlst{nameos}
-%--------------------------------------------------------------------------------------------------------------
-
-% -------------------------------------------------------------------------------------------------------------
-%        Equation of State
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Equation of seawater (\forcode{nn_eos = {-1,1}})]
-{Equation of seawater (\protect\np{nn\_eos}\forcode{ = {-1,1}})}
+
+\begin{listing}
+  \nlst{nameos}
+  \caption{\forcode{&nameos}}
+  \label{lst:nameos}
+\end{listing}
+
+%% =================================================================================================
+\subsection[Equation of seawater (\forcode{ln_}\{\forcode{teos10,eos80,seos}\})]{Equation of seawater (\protect\np{ln_teos10}{ln\_teos10}, \protect\np{ln_teos80}{ln\_teos80}, or \protect\np{ln_seos}{ln\_seos})}
 \label{subsec:TRA_eos}
 
-The Equation Of Seawater (EOS) is an empirical nonlinear thermodynamic relationship linking seawater density,
-$\rho$, to a number of state variables, most typically temperature, salinity and pressure.
+The \textbf{E}quation \textbf{O}f \textbf{S}eawater (EOS) is
+an empirical nonlinear thermodynamic relationship linking
+seawater density, $\rho$, to a number of state variables,
+most typically temperature, salinity and pressure.
 Because density gradients control the pressure gradient force through the hydrostatic balance,
-the equation of state provides a fundamental bridge between the distribution of active tracers and
-the fluid dynamics.
+the equation of state provides a fundamental bridge between
+the distribution of active tracers and the fluid dynamics.
 Nonlinearities of the EOS are of major importance, in particular influencing the circulation through
 determination of the static stability below the mixed layer,
-thus controlling rates of exchange between the atmosphere and the ocean interior \citep{roquet.madec.ea_JPO15}.
-Therefore an accurate EOS based on either the 1980 equation of state (EOS-80, \cite{fofonoff.millard_bk83}) or
-TEOS-10 \citep{ioc.iapso_bk10} standards should be used anytime a simulation of the real ocean circulation is attempted
+thus controlling rates of exchange between the atmosphere and the ocean interior
 \citep{roquet.madec.ea_JPO15}.
+Therefore an accurate EOS based on either the 1980 equation of state
+(EOS-80, \cite{fofonoff.millard_bk83}) or TEOS-10 \citep{ioc.iapso_bk10} standards should
+be used anytime a simulation of the real ocean circulation is attempted \citep{roquet.madec.ea_JPO15}.
 The use of TEOS-10 is highly recommended because
-\textit{(i)}   it is the new official EOS,
-\textit{(ii)}  it is more accurate, being based on an updated database of laboratory measurements, and
-\textit{(iii)} it uses Conservative Temperature and Absolute Salinity (instead of potential temperature and
-practical salinity for EOS-980, both variables being more suitable for use as model variables
-\citep{ioc.iapso_bk10, graham.mcdougall_JPO13}.
-EOS-80 is an obsolescent feature of the NEMO system, kept only for backward compatibility.
+\begin{enumerate*}[label=(\textit{\roman*})]
+\item it is the new official EOS,
+\item it is more accurate, being based on an updated database of laboratory measurements, and
+\item it uses Conservative Temperature and Absolute Salinity
+  (instead of potential temperature and practical salinity for EOS-80),
+  both variables being more suitable for use as model variables
+  \citep{ioc.iapso_bk10, graham.mcdougall_JPO13}.
+\end{enumerate*}
+EOS-80 is an obsolescent feature of the \NEMO\ system, kept only for backward compatibility.
 For process studies, it is often convenient to use an approximation of the EOS.
 To that purposed, a simplified EOS (S-EOS) inspired by \citet{vallis_bk06} is also available.
 
-In the computer code, a density anomaly, $d_a = \rho / \rho_o - 1$, is computed, with $\rho_o$ a reference density.
-Called \textit{rau0} in the code, $\rho_o$ is set in \mdl{phycst} to a value of $1,026~Kg/m^3$.
-This is a sensible choice for the reference density used in a Boussinesq ocean climate model, as,
-with the exception of only a small percentage of the ocean,
-density in the World Ocean varies by no more than 2$\%$ from that value \citep{gill_bk82}.
-
-Options are defined through the \ngn{nameos} namelist variables, and in particular \np{nn\_eos} which
-controls the EOS used (\forcode{= -1} for TEOS10 ; \forcode{= 0} for EOS-80 ; \forcode{= 1} for S-EOS).
+In the computer code, a density anomaly, $d_a = \rho / \rho_o - 1$, is computed,
+with $\rho_o$ a reference density.
+Called \textit{rau0} in the code,
+$\rho_o$ is set in \mdl{phycst} to a value of \texttt{1,026} $Kg/m^3$.
+This is a sensible choice for the reference density used in a Boussinesq ocean climate model,
+as, with the exception of only a small percentage of the ocean,
+density in the World Ocean varies by no more than 2\% from that value \citep{gill_bk82}.
+
+Options which control the EOS used are defined through the \nam{eos}{eos} namelist variables.
 
 \begin{description}
-\item[\np{nn\_eos}\forcode{ = -1}]
-  the polyTEOS10-bsq equation of seawater \citep{roquet.madec.ea_OM15} is used.
+\item [{\np[=.true.]{ln_teos10}{ln\_teos10}}] the polyTEOS10-bsq equation of seawater
+  \citep{roquet.madec.ea_OM15} is used.
   The accuracy of this approximation is comparable to the TEOS-10 rational function approximation,
-  but it is optimized for a boussinesq fluid and the polynomial expressions have simpler and
-  more computationally efficient expressions for their derived quantities which make them more adapted for
-  use in ocean models.
-  Note that a slightly higher precision polynomial form is now used replacement of
-  the TEOS-10 rational function approximation for hydrographic data analysis \citep{ioc.iapso_bk10}.
+  but it is optimized for a Boussinesq fluid and
+  the polynomial expressions have simpler and more computationally efficient expressions for
+  their derived quantities which make them more adapted for use in ocean models.
+  Note that a slightly higher precision polynomial form is now used
+  replacement of the TEOS-10 rational function approximation for hydrographic data analysis
+  \citep{ioc.iapso_bk10}.
   A key point is that conservative state variables are used:
-  Absolute Salinity (unit: g/kg, notation: $S_A$) and Conservative Temperature (unit: \deg{C}, notation: $\Theta$).
+  Absolute Salinity (unit: $g/kg$, notation: $S_A$) and
+  Conservative Temperature (unit: $\deg{C}$, notation: $\Theta$).
   The pressure in decibars is approximated by the depth in meters.
   With TEOS10, the specific heat capacity of sea water, $C_p$, is a constant.
-  It is set to $C_p = 3991.86795711963~J\,Kg^{-1}\,^{\circ}K^{-1}$, according to \citet{ioc.iapso_bk10}.
+  It is set to $C_p$ = 3991.86795711963 $J.Kg^{-1}.\deg{K}^{-1}$,
+  according to \citet{ioc.iapso_bk10}.
   Choosing polyTEOS10-bsq implies that the state variables used by the model are $\Theta$ and $S_A$.
-  In particular, the initial state deined by the user have to be given as \textit{Conservative} Temperature and
-  \textit{Absolute} Salinity.
-  In addition, setting \np{ln\_useCT} to \forcode{.true.} convert the Conservative SST to potential SST prior to
+  In particular, the initial state defined by the user have to be given as
+  \textit{Conservative} Temperature and \textit{Absolute} Salinity.
+  In addition, when using TEOS10, the Conservative SST is converted to potential SST prior to
   either computing the air-sea and ice-sea fluxes (forced mode) or
   sending the SST field to the atmosphere (coupled mode).
-\item[\np{nn\_eos}\forcode{ = 0}]
-  the polyEOS80-bsq equation of seawater is used.
-  It takes the same polynomial form as the polyTEOS10, but the coefficients have been optimized to
-  accurately fit EOS80 (Roquet, personal comm.).
+\item [{\np[=.true.]{ln_eos80}{ln\_eos80}}] the polyEOS80-bsq equation of seawater is used.
+  It takes the same polynomial form as the polyTEOS10,
+  but the coefficients have been optimized to accurately fit EOS80 (Roquet, personal comm.).
   The state variables used in both the EOS80 and the ocean model are:
-  the Practical Salinity ((unit: psu, notation: $S_p$)) and
-  Potential Temperature (unit: $^{\circ}C$, notation: $\theta$).
+  the Practical Salinity (unit: $psu$, notation: $S_p$) and
+  Potential Temperature (unit: $\deg{C}$, notation: $\theta$).
   The pressure in decibars is approximated by the depth in meters.
-  With thsi EOS, the specific heat capacity of sea water, $C_p$, is a function of temperature, salinity and
-  pressure \citep{fofonoff.millard_bk83}.
+  With EOS, the specific heat capacity of sea water, $C_p$, is a function of
+  temperature, salinity and pressure \citep{fofonoff.millard_bk83}.
   Nevertheless, a severe assumption is made in order to have a heat content ($C_p T_p$) which
   is conserved by the model: $C_p$ is set to a constant value, the TEOS10 value.
-\item[\np{nn\_eos}\forcode{ = 1}]
-  a simplified EOS (S-EOS) inspired by \citet{vallis_bk06} is chosen,
-  the coefficients of which has been optimized to fit the behavior of TEOS10
-  (Roquet, personal comm.) (see also \citet{roquet.madec.ea_JPO15}).
+\item [{\np[=.true.]{ln_seos}{ln\_seos}}] a simplified EOS (S-EOS) inspired by
+  \citet{vallis_bk06} is chosen,
+  the coefficients of which has been optimized to fit the behavior of TEOS10 (Roquet, personal comm.)
+  (see also \citet{roquet.madec.ea_JPO15}).
   It provides a simplistic linear representation of both cabbeling and thermobaricity effects which
   is enough for a proper treatment of the EOS in theoretical studies \citep{roquet.madec.ea_JPO15}.
-  With such an equation of state there is no longer a distinction between
-  \textit{conservative} and \textit{potential} temperature,
-  as well as between \textit{absolute} and \textit{practical} salinity.
+  With such an equation of state there is no longer a distinction between \textit{conservative} and
+  \textit{potential} temperature, as well as between \textit{absolute} and
+  \textit{practical} salinity.
   S-EOS takes the following expression:
   \begin{gather*}
-    % \label{eq:tra_S-EOS}
-    \begin{alignedat}{2}
-    &d_a(T,S,z) = \frac{1}{\rho_o} \big[ &- a_0 \; ( 1 + 0.5 \; \lambda_1 \; T_a + \mu_1 \; z ) * &T_a \big. \\
-    &                                    &+ b_0 \; ( 1 - 0.5 \; \lambda_2 \; S_a - \mu_2 \; z ) * &S_a       \\  
-    &                              \big. &- \nu \;                           T_a                  &S_a \big] \\
-    \end{alignedat}
-    \\
+    % \label{eq:TRA_S-EOS}
+    d_a(T,S,z) = \frac{1}{\rho_o} \big[ - a_0 \; ( 1 + 0.5 \; \lambda_1 \; T_a + \mu_1 \; z ) * T_a \big.
+                                        + b_0 \; ( 1 - 0.5 \; \lambda_2 \; S_a - \mu_2 \; z ) * S_a
+                                  \big. - \nu \;                           T_a                  S_a \big] \\
     \text{with~} T_a = T - 10 \, ; \, S_a = S - 35 \, ; \, \rho_o = 1026~Kg/m^3
   \end{gather*}
-  where the computer name of the coefficients as well as their standard value are given in \autoref{tab:SEOS}.
+  where the computer name of the coefficients as well as their standard value are given in
+  \autoref{tab:TRA_SEOS}.
   In fact, when choosing S-EOS, various approximation of EOS can be specified simply by
   changing the associated coefficients.
-  Setting to zero the two thermobaric coefficients $(\mu_1,\mu_2)$ remove thermobaric effect from S-EOS.
-  setting to zero the three cabbeling coefficients $(\lambda_1,\lambda_2,\nu)$ remove cabbeling effect from
-  S-EOS.
+  Setting to zero the two thermobaric coefficients $(\mu_1,\mu_2)$
+  remove thermobaric effect from S-EOS.
+  Setting to zero the three cabbeling coefficients $(\lambda_1,\lambda_2,\nu)$
+  remove   cabbeling effect from S-EOS.
   Keeping non-zero value to $a_0$ and $b_0$ provide a linear EOS function of T and S.
 \end{description}
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{table}[!tb]
-  \begin{center}
-    \begin{tabular}{|l|l|l|l|}
-      \hline
-      coeff.	   & computer name   & S-EOS		      & description		                 \\
-      \hline
-      $a_0$       & \np{rn\_a0}     & $1.6550~10^{-1}$ & linear thermal expansion coeff. \\
-      \hline
-      $b_0$	      & \np{rn\_b0} 	   & $7.6554~10^{-1}$ & linear haline  expansion coeff. \\
-      \hline
-      $\lambda_1$	& \np{rn\_lambda1}& $5.9520~10^{-2}$ & cabbeling coeff. in $T^2$ 	     \\
-      \hline
-      $\lambda_2$	& \np{rn\_lambda2}& $5.4914~10^{-4}$ & cabbeling coeff. in $S^2$	 	  \\
-      \hline
-      $\nu$       & \np{rn\_nu}     & $2.4341~10^{-3}$ & cabbeling coeff. in $T \, S$ 	  \\
-      \hline
-      $\mu_1$     & \np{rn\_mu1} 	& $1.4970~10^{-4}$ & thermobaric coeff. in T    	  \\
-      \hline
-      $\mu_2$     & \np{rn\_mu2} 	& $1.1090~10^{-5}$ & thermobaric coeff. in S   	     \\
-      \hline
-    \end{tabular}
-    \caption{
-      \protect\label{tab:SEOS}
-      Standard value of S-EOS coefficients.
-    }
-\end{center}
+\begin{table}
+  \centering
+  \begin{tabular}{|l|l|l|l|}
+    \hline
+    coeff.      & computer name                & S-EOS            & description                     \\
+    \hline
+    $a_0      $ & \np{rn_a0}{rn\_a0}           & $1.6550~10^{-1}$ & linear thermal expansion coeff. \\
+    \hline
+    $b_0      $ & \np{rn_b0}{rn\_b0}           & $7.6554~10^{-1}$ & linear haline  expansion coeff. \\
+    \hline
+    $\lambda_1$ & \np{rn_lambda1}{rn\_lambda1} & $5.9520~10^{-2}$ & cabbeling coeff. in $T^2$       \\
+    \hline
+    $\lambda_2$ & \np{rn_lambda2}{rn\_lambda2} & $5.4914~10^{-4}$ & cabbeling coeff. in $S^2$       \\
+    \hline
+    $\nu      $ & \np{rn_nu}{rn\_nu}           & $2.4341~10^{-3}$ & cabbeling coeff. in $T \, S$    \\
+    \hline
+    $\mu_1    $ & \np{rn_mu1}{rn\_mu1}         & $1.4970~10^{-4}$ & thermobaric coeff. in T         \\
+    \hline
+    $\mu_2    $ & \np{rn_mu2}{rn\_mu2}         & $1.1090~10^{-5}$ & thermobaric coeff. in S         \\
+    \hline
+  \end{tabular}
+  \caption{Standard value of S-EOS coefficients}
+  \label{tab:TRA_SEOS}
 \end{table}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -------------------------------------------------------------------------------------------------------------
-%        Brunt-V\"{a}is\"{a}l\"{a} Frequency
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Brunt-V\"{a}is\"{a}l\"{a} frequency (\forcode{nn_eos = [0-2]})]
-{Brunt-V\"{a}is\"{a}l\"{a} frequency (\protect\np{nn\_eos}\forcode{ = [0-2]})}
+
+%% =================================================================================================
+\subsection[Brunt-V\"{a}is\"{a}l\"{a} frequency]{Brunt-V\"{a}is\"{a}l\"{a} frequency}
 \label{subsec:TRA_bn2}
 
-An accurate computation of the ocean stability (i.e. of $N$, the brunt-V\"{a}is\"{a}l\"{a} frequency) is of
-paramount importance as determine the ocean stratification and is used in several ocean parameterisations
+An accurate computation of the ocean stability (i.e. of $N$, the Brunt-V\"{a}is\"{a}l\"{a} frequency) is of paramount importance as determine the ocean stratification and
+is used in several ocean parameterisations
 (namely TKE, GLS, Richardson number dependent vertical diffusion, enhanced vertical diffusion,
 non-penetrative convection, tidal mixing  parameterisation, iso-neutral diffusion).
 In particular, $N^2$ has to be computed at the local pressure
 (pressure in decibar being approximated by the depth in meters).
-The expression for $N^2$  is given by: 
+The expression for $N^2$  is given by:
 \[
-  % \label{eq:tra_bn2}
+  % \label{eq:TRA_bn2}
   N^2 = \frac{g}{e_{3w}} \lt( \beta \; \delta_{k + 1/2}[S] - \alpha \; \delta_{k + 1/2}[T] \rt)
 \]
 where $(T,S) = (\Theta,S_A)$ for TEOS10, $(\theta,S_p)$ for TEOS-80, or $(T,S)$ for S-EOS, and,
 $\alpha$ and $\beta$ are the thermal and haline expansion coefficients.
-The coefficients are a polynomial function of temperature, salinity and depth which expression depends on
-the chosen EOS.
-They are computed through \textit{eos\_rab}, a \fortran function that can be found in \mdl{eosbn2}.
-
-% -------------------------------------------------------------------------------------------------------------
-%        Freezing Point of Seawater
-% -------------------------------------------------------------------------------------------------------------
+The coefficients are a polynomial function of temperature, salinity and depth which
+expression depends on the chosen EOS.
+They are computed through \textit{eos\_rab}, a \fortran\ function that can be found in \mdl{eosbn2}.
+
+%% =================================================================================================
 \subsection{Freezing point of seawater}
 \label{subsec:TRA_fzp}
@@ -1355,71 +1351,66 @@
 The freezing point of seawater is a function of salinity and pressure \citep{fofonoff.millard_bk83}:
 \begin{equation}
-  \label{eq:tra_eos_fzp}
-  \begin{split}
-    &T_f (S,p) = \lt( a + b \, \sqrt{S} + c \, S \rt) \, S + d \, p \\
-    &\text{where~} a = -0.0575, \, b = 1.710523~10^{-3}, \, c = -2.154996~10^{-4} \\ 
-    &\text{and~} d = -7.53~10^{-3}
-    \end{split}
-\end{equation}
-
-\autoref{eq:tra_eos_fzp} is only used to compute the potential freezing point of sea water
-(\ie referenced to the surface $p = 0$),
-thus the pressure dependent terms in \autoref{eq:tra_eos_fzp} (last term) have been dropped.
+  \label{eq:TRA_eos_fzp}
+  \begin{gathered}
+    T_f (S,p) = \lt( a + b \, \sqrt{S} + c \, S \rt) \, S + d \, p \\
+    \text{where~} a = -0.0575, \, b = 1.710523~10^{-3}, \, c = -2.154996~10^{-4} \text{and~} d = -7.53~10^{-3}
+    \end{gathered}
+\end{equation}
+
+\autoref{eq:TRA_eos_fzp} is only used to compute the potential freezing point of sea water
+(\ie\ referenced to the surface $p = 0$),
+thus the pressure dependent terms in \autoref{eq:TRA_eos_fzp} (last term) have been dropped.
 The freezing point is computed through \textit{eos\_fzp},
-a \fortran function that can be found in \mdl{eosbn2}.
-
-% -------------------------------------------------------------------------------------------------------------
-%        Potential Energy     
-% -------------------------------------------------------------------------------------------------------------
+a \fortran\ function that can be found in \mdl{eosbn2}.
+
+%% =================================================================================================
 %\subsection{Potential Energy anomalies}
 %\label{subsec:TRA_bn2}
 
 %    =====>>>>> TO BE written
-%
-
-% ================================================================
-% Horizontal Derivative in zps-coordinate 
-% ================================================================
-\section[Horizontal derivative in \textit{zps}-coordinate (\textit{zpshde.F90})]
-{Horizontal derivative in \textit{zps}-coordinate (\protect\mdl{zpshde})}
+
+%% =================================================================================================
+\section[Horizontal derivative in \textit{zps}-coordinate (\textit{zpshde.F90})]{Horizontal derivative in \textit{zps}-coordinate (\protect\mdl{zpshde})}
 \label{sec:TRA_zpshde}
 
-\gmcomment{STEVEN: to be consistent with earlier discussion of differencing and averaging operators, 
+\cmtgm{STEVEN: to be consistent with earlier discussion of differencing and averaging operators,
 I've changed "derivative" to "difference" and "mean" to "average"}
 
-With partial cells (\np{ln\_zps}\forcode{ = .true.}) at bottom and top (\np{ln\_isfcav}\forcode{ = .true.}),
+With partial cells (\np[=.true.]{ln_zps}{ln\_zps}) at bottom and top
+(\np[=.true.]{ln_isfcav}{ln\_isfcav}),
 in general, tracers in horizontally adjacent cells live at different depths.
-Horizontal gradients of tracers are needed for horizontal diffusion (\mdl{traldf} module) and
-the hydrostatic pressure gradient calculations (\mdl{dynhpg} module).
-The partial cell properties at the top (\np{ln\_isfcav}\forcode{ = .true.}) are computed in the same way as
-for the bottom.
+Horizontal gradients of tracers are needed for horizontal diffusion
+(\mdl{traldf} module) and the hydrostatic pressure gradient calculations (\mdl{dynhpg} module).
+The partial cell properties at the top (\np[=.true.]{ln_isfcav}{ln\_isfcav}) are computed in
+the same way as for the bottom.
 So, only the bottom interpolation is explained below.
 
 Before taking horizontal gradients between the tracers next to the bottom,
 a linear interpolation in the vertical is used to approximate the deeper tracer as if
-it actually lived at the depth of the shallower tracer point (\autoref{fig:Partial_step_scheme}).
-For example, for temperature in the $i$-direction the needed interpolated temperature, $\widetilde T$, is:
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!p]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_partial_step_scheme}
-    \caption{
-      \protect\label{fig:Partial_step_scheme}
-      Discretisation of the horizontal difference and average of tracers in the $z$-partial step coordinate
-      (\protect\np{ln\_zps}\forcode{ = .true.}) in the case $(e3w_k^{i + 1} - e3w_k^i) > 0$.
-      A linear interpolation is used to estimate $\widetilde T_k^{i + 1}$,
-      the tracer value at the depth of the shallower tracer point of the two adjacent bottom $T$-points.
-      The horizontal difference is then given by: $\delta_{i + 1/2} T_k = \widetilde T_k^{\, i + 1} -T_k^{\, i}$ and
-      the average by: $\overline T_k^{\, i + 1/2} = (\widetilde T_k^{\, i + 1/2} - T_k^{\, i}) / 2$.
-    }
-  \end{center}
+it actually lived at the depth of the shallower tracer point (\autoref{fig:TRA_Partial_step_scheme}).
+For example, for temperature in the $i$-direction the needed interpolated temperature,
+$\widetilde T$, is:
+
+\begin{figure}
+  \centering
+  \includegraphics[width=0.33\textwidth]{TRA_partial_step_scheme}
+  \caption[Discretisation of the horizontal difference and average of tracers in
+  the $z$-partial step coordinate]{
+    Discretisation of the horizontal difference and average of tracers in
+    the $z$-partial step coordinate (\protect\np[=.true.]{ln_zps}{ln\_zps}) in
+    the case $(e3w_k^{i + 1} - e3w_k^i) > 0$.
+    A linear interpolation is used to estimate $\widetilde T_k^{i + 1}$,
+    the tracer value at the depth of the shallower tracer point of the two adjacent bottom $T$-points.
+    The horizontal difference is then given by:
+    $\delta_{i + 1/2} T_k = \widetilde T_k^{\, i + 1} -T_k^{\, i}$ and the average by:
+    $\overline T_k^{\, i + 1/2} = (\widetilde T_k^{\, i + 1/2} - T_k^{\, i}) / 2$.}
+  \label{fig:TRA_Partial_step_scheme}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
 \[
   \widetilde T = \lt\{
     \begin{alignedat}{2}
       &T^{\, i + 1} &-\frac{ \lt( e_{3w}^{i + 1} -e_{3w}^i \rt) }{ e_{3w}^{i + 1} } \; \delta_k T^{i + 1}
-      & \quad \text{if $e_{3w}^{i + 1} \geq e_{3w}^i$} \\ \\
+      & \quad \text{if $e_{3w}^{i + 1} \geq e_{3w}^i$} \\
       &T^{\, i}     &+\frac{ \lt( e_{3w}^{i + 1} -e_{3w}^i \rt )}{e_{3w}^i       } \; \delta_k T^{i + 1}
       & \quad \text{if $e_{3w}^{i + 1} <    e_{3w}^i$}
@@ -1427,20 +1418,18 @@
   \rt.
 \]
-and the resulting forms for the horizontal difference and the horizontal average value of $T$ at a $U$-point are: 
-\begin{equation}
-  \label{eq:zps_hde}
+and the resulting forms for the horizontal difference and the horizontal average value of
+$T$ at a $U$-point are:
+\begin{equation}
+  \label{eq:TRA_zps_hde}
   \begin{split}
     \delta_{i + 1/2} T       &=
     \begin{cases}
-                                \widetilde T - T^i          & \text{if~} e_{3w}^{i + 1} \geq e_{3w}^i \\
-                                \\
-                                T^{\, i + 1} - \widetilde T & \text{if~} e_{3w}^{i + 1} <    e_{3w}^i
-    \end{cases}
-    \\
+      \widetilde T - T^i          & \text{if~} e_{3w}^{i + 1} \geq e_{3w}^i \\
+      T^{\, i + 1} - \widetilde T & \text{if~} e_{3w}^{i + 1} <    e_{3w}^i
+    \end{cases} \\
     \overline T^{\, i + 1/2} &=
     \begin{cases}
-                                (\widetilde T - T^{\, i}   ) / 2 & \text{if~} e_{3w}^{i + 1} \geq e_{3w}^i \\
-                                \\
-                                (T^{\, i + 1} - \widetilde T) / 2 & \text{if~} e_{3w}^{i + 1} <   e_{3w}^i
+      (\widetilde T - T^{\, i}    ) / 2 & \text{if~} e_{3w}^{i + 1} \geq e_{3w}^i \\
+      (T^{\, i + 1} - \widetilde T) / 2 & \text{if~} e_{3w}^{i + 1} <   e_{3w}^i
     \end{cases}
   \end{split}
@@ -1449,35 +1438,33 @@
 The computation of horizontal derivative of tracers as well as of density is performed once for all at
 each time step in \mdl{zpshde} module and stored in shared arrays to be used when needed.
-It has to be emphasized that the procedure used to compute the interpolated density, $\widetilde \rho$,
-is not the same as that used for $T$ and $S$.
-Instead of forming a linear approximation of density, we compute $\widetilde \rho$ from the interpolated values of
-$T$ and $S$, and the pressure at a $u$-point
-(in the equation of state pressure is approximated by depth, see \autoref{subsec:TRA_eos}): 
+It has to be emphasized that the procedure used to compute the interpolated density,
+$\widetilde \rho$, is not the same as that used for $T$ and $S$.
+Instead of forming a linear approximation of density,
+we compute $\widetilde \rho$ from the interpolated values of $T$ and $S$,
+and the pressure at a $u$-point
+(in the equation of state pressure is approximated by depth, see \autoref{subsec:TRA_eos}):
 \[
-  % \label{eq:zps_hde_rho}
+  % \label{eq:TRA_zps_hde_rho}
   \widetilde \rho = \rho (\widetilde T,\widetilde S,z_u) \quad \text{where~} z_u = \min \lt( z_T^{i + 1},z_T^i \rt)
 \]
 
 This is a much better approximation as the variation of $\rho$ with depth (and thus pressure)
-is highly non-linear with a true equation of state and thus is badly approximated with a linear interpolation.
-This approximation is used to compute both the horizontal pressure gradient (\autoref{sec:DYN_hpg}) and
-the slopes of neutral surfaces (\autoref{sec:LDF_slp}).
-
-Note that in almost all the advection schemes presented in this Chapter,
+is highly non-linear with a true equation of state and thus is badly approximated with
+a linear interpolation.
+This approximation is used to compute both the horizontal pressure gradient (\autoref{sec:DYN_hpg})
+and the slopes of neutral surfaces (\autoref{sec:LDF_slp}).
+
+Note that in almost all the advection schemes presented in this chapter,
 both averaging and differencing operators appear.
-Yet \autoref{eq:zps_hde} has not been used in these schemes:
+Yet \autoref{eq:TRA_zps_hde} has not been used in these schemes:
 in contrast to diffusion and pressure gradient computations,
 no correction for partial steps is applied for advection.
 The main motivation is to preserve the domain averaged mean variance of the advected field when
 using the $2^{nd}$ order centred scheme.
-Sensitivity of the advection schemes to the way horizontal averages are performed in the vicinity of
-partial cells should be further investigated in the near future.
-%%%
-\gmcomment{gm :   this last remark has to be done}
-%%%
-
-\biblio
-
-\pindex
+Sensitivity of the advection schemes to the way horizontal averages are performed in
+the vicinity of partial cells should be further investigated in the near future.
+\cmtgm{gm :   this last remark has to be done}
+
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_ZDF.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_ZDF.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_ZDF.tex	(revision 12143)
@@ -1,22 +1,37 @@
 \documentclass[../main/NEMO_manual]{subfiles}
 
+%% Custom aliases
+\newcommand{\cf}{\ensuremath{C\kern-0.14em f}}
+
 \begin{document}
-% ================================================================
-% Chapter  Vertical Ocean Physics (ZDF)
-% ================================================================
+
 \chapter{Vertical Ocean Physics (ZDF)}
 \label{chap:ZDF}
 
-\minitoc
-
-%gm% Add here a small introduction to ZDF and naming of the different physics (similar to what have been written for TRA and DYN.
-
-\newpage
-
-% ================================================================
-% Vertical Mixing
-% ================================================================
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+\cmtgm{ Add here a small introduction to ZDF and naming of the different physics
+(similar to what have been written for TRA and DYN).}
+
+%% =================================================================================================
 \section{Vertical mixing}
-\label{sec:ZDF_zdf}
+\label{sec:ZDF}
 
 The discrete form of the ocean subgrid scale physics has been presented in
@@ -25,7 +40,7 @@
 At the surface they are prescribed from the surface forcing (see \autoref{chap:SBC}),
 while at the bottom they are set to zero for heat and salt,
-unless a geothermal flux forcing is prescribed as a bottom boundary condition (\ie \np{ln\_trabbc} defined,
+unless a geothermal flux forcing is prescribed as a bottom boundary condition (\ie\ \np{ln_trabbc}{ln\_trabbc} defined,
 see \autoref{subsec:TRA_bbc}), and specified through a bottom friction parameterisation for momentum
-(see \autoref{sec:ZDF_drg}). 
+(see \autoref{sec:ZDF_drg}).
 
 In this section we briefly discuss the various choices offered to compute the vertical eddy viscosity and
@@ -37,24 +52,22 @@
 the \mdl{zdfric}, \mdl{zdftke} or \mdl{zdfgls} or \mdl{zdfosm} modules.
 The trends due to the vertical momentum and tracer diffusion, including the surface forcing,
-are computed and added to the general trend in the \mdl{dynzdf} and \mdl{trazdf} modules, respectively. 
+are computed and added to the general trend in the \mdl{dynzdf} and \mdl{trazdf} modules, respectively.
 %These trends can be computed using either a forward time stepping scheme
-%(namelist parameter \np{ln\_zdfexp}\forcode{ = .true.}) or a backward time stepping scheme
-%(\np{ln\_zdfexp}\forcode{ = .false.}) depending on the magnitude of the mixing coefficients,
-%and thus of the formulation used (see \autoref{chap:STP}).
-
-%--------------------------------------------namzdf--------------------------------------------------------
-
-\nlst{namzdf}
-%--------------------------------------------------------------------------------------------------------------
-
-% -------------------------------------------------------------------------------------------------------------
-%        Constant 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Constant (\forcode{ln_zdfcst = .true.})]
-{Constant (\protect\np{ln\_zdfcst}\forcode{ = .true.})}
+%(namelist parameter \np[=.true.]{ln_zdfexp}{ln\_zdfexp}) or a backward time stepping scheme
+%(\np[=.false.]{ln_zdfexp}{ln\_zdfexp}) depending on the magnitude of the mixing coefficients,
+%and thus of the formulation used (see \autoref{chap:TD}).
+
+\begin{listing}
+  \nlst{namzdf}
+  \caption{\forcode{&namzdf}}
+  \label{lst:namzdf}
+\end{listing}
+
+%% =================================================================================================
+\subsection[Constant (\forcode{ln_zdfcst})]{Constant (\protect\np{ln_zdfcst}{ln\_zdfcst})}
 \label{subsec:ZDF_cst}
 
-Options are defined through the \ngn{namzdf} namelist variables.
-When \np{ln\_zdfcst} is defined, the momentum and tracer vertical eddy coefficients are set to
+Options are defined through the \nam{zdf}{zdf} namelist variables.
+When \np{ln_zdfcst}{ln\_zdfcst} is defined, the momentum and tracer vertical eddy coefficients are set to
 constant values over the whole ocean.
 This is the crudest way to define the vertical ocean physics.
@@ -66,31 +79,29 @@
 \end{align*}
 
-These values are set through the \np{rn\_avm0} and \np{rn\_avt0} namelist parameters. 
+These values are set through the \np{rn_avm0}{rn\_avm0} and \np{rn_avt0}{rn\_avt0} namelist parameters.
 In all cases, do not use values smaller that those associated with the molecular viscosity and diffusivity,
 that is $\sim10^{-6}~m^2.s^{-1}$ for momentum, $\sim10^{-7}~m^2.s^{-1}$ for temperature and
 $\sim10^{-9}~m^2.s^{-1}$ for salinity.
 
-% -------------------------------------------------------------------------------------------------------------
-%        Richardson Number Dependent
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Richardson number dependent (\forcode{ln_zdfric = .true.})]
-{Richardson number dependent (\protect\np{ln\_zdfric}\forcode{ = .true.})}
+%% =================================================================================================
+\subsection[Richardson number dependent (\forcode{ln_zdfric})]{Richardson number dependent (\protect\np{ln_zdfric}{ln\_zdfric})}
 \label{subsec:ZDF_ric}
 
-%--------------------------------------------namric---------------------------------------------------------
-
-\nlst{namzdf_ric}
-%--------------------------------------------------------------------------------------------------------------
-
-When \np{ln\_zdfric}\forcode{ = .true.}, a local Richardson number dependent formulation for the vertical momentum and
-tracer eddy coefficients is set through the \ngn{namzdf\_ric} namelist variables.
-The vertical mixing coefficients are diagnosed from the large scale variables computed by the model. 
+\begin{listing}
+  \nlst{namzdf_ric}
+  \caption{\forcode{&namzdf_ric}}
+  \label{lst:namzdf_ric}
+\end{listing}
+
+When \np[=.true.]{ln_zdfric}{ln\_zdfric}, a local Richardson number dependent formulation for the vertical momentum and
+tracer eddy coefficients is set through the \nam{zdf_ric}{zdf\_ric} namelist variables.
+The vertical mixing coefficients are diagnosed from the large scale variables computed by the model.
 \textit{In situ} measurements have been used to link vertical turbulent activity to large scale ocean structures.
 The hypothesis of a mixing mainly maintained by the growth of Kelvin-Helmholtz like instabilities leads to
 a dependency between the vertical eddy coefficients and the local Richardson number
-(\ie the ratio of stratification to vertical shear).
+(\ie\ the ratio of stratification to vertical shear).
 Following \citet{pacanowski.philander_JPO81}, the following formulation has been implemented:
 \[
-  % \label{eq:zdfric}
+  % \label{eq:ZDF_ric}
   \left\{
     \begin{aligned}
@@ -101,13 +112,13 @@
 \]
 where $Ri = N^2 / \left(\partial_z \textbf{U}_h \right)^2$ is the local Richardson number,
-$N$ is the local Brunt-Vais\"{a}l\"{a} frequency (see \autoref{subsec:TRA_bn2}), 
+$N$ is the local Brunt-Vais\"{a}l\"{a} frequency (see \autoref{subsec:TRA_bn2}),
 $A_b^{vT} $ and $A_b^{vm}$ are the constant background values set as in the constant case
 (see \autoref{subsec:ZDF_cst}), and $A_{ric}^{vT} = 10^{-4}~m^2.s^{-1}$ is the maximum value that
 can be reached by the coefficient when $Ri\leq 0$, $a=5$ and $n=2$.
-The last three values can be modified by setting the \np{rn\_avmri}, \np{rn\_alp} and
-\np{nn\_ric} namelist parameters, respectively.
+The last three values can be modified by setting the \np{rn_avmri}{rn\_avmri}, \np{rn_alp}{rn\_alp} and
+\np{nn_ric}{nn\_ric} namelist parameters, respectively.
 
 A simple mixing-layer model to transfer and dissipate the atmospheric forcings
-(wind-stress and buoyancy fluxes) can be activated setting the \np{ln\_mldw}\forcode{ = .true.} in the namelist.
+(wind-stress and buoyancy fluxes) can be activated setting the \np[=.true.]{ln_mldw}{ln\_mldw} in the namelist.
 
 In this case, the local depth of turbulent wind-mixing or "Ekman depth" $h_{e}(x,y,t)$ is evaluated and
@@ -125,18 +136,17 @@
 \]
 is computed from the wind stress vector $|\tau|$ and the reference density $ \rho_o$.
-The final $h_{e}$ is further constrained by the adjustable bounds \np{rn\_mldmin} and \np{rn\_mldmax}.
+The final $h_{e}$ is further constrained by the adjustable bounds \np{rn_mldmin}{rn\_mldmin} and \np{rn_mldmax}{rn\_mldmax}.
 Once $h_{e}$ is computed, the vertical eddy coefficients within $h_{e}$ are set to
-the empirical values \np{rn\_wtmix} and \np{rn\_wvmix} \citep{lermusiaux_JMS01}.
-
-% -------------------------------------------------------------------------------------------------------------
-%        TKE Turbulent Closure Scheme 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[TKE turbulent closure scheme (\forcode{ln_zdftke = .true.})]
-{TKE turbulent closure scheme (\protect\np{ln\_zdftke}\forcode{ = .true.})}
+the empirical values \np{rn_wtmix}{rn\_wtmix} and \np{rn_wvmix}{rn\_wvmix} \citep{lermusiaux_JMS01}.
+
+%% =================================================================================================
+\subsection[TKE turbulent closure scheme (\forcode{ln_zdftke})]{TKE turbulent closure scheme (\protect\np{ln_zdftke}{ln\_zdftke})}
 \label{subsec:ZDF_tke}
-%--------------------------------------------namzdf_tke--------------------------------------------------
-
-\nlst{namzdf_tke}
-%--------------------------------------------------------------------------------------------------------------
+
+\begin{listing}
+  \nlst{namzdf_tke}
+  \caption{\forcode{&namzdf_tke}}
+  \label{lst:namzdf_tke}
+\end{listing}
 
 The vertical eddy viscosity and diffusivity coefficients are computed from a TKE turbulent closure model based on
@@ -144,5 +154,5 @@
 and a closure assumption for the turbulent length scales.
 This turbulent closure model has been developed by \citet{bougeault.lacarrere_MWR89} in the atmospheric case,
-adapted by \citet{gaspar.gregoris.ea_JGR90} for the oceanic case, and embedded in OPA, the ancestor of NEMO,
+adapted by \citet{gaspar.gregoris.ea_JGR90} for the oceanic case, and embedded in OPA, the ancestor of \NEMO,
 by \citet{blanke.delecluse_JPO93} for equatorial Atlantic simulations.
 Since then, significant modifications have been introduced by \citet{madec.delecluse.ea_NPM98} in both the implementation and
@@ -151,5 +161,5 @@
 its destruction through stratification, its vertical diffusion, and its dissipation of \citet{kolmogorov_IANS42} type:
 \begin{equation}
-  \label{eq:zdftke_e}
+  \label{eq:ZDF_tke_e}
   \frac{\partial \bar{e}}{\partial t} =
   \frac{K_m}{{e_3}^2 }\;\left[ {\left( {\frac{\partial u}{\partial k}} \right)^2
@@ -161,5 +171,5 @@
 \end{equation}
 \[
-  % \label{eq:zdftke_kz}
+  % \label{eq:ZDF_tke_kz}
   \begin{split}
     K_m &= C_k\  l_k\  \sqrt {\bar{e}\; }  	\\
@@ -167,13 +177,13 @@
   \end{split}
 \]
-where $N$ is the local Brunt-Vais\"{a}l\"{a} frequency (see \autoref{subsec:TRA_bn2}), 
-$l_{\epsilon }$ and $l_{\kappa }$ are the dissipation and mixing length scales, 
+where $N$ is the local Brunt-Vais\"{a}l\"{a} frequency (see \autoref{subsec:TRA_bn2}),
+$l_{\epsilon }$ and $l_{\kappa }$ are the dissipation and mixing length scales,
 $P_{rt}$ is the Prandtl number, $K_m$ and $K_\rho$ are the vertical eddy viscosity and diffusivity coefficients.
 The constants $C_k =  0.1$ and $C_\epsilon = \sqrt {2} /2$ $\approx 0.7$ are designed to deal with
-vertical mixing at any depth \citep{gaspar.gregoris.ea_JGR90}. 
-They are set through namelist parameters \np{nn\_ediff} and \np{nn\_ediss}.
+vertical mixing at any depth \citep{gaspar.gregoris.ea_JGR90}.
+They are set through namelist parameters \np{nn_ediff}{nn\_ediff} and \np{nn_ediss}{nn\_ediss}.
 $P_{rt}$ can be set to unity or, following \citet{blanke.delecluse_JPO93}, be a function of the local Richardson number, $R_i$:
 \begin{align*}
-  % \label{eq:prt}
+  % \label{eq:ZDF_prt}
   P_{rt} =
   \begin{cases}
@@ -183,8 +193,8 @@
   \end{cases}
 \end{align*}
-The choice of $P_{rt}$ is controlled by the \np{nn\_pdl} namelist variable.
+The choice of $P_{rt}$ is controlled by the \np{nn_pdl}{nn\_pdl} namelist variable.
 
 At the sea surface, the value of $\bar{e}$ is prescribed from the wind stress field as
-$\bar{e}_o = e_{bb} |\tau| / \rho_o$, with $e_{bb}$ the \np{rn\_ebb} namelist parameter.
+$\bar{e}_o = e_{bb} |\tau| / \rho_o$, with $e_{bb}$ the \np{rn_ebb}{rn\_ebb} namelist parameter.
 The default value of $e_{bb}$ is 3.75. \citep{gaspar.gregoris.ea_JGR90}), however a much larger value can be used when
 taking into account the surface wave breaking (see below Eq. \autoref{eq:ZDF_Esbc}).
@@ -192,5 +202,5 @@
 The time integration of the $\bar{e}$ equation may formally lead to negative values because
 the numerical scheme does not ensure its positivity.
-To overcome this problem, a cut-off in the minimum value of $\bar{e}$ is used (\np{rn\_emin} namelist parameter).
+To overcome this problem, a cut-off in the minimum value of $\bar{e}$ is used (\np{rn_emin}{rn\_emin} namelist parameter).
 Following \citet{gaspar.gregoris.ea_JGR90}, the cut-off value is set to $\sqrt{2}/2~10^{-6}~m^2.s^{-2}$.
 This allows the subsequent formulations to match that of \citet{gargett_JMR84} for the diffusion in
@@ -198,55 +208,51 @@
 In addition, a cut-off is applied on $K_m$ and $K_\rho$ to avoid numerical instabilities associated with
 too weak vertical diffusion.
-They must be specified at least larger than the molecular values, and are set through \np{rn\_avm0} and
-\np{rn\_avt0} (\ngn{namzdf} namelist, see \autoref{subsec:ZDF_cst}).
-
+They must be specified at least larger than the molecular values, and are set through \np{rn_avm0}{rn\_avm0} and
+\np{rn_avt0}{rn\_avt0} (\nam{zdf}{zdf} namelist, see \autoref{subsec:ZDF_cst}).
+
+%% =================================================================================================
 \subsubsection{Turbulent length scale}
 
 For computational efficiency, the original formulation of the turbulent length scales proposed by
 \citet{gaspar.gregoris.ea_JGR90} has been simplified.
-Four formulations are proposed, the choice of which is controlled by the \np{nn\_mxl} namelist parameter.
+Four formulations are proposed, the choice of which is controlled by the \np{nn_mxl}{nn\_mxl} namelist parameter.
 The first two are based on the following first order approximation \citep{blanke.delecluse_JPO93}:
 \begin{equation}
-  \label{eq:tke_mxl0_1}
+  \label{eq:ZDF_tke_mxl0_1}
   l_k = l_\epsilon = \sqrt {2 \bar{e}\; } / N
 \end{equation}
 which is valid in a stable stratified region with constant values of the Brunt-Vais\"{a}l\"{a} frequency.
 The resulting length scale is bounded by the distance to the surface or to the bottom
-(\np{nn\_mxl}\forcode{ = 0}) or by the local vertical scale factor (\np{nn\_mxl}\forcode{ = 1}).
+(\np[=0]{nn_mxl}{nn\_mxl}) or by the local vertical scale factor (\np[=1]{nn_mxl}{nn\_mxl}).
 \citet{blanke.delecluse_JPO93} notice that this simplification has two major drawbacks:
 it makes no sense for locally unstable stratification and the computation no longer uses all
 the information contained in the vertical density profile.
-To overcome these drawbacks, \citet{madec.delecluse.ea_NPM98} introduces the \np{nn\_mxl}\forcode{ = 2, 3} cases,
+To overcome these drawbacks, \citet{madec.delecluse.ea_NPM98} introduces the \np[=2, 3]{nn_mxl}{nn\_mxl} cases,
 which add an extra assumption concerning the vertical gradient of the computed length scale.
-So, the length scales are first evaluated as in \autoref{eq:tke_mxl0_1} and then bounded such that:
+So, the length scales are first evaluated as in \autoref{eq:ZDF_tke_mxl0_1} and then bounded such that:
 \begin{equation}
-  \label{eq:tke_mxl_constraint}
+  \label{eq:ZDF_tke_mxl_constraint}
   \frac{1}{e_3 }\left| {\frac{\partial l}{\partial k}} \right| \leq 1
   \qquad \text{with }\  l =  l_k = l_\epsilon
 \end{equation}
-\autoref{eq:tke_mxl_constraint} means that the vertical variations of the length scale cannot be larger than
+\autoref{eq:ZDF_tke_mxl_constraint} means that the vertical variations of the length scale cannot be larger than
 the variations of depth.
-It provides a better approximation of the \citet{gaspar.gregoris.ea_JGR90} formulation while being much less 
+It provides a better approximation of the \citet{gaspar.gregoris.ea_JGR90} formulation while being much less
 time consuming.
 In particular, it allows the length scale to be limited not only by the distance to the surface or
 to the ocean bottom but also by the distance to a strongly stratified portion of the water column such as
-the thermocline (\autoref{fig:mixing_length}).
-In order to impose the \autoref{eq:tke_mxl_constraint} constraint, we introduce two additional length scales:
+the thermocline (\autoref{fig:ZDF_mixing_length}).
+In order to impose the \autoref{eq:ZDF_tke_mxl_constraint} constraint, we introduce two additional length scales:
 $l_{up}$ and $l_{dwn}$, the upward and downward length scales, and
 evaluate the dissipation and mixing length scales as
 (and note that here we use numerical indexing):
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_mixing_length}
-    \caption{
-      \protect\label{fig:mixing_length}
-      Illustration of the mixing length computation.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{ZDF_mixing_length}
+  \caption[Mixing length computation]{Illustration of the mixing length computation}
+  \label{fig:ZDF_mixing_length}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\[
-  % \label{eq:tke_mxl2}
+\[
+  % \label{eq:ZDF_tke_mxl2}
   \begin{aligned}
     l_{up\ \ }^{(k)} &= \min \left(  l^{(k)} \ , \ l_{up}^{(k+1)} + e_{3t}^{(k)}\ \ \ \;  \right)
@@ -256,11 +262,11 @@
   \end{aligned}
 \]
-where $l^{(k)}$ is computed using \autoref{eq:tke_mxl0_1}, \ie $l^{(k)} = \sqrt {2 {\bar e}^{(k)} / {N^2}^{(k)} }$.
-
-In the \np{nn\_mxl}\forcode{ = 2} case, the dissipation and mixing length scales take the same value:
-$ l_k=  l_\epsilon = \min \left(\ l_{up} \;,\;  l_{dwn}\ \right)$, while in the \np{nn\_mxl}\forcode{ = 3} case,
+where $l^{(k)}$ is computed using \autoref{eq:ZDF_tke_mxl0_1}, \ie\ $l^{(k)} = \sqrt {2 {\bar e}^{(k)} / {N^2}^{(k)} }$.
+
+In the \np[=2]{nn_mxl}{nn\_mxl} case, the dissipation and mixing length scales take the same value:
+$ l_k=  l_\epsilon = \min \left(\ l_{up} \;,\;  l_{dwn}\ \right)$, while in the \np[=3]{nn_mxl}{nn\_mxl} case,
 the dissipation and mixing turbulent length scales are give as in \citet{gaspar.gregoris.ea_JGR90}:
 \[
-  % \label{eq:tke_mxl_gaspar}
+  % \label{eq:ZDF_tke_mxl_gaspar}
   \begin{aligned}
     & l_k          = \sqrt{\  l_{up} \ \ l_{dwn}\ }  	\\
@@ -269,13 +275,13 @@
 \]
 
-At the ocean surface, a non zero length scale is set through the  \np{rn\_mxl0} namelist parameter.
+At the ocean surface, a non zero length scale is set through the  \np{rn_mxl0}{rn\_mxl0} namelist parameter.
 Usually the surface scale is given by $l_o = \kappa \,z_o$ where $\kappa = 0.4$ is von Karman's constant and
 $z_o$ the roughness parameter of the surface.
-Assuming $z_o=0.1$~m \citep{craig.banner_JPO94} leads to a 0.04~m, the default value of \np{rn\_mxl0}.
+Assuming $z_o=0.1$~m \citep{craig.banner_JPO94} leads to a 0.04~m, the default value of \np{rn_mxl0}{rn\_mxl0}.
 In the ocean interior a minimum length scale is set to recover the molecular viscosity when
 $\bar{e}$ reach its minimum value ($1.10^{-6}= C_k\, l_{min} \,\sqrt{\bar{e}_{min}}$ ).
 
+%% =================================================================================================
 \subsubsection{Surface wave breaking parameterization}
-%-----------------------------------------------------------------------%
 
 Following \citet{mellor.blumberg_JPO04}, the TKE turbulence closure model has been modified to
@@ -283,6 +289,6 @@
 This results in a reduction of summertime surface temperature when the mixed layer is relatively shallow.
 The \citet{mellor.blumberg_JPO04} modifications acts on surface length scale and TKE values and
-air-sea drag coefficient. 
-The latter concerns the bulk formulae and is not discussed here. 
+air-sea drag coefficient.
+The latter concerns the bulk formulae and is not discussed here.
 
 Following \citet{craig.banner_JPO94}, the boundary condition on surface TKE value is :
@@ -292,5 +298,5 @@
 \end{equation}
 where $\alpha_{CB}$ is the \citet{craig.banner_JPO94} constant of proportionality which depends on the ''wave age'',
-ranging from 57 for mature waves to 146 for younger waves \citep{mellor.blumberg_JPO04}. 
+ranging from 57 for mature waves to 146 for younger waves \citep{mellor.blumberg_JPO04}.
 The boundary condition on the turbulent length scale follows the Charnock's relation:
 \begin{equation}
@@ -303,13 +309,13 @@
 $\alpha_{CB} = 100$ the Craig and Banner's value.
 As the surface boundary condition on TKE is prescribed through $\bar{e}_o = e_{bb} |\tau| / \rho_o$,
-with $e_{bb}$ the \np{rn\_ebb} namelist parameter, setting \np{rn\_ebb}\forcode{ = 67.83} corresponds 
+with $e_{bb}$ the \np{rn_ebb}{rn\_ebb} namelist parameter, setting \np[=67.83]{rn_ebb}{rn\_ebb} corresponds
 to $\alpha_{CB} = 100$.
-Further setting  \np{ln\_mxl0=.true.},  applies \autoref{eq:ZDF_Lsbc} as the surface boundary condition on the length scale,
+Further setting  \np[=.true.]{ln_mxl0}{ln\_mxl0},  applies \autoref{eq:ZDF_Lsbc} as the surface boundary condition on the length scale,
 with $\beta$ hard coded to the Stacey's value.
-Note that a minimal threshold of \np{rn\_emin0}$=10^{-4}~m^2.s^{-2}$ (namelist parameters) is applied on the 
+Note that a minimal threshold of \np{rn_emin0}{rn\_emin0}$=10^{-4}~m^2.s^{-2}$ (namelist parameters) is applied on the
 surface $\bar{e}$ value.
 
+%% =================================================================================================
 \subsubsection{Langmuir cells}
-%--------------------------------------%
 
 Langmuir circulations (LC) can be described as ordered large-scale vertical motions in
@@ -319,5 +325,5 @@
 The detailed physics behind LC is described in, for example, \citet{craik.leibovich_JFM76}.
 The prevailing explanation is that LC arise from a nonlinear interaction between the Stokes drift and
-wind drift currents. 
+wind drift currents.
 
 Here we introduced in the TKE turbulent closure the simple parameterization of Langmuir circulations proposed by
@@ -325,15 +331,15 @@
 The parameterization, tuned against large-eddy simulation, includes the whole effect of LC in
 an extra source term of TKE, $P_{LC}$.
-The presence of $P_{LC}$ in \autoref{eq:zdftke_e}, the TKE equation, is controlled by setting \np{ln\_lc} to
-\forcode{.true.} in the \ngn{namzdf\_tke} namelist.
- 
+The presence of $P_{LC}$ in \autoref{eq:ZDF_tke_e}, the TKE equation, is controlled by setting \np{ln_lc}{ln\_lc} to
+\forcode{.true.} in the \nam{zdf_tke}{zdf\_tke} namelist.
+
 By making an analogy with the characteristic convective velocity scale (\eg, \citet{dalessio.abdella.ea_JPO98}),
-$P_{LC}$ is assumed to be : 
+$P_{LC}$ is assumed to be :
 \[
 P_{LC}(z) = \frac{w_{LC}^3(z)}{H_{LC}}
 \]
 where $w_{LC}(z)$ is the vertical velocity profile of LC, and $H_{LC}$ is the LC depth.
-With no information about the wave field, $w_{LC}$ is assumed to be proportional to 
-the Stokes drift $u_s = 0.377\,\,|\tau|^{1/2}$, where $|\tau|$ is the surface wind stress module 
+With no information about the wave field, $w_{LC}$ is assumed to be proportional to
+the Stokes drift $u_s = 0.377\,\,|\tau|^{1/2}$, where $|\tau|$ is the surface wind stress module
 \footnote{Following \citet{li.garrett_JMR93}, the surface Stoke drift velocity may be expressed as
   $u_s =  0.016 \,|U_{10m}|$.
@@ -343,5 +349,5 @@
 For the vertical variation, $w_{LC}$ is assumed to be zero at the surface as well as at
 a finite depth $H_{LC}$ (which is often close to the mixed layer depth),
-and simply varies as a sine function in between (a first-order profile for the Langmuir cell structures). 
+and simply varies as a sine function in between (a first-order profile for the Langmuir cell structures).
 The resulting expression for $w_{LC}$ is :
 \[
@@ -354,27 +360,27 @@
 where $c_{LC} = 0.15$ has been chosen by \citep{axell_JGR02} as a good compromise to fit LES data.
 The chosen value yields maximum vertical velocities $w_{LC}$ of the order of a few centimeters per second.
-The value of $c_{LC}$ is set through the \np{rn\_lc} namelist parameter,
-having in mind that it should stay between 0.15 and 0.54 \citep{axell_JGR02}. 
+The value of $c_{LC}$ is set through the \np{rn_lc}{rn\_lc} namelist parameter,
+having in mind that it should stay between 0.15 and 0.54 \citep{axell_JGR02}.
 
 The $H_{LC}$ is estimated in a similar way as the turbulent length scale of TKE equations:
 $H_{LC}$ is the depth to which a water parcel with kinetic energy due to Stoke drift can reach on its own by
-converting its kinetic energy to potential energy, according to 
+converting its kinetic energy to potential energy, according to
 \[
 - \int_{-H_{LC}}^0 { N^2\;z  \;dz} = \frac{1}{2} u_s^2
 \]
 
+%% =================================================================================================
 \subsubsection{Mixing just below the mixed layer}
-%--------------------------------------------------------------%
 
 Vertical mixing parameterizations commonly used in ocean general circulation models tend to
 produce mixed-layer depths that are too shallow during summer months and windy conditions.
 This bias is particularly acute over the Southern Ocean.
-To overcome this systematic bias, an ad hoc parameterization is introduced into the TKE scheme \cite{rodgers.aumont.ea_B14}. 
-The parameterization is an empirical one, \ie not derived from theoretical considerations,
-but rather is meant to account for observed processes that affect the density structure of 
-the ocean’s planetary boundary layer that are not explicitly captured by default in the TKE scheme 
-(\ie near-inertial oscillations and ocean swells and waves).
-
-When using this parameterization (\ie when \np{nn\_etau}\forcode{ = 1}),
+To overcome this systematic bias, an ad hoc parameterization is introduced into the TKE scheme \cite{rodgers.aumont.ea_B14}.
+The parameterization is an empirical one, \ie\ not derived from theoretical considerations,
+but rather is meant to account for observed processes that affect the density structure of
+the ocean’s planetary boundary layer that are not explicitly captured by default in the TKE scheme
+(\ie\ near-inertial oscillations and ocean swells and waves).
+
+When using this parameterization (\ie\ when \np[=1]{nn_etau}{nn\_etau}),
 the TKE input to the ocean ($S$) imposed by the winds in the form of near-inertial oscillations,
 swell and waves is parameterized by \autoref{eq:ZDF_Esbc} the standard TKE surface boundary condition,
@@ -387,51 +393,49 @@
 penetrates in the ocean, $h_\tau$ is a vertical mixing length scale that controls exponential shape of
 the penetration, and $f_i$ is the ice concentration
-(no penetration if $f_i=1$, \ie if the ocean is entirely covered by sea-ice).
-The value of $f_r$, usually a few percents, is specified through \np{rn\_efr} namelist parameter.
-The vertical mixing length scale, $h_\tau$, can be set as a 10~m uniform value (\np{nn\_etau}\forcode{ = 0}) or
+(no penetration if $f_i=1$, \ie\ if the ocean is entirely covered by sea-ice).
+The value of $f_r$, usually a few percents, is specified through \np{rn_efr}{rn\_efr} namelist parameter.
+The vertical mixing length scale, $h_\tau$, can be set as a 10~m uniform value (\np[=0]{nn_etau}{nn\_etau}) or
 a latitude dependent value (varying from 0.5~m at the Equator to a maximum value of 30~m at high latitudes
-(\np{nn\_etau}\forcode{ = 1}). 
-
-Note that two other option exist, \np{nn\_etau}\forcode{ = 2, 3}.
+(\np[=1]{nn_etau}{nn\_etau}).
+
+Note that two other option exist, \np[=2, 3]{nn_etau}{nn\_etau}.
 They correspond to applying \autoref{eq:ZDF_Ehtau} only at the base of the mixed layer,
-or to using the high frequency part of the stress to evaluate the fraction of TKE that penetrates the ocean. 
+or to using the high frequency part of the stress to evaluate the fraction of TKE that penetrates the ocean.
 Those two options are obsolescent features introduced for test purposes.
-They will be removed in the next release. 
+They will be removed in the next release.
 
 % This should be explain better below what this rn_eice parameter is meant for:
-In presence of Sea Ice, the value of this mixing can be modulated by the \np{rn\_eice} namelist parameter.
+In presence of Sea Ice, the value of this mixing can be modulated by the \np{rn_eice}{rn\_eice} namelist parameter.
 This parameter varies from \forcode{0} for no effect to \forcode{4} to suppress the TKE input into the ocean when Sea Ice concentration
-is greater than 25\%. 
-
-% from Burchard et al OM 2008 : 
-% the most critical process not reproduced by statistical turbulence models is the activity of 
-% internal waves and their interaction with turbulence. After the Reynolds decomposition, 
-% internal waves are in principle included in the RANS equations, but later partially 
-% excluded by the hydrostatic assumption and the model resolution. 
-% Thus far, the representation of internal wave mixing in ocean models has been relatively crude 
-% (\eg Mellor, 1989; Large et al., 1994; Meier, 2001; Axell, 2002; St. Laurent and Garrett, 2002).
-
-% -------------------------------------------------------------------------------------------------------------
-%        GLS Generic Length Scale Scheme 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[GLS: Generic Length Scale (\forcode{ln_zdfgls = .true.})]
-{GLS: Generic Length Scale (\protect\np{ln\_zdfgls}\forcode{ = .true.})}
+is greater than 25\%.
+
+% from Burchard et al OM 2008 :
+% the most critical process not reproduced by statistical turbulence models is the activity of
+% internal waves and their interaction with turbulence. After the Reynolds decomposition,
+% internal waves are in principle included in the RANS equations, but later partially
+% excluded by the hydrostatic assumption and the model resolution.
+% Thus far, the representation of internal wave mixing in ocean models has been relatively crude
+% (\eg\ Mellor, 1989; Large et al., 1994; Meier, 2001; Axell, 2002; St. Laurent and Garrett, 2002).
+
+%% =================================================================================================
+\subsection[GLS: Generic Length Scale (\forcode{ln_zdfgls})]{GLS: Generic Length Scale (\protect\np{ln_zdfgls}{ln\_zdfgls})}
 \label{subsec:ZDF_gls}
 
-%--------------------------------------------namzdf_gls---------------------------------------------------------
-
-\nlst{namzdf_gls}
-%--------------------------------------------------------------------------------------------------------------
+\begin{listing}
+  \nlst{namzdf_gls}
+  \caption{\forcode{&namzdf_gls}}
+  \label{lst:namzdf_gls}
+\end{listing}
 
 The Generic Length Scale (GLS) scheme is a turbulent closure scheme based on two prognostic equations:
 one for the turbulent kinetic energy $\bar {e}$, and another for the generic length scale,
 $\psi$ \citep{umlauf.burchard_JMR03, umlauf.burchard_CSR05}.
-This later variable is defined as: $\psi = {C_{0\mu}}^{p} \ {\bar{e}}^{m} \ l^{n}$, 
-where the triplet $(p, m, n)$ value given in Tab.\autoref{tab:GLS} allows to recover a number of
+This later variable is defined as: $\psi = {C_{0\mu}}^{p} \ {\bar{e}}^{m} \ l^{n}$,
+where the triplet $(p, m, n)$ value given in Tab.\autoref{tab:ZDF_GLS} allows to recover a number of
 well-known turbulent closures ($k$-$kl$ \citep{mellor.yamada_RG82}, $k$-$\epsilon$ \citep{rodi_JGR87},
-$k$-$\omega$ \citep{wilcox_AJ88} among others \citep{umlauf.burchard_JMR03,kantha.carniel_JMR03}). 
+$k$-$\omega$ \citep{wilcox_AJ88} among others \citep{umlauf.burchard_JMR03,kantha.carniel_JMR03}).
 The GLS scheme is given by the following set of equations:
 \begin{equation}
-  \label{eq:zdfgls_e}
+  \label{eq:ZDF_gls_e}
   \frac{\partial \bar{e}}{\partial t} =
   \frac{K_m}{\sigma_e e_3 }\;\left[ {\left( \frac{\partial u}{\partial k} \right)^2
@@ -443,5 +447,5 @@
 
 \[
-  % \label{eq:zdfgls_psi}
+  % \label{eq:ZDF_gls_psi}
   \begin{split}
     \frac{\partial \psi}{\partial t} =& \frac{\psi}{\bar{e}} \left\{
@@ -455,5 +459,5 @@
 
 \[
-  % \label{eq:zdfgls_kz}
+  % \label{eq:ZDF_gls_kz}
   \begin{split}
     K_m    &= C_{\mu} \ \sqrt {\bar{e}} \ l         \\
@@ -463,43 +467,40 @@
 
 \[
-  % \label{eq:zdfgls_eps}
+  % \label{eq:ZDF_gls_eps}
   {\epsilon} = C_{0\mu} \,\frac{\bar {e}^{3/2}}{l} \;
 \]
 where $N$ is the local Brunt-Vais\"{a}l\"{a} frequency (see \autoref{subsec:TRA_bn2}) and
-$\epsilon$ the dissipation rate. 
+$\epsilon$ the dissipation rate.
 The constants $C_1$, $C_2$, $C_3$, ${\sigma_e}$, ${\sigma_{\psi}}$ and the wall function ($Fw$) depends of
 the choice of the turbulence model.
-Four different turbulent models are pre-defined (\autoref{tab:GLS}).
-They are made available through the \np{nn\_clo} namelist parameter. 
-
-%--------------------------------------------------TABLE--------------------------------------------------
+Four different turbulent models are pre-defined (\autoref{tab:ZDF_GLS}).
+They are made available through the \np{nn_clo}{nn\_clo} namelist parameter.
+
 \begin{table}[htbp]
-  \begin{center}
-    % \begin{tabular}{cp{70pt}cp{70pt}cp{70pt}cp{70pt}cp{70pt}cp{70pt}c}
-    \begin{tabular}{ccccc}
-      &   $k-kl$   & $k-\epsilon$ & $k-\omega$ &   generic   \\
-      % & \citep{mellor.yamada_RG82} &  \citep{rodi_JGR87}       & \citep{wilcox_AJ88} &                 \\
-      \hline
-      \hline
-      \np{nn\_clo}     & \textbf{0} &   \textbf{1}  &   \textbf{2}   &    \textbf{3}   \\
-      \hline
-      $( p , n , m )$	       &   ( 0 , 1 , 1 )   & ( 3 , 1.5 , -1 )   & ( -1 , 0.5 , -1 )    &  ( 2 , 1 , -0.67 )  \\
-      $\sigma_k$      &    2.44         &     1.              &      2.                &      0.8          \\
-      $\sigma_\psi$  &    2.44         &     1.3            &      2.                 &       1.07       \\
-      $C_1$              &      0.9         &     1.44          &      0.555          &       1.           \\
-      $C_2$              &      0.5         &     1.92          &      0.833          &       1.22       \\
-      $C_3$              &      1.           &     1.              &      1.                &       1.           \\
-      $F_{wall}$        &      Yes        &       --             &     --                  &      --          \\
-      \hline
-      \hline
-    \end{tabular}
-    \caption{
-      \protect\label{tab:GLS}
-      Set of predefined GLS parameters, or equivalently predefined turbulence models available with
-      \protect\np{ln\_zdfgls}\forcode{ = .true.} and controlled by the \protect\np{nn\_clos} namelist variable in \protect\ngn{namzdf\_gls}.
-    }
-  \end{center}
+  \centering
+  % \begin{tabular}{cp{70pt}cp{70pt}cp{70pt}cp{70pt}cp{70pt}cp{70pt}c}
+  \begin{tabular}{ccccc}
+    &   $k-kl$   & $k-\epsilon$ & $k-\omega$ &   generic   \\
+    % & \citep{mellor.yamada_RG82} &  \citep{rodi_JGR87}       & \citep{wilcox_AJ88} &                 \\
+    \hline
+    \hline
+    \np{nn_clo}{nn\_clo}     & \textbf{0} &   \textbf{1}  &   \textbf{2}   &    \textbf{3}   \\
+    \hline
+    $( p , n , m )$	       &   ( 0 , 1 , 1 )   & ( 3 , 1.5 , -1 )   & ( -1 , 0.5 , -1 )    &  ( 2 , 1 , -0.67 )  \\
+    $\sigma_k$      &    2.44         &     1.              &      2.                &      0.8          \\
+    $\sigma_\psi$  &    2.44         &     1.3            &      2.                 &       1.07       \\
+    $C_1$              &      0.9         &     1.44          &      0.555          &       1.           \\
+    $C_2$              &      0.5         &     1.92          &      0.833          &       1.22       \\
+    $C_3$              &      1.           &     1.              &      1.                &       1.           \\
+    $F_{wall}$        &      Yes        &       --             &     --                  &      --          \\
+    \hline
+    \hline
+  \end{tabular}
+  \caption[Set of predefined GLS parameters or equivalently predefined turbulence models available]{
+    Set of predefined GLS parameters, or equivalently predefined turbulence models available with
+    \protect\np[=.true.]{ln_zdfgls}{ln\_zdfgls} and controlled by
+    the \protect\np{nn_clos}{nn\_clos} namelist variable in \protect\nam{zdf_gls}{zdf\_gls}.}
+  \label{tab:ZDF_GLS}
 \end{table}
-%--------------------------------------------------------------------------------------------------------------
 
 In the Mellor-Yamada model, the negativity of $n$ allows to use a wall function to force the convergence of
@@ -508,13 +509,13 @@
 $C_{\mu}$ and $C_{\mu'}$ are calculated from stability function proposed by \citet{galperin.kantha.ea_JAS88},
 or by \citet{kantha.clayson_JGR94} or one of the two functions suggested by \citet{canuto.howard.ea_JPO01}
-(\np{nn\_stab\_func}\forcode{ = 0, 3}, resp.).  
+(\np[=0, 3]{nn_stab_func}{nn\_stab\_func}, resp.).
 The value of $C_{0\mu}$ depends on the choice of the stability function.
 
 The surface and bottom boundary condition on both $\bar{e}$ and $\psi$ can be calculated thanks to Dirichlet or
-Neumann condition through \np{nn\_bc\_surf} and \np{nn\_bc\_bot}, resp.
+Neumann condition through \np{nn_bc_surf}{nn\_bc\_surf} and \np{nn_bc_bot}{nn\_bc\_bot}, resp.
 As for TKE closure, the wave effect on the mixing is considered when
-\np{rn\_crban}\forcode{ > 0.} \citep{craig.banner_JPO94, mellor.blumberg_JPO04}.
-The \np{rn\_crban} namelist parameter is $\alpha_{CB}$ in \autoref{eq:ZDF_Esbc} and
-\np{rn\_charn} provides the value of $\beta$ in \autoref{eq:ZDF_Lsbc}. 
+\np[ > 0.]{rn_crban}{rn\_crban} \citep{craig.banner_JPO94, mellor.blumberg_JPO04}.
+The \np{rn_crban}{rn\_crban} namelist parameter is $\alpha_{CB}$ in \autoref{eq:ZDF_Esbc} and
+\np{rn_charn}{rn\_charn} provides the value of $\beta$ in \autoref{eq:ZDF_Lsbc}.
 
 The $\psi$ equation is known to fail in stably stratified flows, and for this reason
@@ -525,59 +526,256 @@
 the entrainment depth predicted in stably stratified situations,
 and that its value has to be chosen in accordance with the algebraic model for the turbulent fluxes.
-The clipping is only activated if \np{ln\_length\_lim}\forcode{ = .true.},
-and the $c_{lim}$ is set to the \np{rn\_clim\_galp} value.
+The clipping is only activated if \np[=.true.]{ln_length_lim}{ln\_length\_lim},
+and the $c_{lim}$ is set to the \np{rn_clim_galp}{rn\_clim\_galp} value.
 
 The time and space discretization of the GLS equations follows the same energetic consideration as for
 the TKE case described in \autoref{subsec:ZDF_tke_ene} \citep{burchard_OM02}.
 Evaluation of the 4 GLS turbulent closure schemes can be found in \citet{warner.sherwood.ea_OM05} in ROMS model and
- in \citet{reffray.guillaume.ea_GMD15} for the \NEMO model.
-
+ in \citet{reffray.guillaume.ea_GMD15} for the \NEMO\ model.
 
 % -------------------------------------------------------------------------------------------------------------
-%        OSM OSMOSIS BL Scheme 
+%        OSM OSMOSIS BL Scheme
 % -------------------------------------------------------------------------------------------------------------
-\subsection[OSM: OSMosis boundary layer scheme (\forcode{ln_zdfosm = .true.})]
-{OSM: OSMosis boundary layer scheme (\protect\np{ln\_zdfosm}\forcode{ = .true.})}
+\subsection[OSM: OSMOSIS boundary layer scheme (\forcode{ln_zdfosm = .true.})]
+{OSM: OSMOSIS boundary layer scheme (\protect\np{ln_zdfosm}{ln\_zdfosm})}
 \label{subsec:ZDF_osm}
-%--------------------------------------------namzdf_osm---------------------------------------------------------
-
-\nlst{namzdf_osm}
+
+\begin{listing}
+  \nlst{namzdf_osm}
+  \caption{\forcode{&namzdf_osm}}
+  \label{lst:namzdf_osm}
+\end{listing}
+
 %--------------------------------------------------------------------------------------------------------------
-
-The OSMOSIS turbulent closure scheme is based on......   TBC
-
-% -------------------------------------------------------------------------------------------------------------
-%        TKE and GLS discretization considerations
-% -------------------------------------------------------------------------------------------------------------
-\subsection[ Discrete energy conservation for TKE and GLS schemes]
-{Discrete energy conservation for TKE and GLS schemes}
-\label{subsec:ZDF_tke_ene}
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+\paragraph{Namelist choices}
+Most of the namelist options refer to how to specify the Stokes
+surface drift and penetration depth. There are three options:
+\begin{description}
+  \item \protect\np[=0]{nn_osm_wave}{nn\_osm\_wave} Default value in \texttt{namelist\_ref}. In this case the Stokes drift is
+      assumed to be parallel to the surface wind stress, with
+      magnitude consistent with a constant turbulent Langmuir number
+    $\mathrm{La}_t=$ \protect\np{rn_m_la} {rn\_m\_la} i.e.\
+    $u_{s0}=\tau/(\mathrm{La}_t^2\rho_0)$.  Default value of
+    \protect\np{rn_m_la}{rn\_m\_la} is 0.3. The Stokes penetration
+      depth $\delta = $ \protect\np{rn_osm_dstokes}{rn\_osm\_dstokes}; this has default value
+      of 5~m.
+
+  \item \protect\np[=1]{nn_osm_wave}{nn\_osm\_wave} In this case the Stokes drift is
+      assumed to be parallel to the surface wind stress, with
+      magnitude as in the classical Pierson-Moskowitz wind-sea
+      spectrum.  Significant wave height and
+      wave-mean period taken from this spectrum are used to calculate the Stokes penetration
+      depth, following the approach set out in  \citet{breivik.janssen.ea_JPO14}.
+
+    \item \protect\np[=2]{nn_osm_wave}{nn\_osm\_wave} In this case the Stokes drift is
+      taken from  ECMWF wave model output, though only the component parallel
+      to the wind stress is retained. Significant wave height and
+      wave-mean period from ECMWF wave model output are used to calculate the Stokes penetration
+      depth, again following \citet{breivik.janssen.ea_JPO14}.
+
+    \end{description}
+
+    Others refer to the treatment of diffusion and viscosity beneath
+    the surface boundary layer:
+\begin{description}
+   \item \protect\np{ln_kpprimix} {ln\_kpprimix}  Default is \np{.true.}. Switches on KPP-style Ri \#-dependent
+     mixing below the surface boundary layer. If this is set
+     \texttt{.true.}  the following variable settings are honoured:
+    \item \protect\np{rn_riinfty}{rn\_riinfty} Critical value of local Ri \# below which
+      shear instability increases vertical mixing from background value.
+    \item \protect\np{rn_difri} {rn\_difri} Maximum value of Ri \#-dependent mixing at $\mathrm{Ri}=0$.
+    \item \protect\np{ln_convmix}{ln\_convmix} If \texttt{.true.} then, where water column is unstable, specify
+       diffusivity equal to \protect\np{rn_dif_conv}{rn\_dif\_conv} (default value is 1 m~s$^{-2}$).
+ \end{description}
+ Diagnostic output is controlled by:
+  \begin{description}
+    \item \protect\np{ln_dia_osm}{ln\_dia\_osm} Default is \np{.false.}; allows XIOS output of OSMOSIS internal fields.
+  \end{description}
+Obsolete namelist parameters include:
+\begin{description}
+   \item \protect\np{ln_use_osm_la}\np{ln\_use\_osm\_la} With \protect\np[=0]{nn_osm_wave}{nn\_osm\_wave},
+      \protect\np{rn_osm_dstokes} {rn\_osm\_dstokes} is always used to specify the Stokes
+      penetration depth.
+   \item \protect\np{nn_ave} {nn\_ave} Choice of averaging method for KPP-style Ri \#
+      mixing. Not taken account of.
+   \item \protect\np{rn_osm_hbl0} {rn\_osm\_hbl0} Depth of initial boundary layer is now set
+     by a density criterion similar to that used in calculating \emph{hmlp} (output as \texttt{mldr10\_1}) in \mdl{zdfmxl}.
+\end{description}
+
+\subsubsection{Summary}
+Much of the time the turbulent motions in the ocean surface boundary
+layer (OSBL) are not given by
+classical shear turbulence. Instead they are in a regime known as
+`Langmuir turbulence',  dominated by an
+interaction between the currents and the Stokes drift of the surface waves \citep[e.g.][]{mcwilliams.ea_JFM97}.
+This regime is characterised by strong vertical turbulent motion, and appears when the surface Stokes drift $u_{s0}$ is much greater than the friction velocity $u_{\ast}$. More specifically Langmuir turbulence is thought to be crucial where the turbulent Langmuir number $\mathrm{La}_{t}=(u_{\ast}/u_{s0}) > 0.4$.
+
+The OSMOSIS model is fundamentally based on results of Large Eddy
+Simulations (LES) of Langmuir turbulence and aims to fully describe
+this Langmuir regime. The description in this section is of necessity incomplete and further details are available in Grant. A (2019); in prep.
+
+The OSMOSIS turbulent closure scheme is a similarity-scale scheme in
+the same spirit as the K-profile
+parameterization (KPP) scheme of \citet{large.ea_RG97}.
+A specified shape of diffusivity, scaled by the (OSBL) depth
+$h_{\mathrm{BL}}$ and a turbulent velocity scale, is imposed throughout the
+boundary layer
+$-h_{\mathrm{BL}}<z<\eta$. The turbulent closure model
+also includes fluxes of tracers and momentum that are``non-local'' (independent of the local property gradient).
+
+Rather than the OSBL
+depth being diagnosed in terms of a bulk Richardson number criterion,
+as in KPP, it is set by a prognostic equation that is informed by
+energy budget considerations reminiscent of the classical mixed layer
+models of \citet{kraus.turner_tellus67}.
+The model also includes an explicit parametrization of the structure
+of the pycnocline (the stratified region at the bottom of the OSBL).
+
+Presently, mixing below the OSBL is handled by the Richardson
+number-dependent mixing scheme used in \citet{large.ea_RG97}.
+
+Convective parameterizations such as described in \ref{sec:ZDF_conv}
+below should not be used with the OSMOSIS-OBL model: instabilities
+within the OSBL are part of the model, while instabilities below the
+ML are handled by the Ri \# dependent scheme.
+
+\subsubsection{Depth and velocity scales}
+The model supposes a boundary layer of thickness $h_{\mathrm{bl}}$ enclosing a well-mixed layer of thickness $h_{\mathrm{ml}}$ and a relatively thin pycnocline at the base of thickness $\Delta h$; Fig.~\ref{fig: OSBL_structure} shows typical (a) buoyancy structure and (b) turbulent buoyancy flux profile for the unstable boundary layer (losing buoyancy at the surface; e.g.\ cooling).
 \begin{figure}[!t]
   \begin{center}
-    \includegraphics[width=\textwidth]{Fig_ZDF_TKE_time_scheme}
+    %\includegraphics[width=0.7\textwidth]{ZDF_OSM_structure_of_OSBL}
     \caption{
-      \protect\label{fig:TKE_time_scheme}
-      Illustration of the subgrid kinetic energy integration in GLS and TKE schemes and its links to the momentum and tracer time integration.
+      \protect\label{fig: OSBL_structure}
+     The structure of the entraining  boundary layer. (a) Mean buoyancy profile. (b) Profile of the buoyancy flux.
     }
-  \end{center}  
+  \end{center}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+The pycnocline in the OSMOSIS scheme is assumed to have a finite thickness, and may include a number of model levels. This means that the OSMOSIS scheme must parametrize both the thickness of the pycnocline, and the turbulent fluxes within the pycnocline.
+
+Consideration of the power input by wind acting on the Stokes drift suggests that the Langmuir turbulence has velocity scale:
+\begin{equation}\label{eq:w_La}
+w_{*L}= \left(u_*^2 u_{s\,0}\right)^{1/3};
+\end{equation}
+but at times the Stokes drift may be weak due to e.g.\ ice cover, short fetch, misalignment with the surface stress, etc.\ so  a composite velocity scale is assumed for the stable (warming) boundary layer:
+\begin{equation}\label{eq:composite-nu}
+  \nu_{\ast}= \left\{ u_*^3 \left[1-\exp(-.5 \mathrm{La}_t^2)\right]+w_{*L}^3\right\}^{1/3}.
+\end{equation}
+For the unstable boundary layer this is merged with the standard convective velocity scale $w_{*C}=\left(\overline{w^\prime b^\prime}_0 \,h_\mathrm{ml}\right)^{1/3}$, where $\overline{w^\prime b^\prime}_0$ is the upwards surface buoyancy flux, to give:
+\begin{equation}\label{eq:vel-scale-unstable}
+\omega_* = \left(\nu_*^3 + 0.5 w_{*C}^3\right)^{1/3}.
+\end{equation}
+
+\subsubsection{The flux gradient model}
+The flux-gradient relationships used in the OSMOSIS scheme take the form:
+%
+\begin{equation}\label{eq:flux-grad-gen}
+\overline{w^\prime\chi^\prime}=-K\frac{\partial\overline{\chi}}{\partial z} + N_{\chi,s} +N_{\chi,b} +N_{\chi,t},
+\end{equation}
+%
+where $\chi$ is a general variable and $N_{\chi,s}, N_{\chi,b} \mathrm{and} N_{\chi,t}$  are the non-gradient terms, and represent the effects of the different terms in the turbulent flux-budget on the transport of $\chi$. $N_{\chi,s}$ represents the effects that the Stokes shear has on the transport of $\chi$, $N_{\chi,b}$  the effect of buoyancy, and $N_{\chi,t}$ the effect of the turbulent transport.  The same general form for the flux-gradient relationship is used to parametrize the transports of momentum, heat and salinity.
+
+In terms of the non-dimensionalized depth variables
+%
+\begin{equation}\label{eq:sigma}
+\sigma_{\mathrm{ml}}= -z/h_{\mathrm{ml}}; \;\sigma_{\mathrm{bl}}= -z/h_{\mathrm{bl}},
+\end{equation}
+%
+in unstable conditions the eddy diffusivity ($K_d$) and eddy viscosity ($K_\nu$) profiles are parametrized as:
+%
+\begin{align}\label{eq:diff-unstable}
+K_d=&0.8\, \omega_*\, h_{\mathrm{ml}} \, \sigma_{\mathrm{ml}} \left(1-\beta_d \sigma_{\mathrm{ml}}\right)^{3/2}
+\\\label{eq:visc-unstable}
+K_\nu =& 0.3\, \omega_* \,h_{\mathrm{ml}}\, \sigma_{\mathrm{ml}} \left(1-\beta_\nu \sigma_{\mathrm{ml}}\right)\left(1-\tfrac{1}{2}\sigma_{\mathrm{ml}}^2\right)
+\end{align}
+%
+where $\beta_d$ and $\beta_\nu$ are parameters that are determined by matching Eqs \ref{eq:diff-unstable} and \ref{eq:visc-unstable} to the eddy diffusivity and viscosity at the base of the well-mixed layer, given by
+%
+\begin{equation}\label{eq:diff-wml-base}
+K_{d,\mathrm{ml}}=K_{\nu,\mathrm{ml}}=\,0.16\,\omega_* \Delta h.
+\end{equation}
+%
+For stable conditions the eddy diffusivity/viscosity profiles are given by:
+%
+\begin{align}\label{diff-stable}
+K_d= & 0.75\,\, \nu_*\, h_{\mathrm{ml}}\,\,  \exp\left[-2.8 \left(h_{\mathrm{bl}}/L_L\right)^2\right]\sigma_{\mathrm{ml}} \left(1-\sigma_{\mathrm{ml}}\right)^{3/2} \\\label{eq:visc-stable}
+K_\nu = & 0.375\,\,  \nu_*\, h_{\mathrm{ml}} \,\, \exp\left[-2.8 \left(h_{\mathrm{bl}}/L_L\right)^2\right] \sigma_{\mathrm{ml}} \left(1-\sigma_{\mathrm{ml}}\right)\left(1-\tfrac{1}{2}\sigma_{\mathrm{ml}}^2\right).
+\end{align}
+%
+The shape of the eddy viscosity and diffusivity profiles is the same as the shape in the unstable OSBL. The eddy diffusivity/viscosity depends on the stability parameter $h_{\mathrm{bl}}/{L_L}$ where $ L_L$ is analogous to the Obukhov length, but for Langmuir turbulence:
+\begin{equation}\label{eq:L_L}
+  L_L=-w_{*L}^3/\left<\overline{w^\prime b^\prime}\right>_L,
+\end{equation}
+with the mean turbulent buoyancy flux averaged over the boundary layer given in terms of its surface value $\overline{w^\prime b^\prime}_0$ and (downwards) )solar irradiance $I(z)$ by
+\begin{equation} \label{eq:stable-av-buoy-flux}
+\left<\overline{w^\prime b^\prime}\right>_L = \tfrac{1}{2} {\overline{w^\prime b^\prime}}_0-g\alpha_E\left[\tfrac{1}{2}(I(0)+I(-h))-\left<I\right>\right].
+\end{equation}
+%
+In unstable conditions the eddy diffusivity and viscosity depend on stability through the velocity scale $\omega_*$, which depends on the two velocity scales $\nu_*$ and $w_{*C}$.
+
+Details of the non-gradient terms in \eqref{eq:flux-grad-gen} and of the fluxes within the pycnocline $-h_{\mathrm{bl}}<z<h_{\mathrm{ml}}$ can be found in Grant (2019).
+
+\subsubsection{Evolution of the boundary layer depth}
+
+The prognostic equation for the depth of the neutral/unstable boundary layer is given by \citep{grant+etal18},
+
+\begin{equation} \label{eq:dhdt-unstable}
+%\frac{\partial h_\mathrm{bl}}{\partial t} + \mathbf{U}_b\cdot\nabla h_\mathrm{bl}= W_b - \frac{{\overline{w^\prime b^\prime}}_\mathrm{ent}}{\Delta B_\mathrm{bl}}
+\frac{\partial h_\mathrm{bl}}{\partial t} = W_b - \frac{{\overline{w^\prime b^\prime}}_\mathrm{ent}}{\Delta B_\mathrm{bl}}
+\end{equation}
+where $h_\mathrm{bl}$ is the horizontally-varying depth of the OSBL,
+$\mathbf{U}_b$ and $W_b$ are the mean horizontal and vertical
+velocities at the base of the OSBL, ${\overline{w^\prime
+    b^\prime}}_\mathrm{ent}$ is the buoyancy flux due to entrainment
+and $\Delta B_\mathrm{bl}$ is the difference between the buoyancy
+averaged over the depth of the OSBL (i.e.\ including the ML and
+pycnocline) and the buoyancy just below the base of the OSBL. This
+equation for the case when the pycnocline has a finite thickness,
+based on the potential energy budget of the OSBL, is the leading term
+\citep{grant+etal18} of a generalization of that used in mixed-layer
+models e.g.\ \citet{kraus.turner_tellus67}, in which the thickness of the pycnocline is taken to be zero.
+
+The entrainment flux for the combination of convective and Langmuir turbulence is given by
+\begin{equation} \label{eq:entrain-flux}
+  {\overline{w^\prime b^\prime}}_\mathrm{ent} = -\alpha_{\mathrm{B}} {\overline{w^\prime b^\prime}}_0 - \alpha_{\mathrm{S}} \frac{u_*^3}{h_{\mathrm{ml}}}
+  + G\left(\delta/h_{\mathrm{ml}} \right)\left[\alpha_{\mathrm{S}}e^{-1.5\, \mathrm{La}_t}-\alpha_{\mathrm{L}} \frac{w_{\mathrm{*L}}^3}{h_{\mathrm{ml}}}\right]
+\end{equation}
+where the factor $G\equiv 1 - \mathrm{e}^ {-25\delta/h_{\mathrm{bl}}}(1-4\delta/h_{\mathrm{bl}})$ models the lesser efficiency of Langmuir mixing when the boundary-layer depth is much greater than the Stokes depth, and $\alpha_{\mathrm{B}}$, $\alpha_{S}$  and $\alpha_{\mathrm{L}}$ depend on the ratio of the appropriate eddy turnover time to the inertial timescale $f^{-1}$. Results from the LES suggest $\alpha_{\mathrm{B}}=0.18 F(fh_{\mathrm{bl}}/w_{*C})$, $\alpha_{S}=0.15 F(fh_{\mathrm{bl}}/u_*$  and $\alpha_{\mathrm{L}}=0.035 F(fh_{\mathrm{bl}}/u_{*L})$, where $F(x)\equiv\tanh(x^{-1})^{0.69}$.
+
+For the stable boundary layer, the equation for the depth of the OSBL is:
+
+\begin{equation}\label{eq:dhdt-stable}
+\max\left(\Delta B_{bl},\frac{w_{*L}^2}{h_\mathrm{bl}}\right)\frac{\partial h_\mathrm{bl}}{\partial t} = \left(0.06 + 0.52\,\frac{ h_\mathrm{bl}}{L_L}\right) \frac{w_{*L}^3}{h_\mathrm{bl}} +\left<\overline{w^\prime b^\prime}\right>_L.
+\end{equation}
+
+Equation. \ref{eq:dhdt-unstable} always leads to the depth of the entraining OSBL increasing (ignoring the effect of the mean vertical motion), but the change in the thickness of the stable OSBL given by Eq. \ref{eq:dhdt-stable} can be positive or negative, depending on the magnitudes of $\left<\overline{w^\prime b^\prime}\right>_L$ and $h_\mathrm{bl}/L_L$. The rate at which the depth of the OSBL can decrease is limited by choosing an effective buoyancy $w_{*L}^2/h_\mathrm{bl}$, in place of $\Delta B_{bl}$ which will be $\approx 0$ for the collapsing OSBL.
+
+
+%% =================================================================================================
+\subsection[ Discrete energy conservation for TKE and GLS schemes]{Discrete energy conservation for TKE and GLS schemes}
+\label{subsec:ZDF_tke_ene}
+
+\begin{figure}[!t]
+  \centering
+  \includegraphics[width=0.66\textwidth]{ZDF_TKE_time_scheme}
+  \caption[Subgrid kinetic energy integration in GLS and TKE schemes]{
+    Illustration of the subgrid kinetic energy integration in GLS and TKE schemes and
+    its links to the momentum and tracer time integration.}
+  \label{fig:ZDF_TKE_time_scheme}
+\end{figure}
 
 The production of turbulence by vertical shear (the first term of the right hand side of
-\autoref{eq:zdftke_e}) and  \autoref{eq:zdfgls_e}) should balance the loss of kinetic energy associated with the vertical momentum diffusion
-(first line in \autoref{eq:PE_zdf}).
+\autoref{eq:ZDF_tke_e}) and  \autoref{eq:ZDF_gls_e}) should balance the loss of kinetic energy associated with the vertical momentum diffusion
+(first line in \autoref{eq:MB_zdf}).
 To do so a special care has to be taken for both the time and space discretization of
 the kinetic energy equation \citep{burchard_OM02,marsaleix.auclair.ea_OM08}.
 
-Let us first address the time stepping issue. \autoref{fig:TKE_time_scheme} shows how
+Let us first address the time stepping issue. \autoref{fig:ZDF_TKE_time_scheme} shows how
 the two-level Leap-Frog time stepping of the momentum and tracer equations interplays with
 the one-level forward time stepping of the equation for $\bar{e}$.
 With this framework, the total loss of kinetic energy (in 1D for the demonstration) due to
 the vertical momentum diffusion is obtained by multiplying this quantity by $u^t$ and
-summing the result vertically:   
+summing the result vertically:
 \begin{equation}
-  \label{eq:energ1}
+  \label{eq:ZDF_energ1}
   \begin{split}
     \int_{-H}^{\eta}  u^t \,\partial_z &\left( {K_m}^t \,(\partial_z u)^{t+\rdt}  \right) \,dz   \\
@@ -587,11 +785,11 @@
 \end{equation}
 Here, the vertical diffusion of momentum is discretized backward in time with a coefficient, $K_m$,
-known at time $t$ (\autoref{fig:TKE_time_scheme}), as it is required when using the TKE scheme
-(see \autoref{sec:STP_forward_imp}).
-The first term of the right hand side of \autoref{eq:energ1} represents the kinetic energy transfer at
+known at time $t$ (\autoref{fig:ZDF_TKE_time_scheme}), as it is required when using the TKE scheme
+(see \autoref{sec:TD_forward_imp}).
+The first term of the right hand side of \autoref{eq:ZDF_energ1} represents the kinetic energy transfer at
 the surface (atmospheric forcing) and at the bottom (friction effect).
 The second term is always negative.
 It is the dissipation rate of kinetic energy, and thus minus the shear production rate of $\bar{e}$.
-\autoref{eq:energ1} implies that, to be energetically consistent,
+\autoref{eq:ZDF_energ1} implies that, to be energetically consistent,
 the production rate of $\bar{e}$ used to compute $(\bar{e})^t$ (and thus ${K_m}^t$) should be expressed as
 ${K_m}^{t-\rdt}\,(\partial_z u)^{t-\rdt} \,(\partial_z u)^t$
@@ -599,10 +797,10 @@
 
 A similar consideration applies on the destruction rate of $\bar{e}$ due to stratification
-(second term of the right hand side of \autoref{eq:zdftke_e} and \autoref{eq:zdfgls_e}).
+(second term of the right hand side of \autoref{eq:ZDF_tke_e} and \autoref{eq:ZDF_gls_e}).
 This term must balance the input of potential energy resulting from vertical mixing.
 The rate of change of potential energy (in 1D for the demonstration) due to vertical mixing is obtained by
 multiplying the vertical density diffusion tendency by $g\,z$ and and summing the result vertically:
 \begin{equation}
-  \label{eq:energ2}
+  \label{eq:ZDF_energ2}
   \begin{split}
     \int_{-H}^{\eta} g\,z\,\partial_z &\left( {K_\rho}^t \,(\partial_k \rho)^{t+\rdt}   \right) \,dz    \\
@@ -613,16 +811,16 @@
   \end{split}
 \end{equation}
-where we use $N^2 = -g \,\partial_k \rho / (e_3 \rho)$. 
-The first term of the right hand side of \autoref{eq:energ2} is always zero because
+where we use $N^2 = -g \,\partial_k \rho / (e_3 \rho)$.
+The first term of the right hand side of \autoref{eq:ZDF_energ2} is always zero because
 there is no diffusive flux through the ocean surface and bottom).
 The second term is minus the destruction rate of  $\bar{e}$ due to stratification.
-Therefore \autoref{eq:energ1} implies that, to be energetically consistent,
-the product ${K_\rho}^{t-\rdt}\,(N^2)^t$ should be used in \autoref{eq:zdftke_e} and  \autoref{eq:zdfgls_e}.
+Therefore \autoref{eq:ZDF_energ1} implies that, to be energetically consistent,
+the product ${K_\rho}^{t-\rdt}\,(N^2)^t$ should be used in \autoref{eq:ZDF_tke_e} and  \autoref{eq:ZDF_gls_e}.
 
 Let us now address the space discretization issue.
 The vertical eddy coefficients are defined at $w$-point whereas the horizontal velocity components are in
-the centre of the side faces of a $t$-box in staggered C-grid (\autoref{fig:cell}).
+the centre of the side faces of a $t$-box in staggered C-grid (\autoref{fig:DOM_cell}).
 A space averaging is thus required to obtain the shear TKE production term.
-By redoing the \autoref{eq:energ1} in the 3D case, it can be shown that the product of eddy coefficient by
+By redoing the \autoref{eq:ZDF_energ1} in the 3D case, it can be shown that the product of eddy coefficient by
 the shear at $t$ and $t-\rdt$ must be performed prior to the averaging.
 Furthermore, the time variation of $e_3$ has be taken into account.
@@ -630,5 +828,5 @@
 The above energetic considerations leads to the following final discrete form for the TKE equation:
 \begin{equation}
-  \label{eq:zdftke_ene}
+  \label{eq:ZDF_tke_ene}
   \begin{split}
     \frac { (\bar{e})^t - (\bar{e})^{t-\rdt} } {\rdt}  \equiv
@@ -647,18 +845,16 @@
   \end{split}
 \end{equation}
-where the last two terms in \autoref{eq:zdftke_ene} (vertical diffusion and Kolmogorov dissipation)
-are time stepped using a backward scheme (see\autoref{sec:STP_forward_imp}).
+where the last two terms in \autoref{eq:ZDF_tke_ene} (vertical diffusion and Kolmogorov dissipation)
+are time stepped using a backward scheme (see\autoref{sec:TD_forward_imp}).
 Note that the Kolmogorov term has been linearized in time in order to render the implicit computation possible.
 %The restart of the TKE scheme requires the storage of $\bar {e}$, $K_m$, $K_\rho$ and $l_\epsilon$ as
-%they all appear in the right hand side of \autoref{eq:zdftke_ene}.
-%For the latter, it is in fact the ratio $\sqrt{\bar{e}}/l_\epsilon$ which is stored. 
-
-% ================================================================
-% Convection
-% ================================================================
+%they all appear in the right hand side of \autoref{eq:ZDF_tke_ene}.
+%For the latter, it is in fact the ratio $\sqrt{\bar{e}}/l_\epsilon$ which is stored.
+
+%% =================================================================================================
 \section{Convection}
 \label{sec:ZDF_conv}
 
-Static instabilities (\ie light potential densities under heavy ones) may occur at particular ocean grid points.
+Static instabilities (\ie\ light potential densities under heavy ones) may occur at particular ocean grid points.
 In nature, convective processes quickly re-establish the static stability of the water column.
 These processes have been removed from the model via the hydrostatic assumption so they must be parameterized.
@@ -667,40 +863,34 @@
 or/and the use of a turbulent closure scheme.
 
-% -------------------------------------------------------------------------------------------------------------
-%       Non-Penetrative Convective Adjustment 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Non-penetrative convective adjustment (\forcode{ln_tranpc = .true.})]
-{Non-penetrative convective adjustment (\protect\np{ln\_tranpc}\forcode{ = .true.})}
+%% =================================================================================================
+\subsection[Non-penetrative convective adjustment (\forcode{ln_tranpc})]{Non-penetrative convective adjustment (\protect\np{ln_tranpc}{ln\_tranpc})}
 \label{subsec:ZDF_npc}
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!htb]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_npc}
-    \caption{
-      \protect\label{fig:npc}
-      Example of an unstable density profile treated by the non penetrative convective adjustment algorithm.
-      $1^{st}$ step: the initial profile is checked from the surface to the bottom.
-      It is found to be unstable between levels 3 and 4.
-      They are mixed.
-      The resulting $\rho$ is still larger than $\rho$(5): levels 3 to 5 are mixed.
-      The resulting $\rho$ is still larger than $\rho$(6): levels 3 to 6 are mixed.
-      The $1^{st}$ step ends since the density profile is then stable below the level 3.
-      $2^{nd}$ step: the new $\rho$ profile is checked following the same procedure as in $1^{st}$ step:
-      levels 2 to 5 are mixed.
-      The new density profile is checked.
-      It is found stable: end of algorithm.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{ZDF_npc}
+  \caption[Unstable density profile treated by the non penetrative convective adjustment algorithm]{
+    Example of an unstable density profile treated by
+    the non penetrative convective adjustment algorithm.
+    $1^{st}$ step: the initial profile is checked from the surface to the bottom.
+    It is found to be unstable between levels 3 and 4.
+    They are mixed.
+    The resulting $\rho$ is still larger than $\rho$(5): levels 3 to 5 are mixed.
+    The resulting $\rho$ is still larger than $\rho$(6): levels 3 to 6 are mixed.
+    The $1^{st}$ step ends since the density profile is then stable below the level 3.
+    $2^{nd}$ step: the new $\rho$ profile is checked following the same procedure as in $1^{st}$ step:
+    levels 2 to 5 are mixed.
+    The new density profile is checked.
+    It is found stable: end of algorithm.}
+  \label{fig:ZDF_npc}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-Options are defined through the \ngn{namzdf} namelist variables.
-The non-penetrative convective adjustment is used when \np{ln\_zdfnpc}\forcode{ = .true.}.
-It is applied at each \np{nn\_npc} time step and mixes downwards instantaneously the statically unstable portion of
+
+Options are defined through the \nam{zdf}{zdf} namelist variables.
+The non-penetrative convective adjustment is used when \np[=.true.]{ln_zdfnpc}{ln\_zdfnpc}.
+It is applied at each \np{nn_npc}{nn\_npc} time step and mixes downwards instantaneously the statically unstable portion of
 the water column, but only until the density structure becomes neutrally stable
-(\ie until the mixed portion of the water column has \textit{exactly} the density of the water just below)
+(\ie\ until the mixed portion of the water column has \textit{exactly} the density of the water just below)
 \citep{madec.delecluse.ea_JPO91}.
-The associated algorithm is an iterative process used in the following way (\autoref{fig:npc}):
+The associated algorithm is an iterative process used in the following way (\autoref{fig:ZDF_npc}):
 starting from the top of the ocean, the first instability is found.
 Assume in the following that the instability is located between levels $k$ and $k+1$.
@@ -717,5 +907,5 @@
 This algorithm is significantly different from mixing statically unstable levels two by two.
 The latter procedure cannot converge with a finite number of iterations for some vertical profiles while
-the algorithm used in \NEMO converges for any profile in a number of iterations which is less than
+the algorithm used in \NEMO\ converges for any profile in a number of iterations which is less than
 the number of vertical levels.
 This property is of paramount importance as pointed out by \citet{killworth_iprc89}:
@@ -727,6 +917,6 @@
 (L. Brodeau, personnal communication).
 Two main differences have been introduced compared to the original algorithm:
-$(i)$ the stability is now checked using the Brunt-V\"{a}is\"{a}l\"{a} frequency 
-(not the difference in potential density); 
+$(i)$ the stability is now checked using the Brunt-V\"{a}is\"{a}l\"{a} frequency
+(not the difference in potential density);
 $(ii)$ when two levels are found unstable, their thermal and haline expansion coefficients are vertically mixed in
 the same way their temperature and salinity has been mixed.
@@ -734,22 +924,19 @@
 having to recompute the expansion coefficients at each mixing iteration.
 
-% -------------------------------------------------------------------------------------------------------------
-%       Enhanced Vertical Diffusion 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Enhanced vertical diffusion (\forcode{ln_zdfevd = .true.})]
-{Enhanced vertical diffusion (\protect\np{ln\_zdfevd}\forcode{ = .true.})}
+%% =================================================================================================
+\subsection[Enhanced vertical diffusion (\forcode{ln_zdfevd})]{Enhanced vertical diffusion (\protect\np{ln_zdfevd}{ln\_zdfevd})}
 \label{subsec:ZDF_evd}
 
-Options are defined through the  \ngn{namzdf} namelist variables.
-The enhanced vertical diffusion parameterisation is used when \np{ln\_zdfevd}\forcode{ = .true.}.
-In this case, the vertical eddy mixing coefficients are assigned very large values 
+Options are defined through the  \nam{zdf}{zdf} namelist variables.
+The enhanced vertical diffusion parameterisation is used when \np[=.true.]{ln_zdfevd}{ln\_zdfevd}.
+In this case, the vertical eddy mixing coefficients are assigned very large values
 in regions where the stratification is unstable
-(\ie when $N^2$ the Brunt-Vais\"{a}l\"{a} frequency is negative) \citep{lazar_phd97, lazar.madec.ea_JPO99}.
-This is done either on tracers only (\np{nn\_evdm}\forcode{ = 0}) or
-on both momentum and tracers (\np{nn\_evdm}\forcode{ = 1}).
-
-In practice, where $N^2\leq 10^{-12}$, $A_T^{vT}$ and $A_T^{vS}$, and if \np{nn\_evdm}\forcode{ = 1},
+(\ie\ when $N^2$ the Brunt-Vais\"{a}l\"{a} frequency is negative) \citep{lazar_phd97, lazar.madec.ea_JPO99}.
+This is done either on tracers only (\np[=0]{nn_evdm}{nn\_evdm}) or
+on both momentum and tracers (\np[=1]{nn_evdm}{nn\_evdm}).
+
+In practice, where $N^2\leq 10^{-12}$, $A_T^{vT}$ and $A_T^{vS}$, and if \np[=1]{nn_evdm}{nn\_evdm},
 the four neighbouring $A_u^{vm} \;\mbox{and}\;A_v^{vm}$ values also, are set equal to
-the namelist parameter \np{rn\_avevd}.
+the namelist parameter \np{rn_avevd}{rn\_avevd}.
 A typical value for $rn\_avevd$ is between 1 and $100~m^2.s^{-1}$.
 This parameterisation of convective processes is less time consuming than
@@ -759,20 +946,16 @@
 Note that the stability test is performed on both \textit{before} and \textit{now} values of $N^2$.
 This removes a potential source of divergence of odd and even time step in
-a leapfrog environment \citep{leclair_phd10} (see \autoref{sec:STP_mLF}).
-
-% -------------------------------------------------------------------------------------------------------------
-%       Turbulent Closure Scheme 
-% -------------------------------------------------------------------------------------------------------------
-\subsection[Handling convection with turbulent closure schemes (\forcode{ln_zdf/tke/gls/osm = .true.})]
-{Handling convection with turbulent closure schemes (\protect\np{ln\_zdf/tke/gls/osm}\forcode{ = .true.})}
+a leapfrog environment \citep{leclair_phd10} (see \autoref{sec:TD_mLF}).
+
+%% =================================================================================================
+\subsection[Handling convection with turbulent closure schemes (\forcode{ln_zdf_}\{\forcode{tke,gls,osm}\})]{Handling convection with turbulent closure schemes (\forcode{ln_zdf{tke,gls,osm}})}
 \label{subsec:ZDF_tcs}
 
-
 The turbulent closure schemes presented in \autoref{subsec:ZDF_tke}, \autoref{subsec:ZDF_gls} and
-\autoref{subsec:ZDF_osm} (\ie \np{ln\_zdftke} or \np{ln\_zdfgls} or \np{ln\_zdfosm} defined) deal, in theory, 
+\autoref{subsec:ZDF_osm} (\ie\ \np{ln_zdftke}{ln\_zdftke} or \np{ln_zdfgls}{ln\_zdfgls} or \np{ln_zdfosm}{ln\_zdfosm} defined) deal, in theory,
 with statically unstable density profiles.
 In such a case, the term corresponding to the destruction of turbulent kinetic energy through stratification in
-\autoref{eq:zdftke_e} or \autoref{eq:zdfgls_e} becomes a source term, since $N^2$ is negative. 
-It results in large values of $A_T^{vT}$ and  $A_T^{vT}$, and also of the four neighboring values at 
+\autoref{eq:ZDF_tke_e} or \autoref{eq:ZDF_gls_e} becomes a source term, since $N^2$ is negative.
+It results in large values of $A_T^{vT}$ and  $A_T^{vT}$, and also of the four neighboring values at
 velocity points $A_u^{vm} {and}\;A_v^{vm}$ (up to $1\;m^2s^{-1}$).
 These large values restore the static stability of the water column in a way similar to that of
@@ -782,38 +965,30 @@
 because the mixing length scale is bounded by the distance to the sea surface.
 It can thus be useful to combine the enhanced vertical diffusion with the turbulent closure scheme,
-\ie setting the \np{ln\_zdfnpc} namelist parameter to true and
-defining the turbulent closure (\np{ln\_zdftke} or \np{ln\_zdfgls} = \forcode{.true.}) all together.
+\ie\ setting the \np{ln_zdfnpc}{ln\_zdfnpc} namelist parameter to true and
+defining the turbulent closure (\np{ln_zdftke}{ln\_zdftke} or \np{ln_zdfgls}{ln\_zdfgls} = \forcode{.true.}) all together.
 
 The OSMOSIS turbulent closure scheme already includes enhanced vertical diffusion in the case of convection,
 %as governed by the variables $bvsqcon$ and $difcon$ found in \mdl{zdfkpp},
-therefore \np{ln\_zdfevd}\forcode{ = .false.} should be used with the OSMOSIS scheme.
+therefore \np[=.false.]{ln_zdfevd}{ln\_zdfevd} should be used with the OSMOSIS scheme.
 % gm%  + one word on non local flux with KPP scheme trakpp.F90 module...
 
-% ================================================================
-% Double Diffusion Mixing
-% ================================================================
-\section[Double diffusion mixing (\forcode{ln_zdfddm = .true.})]
-{Double diffusion mixing (\protect\np{ln\_zdfddm}\forcode{ = .true.})}
+%% =================================================================================================
+\section[Double diffusion mixing (\forcode{ln_zdfddm})]{Double diffusion mixing (\protect\np{ln_zdfddm}{ln\_zdfddm})}
 \label{subsec:ZDF_ddm}
 
-
-%-------------------------------------------namzdf_ddm-------------------------------------------------
-%
 %\nlst{namzdf_ddm}
-%--------------------------------------------------------------------------------------------------------------
 
 This parameterisation has been introduced in \mdl{zdfddm} module and is controlled by the namelist parameter
-\np{ln\_zdfddm} in \ngn{namzdf}.
+\np{ln_zdfddm}{ln\_zdfddm} in \nam{zdf}{zdf}.
 Double diffusion occurs when relatively warm, salty water overlies cooler, fresher water, or vice versa.
 The former condition leads to salt fingering and the latter to diffusive convection.
 Double-diffusive phenomena contribute to diapycnal mixing in extensive regions of the ocean.
-\citet{merryfield.holloway.ea_JPO99} include a parameterisation of such phenomena in a global ocean model and show that 
+\citet{merryfield.holloway.ea_JPO99} include a parameterisation of such phenomena in a global ocean model and show that
 it leads to relatively minor changes in circulation but exerts significant regional influences on
 temperature and salinity.
 
-
-Diapycnal mixing of S and T are described by diapycnal diffusion coefficients 
+Diapycnal mixing of S and T are described by diapycnal diffusion coefficients
 \begin{align*}
-  % \label{eq:zdfddm_Kz}
+  % \label{eq:ZDF_ddm_Kz}
   &A^{vT} = A_o^{vT}+A_f^{vT}+A_d^{vT}	\\
   &A^{vS} = A_o^{vS}+A_f^{vS}+A_d^{vS}
@@ -827,5 +1002,5 @@
 (1981):
 \begin{align}
-  \label{eq:zdfddm_f}
+  \label{eq:ZDF_ddm_f}
   A_f^{vS} &=
              \begin{cases}
@@ -833,34 +1008,33 @@
                0 				  					    &\text{otherwise}
              \end{cases}
-  \\ 		    \label{eq:zdfddm_f_T}
-  A_f^{vT} &= 0.7 \ A_f^{vS} / R_\rho 
+  \\ 		    \label{eq:ZDF_ddm_f_T}
+  A_f^{vT} &= 0.7 \ A_f^{vS} / R_\rho
 \end{align}
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_zdfddm}
-    \caption{
-      \protect\label{fig:zdfddm}
-      From \citet{merryfield.holloway.ea_JPO99} :
-      (a) Diapycnal diffusivities $A_f^{vT}$ and $A_f^{vS}$ for temperature and salt in regions of salt fingering.
-      Heavy curves denote $A^{\ast v} = 10^{-3}~m^2.s^{-1}$ and thin curves $A^{\ast v} = 10^{-4}~m^2.s^{-1}$;
-      (b) diapycnal diffusivities $A_d^{vT}$ and $A_d^{vS}$ for temperature and salt in regions of
-      diffusive convection.
-      Heavy curves denote the Federov parameterisation and thin curves the Kelley parameterisation.
-      The latter is not implemented in \NEMO.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{ZDF_ddm}
+  \caption[Diapycnal diffusivities for temperature and salt in regions of salt fingering and
+  diffusive convection]{
+    From \citet{merryfield.holloway.ea_JPO99}:
+    (a) Diapycnal diffusivities $A_f^{vT}$ and $A_f^{vS}$ for temperature and salt in
+    regions of salt fingering.
+    Heavy curves denote $A^{\ast v} = 10^{-3}~m^2.s^{-1}$ and
+    thin curves $A^{\ast v} = 10^{-4}~m^2.s^{-1}$;
+    (b) diapycnal diffusivities $A_d^{vT}$ and $A_d^{vS}$ for temperature and salt in
+    regions of diffusive convection.
+    Heavy curves denote the Federov parameterisation and thin curves the Kelley parameterisation.
+    The latter is not implemented in \NEMO.}
+  \label{fig:ZDF_ddm}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-The factor 0.7 in \autoref{eq:zdfddm_f_T} reflects the measured ratio $\alpha F_T /\beta F_S \approx  0.7$ of
+
+The factor 0.7 in \autoref{eq:ZDF_ddm_f_T} reflects the measured ratio $\alpha F_T /\beta F_S \approx  0.7$ of
 buoyancy flux of heat to buoyancy flux of salt (\eg, \citet{mcdougall.taylor_JMR84}).
 Following  \citet{merryfield.holloway.ea_JPO99}, we adopt $R_c = 1.6$, $n = 6$, and $A^{\ast v} = 10^{-4}~m^2.s^{-1}$.
 
 To represent mixing of S and T by diffusive layering,  the diapycnal diffusivities suggested by
-Federov (1988) is used: 
+Federov (1988) is used:
 \begin{align}
-  % \label{eq:zdfddm_d}
+  % \label{eq:ZDF_ddm_d}
   A_d^{vT} &=
              \begin{cases}
@@ -870,5 +1044,5 @@
              \end{cases}
                                        \nonumber \\
-  \label{eq:zdfddm_d_S}
+  \label{eq:ZDF_ddm_d_S}
   A_d^{vS} &=
              \begin{cases}
@@ -879,31 +1053,35 @@
 \end{align}
 
-The dependencies of \autoref{eq:zdfddm_f} to \autoref{eq:zdfddm_d_S} on $R_\rho$ are illustrated in
-\autoref{fig:zdfddm}.
+The dependencies of \autoref{eq:ZDF_ddm_f} to \autoref{eq:ZDF_ddm_d_S} on $R_\rho$ are illustrated in
+\autoref{fig:ZDF_ddm}.
 Implementing this requires computing $R_\rho$ at each grid point on every time step.
 This is done in \mdl{eosbn2} at the same time as $N^2$ is computed.
 This avoids duplication in the computation of $\alpha$ and $\beta$ (which is usually quite expensive).
 
-% ================================================================
-% Bottom Friction
-% ================================================================
- \section[Bottom and top friction (\textit{zdfdrg.F90})]
- {Bottom and top friction (\protect\mdl{zdfdrg})}
- \label{sec:ZDF_drg}
-
-%--------------------------------------------nambfr--------------------------------------------------------
-%
-\nlst{namdrg}
-\nlst{namdrg_top}
-\nlst{namdrg_bot}
-
-%--------------------------------------------------------------------------------------------------------------
-
-Options to define the top and bottom friction are defined through the \ngn{namdrg} namelist variables.
+%% =================================================================================================
+\section[Bottom and top friction (\textit{zdfdrg.F90})]{Bottom and top friction (\protect\mdl{zdfdrg})}
+\label{sec:ZDF_drg}
+
+\begin{listing}
+  \nlst{namdrg}
+  \caption{\forcode{&namdrg}}
+  \label{lst:namdrg}
+\end{listing}
+\begin{listing}
+  \nlst{namdrg_top}
+  \caption{\forcode{&namdrg_top}}
+  \label{lst:namdrg_top}
+\end{listing}
+\begin{listing}
+  \nlst{namdrg_bot}
+  \caption{\forcode{&namdrg_bot}}
+  \label{lst:namdrg_bot}
+\end{listing}
+
+Options to define the top and bottom friction are defined through the \nam{drg}{drg} namelist variables.
 The bottom friction represents the friction generated by the bathymetry.
 The top friction represents the friction generated by the ice shelf/ocean interface.
-As the friction processes at the top and the bottom are treated in and identical way, 
+As the friction processes at the top and the bottom are treated in and identical way,
 the description below considers mostly the bottom friction case, if not stated otherwise.
-
 
 Both the surface momentum flux (wind stress) and the bottom momentum flux (bottom friction) enter the equations as
@@ -911,5 +1089,5 @@
 For the bottom boundary layer, one has:
  \[
-   % \label{eq:zdfbfr_flux}
+   % \label{eq:ZDF_bfr_flux}
    A^{vm} \left( \partial {\textbf U}_h / \partial z \right) = {{\cal F}}_h^{\textbf U}
  \]
@@ -921,5 +1099,5 @@
 one needs a vertical diffusion coefficient $A^{vm} = 0.125$~m$^2$s$^{-1}$
 (for a Coriolis frequency $f = 10^{-4}$~m$^2$s$^{-1}$).
-With a background diffusion coefficient $A^{vm} = 10^{-4}$~m$^2$s$^{-1}$, the Ekman layer depth is only 1.4~m. 
+With a background diffusion coefficient $A^{vm} = 10^{-4}$~m$^2$s$^{-1}$, the Ekman layer depth is only 1.4~m.
 When the vertical mixing coefficient is this small, using a flux condition is equivalent to
 entering the viscous forces (either wind stress or bottom friction) as a body force over the depth of the top or
@@ -927,5 +1105,5 @@
 To illustrate this, consider the equation for $u$ at $k$, the last ocean level:
 \begin{equation}
-  \label{eq:zdfdrg_flux2}
+  \label{eq:ZDF_drg_flux2}
   \frac{\partial u_k}{\partial t} = \frac{1}{e_{3u}} \left[ \frac{A_{uw}^{vm}}{e_{3uw}} \delta_{k+1/2}\;[u] - {\cal F}^u_h \right] \approx - \frac{{\cal F}^u_{h}}{e_{3u}}
 \end{equation}
@@ -947,26 +1125,23 @@
  These coefficients are computed in \mdl{zdfdrg} and generally take the form $c_b^{\textbf U}$ where:
 \begin{equation}
-  \label{eq:zdfbfr_bdef}
+  \label{eq:ZDF_bfr_bdef}
   \frac{\partial {\textbf U_h}}{\partial t} =
   - \frac{{\cal F}^{\textbf U}_{h}}{e_{3u}} = \frac{c_b^{\textbf U}}{e_{3u}} \;{\textbf U}_h^b
 \end{equation}
-where $\textbf{U}_h^b = (u_b\;,\;v_b)$ is the near-bottom, horizontal, ocean velocity. 
-Note than from \NEMO 4.0, drag coefficients are only computed at cell centers (\ie at T-points) and refer to as $c_b^T$ in the following. These are then linearly interpolated in space to get $c_b^\textbf{U}$ at velocity points.
-
-% -------------------------------------------------------------------------------------------------------------
-%       Linear Bottom Friction
-% -------------------------------------------------------------------------------------------------------------
- \subsection[Linear top/bottom friction (\forcode{ln_lin = .true.})]
- {Linear top/bottom friction (\protect\np{ln\_lin}\forcode{ = .true.)}}
- \label{subsec:ZDF_drg_linear}
+where $\textbf{U}_h^b = (u_b\;,\;v_b)$ is the near-bottom, horizontal, ocean velocity.
+Note than from \NEMO\ 4.0, drag coefficients are only computed at cell centers (\ie\ at T-points) and refer to as $c_b^T$ in the following. These are then linearly interpolated in space to get $c_b^\textbf{U}$ at velocity points.
+
+%% =================================================================================================
+\subsection[Linear top/bottom friction (\forcode{ln_lin})]{Linear top/bottom friction (\protect\np{ln_lin}{ln\_lin})}
+\label{subsec:ZDF_drg_linear}
 
 The linear friction parameterisation (including the special case of a free-slip condition) assumes that
-the friction is proportional to the interior velocity (\ie the velocity of the first/last model level):
-\[
-  % \label{eq:zdfbfr_linear}
+the friction is proportional to the interior velocity (\ie\ the velocity of the first/last model level):
+\[
+  % \label{eq:ZDF_bfr_linear}
   {\cal F}_h^\textbf{U} = \frac{A^{vm}}{e_3} \; \frac{\partial \textbf{U}_h}{\partial k} = r \; \textbf{U}_h^b
 \]
 where $r$ is a friction coefficient expressed in $m s^{-1}$.
-This coefficient is generally estimated by setting a typical decay time $\tau$ in the deep ocean, 
+This coefficient is generally estimated by setting a typical decay time $\tau$ in the deep ocean,
 and setting $r = H / \tau$, where $H$ is the ocean depth.
 Commonly accepted values of $\tau$ are of the order of 100 to 200 days \citep{weatherly_JMR84}.
@@ -977,31 +1152,28 @@
 and assuming an ocean depth $H = 4000$~m, the resulting friction coefficient is $r = 4\;10^{-4}$~m\;s$^{-1}$.
 This is the default value used in \NEMO. It corresponds to a decay time scale of 115~days.
-It can be changed by specifying \np{rn\_Uc0} (namelist parameter).
-
- For the linear friction case the drag coefficient used in the general expression \autoref{eq:zdfbfr_bdef} is: 
-\[
-  % \label{eq:zdfbfr_linbfr_b}
+It can be changed by specifying \np{rn_Uc0}{rn\_Uc0} (namelist parameter).
+
+ For the linear friction case the drag coefficient used in the general expression \autoref{eq:ZDF_bfr_bdef} is:
+\[
+  % \label{eq:ZDF_bfr_linbfr_b}
     c_b^T = - r
 \]
-When \np{ln\_lin} \forcode{= .true.}, the value of $r$ used is \np{rn\_Uc0}*\np{rn\_Cd0}.
-Setting \np{ln\_OFF} \forcode{= .true.} (and \forcode{ln_lin = .true.}) is equivalent to setting $r=0$ and leads to a free-slip boundary condition.
+When \np[=.true.]{ln_lin}{ln\_lin}, the value of $r$ used is \np{rn_Uc0}{rn\_Uc0}*\np{rn_Cd0}{rn\_Cd0}.
+Setting \np[=.true.]{ln_OFF}{ln\_OFF} (and \forcode{ln_lin=.true.}) is equivalent to setting $r=0$ and leads to a free-slip boundary condition.
 
 These values are assigned in \mdl{zdfdrg}.
 Note that there is support for local enhancement of these values via an externally defined 2D mask array
-(\np{ln\_boost}\forcode{ = .true.}) given in the \ifile{bfr\_coef} input NetCDF file.
+(\np[=.true.]{ln_boost}{ln\_boost}) given in the \ifile{bfr\_coef} input NetCDF file.
 The mask values should vary from 0 to 1.
 Locations with a non-zero mask value will have the friction coefficient increased by
-$mask\_value$ * \np{rn\_boost} * \np{rn\_Cd0}.
-
-% -------------------------------------------------------------------------------------------------------------
-%       Non-Linear Bottom Friction
-% -------------------------------------------------------------------------------------------------------------
- \subsection[Non-linear top/bottom friction (\forcode{ln_no_lin = .true.})]
- {Non-linear top/bottom friction (\protect\np{ln\_no\_lin}\forcode{ = .true.})}
- \label{subsec:ZDF_drg_nonlinear}
-
-The non-linear bottom friction parameterisation assumes that the top/bottom friction is quadratic: 
-\[
-  % \label{eq:zdfdrg_nonlinear}
+$mask\_value$ * \np{rn_boost}{rn\_boost} * \np{rn_Cd0}{rn\_Cd0}.
+
+%% =================================================================================================
+\subsection[Non-linear top/bottom friction (\forcode{ln_non_lin})]{Non-linear top/bottom friction (\protect\np{ln_non_lin}{ln\_non\_lin})}
+\label{subsec:ZDF_drg_nonlinear}
+
+The non-linear bottom friction parameterisation assumes that the top/bottom friction is quadratic:
+\[
+  % \label{eq:ZDF_drg_nonlinear}
   {\cal F}_h^\textbf{U} = \frac{A^{vm}}{e_3 }\frac{\partial \textbf {U}_h
   }{\partial k}=C_D \;\sqrt {u_b ^2+v_b ^2+e_b } \;\; \textbf {U}_h^b
@@ -1013,5 +1185,5 @@
 $e_b = 2.5\;10^{-3}$m$^2$\;s$^{-2}$, while the FRAM experiment \citep{killworth_JPO92} uses $C_D = 1.4\;10^{-3}$ and
 $e_b =2.5\;\;10^{-3}$m$^2$\;s$^{-2}$.
-The CME choices have been set as default values (\np{rn\_Cd0} and \np{rn\_ke0} namelist parameters).
+The CME choices have been set as default values (\np{rn_Cd0}{rn\_Cd0} and \np{rn_ke0}{rn\_ke0} namelist parameters).
 
 As for the linear case, the friction is imposed in the code by adding the trend due to
@@ -1019,34 +1191,31 @@
 For the non-linear friction case the term computed in \mdl{zdfdrg} is:
 \[
-  % \label{eq:zdfdrg_nonlinbfr}
+  % \label{eq:ZDF_drg_nonlinbfr}
     c_b^T = - \; C_D\;\left[ \left(\bar{u_b}^{i}\right)^2 + \left(\bar{v_b}^{j}\right)^2 + e_b \right]^{1/2}
 \]
 
 The coefficients that control the strength of the non-linear friction are initialised as namelist parameters:
-$C_D$= \np{rn\_Cd0}, and $e_b$ =\np{rn\_bfeb2}.
-Note that for applications which consider tides explicitly, a low or even zero value of \np{rn\_bfeb2} is recommended. A local enhancement of $C_D$ is again possible via an externally defined 2D mask array
-(\np{ln\_boost}\forcode{ = .true.}).
+$C_D$= \np{rn_Cd0}{rn\_Cd0}, and $e_b$ =\np{rn_bfeb2}{rn\_bfeb2}.
+Note that for applications which consider tides explicitly, a low or even zero value of \np{rn_bfeb2}{rn\_bfeb2} is recommended. A local enhancement of $C_D$ is again possible via an externally defined 2D mask array
+(\np[=.true.]{ln_boost}{ln\_boost}).
 This works in the same way as for the linear friction case with non-zero masked locations increased by
-$mask\_value$ * \np{rn\_boost} * \np{rn\_Cd0}.
-
-% -------------------------------------------------------------------------------------------------------------
-%       Bottom Friction Log-layer
-% -------------------------------------------------------------------------------------------------------------
- \subsection[Log-layer top/bottom friction (\forcode{ln_loglayer = .true.})]
- {Log-layer top/bottom friction (\protect\np{ln\_loglayer}\forcode{ = .true.})}
- \label{subsec:ZDF_drg_loglayer}
+$mask\_value$ * \np{rn_boost}{rn\_boost} * \np{rn_Cd0}{rn\_Cd0}.
+
+%% =================================================================================================
+\subsection[Log-layer top/bottom friction (\forcode{ln_loglayer})]{Log-layer top/bottom friction (\protect\np{ln_loglayer}{ln\_loglayer})}
+\label{subsec:ZDF_drg_loglayer}
 
 In the non-linear friction case, the drag coefficient, $C_D$, can be optionally enhanced using
 a "law of the wall" scaling. This assumes that the model vertical resolution can capture the logarithmic layer which typically occur for layers thinner than 1 m or so.
-If  \np{ln\_loglayer} \forcode{= .true.}, $C_D$ is no longer constant but is related to the distance to the wall (or equivalently to the half of the top/bottom layer thickness):
+If  \np[=.true.]{ln_loglayer}{ln\_loglayer}, $C_D$ is no longer constant but is related to the distance to the wall (or equivalently to the half of the top/bottom layer thickness):
 \[
   C_D = \left ( {\kappa \over {\mathrm log}\left ( 0.5 \; e_{3b} / rn\_{z0} \right ) } \right )^2
 \]
 
-\noindent where $\kappa$ is the von-Karman constant and \np{rn\_z0} is a roughness length provided via the namelist.
+\noindent where $\kappa$ is the von-Karman constant and \np{rn_z0}{rn\_z0} is a roughness length provided via the namelist.
 
 The drag coefficient is bounded such that it is kept greater or equal to
-the base \np{rn\_Cd0} value which occurs where layer thicknesses become large and presumably logarithmic layers are not resolved at all. For stability reason, it is also not allowed to exceed the value of an additional namelist parameter:
-\np{rn\_Cdmax}, \ie
+the base \np{rn_Cd0}{rn\_Cd0} value which occurs where layer thicknesses become large and presumably logarithmic layers are not resolved at all. For stability reason, it is also not allowed to exceed the value of an additional namelist parameter:
+\np{rn_Cdmax}{rn\_Cdmax}, \ie
 \[
   rn\_Cd0 \leq C_D \leq rn\_Cdmax
@@ -1054,14 +1223,12 @@
 
 \noindent The log-layer enhancement can also be applied to the top boundary friction if
-under ice-shelf cavities are activated (\np{ln\_isfcav}\forcode{ = .true.}).
-%In this case, the relevant namelist parameters are \np{rn\_tfrz0}, \np{rn\_tfri2} and \np{rn\_tfri2\_max}.
-
-% -------------------------------------------------------------------------------------------------------------
-%       Explicit bottom Friction
-% -------------------------------------------------------------------------------------------------------------
- \subsection{Explicit top/bottom friction (\forcode{ln_drgimp = .false.})}
- \label{subsec:ZDF_drg_stability}
-
-Setting \np{ln\_drgimp} \forcode{= .false.} means that bottom friction is treated explicitly in time, which has the advantage of simplifying the interaction with the split-explicit free surface (see \autoref{subsec:ZDF_drg_ts}). The latter does indeed require the knowledge of bottom stresses in the course of the barotropic sub-iteration, which becomes less straightforward in the implicit case. In the explicit case, top/bottom stresses can be computed using \textit{before} velocities and inserted in the overall momentum tendency budget. This reads:
+under ice-shelf cavities are activated (\np[=.true.]{ln_isfcav}{ln\_isfcav}).
+%In this case, the relevant namelist parameters are \np{rn_tfrz0}{rn\_tfrz0}, \np{rn_tfri2}{rn\_tfri2} and \np{rn_tfri2_max}{rn\_tfri2\_max}.
+
+%% =================================================================================================
+\subsection[Explicit top/bottom friction (\forcode{ln_drgimp=.false.})]{Explicit top/bottom friction (\protect\np[=.false.]{ln_drgimp}{ln\_drgimp})}
+\label{subsec:ZDF_drg_stability}
+
+Setting \np[=.false.]{ln_drgimp}{ln\_drgimp} means that bottom friction is treated explicitly in time, which has the advantage of simplifying the interaction with the split-explicit free surface (see \autoref{subsec:ZDF_drg_ts}). The latter does indeed require the knowledge of bottom stresses in the course of the barotropic sub-iteration, which becomes less straightforward in the implicit case. In the explicit case, top/bottom stresses can be computed using \textit{before} velocities and inserted in the overall momentum tendency budget. This reads:
 
 At the top (below an ice shelf cavity):
@@ -1078,7 +1245,7 @@
 
 Since this is conditionally stable, some care needs to exercised over the choice of parameters to ensure that the implementation of explicit top/bottom friction does not induce numerical instability.
-For the purposes of stability analysis, an approximation to \autoref{eq:zdfdrg_flux2} is:
+For the purposes of stability analysis, an approximation to \autoref{eq:ZDF_drg_flux2} is:
 \begin{equation}
-  \label{eq:Eqn_drgstab}
+  \label{eq:ZDF_Eqn_drgstab}
   \begin{split}
     \Delta u &= -\frac{{{\cal F}_h}^u}{e_{3u}}\;2 \rdt    \\
@@ -1089,7 +1256,7 @@
 To ensure that the friction cannot reverse the direction of flow it is necessary to have:
 \[
-  |\Delta u| < \;|u| 
-\]
-\noindent which, using \autoref{eq:Eqn_drgstab}, gives:
+  |\Delta u| < \;|u|
+\]
+\noindent which, using \autoref{eq:ZDF_Eqn_drgstab}, gives:
 \[
   r\frac{2\rdt}{e_{3u}} < 1 \qquad  \Rightarrow \qquad r < \frac{e_{3u}}{2\rdt}\\
@@ -1104,5 +1271,5 @@
 For example, if $|u| = 1$ m.s$^{-1}$, $rdt = 1800$ s, $r = 10^{-3}$ then $e_{3u}$ should be greater than 3.6 m.
 For most applications, with physically sensible parameters these restrictions should not be of concern.
-But caution may be necessary if attempts are made to locally enhance the bottom friction parameters. 
+But caution may be necessary if attempts are made to locally enhance the bottom friction parameters.
 To ensure stability limits are imposed on the top/bottom friction coefficients both
 during initialisation and at each time step.
@@ -1118,21 +1285,18 @@
 The number of potential breaches of the explicit stability criterion are still reported for information purposes.
 
-% -------------------------------------------------------------------------------------------------------------
-%       Implicit Bottom Friction
-% -------------------------------------------------------------------------------------------------------------
- \subsection[Implicit top/bottom friction (\forcode{ln_drgimp = .true.})]
- {Implicit top/bottom friction (\protect\np{ln\_drgimp}\forcode{ = .true.})}
- \label{subsec:ZDF_drg_imp}
+%% =================================================================================================
+\subsection[Implicit top/bottom friction (\forcode{ln_drgimp=.true.})]{Implicit top/bottom friction (\protect\np[=.true.]{ln_drgimp}{ln\_drgimp})}
+\label{subsec:ZDF_drg_imp}
 
 An optional implicit form of bottom friction has been implemented to improve model stability.
 We recommend this option for shelf sea and coastal ocean applications. %, especially for split-explicit time splitting.
-This option can be invoked by setting \np{ln\_drgimp} to \forcode{.true.} in the \textit{namdrg} namelist.
-%This option requires \np{ln\_zdfexp} to be \forcode{.false.} in the \textit{namzdf} namelist. 
-
-This implementation is performed in \mdl{dynzdf} where the following boundary conditions are set while solving the fully implicit diffusion step: 
+This option can be invoked by setting \np{ln_drgimp}{ln\_drgimp} to \forcode{.true.} in the \nam{drg}{drg} namelist.
+%This option requires \np{ln_zdfexp}{ln\_zdfexp} to be \forcode{.false.} in the \nam{zdf}{zdf} namelist.
+
+This implementation is performed in \mdl{dynzdf} where the following boundary conditions are set while solving the fully implicit diffusion step:
 
 At the top (below an ice shelf cavity):
 \[
-  % \label{eq:dynzdf_drg_top}
+  % \label{eq:ZDF_dynZDF__drg_top}
   \left.{\left( {\frac{A^{vm} }{e_3 }\ \frac{\partial \textbf{U}_h}{\partial k}} \right)} \right|_{t}
   = c_{t}^{\textbf{U}}\textbf{u}^{n+1}_{t}
@@ -1141,53 +1305,47 @@
 At the bottom (above the sea floor):
 \[
-  % \label{eq:dynzdf_drg_bot}
+  % \label{eq:ZDF_dynZDF__drg_bot}
   \left.{\left( {\frac{A^{vm} }{e_3 }\ \frac{\partial \textbf{U}_h}{\partial k}} \right)} \right|_{b}
   = c_{b}^{\textbf{U}}\textbf{u}^{n+1}_{b}
 \]
 
-where $t$ and $b$ refers to top and bottom layers respectively. 
+where $t$ and $b$ refers to top and bottom layers respectively.
 Superscript $n+1$ means the velocity used in the friction formula is to be calculated, so it is implicit.
 
-% -------------------------------------------------------------------------------------------------------------
-%       Bottom Friction with split-explicit free surface
-% -------------------------------------------------------------------------------------------------------------
- \subsection[Bottom friction with split-explicit free surface]
- {Bottom friction with split-explicit free surface}
- \label{subsec:ZDF_drg_ts}
-
-With split-explicit free surface, the sub-stepping of barotropic equations needs the knowledge of top/bottom stresses. An obvious way to satisfy this is to take them as constant over the course of the barotropic integration and equal to the value used to update the baroclinic momentum trend. Provided \np{ln\_drgimp}\forcode{= .false.} and a centred or \textit{leap-frog} like integration of barotropic equations is used (\ie \forcode{ln_bt_fw = .false.}, cf \autoref{subsec:DYN_spg_ts}), this does ensure that barotropic and baroclinic dynamics feel the same stresses during one leapfrog time step. However, if \np{ln\_drgimp}\forcode{= .true.},  stresses depend on the \textit{after} value of the velocities which themselves depend on the barotropic iteration result. This cyclic dependency makes difficult obtaining consistent stresses in 2d and 3d dynamics. Part of this mismatch is then removed when setting the final barotropic component of 3d velocities to the time splitting estimate. This last step can be seen as a necessary evil but should be minimized since it interferes with the adjustment to the boundary conditions. 
-
-The strategy to handle top/bottom stresses with split-explicit free surface in \NEMO is as follows:
+%% =================================================================================================
+\subsection[Bottom friction with split-explicit free surface]{Bottom friction with split-explicit free surface}
+\label{subsec:ZDF_drg_ts}
+
+With split-explicit free surface, the sub-stepping of barotropic equations needs the knowledge of top/bottom stresses. An obvious way to satisfy this is to take them as constant over the course of the barotropic integration and equal to the value used to update the baroclinic momentum trend. Provided \np[=.false.]{ln_drgimp}{ln\_drgimp} and a centred or \textit{leap-frog} like integration of barotropic equations is used (\ie\ \forcode{ln_bt_fw=.false.}, cf \autoref{subsec:DYN_spg_ts}), this does ensure that barotropic and baroclinic dynamics feel the same stresses during one leapfrog time step. However, if \np[=.true.]{ln_drgimp}{ln\_drgimp},  stresses depend on the \textit{after} value of the velocities which themselves depend on the barotropic iteration result. This cyclic dependency makes difficult obtaining consistent stresses in 2d and 3d dynamics. Part of this mismatch is then removed when setting the final barotropic component of 3d velocities to the time splitting estimate. This last step can be seen as a necessary evil but should be minimized since it interferes with the adjustment to the boundary conditions.
+
+The strategy to handle top/bottom stresses with split-explicit free surface in \NEMO\ is as follows:
 \begin{enumerate}
 \item To extend the stability of the barotropic sub-stepping, bottom stresses are refreshed at each sub-iteration. The baroclinic part of the flow entering the stresses is frozen at the initial time of the barotropic iteration. In case of non-linear friction, the drag coefficient is also constant.
 \item In case of an implicit drag, specific computations are performed in \mdl{dynzdf} which renders the overall scheme mixed explicit/implicit: the barotropic components of 3d velocities are removed before seeking for the implicit vertical diffusion result. Top/bottom stresses due to the barotropic components are explicitly accounted for thanks to the updated values of barotropic velocities. Then the implicit solution of 3d velocities is obtained. Lastly, the residual barotropic component is replaced by the time split estimate.
-\end{enumerate} 
-
-Note that other strategies are possible, like considering vertical diffusion step in advance, \ie prior barotropic integration.  
-
-
-% ================================================================
-% Internal wave-driven mixing
-% ================================================================
-\section[Internal wave-driven mixing (\forcode{ln_zdfiwm = .true.})]
-{Internal wave-driven mixing (\protect\np{ln\_zdfiwm}\forcode{ = .true.})}
+\end{enumerate}
+
+Note that other strategies are possible, like considering vertical diffusion step in advance, \ie\ prior barotropic integration.
+
+%% =================================================================================================
+\section[Internal wave-driven mixing (\forcode{ln_zdfiwm})]{Internal wave-driven mixing (\protect\np{ln_zdfiwm}{ln\_zdfiwm})}
 \label{subsec:ZDF_tmx_new}
 
-%--------------------------------------------namzdf_iwm------------------------------------------
-%
-\nlst{namzdf_iwm}
-%--------------------------------------------------------------------------------------------------------------
+\begin{listing}
+  \nlst{namzdf_iwm}
+  \caption{\forcode{&namzdf_iwm}}
+  \label{lst:namzdf_iwm}
+\end{listing}
 
 The parameterization of mixing induced by breaking internal waves is a generalization of
 the approach originally proposed by \citet{st-laurent.simmons.ea_GRL02}.
 A three-dimensional field of internal wave energy dissipation $\epsilon(x,y,z)$ is first constructed,
-and the resulting diffusivity is obtained as 
-\[
-  % \label{eq:Kwave}
+and the resulting diffusivity is obtained as
+\[
+  % \label{eq:ZDF_Kwave}
   A^{vT}_{wave} =  R_f \,\frac{ \epsilon }{ \rho \, N^2 }
 \]
 where $R_f$ is the mixing efficiency and $\epsilon$ is a specified three dimensional distribution of
 the energy available for mixing.
-If the \np{ln\_mevar} namelist parameter is set to \forcode{.false.}, the mixing efficiency is taken as constant and
+If the \np{ln_mevar}{ln\_mevar} namelist parameter is set to \forcode{.false.}, the mixing efficiency is taken as constant and
 equal to 1/6 \citep{osborn_JPO80}.
 In the opposite (recommended) case, $R_f$ is instead a function of
@@ -1198,6 +1356,6 @@
 the mixing efficiency is constant.
 
-In addition to the mixing efficiency, the ratio of salt to heat diffusivities can chosen to vary 
-as a function of $Re_b$ by setting the \np{ln\_tsdiff} parameter to \forcode{.true.}, a recommended choice. 
+In addition to the mixing efficiency, the ratio of salt to heat diffusivities can chosen to vary
+as a function of $Re_b$ by setting the \np{ln_tsdiff}{ln\_tsdiff} parameter to \forcode{.true.}, a recommended choice.
 This parameterization of differential mixing, due to \cite{jackson.rehmann_JPO14},
 is implemented as in \cite{de-lavergne.madec.ea_JPO16}.
@@ -1211,5 +1369,5 @@
   F_{pyc}(i,j,k) &\propto N^{n_p}\\
   F_{bot}(i,j,k) &\propto N^2 \, e^{- h_{wkb} / h_{bot} }
-\end{align*} 
+\end{align*}
 In the above formula, $h_{ab}$ denotes the height above bottom,
 $h_{wkb}$ denotes the WKB-stretched height above bottom, defined by
@@ -1217,5 +1375,5 @@
   h_{wkb} = H \, \frac{ \int_{-H}^{z} N \, dz' } { \int_{-H}^{\eta} N \, dz'  } \; ,
 \]
-The $n_p$ parameter (given by \np{nn\_zpyc} in \ngn{namzdf\_iwm} namelist)
+The $n_p$ parameter (given by \np{nn_zpyc}{nn\_zpyc} in \nam{zdf_iwm}{zdf\_iwm} namelist)
 controls the stratification-dependence of the pycnocline-intensified dissipation.
 It can take values of $1$ (recommended) or $2$.
@@ -1225,34 +1383,265 @@
 $h_{bot}$ is a function of the energy flux $E_{bot}$, the characteristic horizontal scale of
 the abyssal hill topography \citep{goff_JGR10} and the latitude.
-%
 % Jc: input files names ?
 
-% ================================================================
-% surface wave-induced mixing 
-% ================================================================
-\section[Surface wave-induced mixing (\forcode{ln_zdfswm = .true.})]
-{Surface wave-induced mixing (\protect\np{ln\_zdfswm}\forcode{ = .true.})}
+%% =================================================================================================
+\section[Surface wave-induced mixing (\forcode{ln_zdfswm})]{Surface wave-induced mixing (\protect\np{ln_zdfswm}{ln\_zdfswm})}
 \label{subsec:ZDF_swm}
 
-TBC ...
-
-% ================================================================
-% Adaptive-implicit vertical advection
-% ================================================================
-\section[Adaptive-implicit vertical advection (\forcode{ln_zad_Aimp = .true.})]
-{Adaptive-implicit vertical advection(\protect\np{ln\_zad\_Aimp}\forcode{ = .true.})}
+Surface waves produce an enhanced mixing through wave-turbulence interaction.
+In addition to breaking waves induced turbulence (\autoref{subsec:ZDF_tke}),
+the influence of non-breaking waves can be accounted introducing
+wave-induced viscosity and diffusivity as a function of the wave number spectrum.
+Following \citet{qiao.yuan.ea_OD10}, a formulation of wave-induced mixing coefficient
+is provided  as a function of wave amplitude, Stokes Drift and wave-number:
+
+\begin{equation}
+  \label{eq:ZDF_Bv}
+  B_{v} = \alpha {A} {U}_{st} {exp(3kz)}
+\end{equation}
+
+Where $B_{v}$ is the wave-induced mixing coefficient, $A$ is the wave amplitude,
+${U}_{st}$ is the Stokes Drift velocity, $k$ is the wave number and $\alpha$
+is a constant which should be determined by observations or
+numerical experiments and is set to be 1.
+
+The coefficient $B_{v}$ is then directly added to the vertical viscosity
+and diffusivity coefficients.
+
+In order to account for this contribution set: \forcode{ln_zdfswm=.true.},
+then wave interaction has to be activated through \forcode{ln_wave=.true.},
+the Stokes Drift can be evaluated by setting \forcode{ln_sdw=.true.}
+(see \autoref{subsec:SBC_wave_sdw})
+and the needed wave fields can be provided either in forcing or coupled mode
+(for more information on wave parameters and settings see \autoref{sec:SBC_wave})
+
+%% =================================================================================================
+\section[Adaptive-implicit vertical advection (\forcode{ln_zad_Aimp})]{Adaptive-implicit vertical advection(\protect\np{ln_zad_Aimp}{ln\_zad\_Aimp})}
 \label{subsec:ZDF_aimp}
 
-This refers to \citep{shchepetkin_OM15}.
-
-TBC ...
-
-
-
-% ================================================================
-
-\biblio
-
-\pindex
+The adaptive-implicit vertical advection option in NEMO is based on the work of
+\citep{shchepetkin_OM15}.  In common with most ocean models, the timestep used with NEMO
+needs to satisfy multiple criteria associated with different physical processes in order
+to maintain numerical stability. \citep{shchepetkin_OM15} pointed out that the vertical
+CFL criterion is commonly the most limiting. \citep{lemarie.debreu.ea_OM15} examined the
+constraints for a range of time and space discretizations and provide the CFL stability
+criteria for a range of advection schemes. The values for the Leap-Frog with Robert
+asselin filter time-stepping (as used in NEMO) are reproduced in
+\autoref{tab:ZDF_zad_Aimp_CFLcrit}. Treating the vertical advection implicitly can avoid these
+restrictions but at the cost of large dispersive errors and, possibly, large numerical
+viscosity. The adaptive-implicit vertical advection option provides a targetted use of the
+implicit scheme only when and where potential breaches of the vertical CFL condition
+occur. In many practical applications these events may occur remote from the main area of
+interest or due to short-lived conditions such that the extra numerical diffusion or
+viscosity does not greatly affect the overall solution. With such applications, setting:
+\forcode{ln_zad_Aimp=.true.} should allow much longer model timesteps to be used whilst
+retaining the accuracy of the high order explicit schemes over most of the domain.
+
+\begin{table}[htbp]
+  \centering
+  % \begin{tabular}{cp{70pt}cp{70pt}cp{70pt}cp{70pt}}
+  \begin{tabular}{r|ccc}
+    \hline
+    spatial discretization  & 2$^nd$ order centered & 3$^rd$ order upwind & 4$^th$ order compact \\
+    advective CFL criterion &                 0.904 &              0.472  &                0.522 \\
+    \hline
+  \end{tabular}
+  \caption[Advective CFL criteria for the leapfrog with Robert Asselin filter time-stepping]{
+    The advective CFL criteria for a range of spatial discretizations for
+    the leapfrog with Robert Asselin filter time-stepping
+    ($\nu=0.1$) as given in \citep{lemarie.debreu.ea_OM15}.}
+  \label{tab:ZDF_zad_Aimp_CFLcrit}
+\end{table}
+
+In particular, the advection scheme remains explicit everywhere except where and when
+local vertical velocities exceed a threshold set just below the explicit stability limit.
+Once the threshold is reached a tapered transition towards an implicit scheme is used by
+partitioning the vertical velocity into a part that can be treated explicitly and any
+excess that must be treated implicitly. The partitioning is achieved via a Courant-number
+dependent weighting algorithm as described in \citep{shchepetkin_OM15}.
+
+The local cell Courant number ($Cu$) used for this partitioning is:
+
+\begin{equation}
+  \label{eq:ZDF_Eqn_zad_Aimp_Courant}
+  \begin{split}
+    Cu &= {2 \rdt \over e^n_{3t_{ijk}}} \bigg (\big [ \texttt{Max}(w^n_{ijk},0.0) - \texttt{Min}(w^n_{ijk+1},0.0) \big ]    \\
+       &\phantom{=} +\big [ \texttt{Max}(e_{{2_u}ij}e^n_{{3_{u}}ijk}u^n_{ijk},0.0) - \texttt{Min}(e_{{2_u}i-1j}e^n_{{3_{u}}i-1jk}u^n_{i-1jk},0.0) \big ]
+                     \big / e_{{1_t}ij}e_{{2_t}ij}            \\
+       &\phantom{=} +\big [ \texttt{Max}(e_{{1_v}ij}e^n_{{3_{v}}ijk}v^n_{ijk},0.0) - \texttt{Min}(e_{{1_v}ij-1}e^n_{{3_{v}}ij-1k}v^n_{ij-1k},0.0) \big ]
+                     \big / e_{{1_t}ij}e_{{2_t}ij} \bigg )    \\
+  \end{split}
+\end{equation}
+
+\noindent and the tapering algorithm follows \citep{shchepetkin_OM15} as:
+
+\begin{align}
+  \label{eq:ZDF_Eqn_zad_Aimp_partition}
+Cu_{min} &= 0.15 \nonumber \\
+Cu_{max} &= 0.3  \nonumber \\
+Cu_{cut} &= 2Cu_{max} - Cu_{min} \nonumber \\
+Fcu    &= 4Cu_{max}*(Cu_{max}-Cu_{min}) \nonumber \\
+\cf &=
+     \begin{cases}
+        0.0                                                        &\text{if $Cu \leq Cu_{min}$} \\
+        (Cu - Cu_{min})^2 / (Fcu +  (Cu - Cu_{min})^2)             &\text{else if $Cu < Cu_{cut}$} \\
+        (Cu - Cu_{max}) / Cu                                       &\text{else}
+     \end{cases}
+\end{align}
+
+\begin{figure}[!t]
+  \centering
+  \includegraphics[width=0.66\textwidth]{ZDF_zad_Aimp_coeff}
+  \caption[Partitioning coefficient used to partition vertical velocities into parts]{
+    The value of the partitioning coefficient (\cf) used to partition vertical velocities into
+    parts to be treated implicitly and explicitly for a range of typical Courant numbers
+    (\forcode{ln_zad_Aimp=.true.}).}
+  \label{fig:ZDF_zad_Aimp_coeff}
+\end{figure}
+
+\noindent The partitioning coefficient is used to determine the part of the vertical
+velocity that must be handled implicitly ($w_i$) and to subtract this from the total
+vertical velocity ($w_n$) to leave that which can continue to be handled explicitly:
+
+\begin{align}
+  \label{eq:ZDF_Eqn_zad_Aimp_partition2}
+    w_{i_{ijk}} &= \cf_{ijk} w_{n_{ijk}}     \nonumber \\
+    w_{n_{ijk}} &= (1-\cf_{ijk}) w_{n_{ijk}}
+\end{align}
+
+\noindent Note that the coefficient is such that the treatment is never fully implicit;
+the three cases from \autoref{eq:ZDF_Eqn_zad_Aimp_partition} can be considered as:
+fully-explicit; mixed explicit/implicit and mostly-implicit.  With the settings shown the
+coefficient (\cf) varies as shown in \autoref{fig:ZDF_zad_Aimp_coeff}. Note with these values
+the $Cu_{cut}$ boundary between the mixed implicit-explicit treatment and 'mostly
+implicit' is 0.45 which is just below the stability limited given in
+\autoref{tab:ZDF_zad_Aimp_CFLcrit}  for a 3rd order scheme.
+
+The $w_i$ component is added to the implicit solvers for the vertical mixing in
+\mdl{dynzdf} and \mdl{trazdf} in a similar way to \citep{shchepetkin_OM15}.  This is
+sufficient for the flux-limited advection scheme (\forcode{ln_traadv_mus}) but further
+intervention is required when using the flux-corrected scheme (\forcode{ln_traadv_fct}).
+For these schemes the implicit upstream fluxes must be added to both the monotonic guess
+and to the higher order solution when calculating the antidiffusive fluxes. The implicit
+vertical fluxes are then removed since they are added by the implicit solver later on.
+
+The adaptive-implicit vertical advection option is new to NEMO at v4.0 and has yet to be
+used in a wide range of simulations. The following test simulation, however, does illustrate
+the potential benefits and will hopefully encourage further testing and feedback from users:
+
+\begin{figure}[!t]
+  \centering
+  \includegraphics[width=0.66\textwidth]{ZDF_zad_Aimp_overflow_frames}
+  \caption[OVERFLOW: time-series of temperature vertical cross-sections]{
+    A time-series of temperature vertical cross-sections for the OVERFLOW test case.
+    These results are for the default settings with \forcode{nn_rdt=10.0} and
+    without adaptive implicit vertical advection (\forcode{ln_zad_Aimp=.false.}).}
+  \label{fig:ZDF_zad_Aimp_overflow_frames}
+\end{figure}
+
+%% =================================================================================================
+\subsection{Adaptive-implicit vertical advection in the OVERFLOW test-case}
+
+The \href{https://forge.ipsl.jussieu.fr/nemo/chrome/site/doc/NEMO/guide/html/test\_cases.html\#overflow}{OVERFLOW test case}
+provides a simple illustration of the adaptive-implicit advection in action. The example here differs from the basic test case
+by only a few extra physics choices namely:
+
+\begin{verbatim}
+     ln_dynldf_OFF = .false.
+     ln_dynldf_lap = .true.
+     ln_dynldf_hor = .true.
+     ln_zdfnpc     = .true.
+     ln_traadv_fct = .true.
+        nn_fct_h   =  2
+        nn_fct_v   =  2
+\end{verbatim}
+
+\noindent which were chosen to provide a slightly more stable and less noisy solution. The
+result when using the default value of \forcode{nn_rdt=10.} without adaptive-implicit
+vertical velocity is illustrated in \autoref{fig:ZDF_zad_Aimp_overflow_frames}. The mass of
+cold water, initially sitting on the shelf, moves down the slope and forms a
+bottom-trapped, dense plume. Even with these extra physics choices the model is close to
+stability limits and attempts with \forcode{nn_rdt=30.} will fail after about 5.5 hours
+with excessively high horizontal velocities. This time-scale corresponds with the time the
+plume reaches the steepest part of the topography and, although detected as a horizontal
+CFL breach, the instability originates from a breach of the vertical CFL limit. This is a good
+candidate, therefore, for use of the adaptive-implicit vertical advection scheme.
+
+The results with \forcode{ln_zad_Aimp=.true.} and a variety of model timesteps
+are shown in \autoref{fig:ZDF_zad_Aimp_overflow_all_rdt} (together with the equivalent
+frames from the base run).  In this simple example the use of the adaptive-implicit
+vertcal advection scheme has enabled a 12x increase in the model timestep without
+significantly altering the solution (although at this extreme the plume is more diffuse
+and has not travelled so far).  Notably, the solution with and without the scheme is
+slightly different even with \forcode{nn_rdt=10.}; suggesting that the base run was
+close enough to instability to trigger the scheme despite completing successfully.
+To assist in diagnosing how active the scheme is, in both location and time, the 3D
+implicit and explicit components of the vertical velocity are available via XIOS as
+\texttt{wimp} and \texttt{wexp} respectively.  Likewise, the partitioning coefficient
+(\cf) is also available as \texttt{wi\_cff}. For a quick oversight of
+the schemes activity the global maximum values of the absolute implicit component
+of the vertical velocity and the partitioning coefficient are written to the netCDF
+version of the run statistics file (\texttt{run.stat.nc}) if this is active (see
+\autoref{sec:MISC_opt} for activation details).
+
+\autoref{fig:ZDF_zad_Aimp_maxCf} shows examples of the maximum partitioning coefficient for
+the various overflow tests.  Note that the adaptive-implicit vertical advection scheme is
+active even in the base run with \forcode{nn_rdt=10.0s} adding to the evidence that the
+test case is close to stability limits even with this value. At the larger timesteps, the
+vertical velocity is treated mostly implicitly at some location throughout the run. The
+oscillatory nature of this measure appears to be linked to the progress of the plume front
+as each cusp is associated with the location of the maximum shifting to the adjacent cell.
+This is illustrated in \autoref{fig:ZDF_zad_Aimp_maxCf_loc} where the i- and k- locations of the
+maximum have been overlaid for the base run case.
+
+\medskip
+\noindent Only limited tests have been performed in more realistic configurations. In the
+ORCA2\_ICE\_PISCES reference configuration the scheme does activate and passes
+restartability and reproducibility tests but it is unable to improve the model's stability
+enough to allow an increase in the model time-step. A view of the time-series of maximum
+partitioning coefficient (not shown here)  suggests that the default time-step of 5400s is
+already pushing at stability limits, especially in the initial start-up phase. The
+time-series does not, however, exhibit any of the 'cuspiness' found with the overflow
+tests.
+
+\medskip
+\noindent A short test with an eORCA1 configuration promises more since a test using a
+time-step of 3600s remains stable with \forcode{ln_zad_Aimp=.true.} whereas the
+time-step is limited to 2700s without.
+
+\begin{figure}[!t]
+  \centering
+  \includegraphics[width=0.66\textwidth]{ZDF_zad_Aimp_overflow_all_rdt}
+  \caption[OVERFLOW: sample temperature vertical cross-sections from mid- and end-run]{
+    Sample temperature vertical cross-sections from mid- and end-run using
+    different values for \forcode{nn_rdt} and with or without adaptive implicit vertical advection.
+    Without the adaptive implicit vertical advection
+    only the run with the shortest timestep is able to run to completion.
+    Note also that the colour-scale has been chosen to confirm that
+    temperatures remain within the original range of 10$^o$ to 20$^o$.}
+  \label{fig:ZDF_zad_Aimp_overflow_all_rdt}
+\end{figure}
+
+\begin{figure}[!t]
+  \centering
+  \includegraphics[width=0.66\textwidth]{ZDF_zad_Aimp_maxCf}
+  \caption[OVERFLOW: maximum partitioning coefficient during a series of test runs]{
+    The maximum partitioning coefficient during a series of test runs with
+    increasing model timestep length.
+    At the larger timesteps,
+    the vertical velocity is treated mostly implicitly at some location throughout the run.}
+  \label{fig:ZDF_zad_Aimp_maxCf}
+\end{figure}
+
+\begin{figure}[!t]
+  \centering
+  \includegraphics[width=0.66\textwidth]{ZDF_zad_Aimp_maxCf_loc}
+  \caption[OVERFLOW: maximum partitioning coefficient for the case overlaid]{
+    The maximum partitioning coefficient for the \forcode{nn_rdt=10.0} case overlaid with
+    information on the gridcell i- and k-locations of the maximum value.}
+  \label{fig:ZDF_zad_Aimp_maxCf_loc}
+\end{figure}
+
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_cfgs.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_cfgs.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_cfgs.tex	(revision 12143)
@@ -0,0 +1,296 @@
+\documentclass[../main/NEMO_manual]{subfiles}
+
+\begin{document}
+
+\chapter{Configurations}
+\label{chap:CFGS}
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+%% =================================================================================================
+\section{Introduction}
+\label{sec:CFGS_intro}
+
+The purpose of this part of the manual is to introduce the \NEMO\ reference configurations.
+These configurations are offered as means to explore various numerical and physical options,
+thus allowing the user to verify that the code is performing in a manner consistent with that we are running.
+This form of verification is critical as one adopts the code for his or her particular research purposes.
+The reference configurations also provide a sense for some of the options available in the code,
+though by no means are all options exercised in the reference configurations.
+Configuration is defined manually through the \nam{cfg}{cfg} namelist variables.
+
+\begin{listing}
+  \nlst{namcfg}
+  \caption{\forcode{&namcfg}}
+  \label{lst:namcfg}
+\end{listing}
+
+%% =================================================================================================
+\section[C1D: 1D Water column model (\texttt{\textbf{key\_c1d}})]{C1D: 1D Water column model (\protect\key{c1d})}
+\label{sec:CFGS_c1d}
+
+The 1D model option simulates a stand alone water column within the 3D \NEMO\ system.
+It can be applied to the ocean alone or to the ocean-ice system and can include passive tracers or a biogeochemical model.
+It is set up by defining the position of the 1D water column in the grid
+(see \path{./cfgs/SHARED/namelist\_ref}).
+The 1D model is a very useful tool
+\textit{(a)} to learn about the physics and numerical treatment of vertical mixing processes;
+\textit{(b)} to investigate suitable parameterisations of unresolved turbulence
+(surface wave breaking, Langmuir circulation, ...);
+\textit{(c)} to compare the behaviour of different vertical mixing schemes;
+\textit{(d)} to perform sensitivity studies on the vertical diffusion at a particular point of an ocean domain;
+\textit{(d)} to produce extra diagnostics, without the large memory requirement of the full 3D model.
+
+The methodology is based on the configuration of the smallest possible domain:
+a 3x3 domain with 75 vertical levels.
+
+The 1D model has some specifies. First, all the horizontal derivatives are assumed to be zero,
+and second, the two components of the velocity are moved on a $T$-point.
+Therefore, defining \key{c1d} changes some things in the code behaviour:
+\begin{enumerate}
+\item a simplified \rou{stp} routine is used (\rou{stp\_c1d}, see \mdl{step\_c1d} module) in which
+  both lateral tendancy terms and lateral physics are not called;
+\item the vertical velocity is zero
+  (so far, no attempt at introducing a Ekman pumping velocity has been made);
+\item a simplified treatment of the Coriolis term is performed as $U$- and $V$-points are the same
+  (see \mdl{dyncor\_c1d}).
+\end{enumerate}
+All the relevant \textit{\_c1d} modules can be found in the src/OCE/C1D directory of
+the \NEMO\ distribution.
+
+% to be added:  a test case on the yearlong Ocean Weather Station (OWS) Papa dataset of Martin (1985)
+
+%% =================================================================================================
+\section{ORCA family: global ocean with tripolar grid}
+\label{sec:CFGS_orca}
+
+The ORCA family is a series of global ocean configurations that are run together with
+the SI3 model (ORCA-ICE) and possibly with PISCES biogeochemical model (ORCA-ICE-PISCES).
+An appropriate namelist is available in \path{./cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg} for ORCA2.
+The domain of ORCA2 configuration is defined in \ifile{ORCA\_R2\_zps\_domcfg} file,
+this file is available in tar file on the \NEMO\ community zenodo platform: \\
+https://doi.org/10.5281/zenodo.2640723
+
+In this namelist\_cfg the name of domain input file is set in \nam{cfg}{cfg} block of namelist.
+
+\begin{figure}[!t]
+  \centering
+  \includegraphics[width=0.66\textwidth]{CFGS_ORCA_NH_mesh}
+  \caption[ORCA mesh conception]{
+    ORCA mesh conception.
+    The departure from an isotropic Mercator grid start poleward of 20\deg{N}.
+    The two "north pole" are the foci of a series of embedded ellipses (blue curves) which
+    are determined analytically and form the i-lines of the ORCA mesh (pseudo latitudes).
+    Then, following \citet{madec.imbard_CD96},
+    the normal to the series of ellipses (red curves) is computed which
+    provides the j-lines of the mesh (pseudo longitudes).}
+  \label{fig:CFGS_ORCA_msh}
+\end{figure}
+
+%% =================================================================================================
+\subsection{ORCA tripolar grid}
+\label{subsec:CFGS_orca_grid}
+
+The ORCA grid is a tripolar grid based on the semi-analytical method of \citet{madec.imbard_CD96}.
+It allows to construct a global orthogonal curvilinear ocean mesh which has no singularity point inside
+the computational domain since two north mesh poles are introduced and placed on lands.
+The method involves defining an analytical set of mesh parallels in the stereographic polar plan,
+computing the associated set of mesh meridians, and projecting the resulting mesh onto the sphere.
+The set of mesh parallels used is a series of embedded ellipses which foci are the two mesh north poles
+(\autoref{fig:CFGS_ORCA_msh}).
+The resulting mesh presents no loss of continuity in either the mesh lines or the scale factors,
+or even the scale factor derivatives over the whole ocean domain, as the mesh is not a composite mesh.
+\begin{figure}[!tbp]
+  \centering
+  \includegraphics[width=0.66\textwidth]{CFGS_ORCA_NH_msh05_e1_e2}
+  \includegraphics[width=0.66\textwidth]{CFGS_ORCA_aniso}
+  \caption[Horizontal scale factors and ratio of anisotropy for ORCA 0.5\deg\ mesh]{
+    \textit{Top}: Horizontal scale factors ($e_1$, $e_2$) and
+    \textit{Bottom}: ratio of anisotropy ($e_1 / e_2$)
+    for ORCA 0.5\deg\ mesh.
+    South of 20\deg{N} a Mercator grid is used ($e_1 = e_2$) so that the anisotropy ratio is 1.
+    Poleward of 20\deg{N},
+    the two "north pole" introduce a weak anisotropy over the ocean areas ($< 1.2$) except in
+    vicinity of Victoria Island (Canadian Arctic Archipelago).}
+  \label{fig:CFGS_ORCA_e1e2}
+\end{figure}
+
+The method is applied to Mercator grid (\ie\ same zonal and meridional grid spacing) poleward of 20\deg{N},
+so that the Equator is a mesh line, which provides a better numerical solution for equatorial dynamics.
+The choice of the series of embedded ellipses (position of the foci and variation of the ellipses)
+is a compromise between maintaining the ratio of mesh anisotropy ($e_1 / e_2$) close to one in the ocean
+(especially in area of strong eddy activities such as the Gulf Stream) and keeping the smallest scale factor in
+the northern hemisphere larger than the smallest one in the southern hemisphere.
+The resulting mesh is shown in \autoref{fig:CFGS_ORCA_msh} and \autoref{fig:CFGS_ORCA_e1e2} for
+a half a degree grid (ORCA\_R05).
+The smallest ocean scale factor is found in along Antarctica,
+while the ratio of anisotropy remains close to one except near the Victoria Island in the Canadian Archipelago.
+
+%% =================================================================================================
+\subsection{ORCA pre-defined resolution}
+\label{subsec:CFGS_orca_resolution}
+
+The \NEMO\ system is provided with five built-in ORCA configurations which differ in the horizontal resolution.
+The value of the resolution is given by the resolution at the Equator expressed in degrees.
+Each of configuration is set through the \textit{domain\_cfg} domain configuration file,
+which sets the grid size and configuration name parameters.
+The \NEMO\ System Team provides only ORCA2 domain input file "\ifile{ORCA\_R2\_zps\_domcfg}" file
+(\autoref{tab:CFGS_ORCA}).
+
+\begin{table}[!t]
+  \centering
+  \begin{tabular}{p{4cm} c c c c}
+    Horizontal Grid & \jp{ORCA\_index} & \jp{jpiglo} & \jp{jpjglo} \\
+    \hline \hline
+    % 4   \deg\ &              4   &          92 &          76 \\
+    2   \deg\ &              2   &         182 &         149 \\
+    1   \deg\ &              1   &         362 &         292 \\
+    0.5 \deg\ &              05  &         722 &         511 \\
+    0.25\deg\ &              025 &        1442 &        1021 \\
+    \hline \hline
+  \end{tabular}
+  \caption[Domain size of ORCA family configurations]{
+    Domain size of ORCA family configurations.
+    The flag for configurations of ORCA family need to be set in \textit{domain\_cfg} file.}
+  \label{tab:CFGS_ORCA}
+\end{table}
+
+The ORCA\_R2 configuration has the following specificity: starting from a 2\deg\ ORCA mesh,
+local mesh refinements were applied to the Mediterranean, Red, Black and Caspian Seas,
+so that the resolution is 1\deg\ there.
+A local transformation were also applied with in the Tropics in order to refine the meridional resolution up to
+0.5\deg\ at the Equator.
+
+The ORCA\_R1 configuration has only a local tropical transformation to refine the meridional resolution up to
+1/3\deg\ at the Equator.
+Note that the tropical mesh refinements in ORCA\_R2 and R1 strongly increases the mesh anisotropy there.
+
+The ORCA\_R05 and higher global configurations do not incorporate any regional refinements.
+
+For ORCA\_R1 and R025, setting the configuration key to 75 allows to use 75 vertical levels, otherwise 46 are used.
+In the other ORCA configurations, 31 levels are used
+(see \autoref{tab:CFGS_ORCA}). %\sfcomment{HERE I need to put new table for ORCA2 values} and \autoref{fig:DOM_zgr_e3}).
+
+Only the ORCA\_R2 is provided with all its input files in the \NEMO\ distribution.
+%It is very similar to that used as part of the climate model developed at IPSL for the 4th IPCC assessment of
+%climate change (Marti et al., 2009).
+%It is also the basis for the \NEMO\ contribution to the Coordinate Ocean-ice Reference Experiments (COREs)
+%documented in \citet{griffies.biastoch.ea_OM09}.
+
+This version of ORCA\_R2 has 31 levels in the vertical, with the highest resolution (10m) in the upper 150m
+(see \autoref{tab:CFGS_ORCA} and \autoref{fig:DOM_zgr_e3}).
+The bottom topography and the coastlines are derived from the global atlas of Smith and Sandwell (1997).
+The default forcing uses the boundary forcing from \citet{large.yeager_rpt04} (see \autoref{subsec:SBC_blk_ocean}),
+which was developed for the purpose of running global coupled ocean-ice simulations without
+an interactive atmosphere.
+This \citet{large.yeager_rpt04} dataset is available through
+the \href{http://nomads.gfdl.noaa.gov/nomads/forms/mom4/CORE.html}{GFDL web site}.
+The "normal year" of \citet{large.yeager_rpt04} has been chosen of the \NEMO\ distribution since release v3.3.
+
+ORCA\_R2 pre-defined configuration can also be run with multiply online nested zooms (\ie\ with AGRIF, \key{agrif} defined).
+This is available as the AGRIF\_DEMO configuration that can be found in the \path{./cfgs/AGRIF_DEMO/} directory.
+
+A regional Arctic or peri-Antarctic configuration is extracted from an ORCA\_R2 or R05 configurations using
+sponge layers at open boundaries.
+
+%% =================================================================================================
+\section{GYRE family: double gyre basin}
+\label{sec:CFGS_gyre}
+
+The GYRE configuration \citep{levy.klein.ea_OM10} has been built to
+simulate the seasonal cycle of a double-gyre box model.
+It consists in an idealized domain similar to that used in the studies of \citet{drijfhout_JPO94} and
+\citet{hazeleger.drijfhout_JPO98, hazeleger.drijfhout_JPO99, hazeleger.drijfhout_JGR00, hazeleger.drijfhout_JPO00},
+over which an analytical seasonal forcing is applied.
+This allows to investigate the spontaneous generation of a large number of interacting, transient mesoscale eddies
+and their contribution to the large scale circulation.
+
+The GYRE configuration run together with the PISCES biogeochemical model (GYRE-PISCES).
+The domain geometry is a closed rectangular basin on the $\beta$-plane centred at $\sim$ 30\deg{N} and
+rotated by 45\deg, 3180~km long, 2120~km wide and 4~km deep (\autoref{fig:MISC_strait_hand}).
+The domain is bounded by vertical walls and by a flat bottom.
+The configuration is meant to represent an idealized North Atlantic or North Pacific basin.
+The circulation is forced by analytical profiles of wind and buoyancy fluxes.
+The applied forcings vary seasonally in a sinusoidal manner between winter and summer extrema \citep{levy.klein.ea_OM10}.
+The wind stress is zonal and its curl changes sign at 22\deg{N} and 36\deg{N}.
+It forces a subpolar gyre in the north, a subtropical gyre in the wider part of the domain and
+a small recirculation gyre in the southern corner.
+The net heat flux takes the form of a restoring toward a zonal apparent air temperature profile.
+A portion of the net heat flux which comes from the solar radiation is allowed to penetrate within the water column.
+The fresh water flux is also prescribed and varies zonally.
+It is determined such as, at each time step, the basin-integrated flux is zero.
+The basin is initialised at rest with vertical profiles of temperature and salinity uniformly applied to
+the whole domain.
+
+The GYRE configuration is set like an analytical configuration.
+Through \np[=.false.]{ln_read_cfg}{ln\_read\_cfg} in \nam{cfg}{cfg} namelist defined in
+the reference configuration \path{./cfgs/GYRE_PISCES/EXPREF/namelist_cfg}
+analytical definition of grid in GYRE is done in usrdef\_hrg, usrdef\_zgr routines.
+Its horizontal resolution (and thus the size of the domain) is determined by
+setting \np{nn_GYRE}{nn\_GYRE} in \nam{usr_def}{usr\_def}: \\
+
+\jp{jpiglo} $= 30 \times$ \np{nn_GYRE}{nn\_GYRE} + 2   \\
+
+\jp{jpjglo} $= 20 \times$ \np{nn_GYRE}{nn\_GYRE} + 2   \\
+
+Obviously, the namelist parameters have to be adjusted to the chosen resolution,
+see the Configurations pages on the \NEMO\ web site (\NEMO\ Configurations).
+In the vertical, GYRE uses the default 30 ocean levels (\jp{jpk}\forcode{ = 31}) (\autoref{fig:DOM_zgr_e3}).
+
+The GYRE configuration is also used in benchmark test as it is very simple to increase its resolution and
+as it does not requires any input file.
+For example, keeping a same model size on each processor while increasing the number of processor used is very easy,
+even though the physical integrity of the solution can be compromised.
+Benchmark is activate via \np[=.true.]{ln_bench}{ln\_bench} in \nam{usr_def}{usr\_def} in
+namelist \path{./cfgs/GYRE_PISCES/EXPREF/namelist_cfg}.
+
+\begin{figure}[!t]
+  \centering
+  \includegraphics[width=0.66\textwidth]{CFGS_GYRE}
+  \caption[Snapshot of relative vorticity at the surface of the model domain in GYRE R9, R27 and R54]{
+    Snapshot of relative vorticity at the surface of the model domain in GYRE R9, R27 and R54.
+    From \citet{levy.klein.ea_OM10}.}
+  \label{fig:CFGS_GYRE}
+\end{figure}
+
+%% =================================================================================================
+\section{AMM: atlantic margin configuration}
+\label{sec:CFGS_config_AMM}
+
+The AMM, Atlantic Margins Model, is a regional model covering the Northwest European Shelf domain on
+a regular lat-lon grid at approximately 12km horizontal resolution.
+The appropriate \textit{\&namcfg} namelist  is available in \path{./cfgs/AMM12/EXPREF/namelist\_cfg}.
+It is used to build the correct dimensions of the AMM domain.
+
+This configuration tests several features of \NEMO\ functionality specific to the shelf seas.
+In particular, the AMM uses $s$-coordinates in the vertical rather than $z$-coordinates and
+is forced with tidal lateral boundary conditions using a Flather boundary condition from the BDY module.
+Also specific to the AMM configuration is the use of the GLS turbulence scheme (\np[=.true.]{ln_zdfgls}{ln\_zdfgls}).
+
+In addition to the tidal boundary condition the model may also take open boundary conditions from
+a North Atlantic model.
+Boundaries may be completely omitted by setting \np{ln_bdy}{ln\_bdy} to false.
+Sample surface fluxes, river forcing and a sample initial restart file are included to test a realistic model run.
+The Baltic boundary is included within the river input file and is specified as a river source.
+Unlike ordinary river points the Baltic inputs also include salinity and temperature data.
+
+\subinc{\input{../../global/epilogue}}
+
+\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_conservation.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_conservation.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_conservation.tex	(revision 12143)
@@ -3,10 +3,25 @@
 \begin{document}
 
-% ================================================================
-% Invariant of the Equations
-% ================================================================
 \chapter{Invariants of the Primitive Equations}
-\label{chap:Invariant}
-\minitoc
+\label{chap:CONS}
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
 
 The continuous equations of motion have many analytic properties.
@@ -35,5 +50,5 @@
 The alternative is to use diffusive schemes such as upstream or flux corrected schemes.
 This last option was rejected because we prefer a complete handling of the model diffusion,
-\ie of the model physics rather than letting the advective scheme produces its own implicit diffusion without
+\ie\ of the model physics rather than letting the advective scheme produces its own implicit diffusion without
 controlling the space and time structure of this implicit diffusion.
 Note that in some very specific cases as passive tracer studies, the positivity of the advective scheme is required.
@@ -41,9 +56,7 @@
 \citep{Marti1992?, Levy1996?, Levy1998?}.
 
-% -------------------------------------------------------------------------------------------------------------
-%       Conservation Properties on Ocean Dynamics
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \section{Conservation properties on ocean dynamics}
-\label{sec:Invariant_dyn}
+\label{sec:CONS_Invariant_dyn}
 
 The non linear term of the momentum equations has been split into a vorticity term,
@@ -63,5 +76,5 @@
 The continuous formulation of the vorticity term satisfies following integral constraints:
 \[
-  % \label{eq:vor_vorticity}
+  % \label{eq:CONS_vor_vorticity}
   \int_D {{\textbf {k}}\cdot \frac{1}{e_3 }\nabla \times \left( {\varsigma
         \;{\mathrm {\mathbf k}}\times {\textbf {U}}_h } \right)\;dv} =0
@@ -69,5 +82,5 @@
 
 \[
-  % \label{eq:vor_enstrophy}
+  % \label{eq:CONS_vor_enstrophy}
   if\quad \chi =0\quad \quad \int\limits_D {\varsigma \;{\textbf{k}}\cdot
     \frac{1}{e_3 }\nabla \times \left( {\varsigma {\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} =-\int\limits_D {\frac{1}{2}\varsigma ^2\,\chi \;dv}
@@ -76,5 +89,5 @@
 
 \[
-  % \label{eq:vor_energy}
+  % \label{eq:CONS_vor_energy}
   \int_D {{\textbf{U}}_h \times \left( {\varsigma \;{\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} =0
 \]
@@ -88,5 +101,5 @@
 Using the symmetry or anti-symmetry properties of the operators (Eqs II.1.10 and 11),
 it can be shown that the scheme (II.2.11) satisfies (II.4.1b) but not (II.4.1c),
-while scheme (II.2.12) satisfies (II.4.1c) but not (II.4.1b) (see appendix C). 
+while scheme (II.2.12) satisfies (II.4.1c) but not (II.4.1b) (see appendix C).
 Note that the enstrophy conserving scheme on total vorticity has been chosen as the standard discrete form of
 the vorticity term.
@@ -102,12 +115,12 @@
 the horizontal gradient of horizontal kinetic energy:
 
-\begin{equation} \label{eq:keg_zad}
-\int_D {{\textbf{U}}_h \cdot \nabla _h \left( {1/2\;{\textbf{U}}_h ^2} \right)\;dv} =-\int_D {{\textbf{U}}_h \cdot \frac{w}{e_3 }\;\frac{\partial 
+\begin{equation} \label{eq:CONS_keg_zad}
+\int_D {{\textbf{U}}_h \cdot \nabla _h \left( {1/2\;{\textbf{U}}_h ^2} \right)\;dv} =-\int_D {{\textbf{U}}_h \cdot \frac{w}{e_3 }\;\frac{\partial
 {\textbf{U}}_h }{\partial k}\;dv}
 \end{equation}
 
 Using the discrete form given in {\S}II.2-a and the symmetry or anti-symmetry properties of
-the mean and difference operators, \autoref{eq:keg_zad} is demonstrated in the Appendix C.
-The main point here is that satisfying \autoref{eq:keg_zad} links the choice of the discrete forms of
+the mean and difference operators, \autoref{eq:CONS_keg_zad} is demonstrated in the Appendix C.
+The main point here is that satisfying \autoref{eq:CONS_keg_zad} links the choice of the discrete forms of
 the vertical advection and of the horizontal gradient of horizontal kinetic energy.
 Choosing one imposes the other.
@@ -122,10 +135,10 @@
 This properties is satisfied locally with the choice of discretization we have made (property (II.1.9)~).
 In addition, when the equation of state is linear
-(\ie when an advective-diffusive equation for density can be derived from those of temperature and salinity)
+(\ie\ when an advective-diffusive equation for density can be derived from those of temperature and salinity)
 the change of horizontal kinetic energy due to the work of pressure forces is balanced by the change of
 potential energy due to buoyancy forces:
 
 \[
-  % \label{eq:hpg_pe}
+  % \label{eq:CONS_hpg_pe}
   \int_D {-\frac{1}{\rho_o }\left. {\nabla p^h} \right|_z \cdot {\textbf {U}}_h \;dv} \;=\;\int_D {\nabla .\left( {\rho \,{\textbf{U}}} \right)\;g\;z\;\;dv}
 \]
@@ -133,5 +146,5 @@
 Using the discrete form given in {\S}~II.2-a and the symmetry or anti-symmetry properties of
 the mean and difference operators, (II.4.3) is demonstrated in the Appendix C.
-The main point here is that satisfying (II.4.3) strongly constraints the discrete expression of the depth of 
+The main point here is that satisfying (II.4.3) strongly constraints the discrete expression of the depth of
 $T$-points and of the term added to the pressure gradient in $s-$coordinates: the depth of a $T$-point, $z_T$,
 is defined as the sum the vertical scale factors at $w$-points starting from the surface.
@@ -145,8 +158,8 @@
 Nevertheless, the $\psi$-equation is solved numerically by an iterative solver (see {\S}~III.5),
 thus the property is only satisfied with the accuracy required on the solver.
-In addition, with the rigid-lid approximation, the change of horizontal kinetic energy due to the work of 
+In addition, with the rigid-lid approximation, the change of horizontal kinetic energy due to the work of
 surface pressure forces is exactly zero:
 \[
-  % \label{eq:spg}
+  % \label{eq:CONS_spg}
   \int_D {-\frac{1}{\rho_o }\nabla _h } \left( {p_s } \right)\cdot {\textbf{U}}_h \;dv=0
 \]
@@ -157,14 +170,12 @@
 otherwise there is no guarantee that the surface pressure force work vanishes.
 
-% -------------------------------------------------------------------------------------------------------------
-%       Conservation Properties on Ocean Thermodynamics
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \section{Conservation properties on ocean thermodynamics}
-\label{sec:Invariant_tra}
+\label{sec:CONS_Invariant_tra}
 
 In continuous formulation, the advective terms of the tracer equations conserve the tracer content and
 the quadratic form of the tracer, \ie
 \[
-  % \label{eq:tra_tra2}
+  % \label{eq:CONS_tra_tra2}
   \int_D {\nabla .\left( {T\;{\textbf{U}}} \right)\;dv} =0
   \;\text{and}
@@ -176,11 +187,9 @@
 Note that in both continuous and discrete formulations, there is generally no strict conservation of mass,
 since the equation of state is non linear with respect to $T$ and $S$.
-In practice, the mass is conserved with a very good accuracy. 
-
-% -------------------------------------------------------------------------------------------------------------
-%       Conservation Properties on Momentum Physics
-% -------------------------------------------------------------------------------------------------------------
+In practice, the mass is conserved with a very good accuracy.
+
+%% =================================================================================================
 \subsection{Conservation properties on momentum physics}
-\label{subsec:Invariant_dyn_physics}
+\label{subsec:CONS_Invariant_dyn_physics}
 
 \textbf{* lateral momentum diffusion term}
@@ -188,5 +197,5 @@
 The continuous formulation of the horizontal diffusion of momentum satisfies the following integral constraints~:
 \[
-  % \label{eq:dynldf_dyn}
+  % \label{eq:CONS_dynldf_dyn}
   \int\limits_D {\frac{1}{e_3 }{\mathrm {\mathbf k}}\cdot \nabla \times \left[ {\nabla
         _h \left( {A^{lm}\;\chi } \right)-\nabla _h \times \left( {A^{lm}\;\zeta
@@ -195,5 +204,5 @@
 
 \[
-  % \label{eq:dynldf_div}
+  % \label{eq:CONS_dynldf_div}
   \int\limits_D {\nabla _h \cdot \left[ {\nabla _h \left( {A^{lm}\;\chi }
         \right)-\nabla _h \times \left( {A^{lm}\;\zeta \;{\mathrm {\mathbf k}}} \right)}
@@ -202,5 +211,5 @@
 
 \[
-  % \label{eq:dynldf_curl}
+  % \label{eq:CONS_dynldf_curl}
   \int_D {{\mathrm {\mathbf U}}_h \cdot \left[ {\nabla _h \left( {A^{lm}\;\chi }
         \right)-\nabla _h \times \left( {A^{lm}\;\zeta \;{\mathrm {\mathbf k}}} \right)}
@@ -209,5 +218,5 @@
 
 \[
-  % \label{eq:dynldf_curl2}
+  % \label{eq:CONS_dynldf_curl2}
   \mbox{if}\quad A^{lm}=cste\quad \quad \int_D {\zeta \;{\mathrm {\mathbf k}}\cdot
     \nabla \times \left[ {\nabla _h \left( {A^{lm}\;\chi } \right)-\nabla _h
@@ -217,10 +226,9 @@
 
 \[
-  % \label{eq:dynldf_div2}
+  % \label{eq:CONS_dynldf_div2}
   \mbox{if}\quad A^{lm}=cste\quad \quad \int_D {\chi \;\nabla _h \cdot \left[
       {\nabla _h \left( {A^{lm}\;\chi } \right)-\nabla _h \times \left(
           {A^{lm}\;\zeta \;{\mathrm {\mathbf k}}} \right)} \right]\;dv} \leqslant 0
 \]
-
 
 (II.4.6a) and (II.4.6b) means that the horizontal diffusion of momentum conserve both the potential vorticity and
@@ -250,5 +258,5 @@
 
 \[
-  % \label{eq:dynzdf_dyn}
+  % \label{eq:CONS_dynzdf_dyn}
   \begin{aligned}
     & \int_D {\frac{1}{e_3 }}  \frac{\partial }{\partial k}\left( \frac{A^{vm}}{e_3 }\frac{\partial {\textbf{U}}_h }{\partial k} \right) \;dv = \overrightarrow{\textbf{0}} \\
@@ -258,5 +266,5 @@
 conservation of vorticity, dissipation of enstrophy
 \[
-  % \label{eq:dynzdf_vor}
+  % \label{eq:CONS_dynzdf_vor}
   \begin{aligned}
     & \int_D {\frac{1}{e_3 }{\mathrm {\mathbf k}}\cdot \nabla \times \left( {\frac{1}{e_3
@@ -270,5 +278,5 @@
 conservation of horizontal divergence, dissipation of square of the horizontal divergence
 \[
-  % \label{eq:dynzdf_div}
+  % \label{eq:CONS_dynzdf_div}
   \begin{aligned}
     &\int_D {\nabla \cdot \left( {\frac{1}{e_3 }\frac{\partial }{\partial
@@ -283,24 +291,22 @@
 In discrete form, all these properties are satisfied in $z$-coordinate (see Appendix C).
 In $s$-coordinates, only first order properties can be demonstrated,
-\ie the vertical momentum physics conserve momentum, potential vorticity, and horizontal divergence.
-
-% -------------------------------------------------------------------------------------------------------------
-%       Conservation Properties on Tracer Physics
-% -------------------------------------------------------------------------------------------------------------
+\ie\ the vertical momentum physics conserve momentum, potential vorticity, and horizontal divergence.
+
+%% =================================================================================================
 \subsection{Conservation properties on tracer physics}
-\label{subsec:Invariant_tra_physics}
+\label{subsec:CONS_Invariant_tra_physics}
 
 The numerical schemes used for tracer subgridscale physics are written in such a way that
 the heat and salt contents are conserved (equations in flux form, second order centred finite differences).
 As a form flux is used to compute the temperature and salinity,
-the quadratic form of these quantities (\ie their variance) globally tends to diminish.
+the quadratic form of these quantities (\ie\ their variance) globally tends to diminish.
 As for the advective term, there is generally no strict conservation of mass even if,
-in practice, the mass is conserved with a very good accuracy. 
-
-\textbf{* lateral physics: }conservation of tracer, dissipation of tracer 
+in practice, the mass is conserved with a very good accuracy.
+
+\textbf{* lateral physics: }conservation of tracer, dissipation of tracer
 variance, i.e.
 
 \[
-  % \label{eq:traldf_t_t2}
+  % \label{eq:CONS_traldf_t_t2}
   \begin{aligned}
     &\int_D \nabla\, \cdot\, \left( A^{lT} \,\Re \,\nabla \,T \right)\;dv = 0 \\
@@ -312,5 +318,5 @@
 
 \[
-  % \label{eq:trazdf_t_t2}
+  % \label{eq:CONS_trazdf_t_t2}
   \begin{aligned}
     & \int_D \frac{1}{e_3 } \frac{\partial }{\partial k}\left( \frac{A^{vT}}{e_3 }  \frac{\partial T}{\partial k}  \right)\;dv = 0 \\
@@ -328,7 +334,5 @@
 It has not been implemented.
 
-\biblio
-
-\pindex
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_misc.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_misc.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_misc.tex	(revision 12143)
@@ -2,17 +2,28 @@
 
 \begin{document}
-% ================================================================
-% Chapter --- Miscellaneous Topics
-% ================================================================
+
 \chapter{Miscellaneous Topics}
 \label{chap:MISC}
 
-\minitoc
-
-\newpage
-
-% ================================================================
-% Representation of Unresolved Straits
-% ================================================================
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+%% =================================================================================================
 \section{Representation of unresolved straits}
 \label{sec:MISC_strait}
@@ -27,81 +38,91 @@
 balance the net evaporation occurring over the Mediterranean region.
 This problem occurs even in eddy permitting simulations.
-For example, in ORCA 1/4\deg several straits of the Indonesian archipelago (Ombai, Lombok...)
+For example, in ORCA 1/4\deg\ several straits of the Indonesian archipelago (Ombai, Lombok...)
 are much narrow than even a single ocean grid-point.
 
-We describe briefly here the three methods that can be used in \NEMO to handle such improperly resolved straits.
-The first two consist of opening the strait by hand while ensuring that the mass exchanges through
-the strait are not too large by either artificially reducing the surface of the strait grid-cells or,
-locally increasing the lateral friction.
-In the third one, the strait is closed but exchanges of mass, heat and salt across the land are allowed.
-Note that such modifications are so specific to a given configuration that no attempt has been made to
-set them in a generic way.
-However, examples of how they can be set up is given in the ORCA 2\deg and 0.5\deg configurations.
-For example, for details of implementation in ORCA2, search: \texttt{IF( cp\_cfg == "orca" .AND. jp\_cfg == 2 )}
-
-% -------------------------------------------------------------------------------------------------------------
-%       Hand made geometry changes
-% -------------------------------------------------------------------------------------------------------------
+We describe briefly here the two methods that can be used in \NEMO\ to handle such
+improperly resolved straits. The methods consist of opening the strait while ensuring
+that the mass exchanges through the strait are not too large by either artificially
+reducing the cross-sectional area of the strait grid-cells or, locally increasing the
+lateral friction.
+
+%% =================================================================================================
 \subsection{Hand made geometry changes}
 \label{subsec:MISC_strait_hand}
 
-$\bullet$ reduced scale factor in the cross-strait direction to a value in better agreement with
-the true mean width of the strait (\autoref{fig:MISC_strait_hand}).
-This technique is sometime called "partially open face" or "partially closed cells".
-The key issue here is only to reduce the faces of $T$-cell
-(\ie change the value of the horizontal scale factors at $u$- or $v$-point) but not the volume of the $T$-cell.
-Indeed, reducing the volume of strait $T$-cell can easily produce a numerical instability at
-that grid point that would require a reduction of the model time step.
-The changes associated with strait management are done in \mdl{domhgr},
-just after the definition or reading of the horizontal scale factors. 
-
-$\bullet$ increase of the viscous boundary layer thickness by local increase of the fmask value at the coast
-(\autoref{fig:MISC_strait_hand}).
-This is done in \mdl{dommsk} together with the setting of the coastal value of fmask (see  \autoref{sec:LBC_coast}).
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+The first method involves reducing the scale factor in the cross-strait direction to a
+value in better agreement with the true mean width of the strait
+(\autoref{fig:MISC_strait_hand}).  This technique is sometime called "partially open face"
+or "partially closed cells".  The key issue here is only to reduce the faces of $T$-cell
+(\ie\ change the value of the horizontal scale factors at $u$- or $v$-point) but not the
+volume of the $T$-cell.  Indeed, reducing the volume of strait $T$-cell can easily produce
+a numerical instability at that grid point which would require a reduction of the model
+time step.  Thus to instigate a local change in the width of a Strait requires two steps:
+
+\begin{itemize}
+
+\item Add \texttt{e1e2u} and \texttt{e1e2v} arrays to the \np{cn_domcfg}{cn\_domcfg} file. These 2D
+arrays should contain the products of the unaltered values of: $\texttt{e1u}*\texttt{e2u}$
+and $\texttt{e1u}*\texttt{e2v}$ respectively. That is the original surface areas of $u$-
+and $v$- cells respectively.  These areas are usually defined by the corresponding product
+within the \NEMO\ code but the presence of \texttt{e1e2u} and \texttt{e1e2v} in the
+\np{cn_domcfg}{cn\_domcfg} file will suppress this calculation and use the supplied fields instead.
+If the model domain is provided by user-supplied code in \mdl{usrdef\_hgr}, then this
+routine should also return \texttt{e1e2u} and \texttt{e1e2v} and set the integer return
+argument \texttt{ie1e2u\_v} to a non-zero value. Values other than 0 for this argument
+will suppress the calculation of the areas.
+
+\item Change values of \texttt{e2u} or \texttt{e1v} (either in the \np{cn_domcfg}{cn\_domcfg} file or
+via code in  \mdl{usrdef\_hgr}), whereever a Strait reduction is required. The choice of
+whether to alter \texttt{e2u} or \texttt{e1v} depends. respectively,  on whether the
+Strait in question is North-South orientated (\eg\ Gibraltar) or East-West orientated (\eg
+Lombok).
+
+\end{itemize}
+
+The second method is to increase the viscous boundary layer thickness by a local increase
+of the fmask value at the coast. This method can also be effective in wider passages.  The
+concept is illustarted in the second part of  \autoref{fig:MISC_strait_hand} and changes
+to specific locations can be coded in \mdl{usrdef\_fmask}. The \forcode{usr_def_fmask}
+routine is always called after \texttt{fmask} has been defined according to the choice of
+lateral boundary condition as discussed in \autoref{sec:LBC_coast}. The default version of
+\mdl{usrdef\_fmask} contains settings specific to ORCA2 and ORCA1 configurations. These are
+meant as examples only; it is up to the user to verify settings and provide alternatives
+for their own configurations. The default \forcode{usr_def_fmask} makes no changes to
+\texttt{fmask} for any other configuration.
+
 \begin{figure}[!tbp]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_Gibraltar}
-    \includegraphics[width=\textwidth]{Fig_Gibraltar2}
-    \caption{
-      \protect\label{fig:MISC_strait_hand}
-      Example of the Gibraltar strait defined in a $1^{\circ} \times 1^{\circ}$ mesh.
-      \textit{Top}: using partially open cells.
-      The meridional scale factor at $v$-point is reduced on both sides of the strait to account for
-      the real width of the strait (about 20 km).
-      Note that the scale factors of the strait $T$-point remains unchanged.
-      \textit{Bottom}: using viscous boundary layers.
-      The four fmask parameters along the strait coastlines are set to a value larger than 4,
-      \ie "strong" no-slip case (see \autoref{fig:LBC_shlat}) creating a large viscous boundary layer that
-      allows a reduced transport through the strait.
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{MISC_Gibraltar}
+  \includegraphics[width=0.66\textwidth]{MISC_Gibraltar2}
+  \caption[Two methods to defined the Gibraltar strait]{
+    Example of the Gibraltar strait defined in a 1\deg\ $\times$ 1\deg\ mesh.
+    \textit{Top}: using partially open cells.
+    The meridional scale factor at $v$-point is reduced on both sides of the strait to
+    account for the real width of the strait (about 20 km).
+    Note that the scale factors of the strait $T$-point remains unchanged.
+    \textit{Bottom}: using viscous boundary layers.
+    The four fmask parameters along the strait coastlines are set to a value larger than 4,
+    \ie\ "strong" no-slip case (see \autoref{fig:LBC_shlat}) creating a large viscous boundary layer
+    that allows a reduced transport through the strait.}
+  \label{fig:MISC_strait_hand}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
 \begin{figure}[!tbp]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_closea_mask_example}
-    \caption{
-      \protect\label{fig:closea_mask_example}
-      Example of mask fields for the closea module. \textit{Left}: a
-      closea\_mask field; \textit{Right}: a closea\_mask\_rnf
-      field. In this example, if ln\_closea is set to .true., the mean
-      freshwater flux over each of the American Great Lakes will be
-      set to zero, and the total residual for all the lakes, if
-      negative, will be put into the St Laurence Seaway in the area
-      shown. 
-    }
-  \end{center}
+  \centering
+  \includegraphics[width=0.66\textwidth]{MISC_closea_mask_example}
+  \caption[Mask fields for the \protect\mdl{closea} module]{
+    Example of mask fields for the \protect\mdl{closea} module.
+    \textit{Left}: a closea\_mask field;
+    \textit{Right}: a closea\_mask\_rnf field.
+    In this example, if \protect\np{ln_closea}{ln\_closea} is set to \forcode{.true.},
+    the mean freshwater flux over each of the American Great Lakes will be set to zero,
+    and the total residual for all the lakes, if negative, will be put into
+    the St Laurence Seaway in the area shown.}
+  \label{fig:MISC_closea_mask_example}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% ================================================================
-% Closed seas
-% ================================================================
-\section[Closed seas (\textit{closea.F90})]
-{Closed seas (\protect\mdl{closea})}
+
+%% =================================================================================================
+\section[Closed seas (\textit{closea.F90})]{Closed seas (\protect\mdl{closea})}
 \label{sec:MISC_closea}
 
@@ -117,14 +138,14 @@
 to zero and put the residual flux into the ocean.
 
-Prior to NEMO 4 the locations of inland seas and lakes was set via
-hardcoded indices for various ORCA configurations. From NEMO 4 onwards
+Prior to \NEMO\ 4 the locations of inland seas and lakes was set via
+hardcoded indices for various ORCA configurations. From \NEMO\ 4 onwards
 the inland seas and lakes are defined using mask fields in the
 domain configuration file. The options are as follows.
 
 \begin{enumerate}
-\item{{\bfseries No ``closea\_mask'' field is included in domain configuration
+\item {{\bfseries No ``closea\_mask'' field is included in domain configuration
   file.} In this case the closea module does nothing.}
 
-\item{{\bfseries A field called closea\_mask is included in the domain
+\item {{\bfseries A field called closea\_mask is included in the domain
 configuration file and ln\_closea=.false. in namelist namcfg.} In this
 case the inland seas defined by the closea\_mask field are filled in
@@ -132,8 +153,8 @@
 closea\_mask that is nonzero is set to be a land point.}
 
-\item{{\bfseries A field called closea\_mask is included in the domain
+\item {{\bfseries A field called closea\_mask is included in the domain
 configuration file and ln\_closea=.true. in namelist namcfg.} Each
 inland sea or group of inland seas is set to a positive integer value
-in the closea\_mask field (see Figure \ref{fig:closea_mask_example}
+in the closea\_mask field (see \autoref{fig:MISC_closea_mask_example}
 for an example). The net surface flux over each inland sea or group of
 inland seas is set to zero each timestep and the residual flux is
@@ -141,5 +162,5 @@
 closea\_mask is zero).}
 
-\item{{\bfseries Fields called closea\_mask and closea\_mask\_rnf are
+\item {{\bfseries Fields called closea\_mask and closea\_mask\_rnf are
 included in the domain configuration file and ln\_closea=.true. in
 namelist namcfg.} This option works as for option 3, except that if
@@ -150,10 +171,10 @@
 by the closea\_mask\_rnf field. Each mapping is defined by a positive
 integer value for the inland sea(s) and the corresponding runoff
-points. An example is given in Figure
-\ref{fig:closea_mask_example}. If no mapping is provided for a
+points. An example is given in
+\autoref{fig:MISC_closea_mask_example}. If no mapping is provided for a
 particular inland sea then the residual is spread over the global
 ocean.}
 
-\item{{\bfseries Fields called closea\_mask and closea\_mask\_emp are
+\item {{\bfseries Fields called closea\_mask and closea\_mask\_emp are
 included in the domain configuration file and ln\_closea=.true. in
 namelist namcfg.} This option works the same as option 4 except that
@@ -165,85 +186,80 @@
 
 There is a python routine to create the closea\_mask fields and append
-them to the domain configuration file in the utils/tools/DOMAINcfg directory. 
-
-% ================================================================
-% Sub-Domain Functionality 
-% ================================================================
+them to the domain configuration file in the utils/tools/DOMAINcfg directory.
+
+%% =================================================================================================
 \section{Sub-domain functionality}
 \label{sec:MISC_zoom}
 
+%% =================================================================================================
 \subsection{Simple subsetting of input files via NetCDF attributes}
 
-The extended grids for use with the under-shelf ice cavities will result in redundant rows around Antarctica if
-the ice cavities are not active.
-A simple mechanism for subsetting input files associated with the extended domains has been implemented to
-avoid the need to maintain different sets of input fields for use with or without active ice cavities.
-The existing 'zoom' options are overly complex for this task and marked for deletion anyway.
-This alternative subsetting operates for the j-direction only and works by optionally looking for and
-using a global file attribute (named: \np{open\_ocean\_jstart}) to determine the starting j-row for input.
-The use of this option is best explained with an example:
-consider an ORCA1 configuration using the extended grid bathymetry and coordinate files:
-\vspace{-10pt}
-\ifile{eORCA1\_bathymetry\_v2}
-\ifile{eORCA1\_coordinates}
-\noindent These files define a horizontal domain of 362x332.
-Assuming the first row with open ocean wet points in the non-isf bathymetry for this set is row 42
-(\fortran indexing) then the formally correct setting for \np{open\_ocean\_jstart} is 41.
-Using this value as the first row to be read will result in a 362x292 domain which is the same size as
-the original ORCA1 domain.
-Thus the extended coordinates and bathymetry files can be used with all the original input files for ORCA1 if
-the ice cavities are not active (\np{ln\_isfcav = .false.}).
-Full instructions for achieving this are:
-
-\noindent Add the new attribute to any input files requiring a j-row offset, i.e:
-\vspace{-10pt}
+The extended grids for use with the under-shelf ice cavities will result in redundant rows
+around Antarctica if the ice cavities are not active.  A simple mechanism for subsetting
+input files associated with the extended domains has been implemented to avoid the need to
+maintain different sets of input fields for use with or without active ice cavities.  This
+subsetting operates for the j-direction only and works by optionally looking for and using
+a global file attribute (named: \np{open_ocean_jstart}{open\_ocean\_jstart}) to determine the starting j-row
+for input.  The use of this option is best explained with an example:
+\medskip
+
+\noindent Consider an ORCA1
+configuration using the extended grid domain configuration file: \ifile{eORCA1\_domcfg.nc}
+This file define a horizontal domain of 362x332.  The first row with
+open ocean wet points in the non-isf bathymetry for this set is row 42 (\fortran\ indexing)
+then the formally correct setting for \np{open_ocean_jstart}{open\_ocean\_jstart} is 41.  Using this value as
+the first row to be read will result in a 362x292 domain which is the same size as the
+original ORCA1 domain.  Thus the extended domain configuration file can be used with all
+the original input files for ORCA1 if the ice cavities are not active (\np{ln\_isfcav =
+.false.}).  Full instructions for achieving this are:
+
+\begin{itemize}
+\item Add the new attribute to any input files requiring a j-row offset, i.e:
 \begin{cmds}
-ncatted  -a open_ocean_jstart,global,a,d,41 eORCA1_coordinates.nc 
-ncatted  -a open_ocean_jstart,global,a,d,41 eORCA1_bathymetry_v2.nc
+ncatted  -a open_ocean_jstart,global,a,d,41 eORCA1_domcfg.nc
 \end{cmds}
- 
-\noindent Add the logical switch to \ngn{namcfg} in the configuration namelist and set true:
-%--------------------------------------------namcfg--------------------------------------------------------
-
-\nlst{namcfg}
-%--------------------------------------------------------------------------------------------------------------
-
-\noindent Note the j-size of the global domain is the (extended j-size minus \np{open\_ocean\_jstart} + 1 ) and
-this must match the size of all datasets other than bathymetry and coordinates currently.
-However the option can be extended to any global, 2D and 3D, netcdf, input field by adding the:
-\vspace{-10pt}
+
+\item Add the logical switch \np{ln_use_jattr}{ln\_use\_jattr} to \nam{cfg}{cfg} in the configuration
+namelist (if it is not already there) and set \forcode{.true.}
+\end{itemize}
+
+\noindent Note that with this option, the j-size of the global domain is (extended
+j-size minus \np{open_ocean_jstart}{open\_ocean\_jstart} + 1 ) and this must match the \texttt{jpjglo} value
+for the configuration. This means an alternative version of \ifile{eORCA1\_domcfg.nc} must
+be created for when \np{ln_use_jattr}{ln\_use\_jattr} is active. The \texttt{ncap2} tool provides a
+convenient way of achieving this:
+
+\begin{cmds}
+ncap2 -s 'jpjglo=292' eORCA1_domcfg.nc nORCA1_domcfg.nc
+\end{cmds}
+
+The domain configuration file is unique in this respect since it also contains the value of \jp{jpjglo}
+that is read and used by the model.
+Any other global, 2D and 3D, netcdf, input field can be prepared for use in a reduced domain by adding the
+\texttt{open\_ocean\_jstart} attribute to the file's global attributes.
+In particular this is true for any field that is read by \NEMO\ using the following optional argument to
+the appropriate call to \np{iom_get}{iom\_get}.
+
 \begin{forlines}
 lrowattr=ln_use_jattr
 \end{forlines}
-optional argument to the appropriate \np{iom\_get} call and the \np{open\_ocean\_jstart} attribute to
-the corresponding input files.
-It remains the users responsibility to set \np{jpjdta} and \np{jpjglo} values in
-the \np{namelist\_cfg} file according to their needs.
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!ht]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_LBC_zoom}
-    \caption{
-      \protect\label{fig:LBC_zoom}
-      Position of a model domain compared to the data input domain when the zoom functionality is used.
-    }
-  \end{center}
-\end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-
-% ================================================================
-% Accuracy and Reproducibility
-% ================================================================
-\section[Accuracy and reproducibility (\textit{lib\_fortran.F90})]
-{Accuracy and reproducibility (\protect\mdl{lib\_fortran})}
+
+Currently, only the domain configuration variables make use of this optional argument so
+this facility is of little practical use except for tests where no other external input
+files are needed or you wish to use an extended domain configuration with inputs from
+earlier, non-extended configurations. Alternatively, it should be possible to exclude
+empty rows for extended domain, forced ocean runs using interpolation on the fly, by
+adding the optional argument to \texttt{iom\_get} calls for the weights and initial
+conditions. Experimenting with this remains an exercise for the user.
+
+%% =================================================================================================
+\section[Accuracy and reproducibility (\textit{lib\_fortran.F90})]{Accuracy and reproducibility (\protect\mdl{lib\_fortran})}
 \label{sec:MISC_fortran}
 
-\subsection[Issues with intrinsinc SIGN function (\texttt{\textbf{key\_nosignedzero}})]
-{Issues with intrinsinc SIGN function (\protect\key{nosignedzero})}
+%% =================================================================================================
+\subsection[Issues with intrinsinc SIGN function (\texttt{\textbf{key\_nosignedzero}})]{Issues with intrinsinc SIGN function (\protect\key{nosignedzero})}
 \label{subsec:MISC_sign}
 
-The SIGN(A, B) is the \fortran intrinsic function delivers the magnitude of A with the sign of B.
+The SIGN(A, B) is the \fortran\ intrinsic function delivers the magnitude of A with the sign of B.
 For example, SIGN(-3.0,2.0) has the value 3.0.
 The problematic case is when the second argument is zero, because, on platforms that support IEEE arithmetic,
@@ -257,5 +273,5 @@
 and the processor is capable of distinguishing between positive and negative zero,
 and B is negative real zero.
-Then SIGN delivers a negative result where, under \fninety rules, it used to return a positive result.
+Then SIGN delivers a negative result where, under \fninety\ rules, it used to return a positive result.
 This change may be especially sensitive for the ice model,
 so we overwrite the intrinsinc function with our own function simply performing :   \\
@@ -267,15 +283,15 @@
 some computers/compilers.
 
-
+%% =================================================================================================
 \subsection{MPP reproducibility}
 \label{subsec:MISC_glosum}
 
 The numerical reproducibility of simulations on distributed memory parallel computers is a critical issue.
-In particular, within NEMO global summation of distributed arrays is most susceptible to rounding errors,
+In particular, within \NEMO\ global summation of distributed arrays is most susceptible to rounding errors,
 and their propagation and accumulation cause uncertainty in final simulation reproducibility on
 different numbers of processors.
 To avoid so, based on \citet{he.ding_JS01} review of different technics,
 we use a so called self-compensated summation method.
-The idea is to estimate the roundoff error, store it in a buffer, and then add it back in the next addition. 
+The idea is to estimate the roundoff error, store it in a buffer, and then add it back in the next addition.
 
 Suppose we need to calculate $b = a_1 + a_2 + a_3$.
@@ -295,6 +311,7 @@
 The self-compensated summation method should be used in all summation in i- and/or j-direction.
 See \mdl{closea} module for an example.
-Note also that this implementation may be sensitive to the optimization level. 
-
+Note also that this implementation may be sensitive to the optimization level.
+
+%% =================================================================================================
 \subsection{MPP scalability}
 \label{subsec:MISC_mppsca}
@@ -316,21 +333,22 @@
 be set at all the locations actually required by each individual for the fold operation.
 This alternative method should give identical results to the default \textsc{ALLGATHER} method and
-is recommended for large values of \np{jpni}.
-The new method is activated by setting \np{ln\_nnogather} to be true (\ngn{nammpp}).
+is recommended for large values of \np{jpni}{jpni}.
+The new method is activated by setting \np{ln_nnogather}{ln\_nnogather} to be true (\nam{mpp}{mpp}).
 The reproducibility of results using the two methods should be confirmed for each new,
 non-reference configuration.
 
-% ================================================================
-% Model optimisation, Control Print and Benchmark
-% ================================================================
+%% =================================================================================================
 \section{Model optimisation, control print and benchmark}
 \label{sec:MISC_opt}
-%--------------------------------------------namctl-------------------------------------------------------
-
-\nlst{namctl} 
-%--------------------------------------------------------------------------------------------------------------
-
-Options are defined through the  \ngn{namctl} namelist variables.
-
+
+\begin{listing}
+  \nlst{namctl}
+  \caption{\forcode{&namctl}}
+  \label{lst:namctl}
+\end{listing}
+
+Options are defined through the  \nam{ctl}{ctl} namelist variables.
+
+%% =================================================================================================
 \subsection{Vector optimisation}
 
@@ -338,24 +356,25 @@
 This is very a very efficient way to increase the length of vector calculations and thus
 to speed up the model on vector computers.
- 
+
 % Add here also one word on NPROMA technique that has been found useless, since compiler have made significant progress during the last decade.
- 
+
 % Add also one word on NEC specific optimisation (Novercheck option for example)
- 
+
+%% =================================================================================================
 \subsection{Control print}
 
-The \np{ln\_ctl} switch was originally used as a debugging option in two modes:
+The \np{ln_ctl}{ln\_ctl} switch was originally used as a debugging option in two modes:
 
 \begin{enumerate}
-\item{\np{ln\_ctl}: compute and print the trends averaged over the interior domain in all TRA, DYN, LDF and
+\item {\np{ln_ctl}{ln\_ctl}: compute and print the trends averaged over the interior domain in all TRA, DYN, LDF and
 ZDF modules.
 This option is very helpful when diagnosing the origin of an undesired change in model results. }
 
-\item{also \np{ln\_ctl} but using the nictl and njctl namelist parameters to check the source of differences between
+\item {also \np{ln_ctl}{ln\_ctl} but using the nictl and njctl namelist parameters to check the source of differences between
 mono and multi processor runs.}
 \end{enumerate}
 
 However, in recent versions it has also been used to force all processors to assume the
-reporting role. Thus when \np{ln\_ctl} is true all processors produce their own versions
+reporting role. Thus when \np{ln_ctl}{ln\_ctl} is true all processors produce their own versions
 of files such as: ocean.output, layout.dat, etc.  All such files, beyond the the normal
 reporting processor (narea == 1), are named with a \_XXXX extension to their name, where
@@ -363,5 +382,5 @@
 such as run.stat (and its netCDF counterpart: run.stat.nc) and tracer.stat contain global
 information and are only ever produced by the reporting master (narea == 1). For version
-4.0 a start has been made to return \np{ln\_ctl} to its original function by introducing
+4.0 a start has been made to return \np{ln_ctl}{ln\_ctl} to its original function by introducing
 a new control structure which allows finer control over which files are produced. This
 feature is still evolving but it does already allow the user to: select individually the
@@ -389,15 +408,12 @@
 at a suitably long interval. For example:
 
-\begin{verbatim}     
+\begin{verbatim}
        sn_cfctl%ptimincr  = 25
 \end{verbatim}
 
-will carry out the global communications and write the information every 25 timesteps. This 
+will carry out the global communications and write the information every 25 timesteps. This
 increment also applies to the time.step file which is otherwise updated every timestep.
 
-% ================================================================
-\biblio
-
-\pindex
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_model_basics.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_model_basics.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_model_basics.tex	(revision 12143)
@@ -3,87 +3,97 @@
 \begin{document}
 
-% ================================================================
-% Chapter 1  Model Basics
-% ================================================================
 \chapter{Model Basics}
-\label{chap:PE}
-\minitoc
-
-\newpage
-
-% ================================================================
-% Primitive Equations
-% ================================================================
+\label{chap:MB}
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabular}{l||l|l}
+    Release          & Author(s)                                   & Modifications       \\
+    \hline
+    {\em        4.0} & {\em Mike Bell                            } & {\em Review       } \\
+    {\em        3.6} & {\em Tim Graham and Gurvan Madec          } & {\em Updates      } \\
+    {\em $\leq$ 3.4} & {\em Gurvan Madec and S\'{e}bastien Masson} & {\em First version} \\
+  \end{tabular}
+}
+
+\clearpage
+
+%% =================================================================================================
 \section{Primitive equations}
-\label{sec:PE_PE}
-
-% -------------------------------------------------------------------------------------------------------------
-%        Vector Invariant Formulation 
-% -------------------------------------------------------------------------------------------------------------
-
+\label{sec:MB_PE}
+
+%% =================================================================================================
 \subsection{Vector invariant formulation}
-\label{subsec:PE_Vector}
+\label{subsec:MB_PE_vector}
 
 The ocean is a fluid that can be described to a good approximation by the primitive equations,
-\ie the Navier-Stokes equations along with a nonlinear equation of state which
+\ie\ the Navier-Stokes equations along with a nonlinear equation of state which
 couples the two active tracers (temperature and salinity) to the fluid velocity,
 plus the following additional assumptions made from scale considerations:
 
-\begin{enumerate}
-\item
-  \textit{spherical earth approximation}: the geopotential surfaces are assumed to be spheres so that
-  gravity (local vertical) is parallel to the earth's radius
-\item
-  \textit{thin-shell approximation}: the ocean depth is neglected compared to the earth's radius
-\item
-  \textit{turbulent closure hypothesis}: the turbulent fluxes
+\begin{labeling}{Neglect of additional Coriolis terms}
+\item [\textit{Spherical Earth approximation}] The geopotential surfaces are assumed to
+  be oblate spheroids that follow the Earth's bulge;
+  these spheroids are approximated by spheres with gravity locally vertical
+  (parallel to the Earth's radius) and independent of latitude
+  \citep[][section 2]{white.hoskins.ea_QJRMS05}.
+\item [\textit{Thin-shell approximation}] The ocean depth is neglected compared to the earth's radius
+\item [\textit{Turbulent closure hypothesis}] The turbulent fluxes
   (which represent the effect of small scale processes on the large-scale)
   are expressed in terms of large-scale features
-\item
-  \textit{Boussinesq hypothesis}: density variations are neglected except in their contribution to
-  the buoyancy force
+\item [\textit{Boussinesq hypothesis}] Density variations are neglected except in
+  their contribution to the buoyancy force
   \begin{equation}
-    \label{eq:PE_eos}
+    \label{eq:MB_PE_eos}
     \rho = \rho \ (T,S,p)
   \end{equation}
-\item
-  \textit{Hydrostatic hypothesis}: the vertical momentum equation is reduced to a balance between
-  the vertical pressure gradient and the buoyancy force
+\item [\textit{Hydrostatic hypothesis}] The vertical momentum equation is reduced to
+  a balance between the vertical pressure gradient and the buoyancy force
   (this removes convective processes from the initial Navier-Stokes equations and so
   convective processes must be parameterized instead)
   \begin{equation}
-    \label{eq:PE_hydrostatic}
+    \label{eq:MB_PE_hydrostatic}
     \pd[p]{z} = - \rho \ g
   \end{equation}
-\item
-  \textit{Incompressibility hypothesis}: the three dimensional divergence of the velocity vector $\vect U$
-  is assumed to be zero.
+\item [\textit{Incompressibility hypothesis}] The three dimensional divergence of
+  the velocity vector $\vect U$ is assumed to be zero.
   \begin{equation}
-    \label{eq:PE_continuity}
+    \label{eq:MB_PE_continuity}
     \nabla \cdot \vect U = 0
   \end{equation}
-\end{enumerate}
+\item [\textit{Neglect of additional Coriolis terms}] The Coriolis terms that vary with
+  the cosine of latitude are neglected.
+  These terms may be non-negligible where the Brunt-V\"{a}is\"{a}l\"{a} frequency $N$ is small,
+  either in the deep ocean or in the sub-mesoscale motions of the mixed layer,
+  or near the equator \citep[][section 1]{white.hoskins.ea_QJRMS05}.
+  They can be consistently included as part of the ocean dynamics
+  \citep[][section 3(d)]{white.hoskins.ea_QJRMS05} and are retained in the MIT ocean model.
+\end{labeling}
 
 Because the gravitational force is so dominant in the equations of large-scale motions,
-it is useful to choose an orthogonal set of unit vectors $(i,j,k)$ linked to the earth such that
+it is useful to choose an orthogonal set of unit vectors $(i,j,k)$ linked to the Earth such that
 $k$ is the local upward vector and $(i,j)$ are two vectors orthogonal to $k$,
-\ie tangent to the geopotential surfaces.
-Let us define the following variables: $\vect U$ the vector velocity, $\vect U = \vect U_h + w \, \vect k$
-(the subscript $h$ denotes the local horizontal vector, \ie over the $(i,j)$ plane), 
+\ie\ tangent to the geopotential surfaces.
+Let us define the following variables:
+$\vect U$ the vector velocity, $\vect U = \vect U_h + w \, \vect k$
+(the subscript $h$ denotes the local horizontal vector, \ie\ over the $(i,j)$ plane),
 $T$ the potential temperature, $S$ the salinity, $\rho$ the \textit{in situ} density.
 The vector invariant form of the primitive equations in the $(i,j,k)$ vector system provides
 the following equations:
 \begin{subequations}
-  \label{eq:PE}
+  \label{eq:MB_PE}
   \begin{gather}
-    \intertext{$-$ the momentum balance}
-    \label{eq:PE_dyn}
-    \pd[\vect U_h]{t} = - \lt[ (\nabla \times \vect U) \times \vect U + \frac{1}{2} \nabla \lt( \vect U^2 \rt) \rt]_h
-                        - f \; k \times \vect U_h - \frac{1}{\rho_o} \nabla_h p
-                        + \vect D^{\vect U} + \vect F^{\vect U} \\
-    \intertext{$-$ the heat and salt conservation equations}
-    \label{eq:PE_tra_T}
+    \shortintertext{$-$ the momentum balance}
+    \label{eq:MB_PE_dyn}
+    \pd[\vect U_h]{t} = - \lt[ (\nabla \times \vect U) \times \vect U + \frac{1}{2} \nabla \lt( \vect U^2 \rt) \rt]_h - f \; k \times \vect U_h - \frac{1}{\rho_o} \nabla_h p + \vect D^{\vect U} + \vect F^{\vect U}
+    \shortintertext{$-$ the heat and salt conservation equations}
+    \label{eq:MB_PE_tra_T}
     \pd[T]{t} = - \nabla \cdot (T \ \vect U) + D^T + F^T \\
-    \label{eq:PE_tra_S}
+    \label{eq:MB_PE_tra_S}
     \pd[S]{t} = - \nabla \cdot (S \ \vect U) + D^S + F^S
   \end{gather}
@@ -91,198 +101,193 @@
 where $\nabla$ is the generalised derivative vector operator in $(i,j,k)$ directions, $t$ is the time,
 $z$ is the vertical coordinate, $\rho$ is the \textit{in situ} density given by the equation of state
-(\autoref{eq:PE_eos}), $\rho_o$ is a reference density, $p$ the pressure,
+(\autoref{eq:MB_PE_eos}), $\rho_o$ is a reference density, $p$ the pressure,
 $f = 2 \vect \Omega \cdot k$ is the Coriolis acceleration
-(where $\vect \Omega$ is the Earth's angular velocity vector), and $g$ is the gravitational acceleration.
+(where $\vect \Omega$ is the Earth's angular velocity vector),
+and $g$ is the gravitational acceleration.
 $\vect D^{\vect U}$, $D^T$ and $D^S$ are the parameterisations of small-scale physics for momentum,
 temperature and salinity, and $\vect F^{\vect U}$, $F^T$ and $F^S$ surface forcing terms.
-Their nature and formulation are discussed in \autoref{sec:PE_zdf_ldf} and \autoref{subsec:PE_boundary_condition}.
-
-% -------------------------------------------------------------------------------------------------------------
-% Boundary condition
-% -------------------------------------------------------------------------------------------------------------
+Their nature and formulation are discussed in \autoref{sec:MB_zdf_ldf} and
+\autoref{subsec:MB_boundary_condition}.
+
+%% =================================================================================================
 \subsection{Boundary conditions}
-\label{subsec:PE_boundary_condition}
+\label{subsec:MB_boundary_condition}
 
 An ocean is bounded by complex coastlines, bottom topography at its base and
 an air-sea or ice-sea interface at its top.
 These boundaries can be defined by two surfaces, $z = - H(i,j)$ and $z = \eta(i,j,k,t)$,
-where $H$ is the depth of the ocean bottom and $\eta$ is the height of the sea surface.
-Both $H$ and $\eta$ are usually referenced to a given surface, $z = 0$, chosen as a mean sea surface
-(\autoref{fig:ocean_bc}).
-Through these two boundaries, the ocean can exchange fluxes of heat, fresh water, salt, and momentum with
-the solid earth, the continental margins, the sea ice and the atmosphere.
-However, some of these fluxes are so weak that even on climatic time scales of thousands of years
-they can be neglected.
+where $H$ is the depth of the ocean bottom and $\eta$ is the height of the sea surface
+(discretisation can introduce additional artificial ``side-wall'' boundaries).
+Both $H$ and $\eta$ are referenced to a surface of constant geopotential
+(\ie\ a mean sea surface height) on which $z = 0$ (\autoref{fig:MB_ocean_bc}).
+Through these two boundaries, the ocean can exchange fluxes of heat, fresh water, salt,
+and momentum with the solid earth, the continental margins, the sea ice and the atmosphere.
+However, some of these fluxes are so weak that
+even on climatic time scales of thousands of years they can be neglected.
 In the following, we briefly review the fluxes exchanged at the interfaces between the ocean and
 the other components of the earth system.
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!ht]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_I_ocean_bc}
-    \caption{
-      \protect\label{fig:ocean_bc}
-      The ocean is bounded by two surfaces, $z = - H(i,j)$ and $z = \eta(i,j,t)$,
-      where $H$ is the depth of the sea floor and $\eta$ the height of the sea surface.
-      Both $H$ and $\eta$ are referenced to $z = 0$.
-    }
-  \end{center}
+\begin{figure}
+  \centering
+  \includegraphics[width=0.66\textwidth]{MB_ocean_bc}
+  \caption[Ocean boundary conditions]{
+    The ocean is bounded by two surfaces, $z = - H(i,j)$ and $z = \eta(i,j,t)$,
+    where $H$ is the depth of the sea floor and $\eta$ the height of the sea surface.
+    Both $H$ and $\eta$ are referenced to $z = 0$.}
+  \label{fig:MB_ocean_bc}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 \begin{description}
-\item[Land - ocean interface:]
-  the major flux between continental margins and the ocean is a mass exchange of fresh water through river runoff.
+\item [Land - ocean] The major flux between continental margins and the ocean is a mass exchange of
+  fresh water through river runoff.
   Such an exchange modifies the sea surface salinity especially in the vicinity of major river mouths.
-  It can be neglected for short range integrations but has to be taken into account for long term integrations as
+  It can be neglected for short range integrations but
+  has to be taken into account for long term integrations as
   it influences the characteristics of water masses formed (especially at high latitudes).
   It is required in order to close the water cycle of the climate system.
-  It is usually specified as a fresh water flux at the air-sea interface in the vicinity of river mouths.
-\item[Solid earth - ocean interface:]
-  heat and salt fluxes through the sea floor are small, except in special areas of little extent.
-  They are usually neglected in the model
-  \footnote{
+  It is usually specified as a fresh water flux at the air-sea interface in
+  the vicinity of river mouths.
+\item [Solid earth - ocean] Heat and salt fluxes through the sea floor are small,
+  except in special areas of little extent.
+  They are usually neglected in the model \footnote{
     In fact, it has been shown that the heat flux associated with the solid Earth cooling
-    (\ie the geothermal heating) is not negligible for the thermohaline circulation of the world ocean
-    (see \autoref{subsec:TRA_bbc}).
+    (\ie\ the geothermal heating) is not negligible for
+    the thermohaline circulation of the world ocean (see \autoref{subsec:TRA_bbc}).
   }.
   The boundary condition is thus set to no flux of heat and salt across solid boundaries.
-  For momentum, the situation is different. There is no flow across solid boundaries,
-  \ie the velocity normal to the ocean bottom and coastlines is zero (in other words,
-  the bottom velocity is parallel to solid boundaries). This kinematic boundary condition
-  can be expressed as:
+  For momentum, the situation is different.
+  There is no flow across solid boundaries,
+  \ie\ the velocity normal to the ocean bottom and coastlines is zero
+  (in other words, the bottom velocity is parallel to solid boundaries).
+  This kinematic boundary condition can be expressed as:
   \begin{equation}
-    \label{eq:PE_w_bbc}
+    \label{eq:MB_w_bbc}
     w = - \vect U_h \cdot \nabla_h (H)
   \end{equation}
   In addition, the ocean exchanges momentum with the earth through frictional processes.
   Such momentum transfer occurs at small scales in a boundary layer.
-  It must be parameterized in terms of turbulent fluxes using bottom and/or lateral boundary conditions.
+  It must be parameterized in terms of turbulent fluxes using
+  bottom and/or lateral boundary conditions.
   Its specification depends on the nature of the physical parameterisation used for
-  $\vect D^{\vect U}$ in \autoref{eq:PE_dyn}.
-  It is discussed in \autoref{eq:PE_zdf}.% and Chap. III.6 to 9.
-\item[Atmosphere - ocean interface:]
-  the kinematic surface condition plus the mass flux of fresh water PE (the precipitation minus evaporation budget)
-  leads to:
+  $\vect D^{\vect U}$ in \autoref{eq:MB_PE_dyn}.
+  It is discussed in \autoref{eq:MB_zdf}. % and Chap. III.6 to 9.
+\item [Atmosphere - ocean] The kinematic surface condition plus the mass flux of fresh water PE
+  (the precipitation minus evaporation budget) leads to:
   \[
-    % \label{eq:PE_w_sbc}
+    % \label{eq:MB_w_sbc}
     w = \pd[\eta]{t} + \lt. \vect U_h \rt|_{z = \eta} \cdot \nabla_h (\eta) + P - E
   \]
-  The dynamic boundary condition, neglecting the surface tension (which removes capillary waves from the system)
-  leads to the continuity of pressure across the interface $z = \eta$.
+  The dynamic boundary condition, neglecting the surface tension
+  (which removes capillary waves from the system) leads to
+  the continuity of pressure across the interface $z = \eta$.
   The atmosphere and ocean also exchange horizontal momentum (wind stress), and heat.
-\item[Sea ice - ocean interface:]
-  the ocean and sea ice exchange heat, salt, fresh water and momentum.
+\item [Sea ice - ocean] The ocean and sea ice exchange heat, salt, fresh water and momentum.
   The sea surface temperature is constrained to be at the freezing point at the interface.
   Sea ice salinity is very low ($\sim4-6 \, psu$) compared to those of the ocean ($\sim34 \, psu$).
-  The cycle of freezing/melting is associated with fresh water and salt fluxes that cannot be neglected.
+  The cycle of freezing/melting is associated with fresh water and salt fluxes that
+  cannot be neglected.
 \end{description}
 
-% ================================================================
-% The Horizontal Pressure Gradient
-% ================================================================
+%% =================================================================================================
 \section{Horizontal pressure gradient}
-\label{sec:PE_hor_pg}
-
-% -------------------------------------------------------------------------------------------------------------
-% Pressure Formulation
-% -------------------------------------------------------------------------------------------------------------
+\label{sec:MB_hor_pg}
+
+%% =================================================================================================
 \subsection{Pressure formulation}
-\label{subsec:PE_p_formulation}
+\label{subsec:MB_p_formulation}
 
 The total pressure at a given depth $z$ is composed of a surface pressure $p_s$ at
 a reference geopotential surface ($z = 0$) and a hydrostatic pressure $p_h$ such that:
 $p(i,j,k,t) = p_s(i,j,t) + p_h(i,j,k,t)$.
-The latter is computed by integrating (\autoref{eq:PE_hydrostatic}),
-assuming that pressure in decibars can be approximated by depth in meters in (\autoref{eq:PE_eos}).
+The latter is computed by integrating (\autoref{eq:MB_PE_hydrostatic}),
+assuming that pressure in decibars can be approximated by depth in meters in (\autoref{eq:MB_PE_eos}).
 The hydrostatic pressure is then given by:
 \[
-  % \label{eq:PE_pressure}
+  % \label{eq:MB_pressure}
   p_h (i,j,z,t) = \int_{\varsigma = z}^{\varsigma = 0} g \; \rho (T,S,\varsigma) \; d \varsigma
 \]
 Two strategies can be considered for the surface pressure term:
-$(a)$ introduce of a  new variable $\eta$, the free-surface elevation,
+\begin{enumerate*}[label=(\textit{\alph*})]
+\item introduce of a new variable $\eta$, the free-surface elevation,
 for which a prognostic equation can be established and solved;
-$(b)$ assume that the ocean surface is a rigid lid,
+\item assume that the ocean surface is a rigid lid,
 on which the pressure (or its horizontal gradient) can be diagnosed.
+\end{enumerate*}
 When the former strategy is used, one solution of the free-surface elevation consists of
 the excitation of external gravity waves.
 The flow is barotropic and the surface moves up and down with gravity as the restoring force.
 The phase speed of such waves is high (some hundreds of metres per second) so that
-the time step would have to be very short if they were present in the model.
+the time step has to be very short when they are present in the model.
 The latter strategy filters out these waves since the rigid lid approximation implies $\eta = 0$,
-\ie the sea surface is the surface $z = 0$.
+\ie\ the sea surface is the surface $z = 0$.
 This well known approximation increases the surface wave speed to infinity and
-modifies certain other longwave dynamics (\eg barotropic Rossby or planetary waves).
+modifies certain other longwave dynamics (\eg\ barotropic Rossby or planetary waves).
 The rigid-lid hypothesis is an obsolescent feature in modern OGCMs.
-It has been available until the release 3.1 of \NEMO, and it has been removed in release 3.2 and followings.
-Only the free surface formulation is now described in the this document (see the next sub-section).
-
-% -------------------------------------------------------------------------------------------------------------
-% Free Surface Formulation
-% -------------------------------------------------------------------------------------------------------------
+It has been available until the release 3.1 of \NEMO,
+and it has been removed in release 3.2 and followings.
+Only the free surface formulation is now described in this document (see the next sub-section).
+
+%% =================================================================================================
 \subsection{Free surface formulation}
-\label{subsec:PE_free_surface}
+\label{subsec:MB_free_surface}
 
 In the free surface formulation, a variable $\eta$, the sea-surface height,
 is introduced which describes the shape of the air-sea interface.
-This variable is solution of a prognostic equation which is established by forming the vertical average of
-the kinematic surface condition (\autoref{eq:PE_w_bbc}):
+This variable is solution of a prognostic equation which is established by
+forming the vertical average of the kinematic surface condition (\autoref{eq:MB_w_bbc}):
 \begin{equation}
-  \label{eq:PE_ssh}
+  \label{eq:MB_ssh}
   \pd[\eta]{t} = - D + P - E \quad \text{where} \quad D = \nabla \cdot \lt[ (H + \eta) \; \overline{U}_h \, \rt]
 \end{equation}
-and using (\autoref{eq:PE_hydrostatic}) the surface pressure is given by: $p_s = \rho \, g \, \eta$.
-
-Allowing the air-sea interface to move introduces the external gravity waves (EGWs) as
+and using (\autoref{eq:MB_PE_hydrostatic}) the surface pressure is given by:
+$p_s = \rho \, g \, \eta$.
+
+Allowing the air-sea interface to move introduces
+the \textbf{E}xternal \textbf{G}ravity \textbf{W}aves (EGWs) as
 a class of solution of the primitive equations.
-These waves are barotropic because of hydrostatic assumption, and their phase speed is quite high.
+These waves are barotropic (\ie\ nearly independent of depth) and their phase speed is quite high.
 Their time scale is short with respect to the other processes described by the primitive equations.
 
 Two choices can be made regarding the implementation of the free surface in the model,
 depending on the physical processes of interest.
-
-$\bullet$ If one is interested in EGWs, in particular the tides and their interaction with
-the baroclinic structure of the ocean (internal waves) possibly in shallow seas,
-then a non linear free surface is the most appropriate.
-This means that no approximation is made in \autoref{eq:PE_ssh} and that
-the variation of the ocean volume is fully taken into account.
-Note that in order to study the fast time scales associated with EGWs it is necessary to
-minimize time filtering effects
-(use an explicit time scheme with very small time step, or a split-explicit scheme with reasonably small time step,
-see \autoref{subsec:DYN_spg_exp} or \autoref{subsec:DYN_spg_ts}).
-
-$\bullet$ If one is not interested in EGW but rather sees them as high frequency noise,
-it is possible to apply an explicit filter to slow down the fastest waves while
-not altering the slow barotropic Rossby waves.
-If further, an approximative conservation of heat and salt contents is sufficient for the problem solved,
-then it is sufficient to solve a linearized version of \autoref{eq:PE_ssh},
-which still allows to take into account freshwater fluxes applied at the ocean surface \citep{roullet.madec_JGR00}.
-Nevertheless, with the linearization, an exact conservation of heat and salt contents is lost.
-
-The filtering of EGWs in models with a free surface is usually a matter of discretisation of
-the temporal derivatives,
+\begin{itemize}
+\item If one is interested in EGWs, in particular the tides and their interaction with
+  the baroclinic structure of the ocean (internal waves) possibly in shallow seas,
+  then a non linear free surface is the most appropriate.
+  This means that no approximation is made in \autoref{eq:MB_ssh} and that
+  the variation of the ocean volume is fully taken into account.
+  Note that in order to study the fast time scales associated with EGWs it is necessary to
+  minimize time filtering effects
+  (use an explicit time scheme with very small time step,
+  or a split-explicit scheme with reasonably small time step,
+  see \autoref{subsec:DYN_spg_exp} or \autoref{subsec:DYN_spg_ts}).
+\item If one is not interested in EGWs but rather sees them as high frequency noise,
+  it is possible to apply an explicit filter to slow down the fastest waves while
+  not altering the slow barotropic Rossby waves.
+  If further, an approximative conservation of heat and salt contents is sufficient for
+  the problem solved, then it is sufficient to solve a linearized version of \autoref{eq:MB_ssh},
+  which still allows to take into account freshwater fluxes applied at the ocean surface
+  \citep{roullet.madec_JGR00}.
+  Nevertheless, with the linearization, an exact conservation of heat and salt contents is lost.
+\end{itemize}
+The filtering of EGWs in models with a free surface is usually
+a matter of discretisation of the temporal derivatives,
 using a split-explicit method \citep{killworth.webb.ea_JPO91, zhang.endoh_JGR92} or
-the implicit scheme \citep{dukowicz.smith_JGR94} or
-the addition of a filtering force in the momentum equation \citep{roullet.madec_JGR00}.
-With the present release, \NEMO offers the choice between
-an explicit free surface (see \autoref{subsec:DYN_spg_exp}) or
-a split-explicit scheme strongly inspired the one proposed by \citet{shchepetkin.mcwilliams_OM05}
-(see \autoref{subsec:DYN_spg_ts}).
-
-% ================================================================
-% Curvilinear z-coordinate System
-% ================================================================
-\section{Curvilinear \textit{z-}coordinate system}
-\label{sec:PE_zco}
-
-% -------------------------------------------------------------------------------------------------------------
-% Tensorial Formalism
-% -------------------------------------------------------------------------------------------------------------
+the implicit scheme \citep{dukowicz.smith_JGR94} or the addition of a filtering force in
+the momentum equation \citep{roullet.madec_JGR00}.
+With the present release, \NEMO\ offers the choice between an explicit free surface
+(see \autoref{subsec:DYN_spg_exp}) or a split-explicit scheme strongly inspired the one proposed by
+\citet{shchepetkin.mcwilliams_OM05} (see \autoref{subsec:DYN_spg_ts}).
+
+%% =================================================================================================
+\section{Curvilinear \textit{z}-coordinate system}
+\label{sec:MB_zco}
+
+%% =================================================================================================
 \subsection{Tensorial formalism}
-\label{subsec:PE_tensorial}
+\label{subsec:MB_tensorial}
 
 In many ocean circulation problems, the flow field has regions of enhanced dynamics
-(\ie surface layers, western boundary currents, equatorial currents, or ocean fronts).
+(\ie\ surface layers, western boundary currents, equatorial currents, or ocean fronts).
 The representation of such dynamical processes can be improved by
 specifically increasing the model resolution in these regions.
@@ -293,10 +298,14 @@
 A solution consists of introducing an appropriate coordinate transformation that
 shifts the singular point onto land \citep{madec.imbard_CD96, murray_JCP96}.
-As a consequence, it is important to solve the primitive equations in various curvilinear coordinate systems.
-An efficient way of introducing an appropriate coordinate transform can be found when using a tensorial formalism.
+As a consequence,
+it is important to solve the primitive equations in various curvilinear coordinate systems.
+An efficient way of introducing an appropriate coordinate transform can be found when
+using a tensorial formalism.
 This formalism is suited to any multidimensional curvilinear coordinate system.
-Ocean modellers mainly use three-dimensional orthogonal grids on the sphere (spherical earth approximation),
-with preservation of the local vertical. Here we give the simplified equations for this particular case.
-The general case is detailed by \citet{eiseman.stone_SR80} in their survey of the conservation laws of fluid dynamics.
+Ocean modellers mainly use three-dimensional orthogonal grids on the sphere
+(spherical earth approximation), with preservation of the local vertical.
+Here we give the simplified equations for this particular case.
+The general case is detailed by \citet{eiseman.stone_SR80} in
+their survey of the conservation laws of fluid dynamics.
 
 Let $(i,j,k)$ be a set of orthogonal curvilinear coordinates on
@@ -304,157 +313,132 @@
 $(i,j,k)$ linked to the earth such that
 $k$ is the local upward vector and $(i,j)$ are two vectors orthogonal to $k$,
-\ie along geopotential surfaces (\autoref{fig:referential}).
+\ie\ along geopotential surfaces (\autoref{fig:MB_referential}).
 Let $(\lambda,\varphi,z)$ be the geographical coordinate system in which a position is defined by
 the latitude $\varphi(i,j)$, the longitude $\lambda(i,j)$ and
 the distance from the centre of the earth $a + z(k)$ where $a$ is the earth's radius and
-$z$ the altitude above a reference sea level (\autoref{fig:referential}).
+$z$ the altitude above a reference sea level (\autoref{fig:MB_referential}).
 The local deformation of the curvilinear coordinate system is given by $e_1$, $e_2$ and $e_3$,
 the three scale factors:
 \begin{equation}
-  \label{eq:scale_factors}
-  \begin{aligned}
-    e_1 &= (a + z) \lt[ \lt( \pd[\lambda]{i} \cos \varphi \rt)^2 + \lt( \pd[\varphi]{i} \rt)^2 \rt]^{1/2} \\
-    e_2 &= (a + z) \lt[ \lt( \pd[\lambda]{j} \cos \varphi \rt)^2 + \lt( \pd[\varphi]{j} \rt)^2 \rt]^{1/2} \\
-    e_3 &= \lt( \pd[z]{k} \rt)
-  \end{aligned}
+  \label{eq:MB_scale_factors}
+    e_1 = (a + z) \lt[ \lt( \pd[\lambda]{i} \cos \varphi \rt)^2 + \lt( \pd[\varphi]{i} \rt)^2 \rt]^{1/2} \quad e_2 = (a + z) \lt[ \lt( \pd[\lambda]{j} \cos \varphi \rt)^2 + \lt( \pd[\varphi]{j} \rt)^2 \rt]^{1/2} \quad e_3 = \lt( \pd[z]{k} \rt)
 \end{equation}
 
-% >>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!tb]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_I_earth_referential}
-    \caption{
-      \protect\label{fig:referential}
-      the geographical coordinate system $(\lambda,\varphi,z)$ and the curvilinear
-      coordinate system $(i,j,k)$.
-    }
-  \end{center}
+\begin{figure}
+  \centering
+  \includegraphics[width=0.33\textwidth]{MB_earth_referential}
+  \caption[Geographical and curvilinear coordinate systems]{
+    the geographical coordinate system $(\lambda,\varphi,z)$ and the curvilinear
+    coordinate system $(i,j,k)$.}
+  \label{fig:MB_referential}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 
 Since the ocean depth is far smaller than the earth's radius, $a + z$, can be replaced by $a$ in
-(\autoref{eq:scale_factors}) (thin-shell approximation).
+(\autoref{eq:MB_scale_factors}) (thin-shell approximation).
 The resulting horizontal scale factors $e_1$, $e_2$  are independent of $k$ while
 the vertical scale factor is a single function of $k$ as $k$ is parallel to $z$.
 The scalar and vector operators that appear in the primitive equations
-(\autoref{eq:PE_dyn} to \autoref{eq:PE_eos}) can be written in the tensorial form,
+(\autoref{eq:MB_PE_dyn} to \autoref{eq:MB_PE_eos}) can then be written in the tensorial form,
 invariant in any orthogonal horizontal curvilinear coordinate system transformation:
 \begin{subequations}
-  % \label{eq:PE_discrete_operators}
-  \begin{gather}
-    \label{eq:PE_grad}
-    \nabla q =   \frac{1}{e_1} \pd[q]{i} \; \vect i
-               + \frac{1}{e_2} \pd[q]{j} \; \vect j
-               + \frac{1}{e_3} \pd[q]{k} \; \vect k \\
-    \label{eq:PE_div}
-    \nabla \cdot \vect A =   \frac{1}{e_1 \; e_2} \lt[ \pd[(e_2 \; a_1)]{\partial i} + \pd[(e_1 \; a_2)]{j} \rt]
-                           + \frac{1}{e_3} \lt[ \pd[a_3]{k} \rt]
-  \end{gather}
-  \begin{multline}
-    \label{eq:PE_curl}
-      \nabla \times \vect{A} =   \lt[ \frac{1}{e_2} \pd[a_3]{j} - \frac{1}{e_3} \pd[a_2]{k}   \rt] \vect i \\
-                               + \lt[ \frac{1}{e_3} \pd[a_1]{k} - \frac{1}{e_1} \pd[a_3]{i}   \rt] \vect j \\
-                               + \frac{1}{e_1 e_2} \lt[ \pd[(e_2 a_2)]{i} - \pd[(e_1 a_1)]{j} \rt] \vect k
-  \end{multline}
-  \begin{gather}
-    \label{eq:PE_lap}
-    \Delta q = \nabla \cdot (\nabla q) \\
-    \label{eq:PE_lap_vector}
-    \Delta \vect A = \nabla (\nabla \cdot \vect A) - \nabla \times (\nabla \times \vect A)
-  \end{gather}
+  % \label{eq:MB_discrete_operators}
+  \begin{align}
+    \label{eq:MB_grad}
+    \nabla q &=   \frac{1}{e_1} \pd[q]{i} \; \vect i + \frac{1}{e_2} \pd[q]{j} \; \vect j + \frac{1}{e_3} \pd[q]{k} \; \vect k \\
+    \label{eq:MB_div}
+    \nabla \cdot \vect A &=   \frac{1}{e_1 \; e_2} \lt[ \pd[(e_2 \; a_1)]{\partial i} + \pd[(e_1 \; a_2)]{j} \rt] + \frac{1}{e_3} \lt[ \pd[a_3]{k} \rt] \\
+    \label{eq:MB_curl}
+      \nabla \times \vect{A} &=   \lt[ \frac{1}{e_2} \pd[a_3]{j} - \frac{1}{e_3} \pd[a_2]{k}   \rt] \vect i + \lt[ \frac{1}{e_3} \pd[a_1]{k} - \frac{1}{e_1} \pd[a_3]{i}   \rt] \vect j + \frac{1}{e_1 e_2} \lt[ \pd[(e_2 a_2)]{i} - \pd[(e_1 a_1)]{j} \rt] \vect k \\
+    \label{eq:MB_lap}
+    \Delta q &= \nabla \cdot (\nabla q) \\
+    \label{eq:MB_lap_vector}
+    \Delta \vect A &= \nabla (\nabla \cdot \vect A) - \nabla \times (\nabla \times \vect A)
+  \end{align}
 \end{subequations}
-where $q$ is a scalar quantity and $\vect A = (a_1,a_2,a_3)$ a vector in the $(i,j,k)$ coordinates system.
-
-% -------------------------------------------------------------------------------------------------------------
-% Continuous Model Equations
-% -------------------------------------------------------------------------------------------------------------
+where $q$ is a scalar quantity and
+$\vect A = (a_1,a_2,a_3)$ a vector in the $(i,j,k)$ coordinates system.
+
+%% =================================================================================================
 \subsection{Continuous model equations}
-\label{subsec:PE_zco_Eq}
+\label{subsec:MB_zco_Eq}
 
 In order to express the Primitive Equations in tensorial formalism,
-it is necessary to compute the horizontal component of the non-linear and viscous terms of the equation using
-\autoref{eq:PE_grad}) to \autoref{eq:PE_lap_vector}.
-Let us set $\vect U = (u,v,w) = \vect U_h + w \; \vect k $, the velocity in the $(i,j,k)$ coordinates system and
-define the relative vorticity $\zeta$ and the divergence of the horizontal velocity field $\chi$, by:
+it is necessary to compute the horizontal component of the non-linear and viscous terms of
+the equation using \autoref{eq:MB_grad}) to \autoref{eq:MB_lap_vector}.
+Let us set $\vect U = (u,v,w) = \vect U_h + w \; \vect k $,
+the velocity in the $(i,j,k)$ coordinates system,
+and define the relative vorticity $\zeta$ and the divergence of the horizontal velocity field $\chi$,
+by:
 \begin{gather}
-  \label{eq:PE_curl_Uh}
+  \label{eq:MB_curl_Uh}
   \zeta = \frac{1}{e_1 e_2} \lt[ \pd[(e_2 \, v)]{i} - \pd[(e_1 \, u)]{j} \rt] \\
-  \label{eq:PE_div_Uh}
+  \label{eq:MB_div_Uh}
   \chi  = \frac{1}{e_1 e_2} \lt[ \pd[(e_2 \, u)]{i} + \pd[(e_1 \, v)]{j} \rt]
 \end{gather}
 
-Using the fact that the horizontal scale factors $e_1$ and $e_2$ are independent of $k$ and that
+Using again the fact that the horizontal scale factors $e_1$ and $e_2$ are independent of $k$ and that
 $e_3$  is a function of the single variable $k$,
-$NLT$ the nonlinear term of \autoref{eq:PE_dyn} can be transformed as follows:
-\begin{alignat*}{2}
-  &NLT &=   &\lt[ (\nabla \times {\vect U}) \times {\vect U} + \frac{1}{2} \nabla \lt( {\vect U}^2 \rt) \rt]_h \\
-  &    &=   &\lt(
-    \begin{array}{*{20}c}
-                \lt[ \frac{1}{e_3} \pd[u]{k} - \frac{1}{e_1} \pd[w]{i} \rt] w - \zeta \; v   \\
-                \zeta \; u - \lt[ \frac{1}{e_2} \pd[w]{j} - \frac{1}{e_3} \pd[v]{k} \rt] \ w
-    \end{array}
-                                                                                             \rt)
-          + \frac{1}{2} \lt(
-	 \begin{array}{*{20}c}
-                             \frac{1}{e_1} \pd[(u^2 + v^2 + w^2)]{i} \\
-                             \frac{1}{e_2} \pd[(u^2 + v^2 + w^2)]{j}
-    \end{array}
-                                                                     \rt) \\
-  &    &=   &\lt(
-    \begin{array}{*{20}c}
-                  -\zeta \; v \\
-                   \zeta \; u
-    \end{array}
-                              \rt)
-          + \frac{1}{2} \lt(
-	 \begin{array}{*{20}c}
-                             \frac{1}{e_1} \pd[(u^2 + v^2)]{i} \\
-                             \frac{1}{e_2} \pd[(u^2 + v^2)]{j}
-    \end{array}
-                                                               \rt) \\
-  &    &  &+ \frac{1}{e_3} \lt(
-	 \begin{array}{*{20}c}
-                                w \; \pd[u]{k} \\
-                                w \; \pd[v]{k}
-    \end{array}
-                                               \rt)
-           - \lt(
-	 \begin{array}{*{20}c}
-	               \frac{w}{e_1} \pd[w]{i} - \frac{1}{2 e_1} \pd[w^2]{i} \\
-                  \frac{w}{e_2} \pd[w]{j} - \frac{1}{2 e_2} \pd[w^2]{j}
-    \end{array}
-                                                                        \rt)
-\end{alignat*}
-The last term of the right hand side is obviously zero, and thus the nonlinear term of
-\autoref{eq:PE_dyn} is written in the $(i,j,k)$ coordinate system:
+$NLT$ the nonlinear term of \autoref{eq:MB_PE_dyn} can be transformed as follows:
+\begin{align*}
+  NLT &= \lt[ (\nabla \times {\vect U}) \times {\vect U} + \frac{1}{2} \nabla \lt( {\vect U}^2 \rt) \rt]_h \\
+      &= \lt(
+        \begin{array}{*{20}c}
+          \lt[ \frac{1}{e_3} \pd[u]{k} - \frac{1}{e_1} \pd[w]{i} \rt] w - \zeta \; v   \\
+          \zeta \; u - \lt[ \frac{1}{e_2} \pd[w]{j} - \frac{1}{e_3} \pd[v]{k} \rt] \ w
+        \end{array}
+  \rt)
+  + \frac{1}{2} \lt(
+  \begin{array}{*{20}c}
+    \frac{1}{e_1} \pd[(u^2 + v^2 + w^2)]{i} \\
+    \frac{1}{e_2} \pd[(u^2 + v^2 + w^2)]{j}
+  \end{array}
+  \rt) \\
+      &= \lt(
+        \begin{array}{*{20}c}
+          -\zeta \; v \\
+          \zeta \; u
+        \end{array}
+  \rt)
+  + \frac{1}{2} \lt(
+  \begin{array}{*{20}c}
+    \frac{1}{e_1} \pd[(u^2 + v^2)]{i} \\
+    \frac{1}{e_2} \pd[(u^2 + v^2)]{j}
+  \end{array}
+  \rt)
+  + \frac{1}{e_3} \lt(
+  \begin{array}{*{20}c}
+    w \; \pd[u]{k} \\
+    w \; \pd[v]{k}
+  \end{array}
+  \rt)
+  - \lt(
+  \begin{array}{*{20}c}
+    \frac{w}{e_1} \pd[w]{i} - \frac{1}{2 e_1} \pd[w^2]{i} \\
+    \frac{w}{e_2} \pd[w]{j} - \frac{1}{2 e_2} \pd[w^2]{j}
+  \end{array}
+  \rt)
+\end{align*}
+The last term of the right hand side is obviously zero,
+and thus the \textbf{N}on\textbf{L}inear \textbf{T}erm ($NLT$) of \autoref{eq:MB_PE_dyn} is written in
+the $(i,j,k)$ coordinate system:
 \begin{equation}
-  \label{eq:PE_vector_form}
-  NLT =   \zeta \; \vect k \times \vect U_h + \frac{1}{2} \nabla_h \lt( \vect U_h^2 \rt)
-        + \frac{1}{e_3} w \pd[\vect U_h]{k}
+  \label{eq:MB_vector_form}
+  NLT = \zeta \; \vect k \times \vect U_h + \frac{1}{2} \nabla_h \lt( \vect U_h^2 \rt) + \frac{1}{e_3} w \pd[\vect U_h]{k}
 \end{equation}
 
 This is the so-called \textit{vector invariant form} of the momentum advection term.
 For some purposes, it can be advantageous to write this term in the so-called flux form,
-\ie to write it as the divergence of fluxes.
-For example, the first component of \autoref{eq:PE_vector_form} (the $i$-component) is transformed as follows:
-\begin{alignat*}{2}
+\ie\ to write it as the divergence of fluxes.
+For example,
+the first component of \autoref{eq:MB_vector_form} (the $i$-component) is transformed as follows:
+\begin{alignat*}{3}
   &NLT_i &= &- \zeta \; v + \frac{1}{2 \; e_1} \pd[ (u^2 + v^2) ]{i} + \frac{1}{e_3} w \ \pd[u]{k} \\
-  &      &=  &\frac{1}{e_1 \; e_2} \lt( -v \pd[(e_2 \, v)]{i} + v \pd[(e_1 \, u)]{j} \rt)
-            + \frac{1}{e_1 e_2} \lt( e_2 \; u \pd[u]{i} + e_2 \; v \pd[v]{i} \rt) \\
-  &      & &+ \frac{1}{e_3} \lt( w \; \pd[u]{k} \rt) \\
-  &      &=  &\frac{1}{e_1 \; e_2} \lt[ - \lt( v^2 \pd[e_2]{i} + e_2 \, v \pd[v]{i} \rt)
-                                     + \lt( \pd[ \lt( e_1 \, u \, v \rt)]{j} -         e_1 \, u \pd[v]{j} \rt) \rt. \\
-  &      &                       &\lt. + \lt( \pd[ \lt( e_2 \, u \, u \rt)]{i} - u \pd[ \lt( e_2 u \rt)]{i} \rt)
-                                     + e_2 v \pd[v]{i}                                                         \rt] \\
+  &      &= &\frac{1}{e_1 \; e_2} \lt( -v \pd[(e_2 \, v)]{i} + v \pd[(e_1 \, u)]{j} \rt) + \frac{1}{e_1 e_2} \lt( e_2 \; u \pd[u]{i} + e_2 \; v \pd[v]{i} \rt) + \frac{1}{e_3} \lt( w \; \pd[u]{k} \rt) \\
+  &      &= &\frac{1}{e_1 \; e_2} \lt[ - \lt( v^2 \pd[e_2]{i} + e_2 \, v \pd[v]{i} \rt) + \lt( \pd[ \lt( e_1 \, u \, v \rt)]{j} - e_1 \, u \pd[v]{j} \rt) \rt. \lt. + \lt( \pd[ \lt( e_2 \, u \, u \rt)]{i} - u \pd[ \lt( e_2 u \rt)]{i} \rt) + e_2 v \pd[v]{i} \rt] \\
   &      & &+ \frac{1}{e_3} \lt( \pd[(w \, u)]{k} - u \pd[w]{k} \rt) \\
-  &      &=  &\frac{1}{e_1 \; e_2} \lt( \pd[(e_2 \, u \, u)]{i} + \pd[(e_1 \, u \, v)]{j} \rt)
-            + \frac{1}{e_3} \pd[(w \, u)]{k} \\
-  &      & &+ \frac{1}{e_1 e_2} \lt[ - u \lt( \pd[(e_1 v)]{j} - v \, \pd[e_1]{j} \rt)
-                                  - u \pd[(e_2 u)]{i}                              \rt]
-            - \frac{1}{e_3} \pd[w]{k} u \\
+  &      &= &\frac{1}{e_1 \; e_2} \lt( \pd[(e_2 \, u \, u)]{i} + \pd[(e_1 \, u \, v)]{j} \rt) + \frac{1}{e_3} \pd[(w \, u)]{k} + \frac{1}{e_1 e_2} \lt[ - u \lt( \pd[(e_1 v)]{j} - v \, \pd[e_1]{j} \rt) - u \pd[(e_2 u)]{i} \rt] - \frac{1}{e_3} \pd[w]{k} u \\
   &      & &+ \frac{1}{e_1 e_2} \lt( - v^2 \pd[e_2]{i} \rt) \\
-  &      &= &\nabla \cdot (\vect U \, u) - (\nabla \cdot \vect U) \ u
-            + \frac{1}{e_1 e_2} \lt( -v^2 \pd[e_2]{i} + u v \, \pd[e_1]{j} \rt) \\
-  \intertext{as $\nabla \cdot {\vect U} \; = 0$ (incompressibility) it comes:}
+  &      &= &\nabla \cdot (\vect U \, u) - (\nabla \cdot \vect U) \ u + \frac{1}{e_1 e_2} \lt( -v^2 \pd[e_2]{i} + u v \, \pd[e_1]{j} \rt) \\
+  \shortintertext{as $\nabla \cdot {\vect U} \; = 0$ (incompressibility) it becomes:}
   &      &= &\, \nabla \cdot (\vect U \, u) + \frac{1}{e_1 e_2} \lt( v \; \pd[e_2]{i} - u \; \pd[e_1]{j} \rt) (-v)
 \end{alignat*}
@@ -462,25 +446,27 @@
 The flux form of the momentum advection term is therefore given by:
 \begin{equation}
-  \label{eq:PE_flux_form}
-  NLT =   \nabla \cdot \lt(
-    \begin{array}{*{20}c}
-                            \vect U \, u \\
-                            \vect U \, v
-    \end{array}
-                                         \rt)
-        + \frac{1}{e_1 e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt) \vect k \times \vect U_h
+  \label{eq:MB_flux_form}
+  NLT = \nabla \cdot \lt(
+  \begin{array}{*{20}c}
+    \vect U \, u \\
+    \vect U \, v
+  \end{array}
+  \rt)
+  + \frac{1}{e_1 e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt) \vect k \times \vect U_h
 \end{equation}
 
 The flux form has two terms,
-the first one is expressed as the divergence of momentum fluxes (hence the flux form name given to this formulation)
-and the second one is due to the curvilinear nature of the coordinate system used.
-The latter is called the \textit{metric} term and can be viewed as a modification of the Coriolis parameter: 
+the first one is expressed as the divergence of momentum fluxes
+(hence the flux form name given to this formulation) and
+the second one is due to the curvilinear nature of the coordinate system used.
+The latter is called the \textit{metric} term and can be viewed as
+a modification of the Coriolis parameter:
 \[
-  % \label{eq:PE_cor+metric}
+  % \label{eq:MB_cor+metric}
   f \to f + \frac{1}{e_1 e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt)
 \]
 
 Note that in the case of geographical coordinate,
-\ie when $(i,j) \to (\lambda,\varphi)$ and $(e_1,e_2) \to (a \, \cos \varphi,a)$,
+\ie\ when $(i,j) \to (\lambda,\varphi)$ and $(e_1,e_2) \to (a \, \cos \varphi,a)$,
 we recover the commonly used modification of the Coriolis parameter $f \to f + (u / a) \tan \varphi$.
 
@@ -488,77 +474,59 @@
 the following tensorial formalism:
 
-\begin{itemize}
-\item
-  \textbf{Vector invariant form of the momentum equations}:
+\begin{description}
+\item [Vector invariant form of the momentum equations]
   \begin{equation}
-    \label{eq:PE_dyn_vect}
-    \begin{split}
-    % \label{eq:PE_dyn_vect_u}
-      \pd[u]{t} = &+ (\zeta + f) \, v - \frac{1}{2 e_1} \pd[]{i} (u^2 + v^2)
-                   - \frac{1}{e_3} w \pd[u]{k} - \frac{1}{e_1} \pd[]{i} \lt( \frac{p_s + p_h}{\rho_o} \rt) \\
-                  &+ D_u^{\vect U} + F_u^{\vect U} \\
-      \pd[v]{t} = &- (\zeta + f) \, u - \frac{1}{2 e_2} \pd[]{j} (u^2 + v^2)
-                   - \frac{1}{e_3} w \pd[v]{k} - \frac{1}{e_2} \pd[]{j} \lt( \frac{p_s + p_h}{\rho_o} \rt) \\ 
-                  &+ D_v^{\vect U} + F_v^{\vect U}
-    \end{split}
+    \label{eq:MB_dyn_vect}
+    \begin{gathered}
+    % \label{eq:MB_dyn_vect_u}
+      \pd[u]{t} = + (\zeta + f) \, v - \frac{1}{2 e_1} \pd[]{i} (u^2 + v^2) - \frac{1}{e_3} w \pd[u]{k} - \frac{1}{e_1} \pd[]{i} \lt( \frac{p_s + p_h}{\rho_o} \rt) + D_u^{\vect U} + F_u^{\vect U} \\
+      \pd[v]{t} = - (\zeta + f) \, u - \frac{1}{2 e_2} \pd[]{j} (u^2 + v^2) - \frac{1}{e_3} w \pd[v]{k} - \frac{1}{e_2} \pd[]{j} \lt( \frac{p_s + p_h}{\rho_o} \rt) + D_v^{\vect U} + F_v^{\vect U}
+    \end{gathered}
   \end{equation}
-\item
-  \textbf{flux form of the momentum equations}:
-  % \label{eq:PE_dyn_flux}
-  \begin{multline*}
-    % \label{eq:PE_dyn_flux_u}
-    \pd[u]{t} = + \lt[ f + \frac{1}{e_1 \; e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt) \rt] \, v \\
-                - \frac{1}{e_1 \; e_2} \lt( \pd[(e_2 \, u \, u)]{i} + \pd[(e_1 \, v \, u)]{j} \rt) \\
-                - \frac{1}{e_3} \pd[(w \, u)]{k} - \frac{1}{e_1} \pd[]{i} \lt( \frac{p_s + p_h}{\rho_o} \rt)
-                + D_u^{\vect U} + F_u^{\vect U}
-  \end{multline*}
-  \begin{multline*}
-    % \label{eq:PE_dyn_flux_v}
-    \pd[v]{t} = - \lt[ f + \frac{1}{e_1 \; e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt) \rt] \, u \\
-                + \frac{1}{e_1 \; e_2} \lt( \pd[(e_2 \, u \, v)]{i} + \pd[(e_1 \, v \, v)]{j} \rt) \\
-                - \frac{1}{e_3} \pd[(w \, v)]{k} - \frac{1}{e_2} \pd[]{j} \lt( \frac{p_s + p_h}{\rho_o} \rt)
-                + D_v^{\vect U} + F_v^{\vect U}
-  \end{multline*}
-  where $\zeta$, the relative vorticity, is given by \autoref{eq:PE_curl_Uh} and $p_s$, the surface pressure,
-  is given by:
+\item [Flux form of the momentum equations]
+  % \label{eq:MB_dyn_flux}
+  \begin{alignat*}{2}
+    % \label{eq:MB_dyn_flux_u}
+    \pd[u]{t} = &+ \lt[ f + \frac{1}{e_1 \; e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt) \rt] \, v - \frac{1}{e_1 \; e_2} \lt( \pd[(e_2 \, u \, u)]{i} + \pd[(e_1 \, v \, u)]{j} \rt) - \frac{1}{e_3} \pd[(w \, u)]{k} \\
+    &- \frac{1}{e_1} \pd[]{i} \lt( \frac{p_s + p_h}{\rho_o} \rt) + D_u^{\vect U} + F_u^{\vect U}
+  \end{alignat*}
+  \begin{alignat*}{2}
+    % \label{eq:MB_dyn_flux_v}
+    \pd[v]{t} = &- \lt[ f + \frac{1}{e_1 \; e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt) \rt] \, u - \frac{1}{e_1 \; e_2} \lt( \pd[(e_2 \, u \, v)]{i} + \pd[(e_1 \, v \, v)]{j} \rt) - \frac{1}{e_3} \pd[(w \, v)]{k} \\
+    &- \frac{1}{e_2} \pd[]{j} \lt( \frac{p_s + p_h}{\rho_o} \rt) + D_v^{\vect U} + F_v^{\vect U}
+  \end{alignat*}
+  where $\zeta$, the relative vorticity, is given by \autoref{eq:MB_curl_Uh} and
+  $p_s$, the surface pressure, is given by:
   \[
-  % \label{eq:PE_spg}
+  % \label{eq:MB_spg}
     p_s = \rho \,g \, \eta
   \]
-  with $\eta$ is solution of \autoref{eq:PE_ssh}.
+  and $\eta$ is the solution of \autoref{eq:MB_ssh}.
 
   The vertical velocity and the hydrostatic pressure are diagnosed from the following equations:
   \[
-  % \label{eq:w_diag}
-    \pd[w]{k} = - \chi \; e_3 \qquad 
-  % \label{eq:hp_diag}
+  % \label{eq:MB_w_diag}
+    \pd[w]{k} = - \chi \; e_3 \qquad
+  % \label{eq:MB_hp_diag}
     \pd[p_h]{k} = - \rho \; g \; e_3
   \]
-  where the divergence of the horizontal velocity, $\chi$ is given by \autoref{eq:PE_div_Uh}.
-\item \textit{tracer equations}:
-  \[
-    %\label{eq:S}
-    \pd[T]{t} = - \frac{1}{e_1 e_2} \lt[ \pd[(e_2 T \, u)]{i} + \pd[(e_1 T \, v)]{j} \rt]
-                - \frac{1}{e_3} \pd[(T \, w)]{k} + D^T + F^T \\
-    %\label{eq:T}
-    \pd[S]{t} = - \frac{1}{e_1 e_2} \lt[ \pd[(e_2 S \, u)]{i} + \pd[(e_1 S \, v)]{j} \rt]
-                - \frac{1}{e_3} \pd[(S \, w)]{k} + D^S + F^S
-    %\label{eq:rho}
+  where the divergence of the horizontal velocity, $\chi$ is given by \autoref{eq:MB_div_Uh}.
+\item [Tracer equations]
+  \begin{gather*}
+    \pd[T]{t} = - \frac{1}{e_1 e_2} \lt[ \pd[(e_2 T \, u)]{i} + \pd[(e_1 T \, v)]{j} \rt] - \frac{1}{e_3} \pd[(T \, w)]{k} + D^T + F^T \\
+    \pd[S]{t} = - \frac{1}{e_1 e_2} \lt[ \pd[(e_2 S \, u)]{i} + \pd[(e_1 S \, v)]{j} \rt] - \frac{1}{e_3} \pd[(S \, w)]{k} + D^S + F^S \\
     \rho = \rho \big( T,S,z(k) \big)
-  \]
-\end{itemize}
-
-The expression of $\vect D^{U}$, $D^{S}$ and $D^{T}$ depends on the subgrid scale parameterisation used.
-It will be defined in \autoref{eq:PE_zdf}.
+  \end{gather*}
+\end{description}
+
+The expression of $\vect D^{U}$, $D^{S}$ and $D^{T}$ depends on
+the subgrid scale parameterisation used.
+It will be defined in \autoref{eq:MB_zdf}.
 The nature and formulation of $\vect F^{\vect U}$, $F^T$ and $F^S$, the surface forcing terms,
 are discussed in \autoref{chap:SBC}.
 
-\newpage
-
-% ================================================================
-% Curvilinear generalised vertical coordinate System
-% ================================================================
+%% =================================================================================================
 \section{Curvilinear generalised vertical coordinate system}
-\label{sec:PE_gco}
+\label{sec:MB_gco}
 
 The ocean domain presents a huge diversity of situation in the vertical.
@@ -567,47 +535,51 @@
 varying from more than 6,000 meters in abyssal trenches to zero at the coast.
 Last but not least, the ocean stratification exerts a strong barrier to vertical motions and mixing.
-Therefore, in order to represent the ocean with respect to
-the first point a space and time dependent vertical coordinate that follows the variation of the sea surface height
-\eg an \zstar-coordinate;
-for the second point, a space variation to fit the change of bottom topography
-\eg a terrain-following or $\sigma$-coordinate;
-and for the third point, one will be tempted to use a space and time dependent coordinate that
-follows the isopycnal surfaces, \eg an isopycnic coordinate.
-
-In order to satisfy two or more constrains one can even be tempted to mixed these coordinate systems, as in
-HYCOM (mixture of $z$-coordinate at the surface, isopycnic coordinate in the ocean interior and $\sigma$ at
-the ocean bottom) \citep{chassignet.smith.ea_JPO03} or
-OPA (mixture of $z$-coordinate in vicinity the surface and steep topography areas and $\sigma$-coordinate elsewhere)
-\citep{madec.delecluse.ea_JPO96} among others.
+Therefore, in order to represent the ocean with respect to the first point
+a space and time dependent vertical coordinate that follows the variation of the sea surface height
+\eg\ an \zstar-coordinate;
+for the second point,
+a space variation to fit the change of bottom topography
+\eg\ a terrain-following or $\sigma$-coordinate;
+and for the third point,
+one will be tempted to use a space and time dependent coordinate that follows the isopycnal surfaces,
+\eg\ an isopycnic coordinate.
+
+In order to satisfy two or more constraints one can even be tempted to mixed these coordinate systems,
+as in HYCOM (mixture of $z$-coordinate at the surface, isopycnic coordinate in the ocean interior and
+$\sigma$ at the ocean bottom) \citep{chassignet.smith.ea_JPO03} or
+OPA (mixture of $z$-coordinate in vicinity the surface and steep topography areas and
+$\sigma$-coordinate elsewhere) \citep{madec.delecluse.ea_JPO96} among others.
 
 In fact one is totally free to choose any space and time vertical coordinate by
 introducing an arbitrary vertical coordinate :
 \begin{equation}
-  \label{eq:PE_s}
+  \label{eq:MB_s}
   s = s(i,j,k,t)
 \end{equation}
-with the restriction that the above equation gives a single-valued monotonic relationship between $s$ and $k$,
-when $i$, $j$ and $t$ are held fixed.
-\autoref{eq:PE_s} is a transformation from the $(i,j,k,t)$ coordinate system with independent variables into
+with the restriction that the above equation gives a single-valued monotonic relationship between
+$s$ and $k$, when $i$, $j$ and $t$ are held fixed.
+\autoref{eq:MB_s} is a transformation from
+the $(i,j,k,t)$ coordinate system with independent variables into
 the $(i,j,s,t)$ generalised coordinate system with $s$ depending on the other three variables through
-\autoref{eq:PE_s}.
+\autoref{eq:MB_s}.
 This so-called \textit{generalised vertical coordinate} \citep{kasahara_MWR74} is in fact
-an Arbitrary Lagrangian--Eulerian (ALE) coordinate.
-Indeed, choosing an expression for $s$ is an arbitrary choice that determines
-which part of the vertical velocity (defined from a fixed referential) will cross the levels (Eulerian part) and
-which part will be used to move them (Lagrangian part).
-The coordinate is also sometime referenced as an adaptive coordinate \citep{hofmeister.burchard.ea_OM10},
-since the coordinate system is adapted in the course of the simulation.
+an \textbf{A}rbitrary \textbf{L}agrangian--\textbf{E}ulerian (ALE) coordinate.
+Indeed, one has a great deal of freedom in the choice of expression for $s$.
+The choice determines which part of the vertical velocity (defined from a fixed referential)
+will cross the levels (Eulerian part) and which part will be used to move them (Lagrangian part).
+The coordinate is also sometimes referenced as an adaptive coordinate
+\citep{hofmeister.burchard.ea_OM10}, since the coordinate system is adapted in
+the course of the simulation.
 Its most often used implementation is via an ALE algorithm,
 in which a pure lagrangian step is followed by regridding and remapping steps,
-the later step implicitly embedding the vertical advection
+the latter step implicitly embedding the vertical advection
 \citep{hirt.amsden.ea_JCP74, chassignet.smith.ea_JPO03, white.adcroft.ea_JCP09}.
 Here we follow the \citep{kasahara_MWR74} strategy:
-a regridding step (an update of the vertical coordinate) followed by an eulerian step with
+a regridding step (an update of the vertical coordinate) followed by an Eulerian step with
 an explicit computation of vertical advection relative to the moving s-surfaces.
 
-%\gmcomment{
-%A key point here is that the $s$-coordinate depends on $(i,j)$ ==> horizontal pressure gradient...
-the generalized vertical coordinates used in ocean modelling are not orthogonal,
+\cmtgm{A key point here is that the $s$-coordinate depends on $(i,j)$
+  ==> horizontal pressure gradient...}
+The generalized vertical coordinates used in ocean modelling are not orthogonal,
 which contrasts with many other applications in mathematical physics.
 Hence, it is useful to keep in mind the following properties that may seem odd on initial encounter.
@@ -615,9 +587,10 @@
 The horizontal velocity in ocean models measures motions in the horizontal plane,
 perpendicular to the local gravitational field.
-That is, horizontal velocity is mathematically the same regardless the vertical coordinate, be it geopotential,
-isopycnal, pressure, or terrain following.
+That is, horizontal velocity is mathematically the same regardless of the vertical coordinate,
+be it geopotential, isopycnal, pressure, or terrain following.
 The key motivation for maintaining the same horizontal velocity component is that
 the hydrostatic and geostrophic balances are dominant in the large-scale ocean.
-Use of an alternative quasi -horizontal velocity, for example one oriented parallel to the generalized surface,
+Use of an alternative quasi -horizontal velocity,
+for example one oriented parallel to the generalized surface,
 would lead to unacceptable numerical errors.
 Correspondingly, the vertical direction is anti -parallel to the gravitational force in
@@ -626,12 +599,14 @@
 the surface of a constant generalized vertical coordinate.
 
-It is the method used to measure transport across the generalized vertical coordinate surfaces which differs between
-the vertical coordinate choices.
-That is, computation of the dia-surface velocity component represents the fundamental distinction between
+It is the method used to measure transport across the generalized vertical coordinate surfaces which
+differs between the vertical coordinate choices.
+That is,
+computation of the dia-surface velocity component represents the fundamental distinction between
 the various coordinates.
-In some models, such as geopotential, pressure, and terrain following, this transport is typically diagnosed from
-volume or mass conservation.
-In other models, such as isopycnal layered models, this transport is prescribed based on assumptions about
-the physical processes producing a flux across the layer interfaces.
+In some models, such as geopotential, pressure, and terrain following,
+this transport is typically diagnosed from volume or mass conservation.
+In other models, such as isopycnal layered models,
+this transport is prescribed based on assumptions about the physical processes producing
+a flux across the layer interfaces.
 
 In this section we first establish the PE in the generalised vertical $s$-coordinate,
@@ -639,89 +614,71 @@
 %}
 
-% -------------------------------------------------------------------------------------------------------------
-% The s-coordinate Formulation
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \subsection{\textit{S}-coordinate formulation}
 
-Starting from the set of equations established in \autoref{sec:PE_zco} for the special case $k = z$ and
-thus $e_3 = 1$, we introduce an arbitrary vertical coordinate $s = s(i,j,k,t)$,
+Starting from the set of equations established in \autoref{sec:MB_zco} for
+the special case $k = z$ and thus $e_3 = 1$,
+we introduce an arbitrary vertical coordinate $s = s(i,j,k,t)$,
 which includes $z$-, \zstar- and $\sigma$-coordinates as special cases
 ($s = z$, $s = \zstar$, and $s = \sigma = z / H$ or $ = z / \lt( H + \eta \rt)$, resp.).
-A formal derivation of the transformed equations is given in \autoref{apdx:A}.
-Let us define the vertical scale factor by $e_3 = \partial_s z$  ($e_3$ is now a function of $(i,j,k,t)$ ),
+A formal derivation of the transformed equations is given in \autoref{apdx:SCOORD}.
+Let us define the vertical scale factor by $e_3 = \partial_s z$
+($e_3$ is now a function of $(i,j,k,t)$ ),
 and the slopes in the $(i,j)$ directions between $s$- and $z$-surfaces by:
 \begin{equation}
-  \label{eq:PE_sco_slope}
+  \label{eq:MB_sco_slope}
   \sigma_1 = \frac{1}{e_1} \; \lt. \pd[z]{i} \rt|_s \quad \text{and} \quad
   \sigma_2 = \frac{1}{e_2} \; \lt. \pd[z]{j} \rt|_s
 \end{equation}
-We also introduce $\omega$, a dia-surface velocity component, defined as the velocity 
-relative to the moving $s$-surfaces and normal to them:
+We also introduce $\omega$, a dia-surface velocity component,
+defined as the velocity relative to the moving $s$-surfaces and normal to them:
 \[
-  % \label{eq:PE_sco_w}
-  \omega = w - e_3 \, \pd[s]{t} - \sigma_1 \, u - \sigma_2 \, v
+  % \label{eq:MB_sco_w}
+  \omega = w -  \, \lt. \pd[z]{t} \rt|_s - \sigma_1 \, u - \sigma_2 \, v
 \]
 
-The equations solved by the ocean model \autoref{eq:PE} in $s$-coordinate can be written as follows
-(see \autoref{sec:A_momentum}):
-
-\begin{itemize}
-\item \textbf{Vector invariant form of the momentum equation}:
-  \begin{multline*}
-  % \label{eq:PE_sco_u_vector}
-    \pd[u]{t} = + (\zeta + f) \, v - \frac{1}{2 \, e_1} \pd[]{i} (u^2 + v^2) - \frac{1}{e_3} \omega \pd[u]{k} \\
-                - \frac{1}{e_1} \pd[]{i} \lt( \frac{p_s + p_h}{\rho_o} \rt) + g \frac{\rho}{\rho_o} \sigma_1
-                + D_u^{\vect U} + F_u^{\vect U}
-  \end{multline*}
-  \begin{multline*}
-  % \label{eq:PE_sco_v_vector}
-    \pd[v]{t} = - (\zeta + f) \, u - \frac{1}{2 \, e_2} \pd[]{j}(u^2 + v^2) - \frac{1}{e_3} \omega \pd[v]{k} \\
-                - \frac{1}{e_2} \pd[]{j} \lt( \frac{p_s + p_h}{\rho_o} \rt) + g \frac{\rho}{\rho_o} \sigma_2
-                + D_v^{\vect U} + F_v^{\vect U}
-  \end{multline*}
-\item \textbf{Flux form of the momentum equation}:
-  \begin{multline*}
-  % \label{eq:PE_sco_u_flux}
-    \frac{1}{e_3} \pd[(e_3 \, u)]{t} = + \lt[ f + \frac{1}{e_1 \; e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt) \rt] \, v \\
-                                       - \frac{1}{e_1 \; e_2 \; e_3} \lt( \pd[(e_2 \, e_3 \, u \, u)]{i} + \pd[(e_1 \, e_3 \, v \, u)]{j} \rt) \\
-                                       - \frac{1}{e_3} \pd[(\omega \, u)]{k}
-                                       - \frac{1}{e_1} \pd[]{i} \lt( \frac{p_s + p_h}{\rho_o} \rt)
-                                       + g \frac{\rho}{\rho_o} \sigma_1 + D_u^{\vect U} + F_u^{\vect U}
-  \end{multline*}
-  \begin{multline*}
-  % \label{eq:PE_sco_v_flux}
-    \frac{1}{e_3} \pd[(e_3 \, v)]{t} = - \lt[ f + \frac{1}{e_1 \; e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt) \rt] \, u \\
-                                       - \frac{1}{e_1 \; e_2 \; e_3} \lt( \pd[( e_2 \; e_3 \, u \, v)]{i} + \pd[(e_1 \; e_3 \, v \, v)]{j} \rt) \\
-                                       - \frac{1}{e_3} \pd[(\omega \, v)]{k}
-                                       - \frac{1}{e_2} \pd[]{j} \lt( \frac{p_s + p_h}{\rho_o} \rt)
-                                       + g \frac{\rho}{\rho_o}\sigma_2 + D_v^{\vect U} + F_v^{\vect U}
-  \end{multline*}
+The equations solved by the ocean model \autoref{eq:MB_PE} in $s$-coordinate can be written as follows
+(see \autoref{sec:SCOORD_momentum}):
+
+\begin{description}
+\item [Vector invariant form of the momentum equation]
+  \begin{gather*}
+    % \label{eq:MB_sco_u_vector}
+    \pd[u]{t} = + (\zeta + f) \, v - \frac{1}{2 \, e_1} \pd[]{i} (u^2 + v^2) - \frac{1}{e_3} \omega \pd[u]{k} - \frac{1}{e_1} \pd[]{i} \lt( \frac{p_s + p_h}{\rho_o} \rt) - g \frac{\rho}{\rho_o} \sigma_1 + D_u^{\vect U} + F_u^{\vect U} \\
+    % \label{eq:MB_sco_v_vector}
+    \pd[v]{t} = - (\zeta + f) \, u - \frac{1}{2 \, e_2} \pd[]{j} (u^2 + v^2) - \frac{1}{e_3} \omega \pd[v]{k} - \frac{1}{e_2} \pd[]{j} \lt( \frac{p_s + p_h}{\rho_o} \rt) - g \frac{\rho}{\rho_o} \sigma_2 + D_v^{\vect U} + F_v^{\vect U}
+  \end{gather*}
+\item [Flux form of the momentum equation]
+  \begin{alignat*}{2}
+    % \label{eq:MB_sco_u_flux}
+    \frac{1}{e_3} \pd[(e_3 \, u)]{t} = &+ \lt[ f + \frac{1}{e_1 \; e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt) \rt] \, v - \frac{1}{e_1 \; e_2 \; e_3} \lt( \pd[(e_2 \, e_3 \, u \, u)]{i} + \pd[(e_1 \, e_3 \, v \, u)]{j} \rt) - \frac{1}{e_3} \pd[(\omega \, u)]{k} \\
+    &- \frac{1}{e_1} \pd[]{i} \lt( \frac{p_s + p_h}{\rho_o} \rt) - g \frac{\rho}{\rho_o} \sigma_1 + D_u^{\vect U} + F_u^{\vect U}
+  \end{alignat*}
+  \begin{alignat*}{2}
+  % \label{eq:MB_sco_v_flux}
+    \frac{1}{e_3} \pd[(e_3 \, v)]{t} = &- \lt[ f + \frac{1}{e_1 \; e_2} \lt( v \pd[e_2]{i} - u \pd[e_1]{j} \rt) \rt] \, u - \frac{1}{e_1 \; e_2 \; e_3} \lt( \pd[( e_2 \; e_3 \, u \, v)]{i} + \pd[(e_1 \; e_3 \, v \, v)]{j} \rt) - \frac{1}{e_3} \pd[(\omega \, v)]{k} \\
+    &- \frac{1}{e_2} \pd[]{j} \lt( \frac{p_s + p_h}{\rho_o} \rt) - g \frac{\rho}{\rho_o}\sigma_2 + D_v^{\vect U} + F_v^{\vect U}
+  \end{alignat*}
   where the relative vorticity, $\zeta$, the surface pressure gradient,
   and the hydrostatic pressure have the same expressions as in $z$-coordinates although
   they do not represent exactly the same quantities.
-  $\omega$ is provided by the continuity equation (see \autoref{apdx:A}):
+  $\omega$ is provided by the continuity equation (see \autoref{apdx:SCOORD}):
   \[
-  % \label{eq:PE_sco_continuity}
+  % \label{eq:MB_sco_continuity}
     \pd[e_3]{t} + e_3 \; \chi + \pd[\omega]{s} = 0 \quad \text{with} \quad
     \chi = \frac{1}{e_1 e_2 e_3} \lt( \pd[(e_2 e_3 \, u)]{i} + \pd[(e_1 e_3 \, v)]{j} \rt)
   \]
-\item \textit{tracer equations}:
-  \begin{multline*}
-  % \label{eq:PE_sco_t}
-    \frac{1}{e_3} \pd[(e_3 \, T)]{t} = - \frac{1}{e_1 e_2 e_3} \lt(   \pd[(e_2 e_3 \, u \, T)]{i}
-                                                                    + \pd[(e_1 e_3 \, v \, T)]{j} \rt) \\
-                                       - \frac{1}{e_3} \pd[(T \, \omega)]{k} + D^T + F^S
-  \end{multline*}
-  \begin{multline}
-  % \label{eq:PE_sco_s}
-    \frac{1}{e_3} \pd[(e_3 \, S)]{t} = - \frac{1}{e_1 e_2 e_3} \lt(   \pd[(e_2 e_3 \, u \, S)]{i}
-                                                                    + \pd[(e_1 e_3 \, v \, S)]{j} \rt) \\
-                                       - \frac{1}{e_3} \pd[(S \, \omega)]{k} + D^S + F^S
-  \end{multline}
-\end{itemize}
+\item [Tracer equations]
+  \begin{gather*}
+    % \label{eq:MB_sco_t}
+    \frac{1}{e_3} \pd[(e_3 \, T)]{t} = - \frac{1}{e_1 e_2 e_3} \lt(   \pd[(e_2 e_3 \, u \, T)]{i} + \pd[(e_1 e_3 \, v \, T)]{j} \rt) - \frac{1}{e_3} \pd[(T \, \omega)]{k} + D^T + F^S \\
+    % \label{eq:MB_sco_s}
+    \frac{1}{e_3} \pd[(e_3 \, S)]{t} = - \frac{1}{e_1 e_2 e_3} \lt(   \pd[(e_2 e_3 \, u \, S)]{i} + \pd[(e_1 e_3 \, v \, S)]{j} \rt) - \frac{1}{e_3} \pd[(S \, \omega)]{k} + D^S + F^S
+  \end{gather*}
+\end{description}
 The equation of state has the same expression as in $z$-coordinate,
 and similar expressions are used for mixing and forcing terms.
 
-\gmcomment{
+\cmtgm{
   \colorbox{yellow}{ to be updated $= = >$}
   Add a few works on z and zps and s and underlies the differences between all of them
@@ -729,118 +686,110 @@
 }
 
-% -------------------------------------------------------------------------------------------------------------
-% Curvilinear \zstar-coordinate System
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \subsection{Curvilinear \zstar-coordinate system}
-\label{subsec:PE_zco_star}
-
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!b]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_z_zstar}
-    \caption{
-      \protect\label{fig:z_zstar}
-      (a) $z$-coordinate in linear free-surface case ;
-      (b) $z$-coordinate in non-linear free surface case ;
-      (c) re-scaled height coordinate
+\label{subsec:MB_zco_star}
+
+\begin{figure}
+  \centering
+  \includegraphics[width=0.66\textwidth]{MB_z_zstar}
+  \caption[Curvilinear z-coordinate systems (\{non-\}linear free-surface cases and re-scaled \zstar)]{
+    \begin{enumerate*}[label=(\textit{\alph*})]
+    \item $z$-coordinate in linear free-surface case;
+    \item $z$-coordinate in non-linear free surface case;
+    \item re-scaled height coordinate
       (become popular as the \zstar-coordinate \citep{adcroft.campin_OM04}).
-    }
-  \end{center}
+    \end{enumerate*}
+  }
+  \label{fig:MB_z_zstar}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-In that case, the free surface equation is nonlinear, and the variations of volume are fully taken into account.
-These coordinates systems is presented in a report \citep{levier.treguier.ea_rpt07} available on the \NEMO web site.
-
-The \zstar coordinate approach is an unapproximated, non-linear free surface implementation which allows one to
-deal with large amplitude free-surface variations relative to the vertical resolution \citep{adcroft.campin_OM04}.
-In the \zstar formulation,
-the variation of the column thickness due to sea-surface undulations is not concentrated in the surface level,
-as in the $z$-coordinate formulation, but is equally distributed over the full water column.
+
+In this case, the free surface equation is nonlinear,
+and the variations of volume are fully taken into account.
+These coordinates systems is presented in a report \citep{levier.treguier.ea_rpt07} available on
+the \NEMO\ web site.
+
+The \zstar\ coordinate approach is an unapproximated, non-linear free surface implementation which
+allows one to deal with large amplitude free-surface variations relative to the vertical resolution
+\citep{adcroft.campin_OM04}.
+In the \zstar\ formulation, the variation of the column thickness due to sea-surface undulations is
+not concentrated in the surface level, as in the $z$-coordinate formulation,
+but is equally distributed over the full water column.
 Thus vertical levels naturally follow sea-surface variations, with a linear attenuation with depth,
-as illustrated by \autoref{fig:z_zstar}.
-Note that with a flat bottom, such as in \autoref{fig:z_zstar}, the bottom-following $z$ coordinate and \zstar are equivalent.
+as illustrated by \autoref{fig:MB_z_zstar}.
+Note that with a flat bottom, such as in \autoref{fig:MB_z_zstar},
+the bottom-following $z$ coordinate and \zstar\ are equivalent.
 The definition and modified oceanic equations for the rescaled vertical coordinate \zstar,
 including the treatment of fresh-water flux at the surface, are detailed in Adcroft and Campin (2004).
 The major points are summarized here.
-The position (\zstar) and vertical discretization (\zstar) are expressed as:
+The position (\zstar) and vertical discretization ($\delta \zstar$) are expressed as:
 \[
-  % \label{eq:z-star}
-  H + \zstar = (H + z)  / r \quad \text{and}  \quad \delta \zstar
-              = \delta z / r \quad \text{with} \quad r
-              = \frac{H + \eta}{H}
+  % \label{eq:MB_z-star}
+  H + \zstar = (H + z)  / r \quad \text{and}  \quad \delta \zstar = \delta z / r \quad \text{with} \quad r = \frac{H + \eta}{H}
+\]
+Simple re-organisation of the above expressions gives
+\[
+  % \label{eq:MB_zstar_2}
+  \zstar = H \lt( \frac{z - \eta}{H + \eta} \rt)
 \]
 Since the vertical displacement of the free surface is incorporated in the vertical coordinate \zstar,
-the upper and lower boundaries are at fixed  \zstar position,
+the upper and lower boundaries are at fixed \zstar\ position,
 $\zstar = 0$ and $\zstar = -H$ respectively.
 Also the divergence of the flow field is no longer zero as shown by the continuity equation:
 \[
-  \pd[r]{t} = \nabla_{\zstar} \cdot \lt( r \; \vect U_h \rt) (r \; w *) = 0
+  \pd[r]{t} = \nabla_{\zstar} \cdot \lt( r \; \vect U_h \rt) + \pd[r \; w^*]{\zstar} = 0
 \]
-
-% from MOM4p1 documentation
-To overcome problems with vanishing surface and/or bottom cells, we consider the zstar coordinate 
-\[
-  % \label{eq:PE_}
-  \zstar = H \lt( \frac{z - \eta}{H + \eta} \rt)
-\]
-
-This coordinate is closely related to the "eta" coordinate used in many atmospheric models
-(see Black (1994) for a review of eta coordinate atmospheric models).
+This \zstar\ coordinate is closely related to the $\eta$ coordinate used in many atmospheric models
+(see Black (1994) for a review of $\eta$ coordinate atmospheric models).
 It was originally used in ocean models by Stacey et al. (1995) for studies of tides next to shelves,
 and it has been recently promoted by Adcroft and Campin (2004) for global climate modelling.
 
-The surfaces of constant \zstar are quasi -horizontal.
-Indeed, the \zstar coordinate reduces to $z$ when $\eta$ is zero.
+The surfaces of constant \zstar\ are quasi-horizontal.
+Indeed, the \zstar\ coordinate reduces to $z$ when $\eta$ is zero.
 In general, when noting the large differences between
 undulations of the bottom topography versus undulations in the surface height,
-it is clear that surfaces constant \zstar are very similar to the depth surfaces.
+it is clear that surfaces constant \zstar\ are very similar to the depth surfaces.
 These properties greatly reduce difficulties of computing the horizontal pressure gradient relative to
-terrain following sigma models discussed in \autoref{subsec:PE_sco}.
-Additionally, since \zstar when $\eta = 0$,
-no flow is spontaneously generated in an unforced ocean starting from rest, regardless the bottom topography.
-This behaviour is in contrast to the case with "s"-models, where pressure gradient errors in the presence of
-nontrivial topographic variations can generate nontrivial spontaneous flow from a resting state,
+terrain following sigma models discussed in \autoref{subsec:MB_sco}.
+Additionally, since $\zstar = z$ when $\eta = 0$,
+no flow is spontaneously generated in an unforced ocean starting from rest,
+regardless the bottom topography.
+This behaviour is in contrast to the case with ``s''-models,
+where pressure gradient errors in the presence of nontrivial topographic variations can generate
+nontrivial spontaneous flow from a resting state,
 depending on the sophistication of the pressure gradient solver.
-The quasi -horizontal nature of the coordinate surfaces also facilitates the implementation of
-neutral physics parameterizations in \zstar models using the same techniques as in $z$-models
+The quasi-horizontal nature of the coordinate surfaces also facilitates the implementation of
+neutral physics parameterizations in \zstar\ models using the same techniques as in $z$-models
 (see Chapters 13-16 of \cite{griffies_bk04}) for a discussion of neutral physics in $z$-models,
 as well as \autoref{sec:LDF_slp} in this document for treatment in \NEMO).
 
-The range over which \zstar varies is time independent $-H \leq \zstar \leq 0$.
-Hence, all cells remain nonvanishing, so long as the surface height maintains $\eta > ?H$.
-This is a minor constraint relative to that encountered on the surface height when using $s = z$ or $s = z - \eta$.
-
-Because \zstar has a time independent range, all grid cells have static increments ds,
-and the sum of the ver tical increments yields the time independent ocean depth. %k ds = H.
-The \zstar coordinate is therefore invisible to undulations of the free surface,
+The range over which \zstar\ varies is time independent $-H \leq \zstar \leq 0$.
+Hence, all cells remain nonvanishing, so long as the surface height maintains $\eta > -H$.
+This is a minor constraint relative to that encountered on the surface height when
+using $s = z$ or $s = z - \eta$.
+
+Because \zstar\ has a time independent range, all grid cells have static increments ds,
+and the sum of the vertical increments yields the time independent ocean depth. %k ds = H.
+The \zstar\ coordinate is therefore invisible to undulations of the free surface,
 since it moves along with the free surface.
-This proper ty means that no spurious vertical transport is induced across surfaces of constant \zstar by
-the motion of external gravity waves.
-Such spurious transpor t can be a problem in z-models, especially those with tidal forcing.
-Quite generally, the time independent range for the \zstar coordinate is a very convenient property that
-allows for a nearly arbitrary ver tical resolution even in the presence of large amplitude fluctuations of
-the surface height, again so long as $\eta > -H$.
+This property means that no spurious vertical transport is induced across
+surfaces of constant \zstar\  by the motion of external gravity waves.
+Such spurious transport can be a problem in z-models, especially those with tidal forcing.
+Quite generally,
+the time independent range for the \zstar\ coordinate is a very convenient property that
+allows for a nearly arbitrary vertical resolution even in
+the presence of large amplitude fluctuations of the surface height, again so long as $\eta > -H$.
 %end MOM doc %%%
 
-\newpage 
-
-% -------------------------------------------------------------------------------------------------------------
-% Terrain following  coordinate System
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \subsection{Curvilinear terrain-following \textit{s}--coordinate}
-\label{subsec:PE_sco}
-
-% -------------------------------------------------------------------------------------------------------------
-% Introduction
-% -------------------------------------------------------------------------------------------------------------
-\subsubsection{Introduction}
+\label{subsec:MB_sco}
 
 Several important aspects of the ocean circulation are influenced by bottom topography.
-Of course, the most important is that bottom topography determines deep ocean sub-basins, barriers, sills and
-channels that strongly constrain the path of water masses, but more subtle effects exist.
-For example, the topographic $\beta$-effect is usually larger than the planetary one along continental slopes.
+Of course, the most important is that bottom topography determines deep ocean sub-basins, barriers,
+sills and channels that strongly constrain the path of water masses, but more subtle effects exist.
+For example,
+the topographic $\beta$-effect is usually larger than the planetary one along continental slopes.
 Topographic Rossby waves can be excited and can interact with the mean current.
-In the $z$-coordinate system presented in the previous section (\autoref{sec:PE_zco}),
+In the $z$-coordinate system presented in the previous section (\autoref{sec:MB_zco}),
 $z$-surfaces are geopotential surfaces.
 The bottom topography is discretised by steps.
@@ -848,97 +797,107 @@
 large localized depth gradients associated with large localized vertical velocities.
 The response to such a velocity field often leads to numerical dispersion effects.
-One solution to strongly reduce this error is to use a partial step representation of bottom topography instead of
-a full step one \cite{pacanowski.gnanadesikan_MWR98}.
+One solution to strongly reduce this error is to use a partial step representation of
+bottom topography instead of a full step one \cite{pacanowski.gnanadesikan_MWR98}.
 Another solution is to introduce a terrain-following coordinate system (hereafter $s$-coordinate).
 
-The $s$-coordinate avoids the discretisation error in the depth field since the layers of
-computation are gradually adjusted with depth to the ocean bottom.
-Relatively small topographic features as well as  gentle, large-scale slopes of the sea floor in the deep ocean,
-which would be ignored in typical $z$-model applications with the largest grid spacing at greatest depths,
+The $s$-coordinate avoids the discretisation error in the depth field since
+the layers of computation are gradually adjusted with depth to the ocean bottom.
+Relatively small topographic features as well as
+gentle, large-scale slopes of the sea floor in the deep ocean,
+which would be ignored in typical $z$-model applications with
+the largest grid spacing at greatest depths,
 can easily be represented (with relatively low vertical resolution).
-A terrain-following model (hereafter $s$-model) also facilitates the modelling of the boundary layer flows over
-a large depth range, which in the framework of the $z$-model would require high vertical resolution over
+A terrain-following model (hereafter $s$-model) also facilitates
+the modelling of the boundary layer flows over a large depth range,
+which in the framework of the $z$-model would require high vertical resolution over
 the whole depth range.
-Moreover, with a $s$-coordinate it is possible, at least in principle, to have the bottom and the sea surface as
+Moreover,
+with a $s$-coordinate it is possible, at least in principle, to have the bottom and the sea surface as
 the only boundaries of the domain (no more lateral boundary condition to specify).
-Nevertheless, a $s$-coordinate also has its drawbacks. Perfectly adapted to a homogeneous ocean,
+Nevertheless, a $s$-coordinate also has its drawbacks.
+Perfectly adapted to a homogeneous ocean,
 it has strong limitations as soon as stratification is introduced.
 The main two problems come from the truncation error in the horizontal pressure gradient and
 a possibly increased diapycnal diffusion.
-The horizontal pressure force in $s$-coordinate consists of two terms (see \autoref{apdx:A}),
-
+The horizontal pressure force in $s$-coordinate consists of two terms (see \autoref{apdx:SCOORD}),
 \begin{equation}
-  \label{eq:PE_p_sco}
-  \nabla p |_z = \nabla p |_s - \pd[p]{s} \nabla z |_s
+  \label{eq:MB_p_sco}
+  \nabla p |_z = \nabla p |_s - \frac{1}{e_3} \pd[p]{s} \nabla z |_s
 \end{equation}
 
-The second term in \autoref{eq:PE_p_sco} depends on the tilt of the coordinate surface and
-introduces a truncation error that is not present in a $z$-model.
-In the special case of a $\sigma$-coordinate (i.e. a depth-normalised coordinate system $\sigma = z/H$),
-\citet{haney_JPO91} and \citet{beckmann.haidvogel_JPO93} have given estimates of the magnitude of this truncation error.
-It depends on topographic slope, stratification, horizontal and vertical resolution, the equation of state,
-and the finite difference scheme.
+The second term in \autoref{eq:MB_p_sco} depends on the tilt of the coordinate surface and
+leads to a truncation error that is not present in a $z$-model.
+In the special case of a $\sigma$-coordinate
+(i.e. a depth-normalised coordinate system $\sigma = z/H$),
+\citet{haney_JPO91} and \citet{beckmann.haidvogel_JPO93} have given estimates of
+the magnitude of this truncation error.
+It depends on topographic slope, stratification, horizontal and vertical resolution,
+the equation of state, and the finite difference scheme.
 This error limits the possible topographic slopes that a model can handle at
 a given horizontal and vertical resolution.
 This is a severe restriction for large-scale applications using realistic bottom topography.
-The large-scale slopes require high horizontal resolution, and the computational cost becomes prohibitive.
+The large-scale slopes require high horizontal resolution,
+and the computational cost becomes prohibitive.
 This problem can be at least partially overcome by mixing $s$-coordinate and
-step-like representation of bottom topography \citep{gerdes_JGR93*a,gerdes_JGR93*b,madec.delecluse.ea_JPO96}.
+step-like representation of bottom topography
+\citep{gerdes_JGR93*a,gerdes_JGR93*b,madec.delecluse.ea_JPO96}.
 However, the definition of the model domain vertical coordinate becomes then a non-trivial thing for
 a realistic bottom topography:
-a envelope topography is defined in $s$-coordinate on which a full or
-partial step bottom topography is then applied in order to adjust the model depth to the observed one
-(see \autoref{sec:DOM_zgr}.
-
-For numerical reasons a minimum of diffusion is required along the coordinate surfaces of
-any finite difference model.
+an envelope topography is defined in $s$-coordinate on which
+a full or partial step bottom topography is then applied in order to
+adjust the model depth to the observed one (see \autoref{subsec:DOM_zgr}).
+
+For numerical reasons a minimum of diffusion is required along
+the coordinate surfaces of any finite difference model.
 It causes spurious diapycnal mixing when coordinate surfaces do not coincide with isoneutral surfaces.
 This is the case for a $z$-model as well as for a $s$-model.
-However, density varies more strongly on $s$-surfaces than on horizontal surfaces in regions of
-large topographic slopes, implying larger diapycnal diffusion in a $s$-model than in a $z$-model.
-Whereas such a diapycnal diffusion in a $z$-model tends to weaken horizontal density (pressure) gradients and thus
-the horizontal circulation, it usually reinforces these gradients in a $s$-model, creating spurious circulation.
-For example, imagine an isolated bump of topography in an ocean at rest with a horizontally uniform stratification.
+However, density varies more strongly on $s$-surfaces than on horizontal surfaces in
+regions of large topographic slopes,
+implying larger diapycnal diffusion in a $s$-model than in a $z$-model.
+Whereas such a diapycnal diffusion in a $z$-model tends to
+weaken horizontal density (pressure) gradients and thus the horizontal circulation,
+it usually reinforces these gradients in a $s$-model, creating spurious circulation.
+For example, imagine an isolated bump of topography in
+an ocean at rest with a horizontally uniform stratification.
 Spurious diffusion along $s$-surfaces will induce a bump of isoneutral surfaces over the topography,
 and thus will generate there a baroclinic eddy.
 In contrast, the ocean will stay at rest in a $z$-model.
-As for the truncation error, the problem can be reduced by introducing the terrain-following coordinate below
-the strongly stratified portion of the water column (\ie the main thermocline) \citep{madec.delecluse.ea_JPO96}.
-An alternate solution consists of rotating the lateral diffusive tensor to geopotential or to isoneutral surfaces
-(see \autoref{subsec:PE_ldf}).
+As for the truncation error, the problem can be reduced by
+introducing the terrain-following coordinate below the strongly stratified portion of the water column
+(\ie\ the main thermocline) \citep{madec.delecluse.ea_JPO96}.
+An alternate solution consists of rotating the lateral diffusive tensor to
+geopotential or to isoneutral surfaces (see \autoref{subsec:MB_ldf}).
 Unfortunately, the slope of isoneutral surfaces relative to the $s$-surfaces can very large,
-strongly exceeding the stability limit of such a operator when it is discretized (see \autoref{chap:LDF}).
-
-The $s$-coordinates introduced here \citep{lott.madec.ea_OM90,madec.delecluse.ea_JPO96} differ mainly in two aspects from
-similar models:
-it allows a representation of bottom topography with mixed full or partial step-like/terrain following topography;
+strongly exceeding the stability limit of such a operator when it is discretized
+(see \autoref{chap:LDF}).
+
+The $s$-coordinates introduced here \citep{lott.madec.ea_OM90,madec.delecluse.ea_JPO96}
+differ mainly in two aspects from similar models:
+it allows a representation of bottom topography with
+mixed full or partial step-like/terrain following topography;
 It also offers a completely general transformation, $s=s(i,j,z)$ for the vertical coordinate.
 
-% -------------------------------------------------------------------------------------------------------------
-% Curvilinear z-tilde coordinate System
-% -------------------------------------------------------------------------------------------------------------
-\subsection{\texorpdfstring{Curvilinear \ztilde-coordinate}{}}
-\label{subsec:PE_zco_tilde}
-
-The \ztilde -coordinate has been developed by \citet{leclair.madec_OM11}.
-It is available in \NEMO since the version 3.4.
+%% =================================================================================================
+\subsection{Curvilinear \ztilde-coordinate}
+\label{subsec:MB_zco_tilde}
+
+The \ztilde-coordinate has been developed by \citet{leclair.madec_OM11}.
+It is available in \NEMO\ since the version 3.4 and is more robust in version 4.0 than previously.
 Nevertheless, it is currently not robust enough to be used in all possible configurations.
 Its use is therefore not recommended.
 
-\newpage 
-
-% ================================================================
-% Subgrid Scale Physics
-% ================================================================
+%% =================================================================================================
 \section{Subgrid scale physics}
-\label{sec:PE_zdf_ldf}
-
-The primitive equations describe the behaviour of a geophysical fluid at space and time scales larger than
-a few kilometres in the horizontal, a few meters in the vertical and a few minutes.
-They are usually solved at larger scales: the specified grid spacing and time step of the numerical model.
+\label{sec:MB_zdf_ldf}
+
+The hydrostatic primitive equations describe the behaviour of a geophysical fluid at
+space and time scales larger than a few kilometres in the horizontal,
+a few meters in the vertical and a few minutes.
+They are usually solved at larger scales: the specified grid spacing and time step of
+the numerical model.
 The effects of smaller scale motions (coming from the advective terms in the Navier-Stokes equations)
 must be represented entirely in terms of large-scale patterns to close the equations.
 These effects appear in the equations as the divergence of turbulent fluxes
-(\ie fluxes associated with the mean correlation of small scale perturbations).
+(\ie\ fluxes associated with the mean correlation of small scale perturbations).
 Assuming a turbulent closure hypothesis is equivalent to choose a formulation for these fluxes.
 It is usually called the subgrid scale physics.
@@ -947,22 +906,23 @@
 small scale processes \textit{in fine} balance the surface input of kinetic energy and heat.
 
-The control exerted by gravity on the flow induces a strong anisotropy between the lateral and vertical motions.
+The control exerted by gravity on the flow induces a strong anisotropy between
+the lateral and vertical motions.
 Therefore subgrid-scale physics \textbf{D}$^{\vect U}$, $D^{S}$ and $D^{T}$  in
-\autoref{eq:PE_dyn}, \autoref{eq:PE_tra_T} and \autoref{eq:PE_tra_S} are divided into
-a lateral part \textbf{D}$^{l \vect U}$, $D^{l S}$ and $D^{l T}$ and
+\autoref{eq:MB_PE_dyn}, \autoref{eq:MB_PE_tra_T} and \autoref{eq:MB_PE_tra_S} are divided into
+a  lateral part \textbf{D}$^{l \vect U}$, $D^{l S}$ and $D^{l T}$ and
 a vertical part \textbf{D}$^{v \vect U}$, $D^{v S}$ and $D^{v T}$.
-The formulation of these terms and their underlying physics are briefly discussed in the next two subsections.
-
-% -------------------------------------------------------------------------------------------------------------
-% Vertical Subgrid Scale Physics
-% -------------------------------------------------------------------------------------------------------------
+The formulation of these terms and their underlying physics are briefly discussed in
+the next two subsections.
+
+%% =================================================================================================
 \subsection{Vertical subgrid scale physics}
-\label{subsec:PE_zdf}
-
-The model resolution is always larger than the scale at which the major sources of vertical turbulence occur
-(shear instability, internal wave breaking...).
+\label{subsec:MB_zdf}
+
+The model resolution is always larger than the scale at which
+the major sources of vertical turbulence occur (shear instability, internal wave breaking...).
 Turbulent motions are thus never explicitly solved, even partially, but always parameterized.
-The vertical turbulent fluxes are assumed to depend linearly on the gradients of large-scale quantities
-(for example, the turbulent heat flux is given by $\overline{T' w'} = -A^{v T} \partial_z \overline T$,
+The vertical turbulent fluxes are assumed to depend linearly on
+the gradients of large-scale quantities (for example,
+the turbulent heat flux is given by $\overline{T' w'} = -A^{v T} \partial_z \overline T$,
 where $A^{v T}$ is an eddy coefficient).
 This formulation is analogous to that of molecular diffusion and dissipation.
@@ -972,56 +932,61 @@
 The resulting vertical momentum and tracer diffusive operators are of second order:
 \begin{equation}
-  \label{eq:PE_zdf}
+  \label{eq:MB_zdf}
   \begin{gathered}
-    \vect D^{v \vect U} = \pd[]{z} \lt( A^{vm} \pd[\vect U_h]{z} \rt) \ , \\
-          D^{vT}       = \pd[]{z} \lt( A^{vT} \pd[T]{z}         \rt) \quad \text{and} \quad
+    \vect D^{v \vect U} = \pd[]{z} \lt( A^{vm} \pd[\vect U_h]{z} \rt) \text{,} \
+          D^{vT}       = \pd[]{z} \lt( A^{vT} \pd[T]{z}         \rt) \ \text{and} \
           D^{vS}       = \pd[]{z} \lt( A^{vT} \pd[S]{z}         \rt)
   \end{gathered}
 \end{equation}
-where $A^{vm}$ and $A^{vT}$ are the vertical eddy viscosity and diffusivity coefficients, respectively.
+where $A^{vm}$ and $A^{vT}$ are the vertical eddy viscosity and diffusivity coefficients,
+respectively.
 At the sea surface and at the bottom, turbulent fluxes of momentum, heat and salt must be specified
 (see \autoref{chap:SBC} and \autoref{chap:ZDF} and \autoref{sec:TRA_bbl}).
 All the vertical physics is embedded in the specification of the eddy coefficients.
 They can be assumed to be either constant, or function of the local fluid properties
-(\eg Richardson number, Brunt-Vais\"{a}l\"{a} frequency...),
+(\eg\ Richardson number, Brunt-V\"{a}is\"{a}l\"{a} frequency, distance from the boundary ...),
 or computed from a turbulent closure model.
-The choices available in \NEMO are discussed in \autoref{chap:ZDF}).
-
-% -------------------------------------------------------------------------------------------------------------
-% Lateral Diffusive and Viscous Operators Formulation
-% -------------------------------------------------------------------------------------------------------------
+The choices available in \NEMO\ are discussed in \autoref{chap:ZDF}).
+
+%% =================================================================================================
 \subsection{Formulation of the lateral diffusive and viscous operators}
-\label{subsec:PE_ldf}
+\label{subsec:MB_ldf}
 
 Lateral turbulence can be roughly divided into a mesoscale turbulence associated with eddies
 (which can be solved explicitly if the resolution is sufficient since
 their underlying physics are included in the primitive equations),
-and a sub mesoscale turbulence which is never explicitly solved even partially, but always parameterized.
-The formulation of lateral eddy fluxes depends on whether the mesoscale is below or above the grid-spacing
-(\ie the model is eddy-resolving or not).
+and a sub mesoscale turbulence which is never explicitly solved even partially,
+but always parameterized.
+The formulation of lateral eddy fluxes depends on whether
+the mesoscale is below or above the grid-spacing (\ie\ the model is eddy-resolving or not).
 
 In non-eddy-resolving configurations, the closure is similar to that used for the vertical physics.
-The lateral turbulent fluxes are assumed to depend linearly on the lateral gradients of large-scale quantities.
+The lateral turbulent fluxes are assumed to depend linearly on
+the lateral gradients of large-scale quantities.
 The resulting lateral diffusive and dissipative operators are of second order.
-Observations show that lateral mixing induced by mesoscale turbulence tends to be along isopycnal surfaces
+Observations show that
+lateral mixing induced by mesoscale turbulence tends to be along isopycnal surfaces
 (or more precisely neutral surfaces \cite{mcdougall_JPO87}) rather than across them.
-As the slope of neutral surfaces is small in the ocean, a common approximation is to assume that
-the `lateral' direction is the horizontal, \ie the lateral mixing is performed along geopotential surfaces.
+As the slope of neutral surfaces is small in the ocean,
+a common approximation is to assume that the ``lateral'' direction is the horizontal,
+\ie\ the lateral mixing is performed along geopotential surfaces.
 This leads to a geopotential second order operator for lateral subgrid scale physics.
-This assumption can be relaxed: the eddy-induced turbulent fluxes can be better approached by assuming that
+This assumption can be relaxed:
+the eddy-induced turbulent fluxes can be better approached by assuming that
 they depend linearly on the gradients of large-scale quantities computed along neutral surfaces.
 In such a case, the diffusive operator is an isoneutral second order operator and
 it has components in the three space directions.
-However,
-both horizontal and isoneutral operators have no effect on mean (\ie large scale) potential energy whereas
+However, both horizontal and isoneutral operators have no effect on
+mean (\ie\ large scale) potential energy whereas
 potential energy is a main source of turbulence (through baroclinic instabilities).
-\citet{gent.mcwilliams_JPO90} have proposed a parameterisation of mesoscale eddy-induced turbulence which
+\citet{gent.mcwilliams_JPO90} proposed a parameterisation of mesoscale eddy-induced turbulence which
 associates an eddy-induced velocity to the isoneutral diffusion.
 Its mean effect is to reduce the mean potential energy of the ocean.
-This leads to a formulation of lateral subgrid-scale physics made up of an isoneutral second order operator and
-an eddy induced advective part.
+This leads to a formulation of lateral subgrid-scale physics made up of
+an isoneutral second order operator and an eddy induced advective part.
 In all these lateral diffusive formulations,
 the specification of the lateral eddy coefficients remains the problematic point as
-there is no really satisfactory formulation of these coefficients as a function of large-scale features.
+there is no really satisfactory formulation of these coefficients as
+a function of large-scale features.
 
 In eddy-resolving configurations, a second order operator can be used,
@@ -1032,39 +997,44 @@
 not interfering with the resolved mesoscale activity.
 Another approach is becoming more and more popular:
-instead of specifying explicitly a sub-grid scale term in the momentum and tracer time evolution equations,
-one uses a advective scheme which is diffusive enough to maintain the model stability.
-It must be emphasised that then, all the sub-grid scale physics is included in the formulation of
-the advection scheme.
+instead of specifying explicitly a sub-grid scale term in
+the momentum and tracer time evolution equations,
+one uses an advective scheme which is diffusive enough to maintain the model stability.
+It must be emphasised that then,
+all the sub-grid scale physics is included in the formulation of the advection scheme.
 
 All these parameterisations of subgrid scale physics have advantages and drawbacks.
-There are not all available in \NEMO. For active tracers (temperature and salinity) the main ones are:
+They are not all available in \NEMO.
+For active tracers (temperature and salinity) the main ones are:
 Laplacian and bilaplacian operators acting along geopotential or iso-neutral surfaces,
 \citet{gent.mcwilliams_JPO90} parameterisation, and various slightly diffusive advection schemes.
-For momentum, the main ones are: Laplacian and bilaplacian operators acting along geopotential surfaces,
+For momentum, the main ones are:
+Laplacian and bilaplacian operators acting along geopotential surfaces,
 and UBS advection schemes when flux form is chosen for the momentum advection.
 
+%% =================================================================================================
 \subsubsection{Lateral laplacian tracer diffusive operator}
 
-The lateral Laplacian tracer diffusive operator is defined by (see \autoref{apdx:B}):
+The lateral Laplacian tracer diffusive operator is defined by (see \autoref{apdx:DIFFOPERS}):
 \begin{equation}
-  \label{eq:PE_iso_tensor}
-  D^{lT} = \nabla \vect . \lt( A^{lT} \; \Re \; \nabla T \rt) \quad \text{with} \quad
-  \Re =
-    \begin{pmatrix}
-      1    & 0    & -r_1          \\
-      0    & 1    & -r_2          \\
-      -r_1 & -r_2 & r_1^2 + r_2^2 \\
-    \end{pmatrix}
+  \label{eq:MB_iso_tensor}
+  D^{lT} = \nabla \vect . \lt( A^{lT} \; \Re \; \nabla T \rt) \quad \text{with} \quad \Re =
+  \begin{pmatrix}
+    1    & 0    & -r_1          \\
+    0    & 1    & -r_2          \\
+    -r_1 & -r_2 & r_1^2 + r_2^2 \\
+  \end{pmatrix}
 \end{equation}
 where $r_1$ and $r_2$ are the slopes between the surface along which the diffusive operator acts and
-the model level (\eg $z$- or $s$-surfaces).
-Note that the formulation \autoref{eq:PE_iso_tensor} is exact for
+the model level (\eg\ $z$- or $s$-surfaces).
+Note that the formulation \autoref{eq:MB_iso_tensor} is exact for
 the rotation between geopotential and $s$-surfaces,
 while it is only an approximation for the rotation between isoneutral and $z$- or $s$-surfaces.
-Indeed, in the latter case, two assumptions are made to simplify \autoref{eq:PE_iso_tensor} \citep{cox_OM87}.
-First, the horizontal contribution of the dianeutral mixing is neglected since the ratio between iso and
-dia-neutral diffusive coefficients is known to be several orders of magnitude smaller than unity.
+Indeed, in the latter case, two assumptions are made to simplify \autoref{eq:MB_iso_tensor}
+\citep{cox_OM87}.
+First, the horizontal contribution of the dianeutral mixing is neglected since
+the ratio between iso and dia-neutral diffusive coefficients is known to be
+several orders of magnitude smaller than unity.
 Second, the two isoneutral directions of diffusion are assumed to be independent since
-the slopes are generally less than $10^{-2}$ in the ocean (see \autoref{apdx:B}).
+the slopes are generally less than $10^{-2}$ in the ocean (see \autoref{apdx:DIFFOPERS}).
 
 For \textit{iso-level} diffusion, $r_1$ and $r_2 $ are zero.
@@ -1073,16 +1043,18 @@
 For \textit{geopotential} diffusion,
 $r_1$ and $r_2 $ are the slopes between the geopotential and computational surfaces:
-they are equal to $\sigma_1$ and $\sigma_2$, respectively (see \autoref{eq:PE_sco_slope}).
-
-For \textit{isoneutral} diffusion $r_1$ and $r_2$ are the slopes between the isoneutral and computational surfaces.
+they are equal to $\sigma_1$ and $\sigma_2$, respectively (see \autoref{eq:MB_sco_slope}).
+
+For \textit{isoneutral} diffusion $r_1$ and $r_2$ are the slopes between
+the isoneutral and computational surfaces.
 Therefore, they are different quantities, but have similar expressions in $z$- and $s$-coordinates.
 In $z$-coordinates:
 \begin{equation}
-  \label{eq:PE_iso_slopes}
-  r_1 = \frac{e_3}{e_1}	\lt( \pd[\rho]{i} \rt) \lt( \pd[\rho]{k} \rt)^{-1} \quad
-  r_2 = \frac{e_3}{e_2}	\lt( \pd[\rho]{j} \rt) \lt( \pd[\rho]{k} \rt)^{-1}
+  \label{eq:MB_iso_slopes}
+  r_1 = \frac{e_3}{e_1} \lt( \pd[\rho]{i} \rt) \lt( \pd[\rho]{k} \rt)^{-1} \quad
+  r_2 = \frac{e_3}{e_2} \lt( \pd[\rho]{j} \rt) \lt( \pd[\rho]{k} \rt)^{-1}
 \end{equation}
 while in $s$-coordinates $\pd[]{k}$ is replaced by $\pd[]{s}$.
 
+%% =================================================================================================
 \subsubsection{Eddy induced velocity}
 
@@ -1090,22 +1062,24 @@
 an additional tracer advection is introduced in combination with the isoneutral diffusion of tracers:
 \[
-  % \label{eq:PE_iso+eiv}
+  % \label{eq:MB_iso+eiv}
   D^{lT} = \nabla \cdot \lt( A^{lT} \; \Re \; \nabla T \rt) + \nabla \cdot \lt( \vect U^\ast \, T \rt)
 \]
 where $ \vect U^\ast = \lt( u^\ast,v^\ast,w^\ast \rt)$ is a non-divergent,
 eddy-induced transport velocity. This velocity field is defined by:
-\begin{gather}
-  % \label{eq:PE_eiv}
-  u^\ast =   \frac{1}{e_3}            \pd[]{k} \lt( A^{eiv} \;        \tilde{r}_1 \rt) \\
-  v^\ast =   \frac{1}{e_3}            \pd[]{k} \lt( A^{eiv} \;        \tilde{r}_2 \rt) \\
+\[
+  % \label{eq:MB_eiv}
+  u^\ast =   \frac{1}{e_3}            \pd[]{k} \lt( A^{eiv} \;        \tilde{r}_1 \rt) \quad
+  v^\ast =   \frac{1}{e_3}            \pd[]{k} \lt( A^{eiv} \;        \tilde{r}_2 \rt) \quad
   w^\ast = - \frac{1}{e_1 e_2} \lt[   \pd[]{i} \lt( A^{eiv} \; e_2 \, \tilde{r}_1 \rt)
                                      + \pd[]{j} \lt( A^{eiv} \; e_1 \, \tilde{r}_2 \rt) \rt]
-\end{gather}
+\]
 where $A^{eiv}$ is the eddy induced velocity coefficient
 (or equivalently the isoneutral thickness diffusivity coefficient),
-and $\tilde r_1$ and $\tilde r_2$ are the slopes between isoneutral and \textit{geopotential} surfaces.
-Their values are thus independent of the vertical coordinate, but their expression depends on the coordinate: 
-\begin{align}
-  \label{eq:PE_slopes_eiv}
+and $\tilde r_1$ and $\tilde r_2$ are the slopes between
+isoneutral and \textit{geopotential} surfaces.
+Their values are thus independent of the vertical coordinate,
+but their expression depends on the coordinate:
+\begin{equation}
+  \label{eq:MB_slopes_eiv}
   \tilde{r}_n =
     \begin{cases}
@@ -1114,63 +1088,67 @@
     \end{cases}
   \quad \text{where~} n = 1, 2
-\end{align}
+\end{equation}
 
 The normal component of the eddy induced velocity is zero at all the boundaries.
-This can be achieved in a model by tapering either the eddy coefficient or the slopes to zero in the vicinity of
-the boundaries.
-The latter strategy is used in \NEMO (cf. \autoref{chap:LDF}).
-
+This can be achieved in a model by tapering either the eddy coefficient or the slopes to zero in
+the vicinity of the boundaries.
+The latter strategy is used in \NEMO\ (cf. \autoref{chap:LDF}).
+
+%% =================================================================================================
 \subsubsection{Lateral bilaplacian tracer diffusive operator}
 
 The lateral bilaplacian tracer diffusive operator is defined by:
 \[
-  % \label{eq:PE_bilapT}
+  % \label{eq:MB_bilapT}
   D^{lT}= - \Delta \; (\Delta T) \quad \text{where} \quad
   \Delta \bullet = \nabla \lt( \sqrt{B^{lT}} \; \Re \; \nabla \bullet \rt)
 \]
-It is the Laplacian operator given by \autoref{eq:PE_iso_tensor} applied twice with
+It is the Laplacian operator given by \autoref{eq:MB_iso_tensor} applied twice with
 the harmonic eddy diffusion coefficient set to the square root of the biharmonic one.
 
+%% =================================================================================================
 \subsubsection{Lateral Laplacian momentum diffusive operator}
 
 The Laplacian momentum diffusive operator along $z$- or $s$-surfaces is found by
-applying \autoref{eq:PE_lap_vector} to the horizontal velocity vector (see \autoref{apdx:B}):
+applying \autoref{eq:MB_lap_vector} to the horizontal velocity vector (see \autoref{apdx:DIFFOPERS}):
 \begin{align*}
-  % \label{eq:PE_lapU}
+  % \label{eq:MB_lapU}
   \vect D^{l \vect U} &=   \nabla_h        \big( A^{lm}    \chi             \big)
                          - \nabla_h \times \big( A^{lm} \, \zeta \; \vect k \big) \\
                       &= \lt(   \frac{1}{e_1}     \pd[ \lt( A^{lm}    \chi      \rt) ]{i} \rt.
-                              - \frac{1}{e_2 e_3} \pd[ \lt( A^{lm} \; e_3 \zeta \rt) ]{j}
+                              - \frac{1}{e_2 e_3} \pd[ \lt( A^{lm} \; e_3 \zeta \rt) ]{j} ,
                                 \frac{1}{e_2}     \pd[ \lt( A^{lm}    \chi      \rt) ]{j}
                          \lt. + \frac{1}{e_1 e_3} \pd[ \lt( A^{lm} \; e_3 \zeta \rt) ]{i} \rt)
 \end{align*}
 
-Such a formulation ensures a complete separation between the vorticity and horizontal divergence fields
-(see \autoref{apdx:C}).
+Such a formulation ensures a complete separation between
+the vorticity and horizontal divergence fields (see \autoref{apdx:INVARIANTS}).
 Unfortunately, it is only available in \textit{iso-level} direction.
 When a rotation is required
-(\ie geopotential diffusion in $s$-coordinates or isoneutral diffusion in both $z$- and $s$-coordinates),
-the $u$ and $v$-fields are considered as independent scalar fields, so that the diffusive operator is given by:
-\begin{gather*}
-  % \label{eq:PE_lapU_iso}
-    D_u^{l \vect U} = \nabla . \lt( A^{lm} \; \Re \; \nabla u \rt) \\
+(\ie\ geopotential diffusion in $s$-coordinates or
+isoneutral diffusion in both $z$- and $s$-coordinates),
+the $u$ and $v$-fields are considered as independent scalar fields,
+so that the diffusive operator is given by:
+\[
+  % \label{eq:MB_lapU_iso}
+    D_u^{l \vect U} = \nabla . \lt( A^{lm} \; \Re \; \nabla u \rt) \quad
     D_v^{l \vect U} = \nabla . \lt( A^{lm} \; \Re \; \nabla v \rt)
-\end{gather*}
-where $\Re$ is given by \autoref{eq:PE_iso_tensor}.
+\]
+where $\Re$ is given by \autoref{eq:MB_iso_tensor}.
 It is the same expression as those used for diffusive operator on tracers.
 It must be emphasised that such a formulation is only exact in a Cartesian coordinate system,
-\ie on a $f$- or $\beta$-plane, not on the sphere.
+\ie\ on a $f$- or $\beta$-plane, not on the sphere.
 It is also a very good approximation in vicinity of the Equator in
 a geographical coordinate system \citep{lengaigne.madec.ea_JGR03}.
 
-\subsubsection{lateral bilaplacian momentum diffusive operator}
-
-As for tracers, the bilaplacian order momentum diffusive operator is a re-entering Laplacian operator with
+%% =================================================================================================
+\subsubsection{Lateral bilaplacian momentum diffusive operator}
+
+As for tracers,
+the bilaplacian order momentum diffusive operator is a re-entering Laplacian operator with
 the harmonic eddy diffusion coefficient set to the square root of the biharmonic one.
 Nevertheless it is currently not available in the iso-neutral case.
 
-\biblio
-
-\pindex
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_model_basics_zstar.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_model_basics_zstar.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_model_basics_zstar.tex	(revision 12143)
@@ -2,21 +2,33 @@
 
 \begin{document}
-% ================================================================
-% Chapter 1 Model Basics
-% ================================================================
-% ================================================================
-% Curvilinear \zstar- \sstar-coordinate System
-% ================================================================
+
 \chapter{ essai \zstar \sstar}
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{\textwidth}{l||X|X}
+    Release & Author(s) & Modifications \\
+    \hline
+    {\em   4.0} & {\em ...} & {\em ...} \\
+    {\em   3.6} & {\em ...} & {\em ...} \\
+    {\em   3.4} & {\em ...} & {\em ...} \\
+    {\em <=3.4} & {\em ...} & {\em ...}
+  \end{tabularx}
+}
+
+\clearpage
+
+%% =================================================================================================
 \section{Curvilinear \zstar- or \sstar coordinate system}
 
-% -------------------------------------------------------------------------------------------------------------
-% ????
-% -------------------------------------------------------------------------------------------------------------
-
 \colorbox{yellow}{ to be updated }
 
 In that case, the free surface equation is nonlinear, and the variations of volume are fully taken into account.
-These coordinates systems is presented in a report \citep{levier.treguier.ea_rpt07} available on the \NEMO web site. 
+These coordinates systems is presented in a report \citep{levier.treguier.ea_rpt07} available on the \NEMO\ web site.
 
 \colorbox{yellow}{  end of to be updated}
@@ -24,7 +36,7 @@
 % from MOM4p1 documentation
 
-To overcome problems with vanishing surface and/or bottom cells, we consider the zstar coordinate 
-\[
-  % \label{eq:PE_}
+To overcome problems with vanishing surface and/or bottom cells, we consider the zstar coordinate
+\[
+  % \label{eq:MBZ_PE_}
   z^\star = H \left( \frac{z-\eta}{H+\eta} \right)
 \]
@@ -40,5 +52,5 @@
 the surface height, it is clear that surfaces constant $z^\star$ are very similar to the depth surfaces.
 These properties greatly reduce difficulties of computing the horizontal pressure gradient relative to
-terrain following sigma models discussed in \autoref{subsec:PE_sco}. 
+terrain following sigma models discussed in \autoref{subsec:MB_sco}.
 Additionally, since $z^\star$ when $\eta = 0$, no flow is spontaneously generated in
 an unforced ocean starting from rest, regardless the bottom topography.
@@ -49,12 +61,12 @@
 neutral physics parameterizations in $z^\star$ models using the same techniques as in $z$-models
 (see Chapters 13-16 of Griffies (2004) for a discussion of neutral physics in $z$-models,
-as well as  \autoref{sec:LDF_slp} in this document for treatment in \NEMO). 
+as well as  \autoref{sec:LDF_slp} in this document for treatment in \NEMO).
 
 The range over which $z^\star$ varies is time independent $-H \leq z^\star \leq 0$.
 Hence, all cells remain nonvanishing, so long as the surface height maintains $\eta > ?H$.
-This is a minor constraint relative to that encountered on the surface height when using $s = z$ or $s = z - \eta$. 
+This is a minor constraint relative to that encountered on the surface height when using $s = z$ or $s = z - \eta$.
 
 Because $z^\star$ has a time independent range, all grid cells have static increments ds,
-and the sum of the ver tical increments yields the time independent ocean depth %�k ds = H. 
+and the sum of the ver tical increments yields the time independent ocean depth %�k ds = H.
 The $z^\star$ coordinate is therefore invisible to undulations of the free surface,
 since it moves along with the free surface.
@@ -64,41 +76,32 @@
 Quite generally, the time independent range for the $z^\star$ coordinate is a very convenient property that
 allows for a nearly arbitrary vertical resolution even in the presence of large amplitude fluctuations of
-the surface height, again so long as $\eta > -H$. 
-
-%%%
+the surface height, again so long as $\eta > -H$.
+
 %  essai update time splitting...
-%%%
-
-% ================================================================
-% Surface Pressure Gradient and Sea Surface Height
-% ================================================================
-\section[Surface pressure gradient and sea surface heigth (\textit{dynspg.F90})]
-{Surface pressure gradient and sea surface heigth (\protect\mdl{dynspg})}
-\label{sec:DYN_hpg_spg}
-%-----------------------------------------nam_dynspg----------------------------------------------------
-
-%\nlst{nam_dynspg} 
-%------------------------------------------------------------------------------------------------------------
-Options are defined through the \ngn{nam\_dynspg} namelist variables.
-The surface pressure gradient term is related to the representation of the free surface (\autoref{sec:PE_hor_pg}).
+
+%% =================================================================================================
+\section[Surface pressure gradient and sea surface heigth (\textit{dynspg.F90})]{Surface pressure gradient and sea surface heigth (\protect\mdl{dynspg})}
+\label{sec:MBZ_dyn_hpg_spg}
+
+%\nlst{nam_dynspg}
+Options are defined through the \nam{_dynspg}{\_dynspg} namelist variables.
+The surface pressure gradient term is related to the representation of the free surface (\autoref{sec:MB_hor_pg}).
 The main distinction is between the fixed volume case (linear free surface or rigid lid) and
 the variable volume case (nonlinear free surface, \key{vvl} is active).
-In the linear free surface case (\autoref{subsec:PE_free_surface}) and rigid lid (\autoref{PE_rigid_lid}),
+In the linear free surface case (\autoref{subsec:MB_free_surface}) and rigid lid (\autoref{PE_rigid_lid}),
 the vertical scale factors $e_{3}$ are fixed in time,
-while in the nonlinear case (\autoref{subsec:PE_free_surface}) they are time-dependent.
+while in the nonlinear case (\autoref{subsec:MB_free_surface}) they are time-dependent.
 With both linear and nonlinear free surface, external gravity waves are allowed in the equations,
 which imposes a very small time step when an explicit time stepping is used.
 Two methods are proposed to allow a longer time step for the three-dimensional equations:
-the filtered free surface, which is a modification of the continuous equations %(see \autoref{eq:PE_flt?}),
+the filtered free surface, which is a modification of the continuous equations %(see \autoref{eq:MB_flt?}),
 and the split-explicit free surface described below.
 The extra term introduced in the filtered method is calculated implicitly,
 so that the update of the next velocities is done in module \mdl{dynspg\_flt} and not in \mdl{dynnxt}.
 
-%-------------------------------------------------------------
 % Explicit
-%-------------------------------------------------------------
-\subsubsection[Explicit (\texttt{\textbf{key\_dynspg\_exp}})]
-{Explicit (\protect\key{dynspg\_exp})}
-\label{subsec:DYN_spg_exp}
+%% =================================================================================================
+\subsubsection[Explicit (\texttt{\textbf{key\_dynspg\_exp}})]{Explicit (\protect\key{dynspg\_exp})}
+\label{subsec:MBZ_dyn_spg_exp}
 
 In the explicit free surface formulation, the model time step is chosen small enough to
@@ -106,5 +109,5 @@
 The sea surface height is given by:
 \begin{equation}
-  \label{eq:dynspg_ssh}
+  \label{eq:MBZ_dynspg_ssh}
   \frac{\partial \eta }{\partial t}\equiv \frac{\text{EMP}}{\rho_w }+\frac{1}{e_{1T}
     e_{2T} }\sum\limits_k {\left( {\delta_i \left[ {e_{2u} e_{3u} u}
@@ -116,9 +119,9 @@
 and $\rho_w =1,000\,Kg.m^{-3}$ is the volumic mass of pure water.
 The sea-surface height is evaluated using a leapfrog scheme in combination with an Asselin time filter,
-(\ie the velocity appearing in (\autoref{eq:dynspg_ssh}) is centred in time (\textit{now} velocity). 
+(\ie\ the velocity appearing in (\autoref{eq:DYN_spg_ssh}) is centred in time (\textit{now} velocity).
 
 The surface pressure gradient, also evaluated using a leap-frog scheme, is then simply given by:
 \begin{equation}
-  \label{eq:dynspg_exp}
+  \label{eq:MBZ_dynspg_exp}
   \left\{
     \begin{aligned}
@@ -127,53 +130,46 @@
     \end{aligned}
   \right.
-\end{equation} 
+\end{equation}
 
 Consistent with the linearization, a $\left. \rho \right|_{k=1} / \rho_o$ factor is omitted in
-(\autoref{eq:dynspg_exp}). 
-
-%-------------------------------------------------------------
+(\autoref{eq:DYN_spg_exp}).
+
 % Split-explicit time-stepping
-%-------------------------------------------------------------
-\subsubsection[Split-explicit time-stepping (\texttt{\textbf{key\_dynspg\_ts}})]
-{Split-explicit time-stepping (\protect\key{dynspg\_ts})}
-\label{subsec:DYN_spg_ts}
-%--------------------------------------------namdom----------------------------------------------------
-
-\nlst{namdom} 
-%--------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
+\subsubsection[Split-explicit time-stepping (\texttt{\textbf{key\_dynspg\_ts}})]{Split-explicit time-stepping (\protect\key{dynspg\_ts})}
+\label{subsec:MBZ_dyn_spg_ts}
+
 The split-explicit free surface formulation used in OPA follows the one proposed by \citet{Griffies2004?}.
 The general idea is to solve the free surface equation with a small time step,
 while the three dimensional prognostic variables are solved with a longer time step that
-is a multiple of \np{rdtbt} in the \ngn{namdom} namelist (Figure III.3). 
-
-%>   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >
+is a multiple of \np{rdtbt}{rdtbt} in the \nam{dom}{dom} namelist (Figure III.3).
+
 \begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_DYN_dynspg_ts}
-    \caption{
-      \protect\label{fig:DYN_dynspg_ts}
-      Schematic of the split-explicit time stepping scheme for the barotropic and baroclinic modes,
-      after \citet{Griffies2004?}.
-      Time increases to the right.
-      Baroclinic time steps are denoted by $t-\Delta t$, $t, t+\Delta t$, and $t+2\Delta t$.
-      The curved line represents a leap-frog time step,
-      and the smaller barotropic time steps $N \Delta t=2\Delta t$ are denoted by the zig-zag line.
-      The vertically integrated forcing \textbf{M}(t) computed at
-      baroclinic time step t represents the interaction between the barotropic and baroclinic motions.
-      While keeping the total depth, tracer, and freshwater forcing fields fixed,
-      a leap-frog integration carries the surface height and vertically integrated velocity from
-      t to $t+2 \Delta t$ using N barotropic time steps of length $\Delta t$.
-      Time averaging the barotropic fields over the N+1 time steps (endpoints included)
-      centers the vertically integrated velocity at the baroclinic timestep $t+\Delta t$.
-      A baroclinic leap-frog time step carries the surface height to $t+\Delta t$ using the convergence of
-      the time averaged vertically integrated velocity taken from baroclinic time step t.
-    }
-  \end{center}
+  \centering
+  %\includegraphics[width=0.66\textwidth]{MBZ_DYN_dynspg_ts}
+  \caption[Schematic of the split-explicit time stepping scheme for
+  the barotropic and baroclinic modes, after \citet{Griffies2004?}]{
+    Schematic of the split-explicit time stepping scheme for the barotropic and baroclinic modes,
+    after \citet{Griffies2004?}.
+    Time increases to the right.
+    Baroclinic time steps are denoted by $t-\Delta t$, $t, t+\Delta t$, and $t+2\Delta t$.
+    The curved line represents a leap-frog time step,
+    and the smaller barotropic time steps $N \Delta t=2\Delta t$ are denoted by the zig-zag line.
+    The vertically integrated forcing \textbf{M}(t) computed at
+    baroclinic time step t represents the interaction between the barotropic and baroclinic motions.
+    While keeping the total depth, tracer, and freshwater forcing fields fixed,
+    a leap-frog integration carries the surface height and vertically integrated velocity from
+    t to $t+2 \Delta t$ using N barotropic time steps of length $\Delta t$.
+    Time averaging the barotropic fields over the N+1 time steps (endpoints included)
+    centers the vertically integrated velocity at the baroclinic timestep $t+\Delta t$.
+    A baroclinic leap-frog time step carries the surface height to $t+\Delta t$ using
+    the convergence of the time averaged vertically integrated velocity taken from
+    baroclinic time step t.}
+  \label{fig:MBZ_dyn_dynspg_ts}
 \end{figure}
-%>   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >   >
 
 The split-explicit formulation has a damping effect on external gravity waves,
 which is weaker than the filtered free surface but still significant as shown by \citet{levier.treguier.ea_rpt07} in
-the case of an analytical barotropic Kelvin wave. 
+the case of an analytical barotropic Kelvin wave.
 
 %from griffies book: .....   copy past !
@@ -186,10 +182,10 @@
 We have
 \[
-  % \label{eq:DYN_spg_ts_eta}
+  % \label{eq:MBZ_dyn_spg_ts_eta}
   \eta^{(b)}(\tau,t_{n+1}) - \eta^{(b)}(\tau,t_{n+1}) (\tau,t_{n-1})
-  = 2 \Delta t \left[-\nabla \cdot \textbf{U}^{(b)}(\tau,t_n) + \text{EMP}_w(\tau) \right] 
+  = 2 \Delta t \left[-\nabla \cdot \textbf{U}^{(b)}(\tau,t_n) + \text{EMP}_w(\tau) \right]
 \]
 \begin{multline*}
-  % \label{eq:DYN_spg_ts_u}
+  % \label{eq:MBZ_dyn_spg_ts_u}
   \textbf{U}^{(b)}(\tau,t_{n+1}) - \textbf{U}^{(b)}(\tau,t_{n-1})  \\
   = 2\Delta t \left[ - f \textbf{k} \times \textbf{U}^{(b)}(\tau,t_{n})
@@ -205,13 +201,13 @@
 the freshwater flux $\text{EMP}_w(\tau)$, and total depth of the ocean $H(\tau)$ are held for
 the duration of the barotropic time stepping over a single cycle.
-This is also the time that sets the barotropic time steps via 
-\[
-  % \label{eq:DYN_spg_ts_t}
-  t_n=\tau+n\Delta t   
+This is also the time that sets the barotropic time steps via
+\[
+  % \label{eq:MBZ_dyn_spg_ts_t}
+  t_n=\tau+n\Delta t
 \]
 with $n$ an integer.
-The density scaled surface pressure is evaluated via 
-\[
-  % \label{eq:DYN_spg_ts_ps}
+The density scaled surface pressure is evaluated via
+\[
+  % \label{eq:MBZ_dyn_spg_ts_ps}
   p_s^{(b)}(\tau,t_{n}) =
   \begin{cases}
@@ -220,7 +216,7 @@
   \end{cases}
 \]
-To get started, we assume the following initial conditions 
-\[
-  % \label{eq:DYN_spg_ts_eta}
+To get started, we assume the following initial conditions
+\[
+  % \label{eq:MBZ_dyn_spg_ts_eta}
   \begin{split}
     \eta^{(b)}(\tau,t_{n=0}) &= \overline{\eta^{(b)}(\tau)} \\
@@ -228,7 +224,7 @@
   \end{split}
 \]
-with 
-\[
-  % \label{eq:DYN_spg_ts_etaF}
+with
+\[
+  % \label{eq:MBZ_dyn_spg_ts_etaF}
   \overline{\eta^{(b)}(\tau)} = \frac{1}{N+1} \sum\limits_{n=0}^N \eta^{(b)}(\tau-\Delta t,t_{n})
 \]
@@ -236,27 +232,27 @@
 Likewise,
 \[
-  % \label{eq:DYN_spg_ts_u}
+  % \label{eq:MBZ_dyn_spg_ts_u}
   \textbf{U}^{(b)}(\tau,t_{n=0}) = \overline{\textbf{U}^{(b)}(\tau)}	\\ \\
   \textbf{U}(\tau,t_{n=1}) = \textbf{U}^{(b)}(\tau,t_{n=0}) + \Delta t \ \text{RHS}_{n=0}
 \]
-with 
-\[
-  % \label{eq:DYN_spg_ts_u}
+with
+\[
+  % \label{eq:MBZ_dyn_spg_ts_u}
   \overline{\textbf{U}^{(b)}(\tau)} = \frac{1}{N+1} \sum\limits_{n=0}^N\textbf{U}^{(b)}(\tau-\Delta t,t_{n})
 \]
 the time averaged vertically integrated transport.
-Notably, there is no Robert-Asselin time filter used in the barotropic portion of the integration. 
+Notably, there is no Robert-Asselin time filter used in the barotropic portion of the integration.
 
 Upon reaching $t_{n=N} = \tau + 2\Delta \tau$ , the vertically integrated velocity is time averaged to
-produce the updated vertically integrated velocity at baroclinic time $\tau + \Delta \tau$ 
-\[
-  % \label{eq:DYN_spg_ts_u}
+produce the updated vertically integrated velocity at baroclinic time $\tau + \Delta \tau$
+\[
+  % \label{eq:MBZ_dyn_spg_ts_u}
   \textbf{U}(\tau+\Delta t) = \overline{\textbf{U}^{(b)}(\tau+\Delta t)}
   = \frac{1}{N+1} \sum\limits_{n=0}^N\textbf{U}^{(b)}(\tau,t_{n})
 \]
 The surface height on the new baroclinic time step is then determined via
-a baroclinic leap-frog using the following form 
+a baroclinic leap-frog using the following form
 \begin{equation}
-  \label{eq:DYN_spg_ts_ssh}
+  \label{eq:MBZ_dyn_spg_ts_ssh}
   \eta(\tau+\Delta) - \eta^{F}(\tau-\Delta) = 2\Delta t \ \left[ - \nabla \cdot \textbf{U}(\tau) + \text{EMP}_w \right]
 \end{equation}
@@ -264,20 +260,20 @@
 The use of this "big-leap-frog" scheme for the surface height ensures compatibility between
 the mass/volume budgets and the tracer budgets.
-More discussion of this point is provided in Chapter 10 (see in particular Section 10.2). 
- 
+More discussion of this point is provided in Chapter 10 (see in particular Section 10.2).
+
 In general, some form of time filter is needed to maintain integrity of the surface height field due to
-the leap-frog splitting mode in equation \autoref{eq:DYN_spg_ts_ssh}.
+the leap-frog splitting mode in equation \autoref{eq:MBZ_dyn_spg_ts_ssh}.
 We have tried various forms of such filtering,
 with the following method discussed in Griffies et al. (2001) chosen due to its stability and
-reasonably good maintenance of tracer conservation properties (see ??) 
+reasonably good maintenance of tracer conservation properties (see ??)
 
 \begin{equation}
-  \label{eq:DYN_spg_ts_sshf}
+  \label{eq:MBZ_dyn_spg_ts_sshf}
   \eta^{F}(\tau-\Delta) =  \overline{\eta^{(b)}(\tau)}
 \end{equation}
-Another approach tried was 
-
-\[
-  % \label{eq:DYN_spg_ts_sshf2}
+Another approach tried was
+
+\[
+  % \label{eq:MBZ_dyn_spg_ts_sshf2}
   \eta^{F}(\tau-\Delta) = \eta(\tau)
   + (\alpha/2) \left[\overline{\eta^{(b)}}(\tau+\Delta t)
@@ -288,38 +284,32 @@
 This isolation allows for an easy check that tracer conservation is exact when eliminating tracer and
 surface height time filtering (see ?? for more complete discussion).
-However, in the general case with a non-zero $\alpha$, the filter \autoref{eq:DYN_spg_ts_sshf} was found to
-be more conservative, and so is recommended. 
-
-%-------------------------------------------------------------
-% Filtered formulation 
-%-------------------------------------------------------------
-\subsubsection[Filtered formulation (\texttt{\textbf{key\_dynspg\_flt}})]
-{Filtered formulation (\protect\key{dynspg\_flt})}
-\label{subsec:DYN_spg_flt}
+However, in the general case with a non-zero $\alpha$, the filter \autoref{eq:MBZ_dyn_spg_ts_sshf} was found to
+be more conservative, and so is recommended.
+
+% Filtered formulation
+%% =================================================================================================
+\subsubsection[Filtered formulation (\texttt{\textbf{key\_dynspg\_flt}})]{Filtered formulation (\protect\key{dynspg\_flt})}
+\label{subsec:MBZ_dyn_spg_flt}
 
 The filtered formulation follows the \citet{Roullet2000?} implementation.
 The extra term introduced in the equations (see {\S}I.2.2) is solved implicitly.
 The elliptic solvers available in the code are documented in \autoref{chap:MISC}.
-The amplitude of the extra term is given by the namelist variable \np{rnu}.
+The amplitude of the extra term is given by the namelist variable \np{rnu}{rnu}.
 The default value is 1, as recommended by \citet{Roullet2000?}
 
-\colorbox{red}{\np{rnu}\forcode{ = 1} to be suppressed from namelist !}
-
-%-------------------------------------------------------------
-% Non-linear free surface formulation 
-%-------------------------------------------------------------
-\subsection[Non-linear free surface formulation (\texttt{\textbf{key\_vvl}})]
-{Non-linear free surface formulation (\protect\key{vvl})}
-\label{subsec:DYN_spg_vvl}
+\colorbox{red}{\np[=1]{rnu}{rnu} to be suppressed from namelist !}
+
+% Non-linear free surface formulation
+%% =================================================================================================
+\subsection[Non-linear free surface formulation (\texttt{\textbf{key\_vvl}})]{Non-linear free surface formulation (\protect\key{vvl})}
+\label{subsec:MBZ_dyn_spg_vvl}
 
 In the non-linear free surface formulation, the variations of volume are fully taken into account.
-This option is presented in a report \citep{levier.treguier.ea_rpt07} available on the NEMO web site.
+This option is presented in a report \citep{levier.treguier.ea_rpt07} available on the \NEMO\ web site.
 The three time-stepping methods (explicit, split-explicit and filtered) are the same as in
-\autoref{DYN_spg_linear} except that the ocean depth is now time-dependent.
+\autoref{?:DYN_spg_linear?} except that the ocean depth is now time-dependent.
 In particular, this means that in filtered case, the matrix to be inverted has to be recomputed at each time-step.
 
-\biblio
-
-\pindex
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_time_domain.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_time_domain.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/chap_time_domain.tex	(revision 12143)
@@ -3,48 +3,63 @@
 \begin{document}
 
-% ================================================================
-% Chapter 2 ——— Time Domain (step.F90)
-% ================================================================
-\chapter{Time Domain (STP)}
-\label{chap:STP}
-\minitoc
+\chapter{Time Domain}
+\label{chap:TD}
+
+\thispagestyle{plain}
+
+\chaptertoc
+
+\paragraph{Changes record} ~\\
+
+{\footnotesize
+  \begin{tabularx}{0.5\textwidth}{l||X|X}
+    Release          & Author(s)                                       &
+    Modifications                                                      \\
+    \hline
+    {\em        4.0} & {\em J\'{e}r\^{o}me Chanut \newline Tim Graham} &
+    {\em Review \newline Update                                      } \\
+    {\em        3.6} & {\em Christian \'{E}th\'{e}                   } &
+    {\em Update                                                      } \\
+    {\em $\leq$ 3.4} & {\em Gurvan Madec                             } &
+    {\em First version                                               } \\
+  \end{tabularx}
+}
+
+\clearpage
 
 % Missing things:
-%	- daymod: definition of the time domain (nit000, nitend and the calendar)
-
-\gmcomment{STEVEN :maybe a picture of the directory structure in the introduction which could be referred to here,
-  would help  ==> to be added}
-%%%%
-
-\newpage
-
-Having defined the continuous equations in \autoref{chap:PE}, we need now to choose a time discretization,
+% - daymod: definition of the time domain (nit000, nitend and the calendar)
+
+\cmtgm{STEVEN :maybe a picture of the directory structure in the introduction which
+could be referred to here, would help  ==> to be added}
+
+Having defined the continuous equations in \autoref{chap:MB},
+we need now to choose a time discretization,
 a key feature of an ocean model as it exerts a strong influence on the structure of the computer code
-(\ie on its flowchart).
-In the present chapter, we provide a general description of the \NEMO  time stepping strategy and
+(\ie\ on its flowchart).
+In the present chapter, we provide a general description of the \NEMO\ time stepping strategy and
 the consequences for the order in which the equations are solved.
 
-% ================================================================
-% Time Discretisation
-% ================================================================
+%% =================================================================================================
 \section{Time stepping environment}
-\label{sec:STP_environment}
-
-The time stepping used in \NEMO is a three level scheme that can be represented as follows:
+\label{sec:TD_environment}
+
+The time stepping used in \NEMO\ is a three level scheme that can be represented as follows:
 \begin{equation}
-  \label{eq:STP}
+  \label{eq:TD}
   x^{t + \rdt} = x^{t - \rdt} + 2 \, \rdt \ \text{RHS}_x^{t - \rdt, \, t, \, t + \rdt}
-\end{equation} 
+\end{equation}
 where $x$ stands for $u$, $v$, $T$ or $S$;
-RHS is the Right-Hand-Side of the corresponding time evolution equation;
+RHS is the \textbf{R}ight-\textbf{H}and-\textbf{S}ide of the corresponding time evolution equation;
 $\rdt$ is the time step;
 and the superscripts indicate the time at which a quantity is evaluated.
-Each term of the RHS is evaluated at a specific time stepping depending on the physics with which it is associated.
+Each term of the RHS is evaluated at a specific time stepping depending on
+the physics with which it is associated.
 
 The choice of the time stepping used for this evaluation is discussed below as well as
 the implications for starting or restarting a model simulation.
 Note that the time stepping calculation is generally performed in a single operation.
-With such a complex and nonlinear system of equations it would be dangerous to let a prognostic variable evolve in
-time for each term separately.
+With such a complex and nonlinear system of equations it would be dangerous to
+let a prognostic variable evolve in time for each term separately.
 
 The three level scheme requires three arrays for each prognostic variable.
@@ -52,68 +67,73 @@
 The third array, although referred to as $x_a$ (after) in the code,
 is usually not the variable at the after time step;
-but rather it is used to store the time derivative (RHS in \autoref{eq:STP}) prior to time-stepping the equation.
-The time stepping itself is performed once at each time step where implicit vertical diffusion is computed, \ie in the \mdl{trazdf} and \mdl{dynzdf} modules.
-
-% -------------------------------------------------------------------------------------------------------------
-%        Non-Diffusive Part---Leapfrog Scheme
-% -------------------------------------------------------------------------------------------------------------
+but rather it is used to store the time derivative (RHS in \autoref{eq:TD})
+prior to time-stepping the equation.
+The time stepping itself is performed once at each time step where
+implicit vertical diffusion is computed,
+\ie\ in the \mdl{trazdf} and \mdl{dynzdf} modules.
+
+%% =================================================================================================
 \section{Non-diffusive part --- Leapfrog scheme}
-\label{sec:STP_leap_frog}
-
-The time stepping used for processes other than diffusion is the well-known leapfrog scheme
-\citep{mesinger.arakawa_bk76}.
+\label{sec:TD_leap_frog}
+
+The time stepping used for processes other than diffusion is
+the well-known \textbf{L}eap\textbf{F}rog (LF) scheme \citep{mesinger.arakawa_bk76}.
 This scheme is widely used for advection processes in low-viscosity fluids.
-It is a time centred scheme, \ie the RHS in \autoref{eq:STP} is evaluated at time step $t$, the now time step.
+It is a time centred scheme, \ie\ the RHS in \autoref{eq:TD} is evaluated at
+time step $t$, the now time step.
 It may be used for momentum and tracer advection, pressure gradient, and Coriolis terms,
 but not for diffusion terms.
 It is an efficient method that achieves second-order accuracy with
 just one right hand side evaluation per time step.
-Moreover, it does not artificially damp linear oscillatory motion nor does it produce instability by
-amplifying the oscillations.
+Moreover, it does not artificially damp linear oscillatory motion
+nor does it produce instability by amplifying the oscillations.
 These advantages are somewhat diminished by the large phase-speed error of the leapfrog scheme,
-and the unsuitability of leapfrog differencing for the representation of diffusion and Rayleigh damping processes.
+and the unsuitability of leapfrog differencing for the representation of diffusion and
+Rayleigh damping processes.
 However, the scheme allows the coexistence of a numerical and a physical mode due to
 its leading third order dispersive error.
 In other words a divergence of odd and even time steps may occur.
-To prevent it, the leapfrog scheme is often used in association with a Robert-Asselin time filter
-(hereafter the LF-RA scheme).
-This filter, first designed by \citet{robert_JMSJ66} and more comprehensively studied by \citet{asselin_MWR72},
+To prevent it, the leapfrog scheme is often used in association with
+a \textbf{R}obert-\textbf{A}sselin time filter (hereafter the LF-RA scheme).
+This filter,
+first designed by \citet{robert_JMSJ66} and more comprehensively studied by \citet{asselin_MWR72},
 is a kind of laplacian diffusion in time that mixes odd and even time steps:
 \begin{equation}
-  \label{eq:STP_asselin}
+  \label{eq:TD_asselin}
   x_F^t = x^t + \gamma \, \lt[ x_F^{t - \rdt} - 2 x^t + x^{t + \rdt} \rt]
 \end{equation}
 where the subscript $F$ denotes filtered values and $\gamma$ is the Asselin coefficient.
-$\gamma$ is initialized as \np{rn\_atfp} (namelist parameter).
-Its default value is \np{rn\_atfp}\forcode{ = 10.e-3} (see \autoref{sec:STP_mLF}),
+$\gamma$ is initialized as \np{rn_atfp}{rn\_atfp} (namelist parameter).
+Its default value is \np[=10.e-3]{rn_atfp}{rn\_atfp} (see \autoref{sec:TD_mLF}),
 causing only a weak dissipation of high frequency motions (\citep{farge-coulombier_phd87}).
 The addition of a time filter degrades the accuracy of the calculation from second to first order.
 However, the second order truncation error is proportional to $\gamma$, which is small compared to 1.
 Therefore, the LF-RA is a quasi second order accurate scheme.
-The LF-RA scheme is preferred to other time differencing schemes such as predictor corrector or trapezoidal schemes,
-because the user has an explicit and simple control of the magnitude of the time diffusion of the scheme. 
-When used with the 2nd order space centred discretisation of the advection terms in
+The LF-RA scheme is preferred to other time differencing schemes such as
+predictor corrector or trapezoidal schemes, because the user has an explicit and simple control of
+the magnitude of the time diffusion of the scheme.
+When used with the 2$^nd$ order space centred discretisation of the advection terms in
 the momentum and tracer equations, LF-RA avoids implicit numerical diffusion:
-diffusion is set explicitly by the user through the Robert-Asselin 
-filter parameter and the viscosity and diffusion coefficients.
-
-% -------------------------------------------------------------------------------------------------------------
-%        Diffusive Part---Forward or Backward Scheme
-% -------------------------------------------------------------------------------------------------------------
+diffusion is set explicitly by the user through the Robert-Asselin filter parameter and
+the viscosity and diffusion coefficients.
+
+%% =================================================================================================
 \section{Diffusive part --- Forward or backward scheme}
-\label{sec:STP_forward_imp}
-
-The leapfrog differencing scheme is unsuitable for the representation of diffusion and damping processes.
+\label{sec:TD_forward_imp}
+
+The leapfrog differencing scheme is unsuitable for
+the representation of diffusion and damping processes.
 For a tendency $D_x$, representing a diffusion term or a restoring term to a tracer climatology
 (when present, see \autoref{sec:TRA_dmp}), a forward time differencing scheme is used :
 \[
-  %\label{eq:STP_euler}
+  %\label{eq:TD_euler}
   x^{t + \rdt} = x^{t - \rdt} + 2 \, \rdt \ D_x^{t - \rdt}
 \]
 
 This is diffusive in time and conditionally stable.
-The conditions for stability of second and fourth order horizontal diffusion schemes are \citep{griffies_bk04}:
+The conditions for stability of second and fourth order horizontal diffusion schemes are
+\citep{griffies_bk04}:
 \begin{equation}
-  \label{eq:STP_euler_stability}
+  \label{eq:TD_euler_stability}
   A^h <
   \begin{cases}
@@ -122,24 +142,26 @@
   \end{cases}
 \end{equation}
-where $e$ is the smallest grid size in the two horizontal directions and $A^h$ is the mixing coefficient.
-The linear constraint \autoref{eq:STP_euler_stability} is a necessary condition, but not sufficient.
+where $e$ is the smallest grid size in the two horizontal directions and
+$A^h$ is the mixing coefficient.
+The linear constraint \autoref{eq:TD_euler_stability} is a necessary condition, but not sufficient.
 If it is not satisfied, even mildly, then the model soon becomes wildly unstable.
-The instability can be removed by either reducing the length of the time steps or reducing the mixing coefficient.
+The instability can be removed by either reducing the length of the time steps or
+reducing the mixing coefficient.
 
 For the vertical diffusion terms, a forward time differencing scheme can be used,
-but usually the numerical stability condition imposes a strong constraint on the time step. To overcome the stability constraint, a 
-backward (or implicit) time differencing scheme is used. This scheme is unconditionally stable but diffusive and can be written as follows:
+but usually the numerical stability condition imposes a strong constraint on the time step.
+To overcome the stability constraint, a backward (or implicit) time differencing scheme is used.
+This scheme is unconditionally stable but diffusive and can be written as follows:
 \begin{equation}
-  \label{eq:STP_imp}
+  \label{eq:TD_imp}
   x^{t + \rdt} = x^{t - \rdt} + 2 \, \rdt \ \text{RHS}_x^{t + \rdt}
 \end{equation}
 
-%%gm
-%%gm   UPDATE the next paragraphs with time varying thickness ...
-%%gm
-
-This scheme is rather time consuming since it requires a matrix inversion. For example, the finite difference approximation of the temperature equation is:
+\cmtgm{UPDATE the next paragraphs with time varying thickness ...}
+
+This scheme is rather time consuming since it requires a matrix inversion.
+For example, the finite difference approximation of the temperature equation is:
 \[
-  % \label{eq:STP_imp_zdf}
+  % \label{eq:TD_imp_zdf}
   \frac{T(k)^{t + 1} - T(k)^{t - 1}}{2 \; \rdt}
   \equiv
@@ -147,94 +169,98 @@
 \]
 where RHS is the right hand side of the equation except for the vertical diffusion term.
-We rewrite \autoref{eq:STP_imp} as:
+We rewrite \autoref{eq:TD_imp} as:
 \begin{equation}
-  \label{eq:STP_imp_mat}
+  \label{eq:TD_imp_mat}
   -c(k + 1) \; T^{t + 1}(k + 1) + d(k) \; T^{t + 1}(k) - \; c(k) \; T^{t + 1}(k - 1) \equiv b(k)
 \end{equation}
-where 
-\begin{align*} 
-  c(k) &= A_w^{vT} (k) \, / \, e_{3w} (k)     \\
-  d(k) &= e_{3t}   (k)       \, / \, (2 \rdt) + c_k + c_{k + 1}    \\
-  b(k) &= e_{3t}   (k) \; \lt( T^{t - 1}(k) \, / \, (2 \rdt) + \text{RHS} \rt)
-\end{align*}
-
-\autoref{eq:STP_imp_mat} is a linear system of equations with an associated matrix which is tridiagonal.
-Moreover,
-$c(k)$ and $d(k)$ are positive and the diagonal term is greater than the sum of the two extra-diagonal terms,
+where
+\[
+  c(k) = A_w^{vT} (k) \, / \, e_{3w} (k) \text{,} \quad
+  d(k) = e_{3t}   (k)       \, / \, (2 \rdt) + c_k + c_{k + 1} \quad \text{and} \quad
+  b(k) = e_{3t}   (k) \; \lt( T^{t - 1}(k) \, / \, (2 \rdt) + \text{RHS} \rt)
+\]
+
+\autoref{eq:TD_imp_mat} is a linear system of equations with
+an associated matrix which is tridiagonal.
+Moreover, $c(k)$ and $d(k)$ are positive and
+the diagonal term is greater than the sum of the two extra-diagonal terms,
 therefore a special adaptation of the Gauss elimination procedure is used to find the solution
 (see for example \citet{richtmyer.morton_bk67}).
 
-% -------------------------------------------------------------------------------------------------------------
-%        Surface Pressure gradient
-% -------------------------------------------------------------------------------------------------------------
+%% =================================================================================================
 \section{Surface pressure gradient}
-\label{sec:STP_spg_ts}
-
-The leapfrog environment supports a centred in time computation of the surface pressure, \ie evaluated 
-at \textit{now} time step. This refers to as the explicit free surface case in the code (\np{ln\_dynspg\_exp}\forcode{ = .true.}). 
-This choice however imposes a strong constraint on the time step which should be small enough to resolve the propagation 
-of external gravity waves. As a matter of fact, one rather use in a realistic setup, a split-explicit free surface 
-(\np{ln\_dynspg\_ts}\forcode{ = .true.}) in which barotropic and baroclinic dynamical equations are solved separately with ad-hoc 
-time steps. The use of the time-splitting (in combination with non-linear free surface) imposes some constraints on the design of 
-the overall flowchart, in particular to ensure exact tracer conservation (see \autoref{fig:TimeStep_flowchart}).
-
-Compared to the former use of the filtered free surface in \NEMO v3.6 (\citet{roullet.madec_JGR00}), the use of a split-explicit free surface is advantageous 
-on massively parallel computers. Indeed, no global computations are anymore required by the elliptic solver which saves a substantial amount of communication 
-time. Fast barotropic motions (such as tides) are also simulated with a better accuracy. 
-
-%\gmcomment{ 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_TimeStepping_flowchart_v4}
-    \caption{
-      \protect\label{fig:TimeStep_flowchart}
-      Sketch of the leapfrog time stepping sequence in \NEMO with split-explicit free surface. The latter combined
-       with non-linear free surface requires the dynamical tendency being updated prior tracers tendency to ensure 
-       conservation. Note the use of time integrated fluxes issued from the barotropic loop  in subsequent calculations 
-       of tracer advection and in the continuity equation. Details about the time-splitting scheme can be found 
-       in \autoref{subsec:DYN_spg_ts}.
-    }
-  \end{center}
+\label{sec:TD_spg_ts}
+
+The leapfrog environment supports a centred in time computation of the surface pressure,
+\ie\ evaluated at \textit{now} time step.
+This refers to as the explicit free surface case in the code
+(\np[=.true.]{ln_dynspg_exp}{ln\_dynspg\_exp}).
+This choice however imposes a strong constraint on the time step which
+should be small enough to resolve the propagation of external gravity waves.
+As a matter of fact, one rather use in a realistic setup,
+a split-explicit free surface (\np[=.true.]{ln_dynspg_ts}{ln\_dynspg\_ts}) in which
+barotropic and baroclinic dynamical equations are solved separately with ad-hoc time steps.
+The use of the time-splitting (in combination with non-linear free surface) imposes
+some constraints on the design of the overall flowchart,
+in particular to ensure exact tracer conservation (see \autoref{fig:TD_TimeStep_flowchart}).
+
+Compared to the former use of the filtered free surface in \NEMO\ v3.6 (\citet{roullet.madec_JGR00}),
+the use of a split-explicit free surface is advantageous on massively parallel computers.
+Indeed, no global computations are anymore required by the elliptic solver which
+saves a substantial amount of communication time.
+Fast barotropic motions (such as tides) are also simulated with a better accuracy.
+
+%\cmtgm{
+\begin{figure}
+  \centering
+  \includegraphics[width=0.66\textwidth]{TD_TimeStepping_flowchart_v4}
+  \caption[Leapfrog time stepping sequence with split-explicit free surface]{
+    Sketch of the leapfrog time stepping sequence in \NEMO\ with split-explicit free surface.
+    The latter combined with non-linear free surface requires
+    the dynamical tendency being updated prior tracers tendency to ensure conservation.
+    Note the use of time integrated fluxes issued from the barotropic loop in
+    subsequent calculations of tracer advection and in the continuity equation.
+    Details about the time-splitting scheme can be found in \autoref{subsec:DYN_spg_ts}.}
+  \label{fig:TD_TimeStep_flowchart}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 %}
 
-% -------------------------------------------------------------------------------------------------------------
-%        The Modified Leapfrog -- Asselin Filter scheme
-% -------------------------------------------------------------------------------------------------------------
-\section{Modified Leapfrog -- Asselin filter scheme}
-\label{sec:STP_mLF}
-
-Significant changes have been introduced by \cite{leclair.madec_OM09} in the LF-RA scheme in order to
-ensure tracer conservation and to allow the use of a much smaller value of the Asselin filter parameter.
+%% =================================================================================================
+\section{Modified LeapFrog -- Robert Asselin filter scheme (LF-RA)}
+\label{sec:TD_mLF}
+
+Significant changes have been introduced by \cite{leclair.madec_OM09} in
+the LF-RA scheme in order to ensure tracer conservation and to
+allow the use of a much smaller value of the Asselin filter parameter.
 The modifications affect both the forcing and filtering treatments in the LF-RA scheme.
 
-In a classical LF-RA environment, the forcing term is centred in time,
-\ie it is time-stepped over a $2 \rdt$ period:
+In a classical LF-RA environment,
+the forcing term is centred in time, \ie\ it is time-stepped over a $2 \rdt$ period:
 $x^t = x^t + 2 \rdt Q^t$ where $Q$ is the forcing applied to $x$,
-and the time filter is given by \autoref{eq:STP_asselin} so that $Q$ is redistributed over several time step.
+and the time filter is given by \autoref{eq:TD_asselin} so that
+$Q$ is redistributed over several time step.
 In the modified LF-RA environment, these two formulations have been replaced by:
 \begin{gather}
-  \label{eq:STP_forcing}
+  \label{eq:TD_forcing}
   x^{t + \rdt} = x^{t - \rdt} + \rdt \lt( Q^{t - \rdt / 2} + Q^{t + \rdt / 2} \rt)  \\
-  \label{eq:STP_RA}
+  \label{eq:TD_RA}
   x_F^t       = x^t + \gamma \, \lt( x_F^{t - \rdt} - 2 x^t + x^{t + \rdt} \rt)
                     - \gamma \, \rdt \, \lt( Q^{t + \rdt / 2} - Q^{t - \rdt / 2} \rt)
 \end{gather}
-The change in the forcing formulation given by \autoref{eq:STP_forcing} (see \autoref{fig:MLF_forcing})
-has a significant effect:
-the forcing term no longer excites the divergence of odd and even time steps \citep{leclair.madec_OM09}.
+The change in the forcing formulation given by \autoref{eq:TD_forcing}
+(see \autoref{fig:TD_MLF_forcing}) has a significant effect:
+the forcing term no longer excites the divergence of odd and even time steps
+\citep{leclair.madec_OM09}.
 % forcing seen by the model....
 This property improves the LF-RA scheme in two aspects.
 First, the LF-RA can now ensure the local and global conservation of tracers.
 Indeed, time filtering is no longer required on the forcing part.
-The influence of the Asselin filter on the forcing is explicitly removed by adding a new term in the filter
-(last term in \autoref{eq:STP_RA} compared to \autoref{eq:STP_asselin}).
+The influence of the Asselin filter on the forcing is explicitly removed by
+adding a new term in the filter (last term in \autoref{eq:TD_RA} compared to \autoref{eq:TD_asselin}).
 Since the filtering of the forcing was the source of non-conservation in the classical LF-RA scheme,
 the modified formulation becomes conservative \citep{leclair.madec_OM09}.
-Second, the LF-RA becomes a truly quasi -second order scheme.
-Indeed, \autoref{eq:STP_forcing} used in combination with a careful treatment of static instability
-(\autoref{subsec:ZDF_evd}) and of the TKE physics (\autoref{subsec:ZDF_tke_ene}) 
+Second, the LF-RA becomes a truly quasi-second order scheme.
+Indeed, \autoref{eq:TD_forcing} used in combination with a careful treatment of static instability
+(\autoref{subsec:ZDF_evd}) and of the TKE physics (\autoref{subsec:ZDF_tke_ene})
 (the two other main sources of time step divergence),
 allows a reduction by two orders of magnitude of the Asselin filter parameter.
@@ -242,45 +268,44 @@
 Note that the forcing is now provided at the middle of a time step:
 $Q^{t + \rdt / 2}$ is the forcing applied over the $[t,t + \rdt]$ time interval.
-This and the change in the time filter, \autoref{eq:STP_RA},
+This and the change in the time filter, \autoref{eq:TD_RA},
 allows for an exact evaluation of the contribution due to the forcing term between any two time steps,
 even if separated by only $\rdt$ since the time filter is no longer applied to the forcing term.
 
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-\begin{figure}[!t]
-  \begin{center}
-    \includegraphics[width=\textwidth]{Fig_MLF_forcing}
-    \caption{
-      \protect\label{fig:MLF_forcing}
-      Illustration of forcing integration methods.
-      (top) ''Traditional'' formulation:
-      the forcing is defined at the same time as the variable to which it is applied
-      (integer value of the time step index) and it is applied over a $2 \rdt$ period.
-      (bottom)  modified formulation:
-      the forcing is defined in the middle of the time (integer and a half value of the time step index) and
-      the mean of two successive forcing values ($n - 1 / 2$, $n + 1 / 2$) is applied over a $2 \rdt$ period.
-    }
-  \end{center}
+\begin{figure}
+  \centering
+  \includegraphics[width=0.66\textwidth]{TD_MLF_forcing}
+  \caption[Forcing integration methods for modified leapfrog (top and bottom)]{
+    Illustration of forcing integration methods.
+    (top) ''Traditional'' formulation:
+    the forcing is defined at the same time as the variable to which it is applied
+    (integer value of the time step index) and it is applied over a $2 \rdt$ period.
+    (bottom)  modified formulation:
+    the forcing is defined in the middle of the time
+    (integer and a half value of the time step index) and
+    the mean of two successive forcing values ($n - 1 / 2$, $n + 1 / 2$) is applied over
+    a $2 \rdt$ period.}
+  \label{fig:TD_MLF_forcing}
 \end{figure}
-%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-
-% -------------------------------------------------------------------------------------------------------------
-%        Start/Restart strategy
-% -------------------------------------------------------------------------------------------------------------
+
+%% =================================================================================================
 \section{Start/Restart strategy}
-\label{sec:STP_rst}
-
-%--------------------------------------------namrun-------------------------------------------
-\nlst{namrun}
-%--------------------------------------------------------------------------------------------------------------
-
-The first time step of this three level scheme when starting from initial conditions is a forward step
-(Euler time integration):
+\label{sec:TD_rst}
+
+\begin{listing}
+  \nlst{namrun}
+  \caption{\forcode{&namrun}}
+  \label{lst:namrun}
+\end{listing}
+
+The first time step of this three level scheme when starting from initial conditions is
+a forward step (Euler time integration):
 \[
-  % \label{eq:DOM_euler}
+  % \label{eq:TD_DOM_euler}
   x^1 = x^0 + \rdt \ \text{RHS}^0
 \]
-This is done simply by keeping the leapfrog environment (\ie the \autoref{eq:STP} three level time stepping) but
+This is done simply by keeping the leapfrog environment
+(\ie\ the \autoref{eq:TD} three level time stepping) but
 setting all $x^0$ (\textit{before}) and $x^1$ (\textit{now}) fields equal at the first time step and
-using half the value of a leapfrog time step ($2 \rdt$). 
+using half the value of a leapfrog time step ($2 \rdt$).
 
 It is also possible to restart from a previous computation, by using a restart file.
@@ -289,48 +314,42 @@
 running the model for $2N$ time steps in one go,
 or by performing two consecutive experiments of $N$ steps with a restart.
-This requires saving two time levels and many auxiliary data in the restart files in machine precision.
+This requires saving two time levels and many auxiliary data in
+the restart files in machine precision.
 
 Note that the time step $\rdt$, is also saved in the restart file.
-When restarting, if the time step has been changed, or one of the prognostic variables at \textit{before} time step 
-is missing, an Euler time stepping scheme is imposed. A forward initial step can still be enforced by the user by setting 
-the namelist variable \np{nn\_euler}\forcode{=0}. Other options to control the time integration of the model 
-are defined through the  \ngn{namrun} namelist variables.
-%%%
-\gmcomment{
+When restarting, if the time step has been changed, or
+one of the prognostic variables at \textit{before} time step is missing,
+an Euler time stepping scheme is imposed.
+A forward initial step can still be enforced by the user by
+setting the namelist variable \np[=0]{nn_euler}{nn\_euler}.
+Other options to control the time integration of the model are defined through
+the \nam{run}{run} namelist variables.
+
+\cmtgm{
 add here how to force the restart to contain only one time step for operational purposes
 
 add also the idea of writing several restart for seasonal forecast : how is it done ?
 
-verify that all namelist pararmeters are truly described 
+verify that all namelist parameters are truly described
 
 a word on the check of restart  .....
 }
-%%%
-
-\gmcomment{       % add a subsection here  
-
-%-------------------------------------------------------------------------------------------------------------
-%        Time Domain
-% -------------------------------------------------------------------------------------------------------------
+
+\cmtgm{       % add a subsection here
+
+%% =================================================================================================
 \subsection{Time domain}
-\label{subsec:STP_time}
-%--------------------------------------------namrun-------------------------------------------
-
-\nlst{namdom}         
-%--------------------------------------------------------------------------------------------------------------
-
-Options are defined through the  \ngn{namdom} namelist variables.
+\label{subsec:TD_time}
+
+Options are defined through the\nam{dom}{dom} namelist variables.
  \colorbox{yellow}{add here a few word on nit000 and nitend}
 
  \colorbox{yellow}{Write documentation on the calendar and the key variable adatrj}
 
-add a description of daymod, and the model calandar (leap-year and co)
-
-}     	%% end add
-
-
-
-%%
-\gmcomment{       % add implicit in vvl case  and Crant-Nicholson scheme   
+add a description of daymod, and the model calendar (leap-year and co)
+
+}     %% end add
+
+\cmtgm{       % add implicit in vvl case  and Crant-Nicholson scheme
 
 Implicit time stepping in case of variable volume thickness.
@@ -381,10 +400,7 @@
 \end{flalign*}
 
-%%
 }
 
-\biblio
-
-\pindex
+\subinc{\input{../../global/epilogue}}
 
 \end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/introduction.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/introduction.tex	(revision 12062)
+++ 	(revision )
@@ -1,350 +1,0 @@
-\documentclass[../main/NEMO_manual]{subfiles}
-
-\begin{document}
-
-% ================================================================
-% INTRODUCTION
-% ================================================================
-
-\chapter{Introduction}
-
-The Nucleus for European Modelling of the Ocean (\NEMO) is a framework of ocean related engines,
-namely OPA \footnote{OPA: Oc\'{e}an PArall\'{e}lis\'{e} (french)} for the ocean dynamics and thermodynamics,
-SI$^3$ \footnote{SI$^3$: Sea-Ice modelling Integrated Initiative} for the sea-ice dynamics and thermodynamics,
-TOP \footnote{TOP: Tracer in the Ocean Paradigm} for the biogeochemistry 
-(both transport (TRP) and sources minus sinks 
-(PISCES \footnote{PISCES: Pelagic Interactions Scheme for Carbon and Ecosystem Studies})).
-It is intended to be a flexible tool for studying the ocean and its interactions with the other components of
-the earth climate system (atmosphere, sea-ice, biogeochemical tracers, ...) over
-a wide range of space and time scales.
-This manual provides information about the physics represented by the ocean component of \NEMO and
-the rationale for the choice of numerical schemes and the model design.
-For the use of framework, 
-a guide which gathers the \texttt{README} files spread out in the source code can be build and 
-exported in web or printable format (see \path{./doc/rst}).
-An online version of the guide is also available on the 
-\href{http://forge.ipsl.jussieu.fr/nemo}{\NEMO forge platform}.
-
-The ocean component of \NEMO has been developed from the legacy of the OPA model, release 8.2, 
-described in \citet{madec.delecluse.ea_NPM98}.
-This model has been used for a wide range of applications, both regional or global, as a forced ocean model and 
-as a model coupled with the sea-ice and/or the atmosphere.
-
-This manual is organised in as follows.
-\autoref{chap:PE} presents the model basics, \ie the equations and their assumptions,
-the vertical coordinates used, and the subgrid scale physics.
-This part deals with the continuous equations of the model
-(primitive equations, with temperature, salinity and an equation of seawater).
-The equations are written in a curvilinear coordinate system, with a choice of vertical coordinates
-($z$, $s$, \zstar, \sstar, \ztilde, \stilde, and a mix of them).
-Momentum equations are formulated in vector invariant or flux form.
-Dimensional units in the meter, kilogram, second (MKS) international system are used throughout.
-
-The following chapters deal with the discrete equations.
-\autoref{chap:STP} presents the time domain.
-The model time stepping environment is a three level scheme in which 
-the tendency terms of the equations are evaluated either centered in time, or forward, or backward depending of 
-the nature of the term.
-\autoref{chap:DOM} presents the space domain.
-The model is discretised on a staggered grid (Arakawa C grid) with masking of land areas.
-Vertical discretisation used depends on both how the bottom topography is represented and whether 
-the free surface is linear or not.
-Full step or partial step $z$-coordinate or $s$- (terrain-following) coordinate is used with linear free surface 
-(level position are then fixed in time).
-In non-linear free surface, the corresponding rescaled height coordinate formulation (\zstar or \sstar) is used
-(the level position then vary in time as a function of the sea surface heigh).
-The following two chapters (\autoref{chap:TRA} and \autoref{chap:DYN}) describe the discretisation of
-the prognostic equations for the active tracers and the momentum.
-Explicit, split-explicit and filtered free surface formulations are implemented.
-A number of numerical schemes are available for momentum advection, 
-for the computation of the pressure gradients, as well as for the advection of tracers 
-(second or higher order advection schemes, including positive ones).
-
-Surface boundary conditions (\autoref{chap:SBC}) can be implemented as prescribed fluxes, or bulk formulations for 
-the surface fluxes (wind stress, heat, freshwater).
-The model allows penetration of solar radiation.
-There is an optional geothermal heating at the ocean bottom.
-Within the \NEMO system the ocean model is interactively coupled with a sea ice model (SI$^3$) and
-a biogeochemistry model (PISCES).
-Interactive coupling to Atmospheric models is possible via the \href{https://portal.enes.org/oasis}{OASIS coupler}.
-Two-way nesting is also available through an interface to the AGRIF package
-(Adaptative Grid Refinement in \fortran) \citep{debreu.vouland.ea_CG08}.
-% Needs to be reviewed
-%The interface code for coupling to an alternative sea ice model (CICE, \citet{Hunke2008}) has now been upgraded so
-%that it works for both global and regional domains, although AGRIF is still not available.
-
-Other model characteristics are the lateral boundary conditions (\autoref{chap:LBC}).
-Global configurations of the model make use of the ORCA tripolar grid, with special north fold boundary condition.
-Free-slip or no-slip boundary conditions are allowed at land boundaries.
-Closed basin geometries as well as periodic domains and open boundary conditions are possible.
-
-Physical parameterisations are described in \autoref{chap:LDF} and \autoref{chap:ZDF}.
-The model includes an implicit treatment of vertical viscosity and diffusivity.
-The lateral Laplacian and biharmonic viscosity and diffusion can be rotated following
-a geopotential or neutral direction.
-There is an optional eddy induced velocity \citep{gent.mcwilliams_JPO90} with a space and time variable coefficient
-\citet{treguier.held.ea_JPO97}.
-The model has vertical harmonic viscosity and diffusion with a space and time variable coefficient,
-with options to compute the coefficients with \citet{blanke.delecluse_JPO93}, \citet{pacanowski.philander_JPO81}, or 
-\citet{umlauf.burchard_JMR03} mixing schemes.
- 
-%%gm    To be put somewhere else ....
-%%nm    We should consider creating a glossary for all this kind of stuff (terms, acronyms and symbols)
-%%      http://en.wikibooks.org/wiki/LaTeX/Glossary
-\noindent CPP keys and namelists are used as inputs to the code.
-
-\noindent \index{CPP keys} CPP keys
-
-Some CPP keys are implemented in the \fortran code to allow code selection at compiling step.
-This selection of code at compilation time reduces the reliability of the whole platform since
-it changes the code from one set of CPP keys to the other.
-It is used only when the addition/suppression of the part of code highly changes the amount of memory at run time.
-Usual coding looks like: 
-
-\begin{forlines}
-#if defined key_option1
-	! This part of the \fortran code will be active
-	! only if key_option1 is activated at compiling step
-#endif
-\end{forlines}
-
-\noindent \index{Namelist} Namelists
-
-The namelist allows to input variables (character, logical, real and integer) into the code.
-There is one namelist file for each component of NEMO (dynamics, sea-ice, biogeochemistry...)
-containing all the \fortran namelists needed.
-The implementation in NEMO uses a 2-step process. 
-For each \fortran namelist, two files are read:
-
-\begin{enumerate}
-\item
-  A reference namelist (in \path{./cfgs/SHARED/namelist_ref}) is read first.
-  This file contains all the namelist variables which are initialised to default values
-\item
-  A configuration namelist (in \path{./cfgs/CFG_NAME/EXP00/namelist_cfg}) is read aferwards.
-  This file contains only the namelist variables which are changed from default values, and overwrites those.
-\end{enumerate}
-A template can be found in \path{NEMO/OPA_SRC/module.example}.
-The effective namelist, taken in account during the run, is stored at execution time in
-an \texttt{output\_namelist\_dyn} (or \texttt{\_ice} or \texttt{\_top}) file.
-%%gm  end
-
-Model outputs management and specific online diagnostics are described in \autoref{chap:DIA}.
-The diagnostics includes the output of all the tendencies of the momentum and tracers equations,
-the output of tracers tendencies averaged over the time evolving mixed layer,
-the output of the tendencies of the barotropic vorticity equation,
-the computation of on-line floats trajectories...
-\autoref{chap:OBS} describes a tool which reads in observation files
-(profile temperature and salinity, sea surface temperature, sea level anomaly and sea ice concentration) 
-and calculates an interpolated model equivalent value at the observation location and nearest model timestep.
-Originally developed of data assimilation, it is a fantastic tool for model and data comparison.
-\autoref{chap:ASM} describes how increments produced by data assimilation may be applied to the model equations.
-Finally, \autoref{chap:CFG} provides a brief introduction to the pre-defined model configurations
-(water column model, ORCA and GYRE families of configurations).
-
-%%nm: Add some words on the NEMO dependencies
-The model is implemented in \fninety, with preprocessing (C pre-processor).
-It runs under UNIX.
-It is optimized for vector computers and parallelised by domain decomposition with MPI.
-All input and output is done in NetCDF (Network Common Data Format) with a optional direct access format for output.
-To ensure the clarity and readability of the code it is necessary to follow coding rules.
-The coding rules for OPA include conventions for naming variables,
-with different starting letters for different types of variables (real, integer, parameter\ldots).
-Those rules are briefly presented in \autoref{apdx:coding} and a more complete document is available .
-
-The model is organized with a high internal modularity based on physics.
-For example, each trend (\ie, a term in the RHS of the prognostic equation) for momentum and tracers
-is computed in a dedicated module.
-To make it easier for the user to find his way around the code, the module names follow a three-letter rule.
-For example, \mdl{traldf} is a module related to the TRAcers equation, computing the Lateral DiFfussion.
-%The complete list of module names is presented in \autoref{apdx:coding}.      %====>>>> to be done !
-Furthermore, modules are organized in a few directories that correspond to their category,
-as indicated by the first three letters of their name (\autoref{tab:chapters}).
-
-The manual mirrors the organization of the model.
-After the presentation of the continuous equations (\autoref{chap:PE}),
-the following chapters refer to specific terms of the equations each associated with a group of modules 
-(\autoref{tab:chapters}).
-
-%--------------------------------------------------TABLE--------------------------------------------------
-\begin{table}[!t]	
-  \caption{
-    \protect\label{tab:chapters}
-    Organization of Chapters mimicking the one of the model directories.
-  }
-  \begin{center}
-    \begin{tabular}{|l|l|l|}
-      \hline
-      \autoref{chap:STP}  & -   & model time STePping environment \\
-      \hline
-      \autoref{chap:DOM}  & DOM & model DOMain \\
-      \hline
-      \autoref{chap:TRA}  & TRA & TRAcer equations (potential temperature and salinity) \\
-      \hline
-      \autoref{chap:DYN}  & DYN & DYNamic equations (momentum) \\
-      \hline
-      \autoref{chap:SBC}  & SBC & Surface Boundary Conditions \\
-      \hline
-      \autoref{chap:LBC}  & LBC & Lateral Boundary Conditions (also OBC and BDY)  \\
-      \hline
-      \autoref{chap:LDF}  & LDF & Lateral DiFfusion (parameterisations) \\
-      \hline
-      \autoref{chap:ZDF}  & ZDF & vertical (Z) DiFfusion (parameterisations)  \\
-      \hline
-      \autoref{chap:DIA}  & DIA & I/O and DIAgnostics (also IOM, FLO and TRD) \\
-      \hline
-      \autoref{chap:OBS}  & OBS & OBServation and model comparison  \\
-      \hline
-      \autoref{chap:ASM}  & ASM & ASsiMilation increment  \\
-      \hline
-      \autoref{chap:MISC} & SOL & Miscellaneous  topics (including solvers)  \\
-      \hline
-      \autoref{chap:CFG}  & -   & predefined configurations (including C1D) \\
-      \hline
-    \end{tabular}
-  \end{center}
-\end{table}
-%--------------------------------------------------------------------------------------------------------------
-
-%% nm: the following section has to vastly remodeled to focus only on well-identified versions of NEMO
-%% (3.4, 3.6, 4.0 and further releases). Then its formatting must be improved too.
-\subsubsection{Changes between releases}
-
-NEMO/OPA, like all research tools, is in perpetual evolution.
-The present document describes the OPA version include in the release 3.4 of NEMO.
-This release differs significantly from version 8, documented in \citet{madec.delecluse.ea_NPM98}. \\
-
-The main modifications from OPA v8 and NEMO/OPA v3.2 are :
-
-\begin{itemize}
-\item
-  transition to full native \fninety, deep code restructuring and drastic reduction of CPP keys; 
-\item
-  introduction of partial step representation of bottom topography
-  \citep{barnier.madec.ea_OD06, le-sommer.penduff.ea_OM09, penduff.le-sommer.ea_OS07};
-\item
-  partial reactivation of a terrain-following vertical coordinate ($s$- and hybrid $s$-$z$) with
-  the addition of several options for pressure gradient computation
-  \footnote{
-    Partial support of $s$-coordinate: there is presently no support for neutral physics in
-    $s$-coordinate and for the new options for horizontal pressure gradient computation with
-    a non-linear equation of state.
-  }
-  ;
-\item
-  more choices for the treatment of the free surface: full explicit, split-explicit or filtered schemes,
-  and suppression of the rigid-lid option;
-\item
-  non linear free surface associated with the rescaled height coordinate \zstar or $s$;
-\item
-  additional schemes for vector and flux forms of the momentum advection;
-\item
-  additional advection schemes for tracers;
-\item
-  implementation of the AGRIF package (Adaptative Grid Refinement in \fortran) \citep{debreu.vouland.ea_CG08};
-\item
-  online diagnostics : tracers trend in the mixed layer and vorticity balance;
-\item
-  rewriting of the I/O management with the use of an I/O server;
-\item
-  generalized ocean-ice-atmosphere-CO2 coupling interface, interfaced with OASIS 3 coupler;
-\item
-  surface module (SBC) that simplify the way the ocean is forced and include two bulk formulea (CLIO and CORE) and
-  which includes an on-the-fly interpolation of input forcing fields;
-\item
-  RGB light penetration and optional use of ocean color 
-\item
-  major changes in the TKE schemes: it now includes a Langmuir cell parameterization \citep{axell_JGR02},
-  the \citet{mellor.blumberg_JPO04} surface wave breaking parameterization, and has a time discretization which
-  is energetically consistent with the ocean model equations \citep{burchard_OM02, marsaleix.auclair.ea_OM08};
-\item
-  tidal mixing parametrisation (bottom intensification) + Indonesian specific tidal mixing
-  \citep{koch-larrouy.madec.ea_GRL07};
-\item
-  introduction of LIM-3, the new Louvain-la-Neuve sea-ice model
-  (C-grid rheology and new thermodynamics including bulk ice salinity)
-  \citep{vancoppenolle.fichefet.ea_OM09*a, vancoppenolle.fichefet.ea_OM09*b}
-\end{itemize}
-
-The main modifications from NEMO/OPA v3.2 and v3.3 are:
-
-\begin{itemize}
-\item
-  introduction of a modified leapfrog-Asselin filter time stepping scheme
-  \citep{leclair.madec_OM09}; 
-\item
-  additional scheme for iso-neutral mixing \citep{griffies.gnanadesikan.ea_JPO98}, although it is still a "work in progress";
-\item
-  a rewriting of the bottom boundary layer scheme, following \citet{campin.goosse_T99};
-\item
-  addition of a Generic Length Scale vertical mixing scheme, following \citet{umlauf.burchard_JMR03};
-\item
-  addition of the atmospheric pressure as an external forcing on both ocean and sea-ice dynamics;
-\item
-  addition of a diurnal cycle on solar radiation \citep{bernie.guilyardi.ea_CD07};
-\item
-  river runoffs added through a non-zero depth, and having its own temperature and salinity;
-\item
-  CORE II normal year forcing set as the default forcing of ORCA2-LIM configuration;
-\item
-  generalisation of the use of \mdl{fldread} for all input fields (ocean climatology, sea-ice damping...);
-\item
-  addition of an on-line observation and model comparison (thanks to NEMOVAR project);
-\item
-  optional application of an assimilation increment (thanks to NEMOVAR project);
-\item
-  coupling interface adjusted for WRF atmospheric model;
-\item
-  C-grid ice rheology now available fro both LIM-2 and LIM-3 \citep{bouillon.maqueda.ea_OM09};
-\item
-  LIM-3 ice-ocean momentum coupling applied to LIM-2;
-\item
-  a deep re-writting and simplification of the off-line tracer component (OFF\_SRC);
-\item
-  the merge of passive and active advection and diffusion modules;
-\item
-  Use of the Flexible Configuration Manager (FCM) to build configurations,
-  generate the Makefile and produce the executable;
-\item
-  Linear-tangent and Adjoint component (TAM) added, phased with v3.0
-\end{itemize}
-
-\vspace{1cm}
-
-In addition, several minor modifications in the coding have been introduced with the constant concern of
-improving the model performance.
-
-The main modifications from NEMO/OPA v3.3 and v3.4 are:
-
-\begin{itemize}
-\item finalisation of above iso-neutral mixing \citep{griffies.gnanadesikan.ea_JPO98}";
-\item "Neptune effect" parametrisation;
-\item horizontal pressure gradient suitable for s-coordinate;
-\item semi -implicit bottom friction;
-\item finalisation of the merge of passive and active tracers advection-diffusion modules;
-\item a new bulk formulae (so-called MFS);
-\item use fldread for the off-line tracer component (OFF\_SRC);
-\item use MPI point to point communications for north fold;
-\item diagnostic of transport;
-\end{itemize}
-
-The main modifications from NEMO/OPA v3.4 and v3.6 are:
-
-\begin{itemize}
- \item ...;
-\end{itemize}
-
-The main modifications from NEMO/OPA v3.6 and v4.0 are:
-
-\begin{itemize}
-\item new definition of configurations;
-\item bulk formulation;
-\item NEMO-wave large scale interactions;
-\item ...;
-\end{itemize}
-
-\biblio
-
-\pindex
-
-\end{document}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/keys.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/keys.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/keys.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/keys.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/modules.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/modules.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/modules.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/modules.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/parameters.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/parameters.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/parameters.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/parameters.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/subroutines.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/subroutines.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/NEMO/subfiles/subroutines.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/subroutines.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/build/SI3_manual.ist
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/build/SI3_manual.ist	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../global/index.ist
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/SI3_manual.ist
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/SI3_manual.ist	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../global/index.ist
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/abstract.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/abstract.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/abstract.tex	(revision 12143)
@@ -0,0 +1,25 @@
+%% ================================================================
+%% Abstract
+%% ================================================================
+
+%% Common part between NEMO-SI3-TOP
+``Sea Ice Modelling Integrated Initiative'' (\SIcube) is the sea ice engine of
+the \NEMO\ ocean model (``Nucleus for European Modelling of the Ocean'').
+It is intended to be a flexible tool for studying the sea ice dynamics and thermodynamics,
+brine inclusions and subgrid-scale thickness variations (``white ocean''),
+as well as its interactions with the other components of the Earth climate system over
+a wide range of space and time scales.
+\SIcube\ is interfaced with the \NEMO\ ocean engine, and,
+via the \href{http://portal.enes.org/oasis}{OASIS} coupler,
+with several atmospheric general circulation models.
+It also supports two-way grid embedding by means of the \href{http://agrif.imag.fr}{AGRIF} software.
+
+%% Specific part
+Designed for global to regional applications up to $~$10 km of effective resolution,
+\SIcube\ is a curvilinear grid, finite-difference implementation of the classical AIDJEX model
+(Arctic Ice Dynamics Joint EXperiment),
+combining the conservation of momentum for viscous-plastic continuum,
+energy and salt-conserving halo-thermodynamics,
+an explicit representation of subgrid-scale ice thickness variations, snow and melt ponds.
+An option to switch back to the \textit{single-category} (or \textit{2-level}) framework provides
+a cheap sea ice modelling solution.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/authors.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/authors.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/authors.tex	(revision 12143)
@@ -0,0 +1,16 @@
+Yevgeny Aksenov       \\
+Ed Blockley           \\
+Matthieu Chevallier   \\
+Danny Feltham         \\
+Thierry Fichefet      \\
+Gilles Garric         \\
+Paul Holland          \\
+Dorotea Iovino        \\
+Gurvan Madec          \\
+Fran\c cois Massonnet \\
+Jeff Ridley           \\
+Cl\'ement Rousset     \\
+David Salas           \\
+David Schroeder       \\
+Steffen Tietsche      \\
+Martin Vancoppenolle
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/chapters.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/chapters.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/chapters.tex	(revision 12143)
@@ -1,5 +1,3 @@
 \subfile{../subfiles/todolist}
-
-\subfile{../subfiles/introduction}               % Introduction
 
 \subfile{../subfiles/chap_model_basics}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/definitions.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/definitions.tex	(revision 12062)
+++ 	(revision )
@@ -1,15 +1,0 @@
-%% Engine (folder name)
-\def \engine{SI3}
-
-%% Title (variable name already use by 'titling' pkg)
-\def \heading{Sea Ice modelling Integrated Initiative (SI$^3$) \\ The NEMO sea ice engine}
-
-%% Authors (thanks will apply to the second author)
-\def \firstauthor{}
-\def \secondauthor{NEMO Sea Ice Working Group}
-
-%% IPSL publication number
-\def \ipslnum{31}
-
-%% Zenodo ID, i.e. doi:10.5281/zenodo.\([0-9]*\)
-\def \zid{1471689}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/introduction.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/introduction.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/introduction.tex	(revision 12143)
@@ -0,0 +1,63 @@
+
+% ================================================================
+% INTRODUCTION
+% ================================================================
+
+\chapter*{Introduction}
+
+\textcolor{red}{[ \textit{July 2018} ]} \\
+
+%Near the poles of the Earth, the seas and oceans freeze when seawater at the freezing point loses heat. The resulting forms of saline ice are collectively called \textit{sea ice} \citep{WMO70}, reaching up to a few meters in thickness, where as sea ice coverage is about 5\% of the global ocean, about 30 million square kilometers. All sea ice characteristics vary over a wide range of spatio-temporal scales, reflecting changes in heat, mass and momentum exchanges with the atmosphere and the ocean; the clearest temporal signal being an ample seasonal cycle. Sea ice formation and melting affects water mass formation in the ocean \citep{goosse_1999}. It not only impacts, but also reflects the state of the climate system \citep{budyko_1969,notz_2016}.  Sea ice also affects marine life, water chemistry and human activities in polar regions. Local populations use sea ice for travelling and hunting, whereas navigation and resource exploitation are dependent on sea ice conditions. For such reasons, ocean modelling systems, including \NEMO, must include a sea ice component.
+
+\SIcube\ is the result of the recommendation of the Sea Ice Working Group (SIWG) to
+reduce duplication and better use development resources.
+\SIcube\ merges the capabilities of the 3 formerly sea ice models used in \NEMO\ (CICE, GELATO and LIM).
+The \textbf{3} in \SIcube\ refers either to the three formerly used sea ice models and
+linkages between 3 different media (ocean-ice-snow).
+The model would be pronounced as ``SI cube'' for short (or ``Sea Ice cubed'' for slightly longer),
+otherwise it can be spelt ``SI three'' in situations where the superscript could be problematic.
+
+% Limitations & scope
+%There are limitations to the applicability of models such as \SIcube. The continuum approach is not invalid for grid cell size above at least 1 km, below which sea ice particles may include just a few floes, which is not sufficient \citep{lepparanta_2011}. Second, one must remember that our current knowledge of sea ice is not as complete as for the ocean: there are no fundamental equations such as Navier Stokes equations for sea ice. Besides, important features and processes span widely different scales, such as brine inclusions (1 $\mu$m-1 mm) \citep{perovich_1996}, horizontal thickness variations (1 m-100 km) \citep{percival_2008}, deformation and fracturing (10 m-1000 km) \citep{marsan_2004}. These impose complicated and often subjective subgrid-scale treatments. All in all, there is more empiricism in sea ice models than in ocean models.
+
+In order to handle all the subsequent required subjective choices, we applied the following guidelines or principles:
+\begin{itemize}
+\item Sea ice is frozen seawater that is in tight interaction with the underlying ocean. This close connexion suggests that the sea ice and ocean model components must be as consistent as possible. In practice, this is materialized by the close match between LIM and \NEMO, in terms of numerical choices, regarding the grid (Arakawa C-type) and the numerical discretization (finite differences with \NEMO\ scale factors).
+\item It is useful to be able to either prescribe the atmospheric state or to use an atmospheric model. For consistency and simplicity of the code, we choose to use formulations as close as possible in both cases.
+\item Different resolutions and time steps can be used. There are parameters that depend on such choices. We thrived to achieve a resolution and time-step independent code, by imposing a priori scaling on the resolution / time step dependence of such parameters.
+\item Energy, mass and salt must be conserved as much as possible.
+\end{itemize}
+
+This manual is organised as follows. \\
+
+List of chapters... \\
+
+There are no more CPP keys in the code. \\
+
+Namelists and output management follow \NEMO\ guidelines. \\
+
+Changes between releases. \\
+
+The list of people that should be acknowledged is too long, but a great number of people or more exactly a number of great people contributed to the code and should be gratefully acknowledged. As for today,
+the SIWG members are \textit{(July 2018)}.
+
+\begin{itemize}
+\begin{footnotesize}
+\item Yevgeny Aksenov (NOCS, Southampton, UK)
+\item Ed Blockley (Met Office, Exeter, UK, co-chair)
+\item Matthieu Chevallier (CNRM-GAME, M\'et\'eo France, Toulouse)
+\item Danny Feltham (CPOM, Reading, UK)
+\item Thierry Fichefet (UCL, Louvain-la-Neuve, Belgium)
+\item Gilles Garric (Mercator-Oc\'ean, Toulouse, France)
+\item Paul Holland (BAS, Cambridge, UK)
+\item Dorotea Iovino (CMCC, Bologna, Italy)
+\item Gurvan Madec (LOCEAN, CNRS, Paris, France)
+\item Fran\c cois Massonnet (UCL, Louain-la-Neuve, Belgium)
+\item Jeff Ridley (Met Office, Exeter, UK)
+\item Cl\'ement Rousset (LOCEAN, CNRS, Paris, France)
+\item David Salas (CNRM-GAME, M\'et\'eo France, Toulouse)
+\item David Schroeder (CPOM, Reading, UK)
+\item Steffen Tietsche (ECMWF, Reading, UK)
+\item Martin Vancoppenolle (LOCEAN, CNRS, Paris, France, co-chair)
+\end{footnotesize}
+\end{itemize}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/settings.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/settings.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/settings.tex	(revision 12143)
@@ -0,0 +1,20 @@
+%% Engine (folder name)
+\def \engine{SI3}
+
+%% Title and cover page settings
+\def \spacetop{  \vspace*{1.2cm} }
+\def \heading{Sea Ice modelling Integrated Initiative (SI$^3$)}
+\def \subheading{The NEMO sea ice engine}
+\def \spacedown{ \vspace*{  1cm} }
+\def \authorswidth{0.2\linewidth}
+\def \rulelenght{230pt}
+\def \abstractwidth{0.65\linewidth}
+
+%% Color for document (frontpage banner, links and chapter boxes)
+\def \setmanualcolor{ \definecolor{manualcolor}{cmyk}{0, 0, 0, 0.4} }
+
+%% IPSL publication number
+\def \ipslnum{31}
+
+%% Zenodo ID, i.e. doi:10.5281/zenodo.\([0-9]*\)
+\def \zid{1471689}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/thanks.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/main/thanks.tex	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-TBD
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/namelists/namdyn_adv
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/namelists/namdyn_adv	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/namelists/namdyn_adv	(revision 12143)
@@ -2,6 +2,6 @@
 &namdyn_adv     !   Ice advection
 !------------------------------------------------------------------------------
-   ln_adv_Pra       = .false.         !  Advection scheme (Prather)
-   ln_adv_UMx       = .true.          !  Advection scheme (Ultimate-Macho)
+   ln_adv_Pra       = .true.         !  Advection scheme (Prather)
+   ln_adv_UMx       = .false.          !  Advection scheme (Ultimate-Macho)
       nn_UMx        =   5             !     order of the scheme for UMx (1-5 ; 20=centered 2nd order)
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/blocks.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/blocks.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/blocks.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/blocks.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_bdy_agrif.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_bdy_agrif.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_bdy_agrif.tex	(revision 12143)
@@ -9,5 +9,5 @@
 \chapter{BDY and AGRIF with SI$^3$}
 \label{chap:REG}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_domain.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_domain.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_domain.tex	(revision 12143)
@@ -10,5 +10,5 @@
 \chapter{Time, space and thickness space domain}
 \label{chap:DOM}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_dynamics.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_dynamics.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_dynamics.tex	(revision 12143)
@@ -10,5 +10,5 @@
 \chapter{Ice dynamics}
 \label{chap:DYN}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_interfaces.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_interfaces.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_interfaces.tex	(revision 12143)
@@ -9,5 +9,5 @@
 \chapter{Ice-atmosphere and ice-ocean interfaces}
 \label{chap:INT}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_miscellaneous.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_miscellaneous.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_miscellaneous.tex	(revision 12143)
@@ -9,5 +9,5 @@
 \chapter{Miscellaneous topics}
 \label{chap:MIS}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_model_basics.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_model_basics.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_model_basics.tex	(revision 12143)
@@ -9,5 +9,5 @@
 \chapter{Model Basics}
 \label{chap:MB}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_output_diagnostics.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_output_diagnostics.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_output_diagnostics.tex	(revision 12143)
@@ -9,5 +9,5 @@
 \chapter{Output and diagnostics}
 \label{chap:DIA}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_radiative_transfer.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_radiative_transfer.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_radiative_transfer.tex	(revision 12143)
@@ -13,5 +13,5 @@
 \chapter{Radiative transfer}
 \label{chap:RAD}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_ridging_rafting.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_ridging_rafting.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_ridging_rafting.tex	(revision 12143)
@@ -10,5 +10,5 @@
 \chapter{Ridging and rafting}
 \label{chap:RDG}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_single_category_use.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_single_category_use.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_single_category_use.tex	(revision 12143)
@@ -11,5 +11,5 @@
 
 \label{chap:INT}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_thermo.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_thermo.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_thermo.tex	(revision 12143)
@@ -9,5 +9,5 @@
 \chapter{Ice thermodynamics}
 \label{chap:THD}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_transport.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_transport.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/chap_transport.tex	(revision 12143)
@@ -10,5 +10,5 @@
 \chapter{Ice transport}
 \label{chap:TRP}
-\minitoc
+\chaptertoc
 
 \newpage
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/introduction.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/introduction.tex	(revision 12062)
+++ 	(revision )
@@ -1,59 +1,0 @@
-
-% ================================================================
-% INTRODUCTION
-% ================================================================
-
-\chapter*{Introduction}
-
-\textcolor{red}{[ \textit{July 2018} ]} \\
-
-%Near the poles of the Earth, the seas and oceans freeze when seawater at the freezing point loses heat. The resulting forms of saline ice are collectively called \textit{sea ice} \citep{WMO70}, reaching up to a few meters in thickness, where as sea ice coverage is about 5\% of the global ocean, about 30 million square kilometers. All sea ice characteristics vary over a wide range of spatio-temporal scales, reflecting changes in heat, mass and momentum exchanges with the atmosphere and the ocean; the clearest temporal signal being an ample seasonal cycle. Sea ice formation and melting affects water mass formation in the ocean \citep{goosse_1999}. It not only impacts, but also reflects the state of the climate system \citep{budyko_1969,notz_2016}.  Sea ice also affects marine life, water chemistry and human activities in polar regions. Local populations use sea ice for travelling and hunting, whereas navigation and resource exploitation are dependent on sea ice conditions. For such reasons, ocean modelling systems, including NEMO, must include a sea ice component.
-
-The sea Ice Modelling Integrated Initiative (SI$^3$) is the sea ice engine of the Nucleus for European Modelling of the Ocean (NEMO). It is intended to be a flexible tool for studying sea ice and its interactions with the other components of the Earth System over a wide range of space and time scales. SI$^3$ is a curvilinear grid, finite-difference implementation of the classical AIDJEX\footnote{AIDJEX=\textbf{A}rctic \textbf{I}ce \textbf{D}ynamics \textbf{J}oint \textbf{EX}periment} model \citep{coon_1974}, combining the conservation of momentum for viscous-plastic continuum, energy and salt-conserving halo-thermodynamics, an explicit representation of subgrid-scale ice thickness variations, snow and melt ponds. An option to switch back to the \textit{single-category} (or \textit{2-level}) framework of \cite{hibler_1979} provides a cheap sea ice modelling solution.
-
-SI$^3$ is the result of the recommendation of the Sea Ice Working Group (SIWG) to reduce duplication and better use development resources. SI$^3$ merges the capabilities of the 3 formerly used NEMO sea ice models (CICE, GELATO and LIM). The \textbf{3} in SI$^3$ refers to the three formerly used sea ice models. It also refers to linkages between 3 different media (ocean, ice, snow). The model can be spelt 'SI3' in situations where the superscript could be problematic (i.e., within code and svn repository etc.) The model name would be pronounced as 'si-cube' for short (or 'sea ice cubed' for slightly longer). 
-
-% Limitations & scope
-%There are limitations to the applicability of models such as SI$^3$. The continuum approach is not invalid for grid cell size above at least 1 km, below which sea ice particles may include just a few floes, which is not sufficient \citep{lepparanta_2011}. Second, one must remember that our current knowledge of sea ice is not as complete as for the ocean: there are no fundamental equations such as Navier Stokes equations for sea ice. Besides, important features and processes span widely different scales, such as brine inclusions (1 $\mu$m-1 mm) \citep{perovich_1996}, horizontal thickness variations (1 m-100 km) \citep{percival_2008}, deformation and fracturing (10 m-1000 km) \citep{marsan_2004}. These impose complicated and often subjective subgrid-scale treatments. All in all, there is more empirism in sea ice models than in ocean models. 
-
-In order to handle all the subsequent required subjective choices, we applied the following guidelines or principles:
-\begin{itemize}
-\item Sea ice is frozen seawater that is in tight interaction with the underlying ocean. This close connexion suggests that the sea ice and ocean model components must be as consistent as possible. In practice, this is materialized by the close match between LIM and NEMO, in terms of numerical choices, regarding the grid (Arakawa C-type) and the numerical discretization (finite differences with NEMO scale factors).
-\item It is useful to be able to either prescribe the atmospheric state or to use an atmospheric model. For consistency and simplicity of the code, we choose to use formulations as close as possible in both cases.
-\item Different resolutions and time steps can be used. There are parameters that depend on such choices. We thrieved to achieve a resolution and time-step independent code, by imposing a priori scaling on the resolution / time step dependence of such parameters.
-\item Energy, mass and salt must be conserved as much as possible.
-\end{itemize}
-
-This manual is organised as follows. \\
-
-List of chapters... \\
-
-There are no more CPP keys in the code. \\
-
-Namelists and output management follow NEMO guidelines. \\
-
-Changes between releases. \\
-
-The list of people that should be acknowledged is too long, but a great number of people or more exactly a number of great people contributed to the code and should be gratefully acknowledged. As for today,
-the SIWG members are \textit{(July 2018)}.
-
-\begin{itemize}
-\begin{footnotesize}
-\item Yevgeny Aksenov (NOCS, Southampton, UK)
-\item Ed Blockley (Met Office, Exeter, UK, co-chair)
-\item Matthieu Chevallier (CNRM-GAME, M\'et\'eo France, Toulouse)
-\item Danny Feltham (CPOM, Reading, UK)
-\item Thierry Fichefet (UCL, Louvain-la-Neuve, Belgium)
-\item Gilles Garric (Mercator-Oc\'ean, Toulouse, France)
-\item Paul Holland (BAS, Cambridge, UK)
-\item Dorotea Iovino (CMCC, Bologna, Italy)
-\item Gurvan Madec (LOCEAN, CNRS, Paris, France)
-\item Fran\c cois Massonnet (UCL, Louain-la-Neuve, Belgium)
-\item Jeff Ridley (Met Office, Exeter, UK)
-\item Cl\'ement Rousset (LOCEAN, CNRS, Paris, France)
-\item David Salas (CNRM-GAME, M\'et\'eo France, Toulouse)
-\item David Schroeder (CPOM, Reading, UK)
-\item Steffen Tietsche (ECMWF, Reading, UK)
-\item Martin Vancoppenolle (LOCEAN, CNRS, Paris, France, co-chair) 
-\end{footnotesize}
-\end{itemize}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/keys.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/keys.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/keys.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/keys.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/modules.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/modules.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/modules.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/modules.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/parameters.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/parameters.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/parameters.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/parameters.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/subroutines.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/subroutines.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/SI3/subfiles/subroutines.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/subroutines.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/build/TOP_manual.ist
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/build/TOP_manual.ist	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../global/index.ist
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/TOP_manual.ist
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/TOP_manual.ist	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../global/index.ist
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/abstract.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/abstract.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/abstract.tex	(revision 12143)
@@ -0,0 +1,26 @@
+%% ================================================================
+%% Abstract
+%% ================================================================
+
+%% Common part between NEMO-SI3-TOP
+``Tracers in Ocean Paradigm'' (\TOP) is the passive tracers engine of
+the \NEMO\ ocean model (``Nucleus for European Modelling of the Ocean'').
+It is intended to be a flexible tool for studying the on/offline oceanic tracers transport and
+the biogeochemical processes (``green ocean''),
+as well as its interactions with the other components of the Earth climate system over
+a wide range of space and time scales.
+\TOP\ is interfaced with the \NEMO\ ocean engine, and,
+via the \href{http://portal.enes.org/oasis}{OASIS} coupler,
+with several atmospheric general circulation models.
+%It also supports two-way grid embedding by means of the \href{http://agrif.imag.fr}{AGRIF} software.
+
+%% Specific part
+This component provides the physical constraints and boundaries conditions for
+oceanic tracers transport and represents a generalized, hardwired interface toward
+biogeochemical models to enable a seamless coupling.
+In particular, transport dynamics are supplied by the ocean dynamical core thus
+enabling the use of all available advection and diffusion schemes in both on- and off-line modes.
+\TOP\ is designed to handle multiple oceanic tracers through a modular approach and
+it includes different sub-modules: ocean water age, inorganic carbon (CFCs) \& radiocarbon (C14b),
+built-in biogeochemical model (PISCES), and prototype for user-defined cases or
+coupling with alternative biogeochemical models (\eg \href{http://www.bfm-community.eu}{BFM}).
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/authors.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/authors.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/authors.tex	(revision 12143)
@@ -0,0 +1,7 @@
+Olivier Aumont         \\
+Christian \'{E}th\'{e} \\
+Tomas Lovato           \\
+Anne Mouchet           \\
+Georges Nurser         \\
+Julien Palmi\'{e}ri    \\
+Andrew Yool
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/byrd-co2-2008.txt
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/byrd-co2-2008.txt	(revision 12062)
+++ 	(revision )
@@ -1,273 +1,0 @@
-Byrd Ice Core CO2 Data for 20-90 KYrBP
------------------------------------------------------------------------
-               World Data Center for Paleoclimatology, Boulder
-                                  and
-                     NOAA Paleoclimatology Program
------------------------------------------------------------------------
-NOTE: PLEASE CITE ORIGINAL REFERENCE WHEN USING THIS DATA!!!!!
-
-
-NAME OF DATA SET: Byrd Ice Core CO2 Data for 20-90 KYrBP
-
-LAST UPDATE: 10/2008 (Original receipt by WDC Paleo)
-CONTRIBUTORS: Jinho Ahn and Edward J. Brook
-IGBP PAGES/WDCA CONTRIBUTION SERIES NUMBER: 2008-095
-
-WDC PALEO CONTRIBUTION SERIES CITATION: 
-Ahn, J. and E.J. Brook. 2008.
-Byrd Ice Core CO2 Data for 20-90 KYrBP. 
-IGBP PAGES/World Data Center for Paleoclimatology 
-Data Contribution Series # 2008-095. 
-NOAA/NCDC Paleoclimatology Program, Boulder CO, USA.
-
-
-ORIGINAL REFERENCES: 
-References for CO2 data: 
- 
-Ahn, J. and E.J. Brook. 2008.
-Atmospheric CO2 and Climate on Millennial Time Scales During 
-the Last Glacial Period. 
-Science, 322, 83-85, doi: 10.1126/science.1160832.
-
-Ahn, J. and Brook, E.J.  2007.  
-Atmospheric CO2 and climate from 65 to 30 ka B.P.. 
-Geophysical Research Letters, 34, L10703, doi:10.1029/2007GL029551.
-
- 
-References for CO2 age:	 
-  
-Blunier-01 age: 
-Blunier, T., and Brook, E.J.  2001. 
-Timing of millennial-scale climate change in Antarctica and Greenland 
-during the last glacial period.  
-Science, 291, 109-112.  
-	   
-Ahn-08 age: 
-Ahn, J. and E.J. Brook. 2008.
-Atmospheric CO2 and Climate on Millennial Time Scales During 
-the Last Glacial Period. 
-Science, 322, 83-85, doi: 10.1126/science.1160832.
-
-
-ABSTRACT (Ahn and Brook 2008):
-Reconstructions of ancient atmospheric carbon dioxide (CO2) variations 
-help us better understand how the global carbon cycle and climate are 
-linked.  We compared CO2 variations on millennial time scales between 
-20,000 and 90,000 years ago with an Antarctic temperature proxy and 
-records of abrupt climate change in the Northern Hemisphere. CO2 
-concentration and Antarctic temperature were positively correlated 
-over millennial-scale climate cycles, implying a strong connection 
-to Southern Ocean processes. Evidence from marine sediment proxies 
-indicates that CO2 concentration rose most rapidly when North Atlantic 
-Deep Water shoaled and stratification in the Southern Ocean was reduced. 
-These increases in CO2 concentration occurred during stadial (cold) 
-periods in the Northern Hemisphere, several thousand years before 
-abrupt warming events in Greenland.
-
-
-
-GEOGRAPHIC REGION: Antarctica
-PERIOD OF RECORD:  90 - 20 KYrBP
-
-FUNDING SOURCES: 
-Gary Comer Science and Education Foundation, and
-US National Science Foundation  grants OPP 0337891 and ATM 0602395.
-
-
-
-DESCRIPTION:  
-Byrd ice core carbon dioxide data for 20-90 KYrBP, analyzed at 
-Oregon State University.  
-
-Byrd Ice Core location: 
-80.01°S , 119.51°W; 1530 m elev. 
-  
-
-
-
-DATA:
-Byrd Ice Core CO2 Data for 20-90 KYrBP
-
-Column 1: Depth (m) 
-Column 2: Blunier 2001 Age (ka before 1950 AD)
-Column 3: Ahn 2008 Age (ka before 1950 AD)
-Column 4: Mean CO2 (ppm)
-Column 5: Number of replicates
-Column 6: Uncertainty (ppm)*
-Column 7: Reference
-
-*Uncertainty is estimated from the standard deviation of the mean for 2~5 ice samples
-
-Depth       Age Bl01  Age Ahn08   Mean CO2    Repl.  Uncert.    Ref.
-1315.91       19.460     19.286     194.36      2     0.97     AB-08
-1332.34       20.061     19.887     191.14      2     0.19     AB-08
-1334.20       20.152     19.978     192.54      2     0.09     AB-08
-1346.28       20.578     20.404     204.27      2     0.48     AB-08
-1353.02       20.759     20.585     195.37      2     0.02     AB-08
-1363.17       21.065     20.891     197.12      2     1.04     AB-08
-1381.14       21.731     21.557     195.81      2     1.66     AB-08
-1401.95       22.399     22.225     199.75      3     4.49     AB-08
-1410.30       22.729     22.555     194.62      2     0.31     AB-08
-1420.27       23.530     23.356     195.97      2     1.88     AB-08
-1430.78       24.824     24.650     194.74      2     1.94     AB-08
-1441.45       26.002     25.828     189.76      2     1.30     AB-08
-1460.20       26.711     26.537     192.21      2     1.28     AB-08
-1470.77       27.148     26.974     184.40      2     1.42     AB-08
-1480.48       27.619     27.445     188.07      2     1.48     AB-08
-1490.87       27.989     27.815     201.96      2     0.46     AB-08
-1496.52       28.135     27.961     204.98      2     1.71     AB-08
-1503.54       28.395     28.221     205.91      3     2.43     AB-08
-1512.46       28.660     28.486     207.48      2     1.73     AB-08
-1523.46       29.147     28.973     205.54      2     0.40     AB-08
-1533.76       29.568     29.396     201.49      2     1.84     AB-08
-1543.63       30.013     29.843     197.51      2     3.18     AB-08
-1552.76       30.412     30.245     195.36      2     0.89     AB-08
-1573.34       31.216     31.053     195.09      3     2.37     AB-08
-1581.93       31.738     31.577     202.29      2     0.38     AB-08
-1594.06       32.328     32.170     203.67      2     0.40     AB-08
-1615.15       33.450     33.297     208.11      2     0.11     AB-08
-1620.38       33.692     33.541     205.25      2     0.53     AB-08
-1631.11       34.183     34.033     201.53      2     1.67     AB-08
-1640.90       34.630     34.484     213.08      2     0.47     AB-08
-1650.56       35.097     34.953     206.62      2     1.72     AB-08
-1658.96       35.428     35.286     209.93      2     1.10     AB-08
-1677.79       36.249     36.111     207.76      2     0.00     AB-08
-1688.63       36.840     36.704     212.63      2     0.99     AB-08
-1693.68       37.167     37.033     213.98      2     1.37     AB-08
-1699.73       37.621     37.488     217.48      2     1.16     AB-08
-1708.70       38.122     37.992     216.21      2     1.03     AB-08
-1714.20       38.428     38.298     216.52      2     2.21     AB-08
-1717.20       38.545     38.415     212.50      2     1.51     AB-08
-1719.47       38.655     38.520     211.09      2     1.83     AB-08
-1723.22       38.850     38.708     214.78      2     2.64     AB-08
-1730.78       39.163     39.006     207.63      2     0.18     AB-08
-1740.51       39.539     39.364     214.06      2     0.14     AB-08
-1743.27       39.651     39.470     213.84      2     1.23     AB-08
-1747.69       39.811     39.621     203.03      2     1.03     AB-08
-1755.15       40.038     39.834     202.11      2     0.45     AB-08
-1760.29       40.172     39.958     203.78      2     2.59     AB-08
-1770.24       40.544     40.311     203.40      2     1.56     AB-08
-1779.99       40.966     40.714     201.30      2     1.46     AB-08
-1790.29       41.585     41.313     202.69      2     2.43     AB-08
-1802.03       42.320     42.025     204.64      2     0.56     AB-08
-1811.74       42.851     42.537     207.18      2     1.53     AB-08
-1821.19       43.591     43.259     210.31      2     0.60     AB-08
-1830.63       44.137     43.786     214.57      2     0.51     AB-08
-1840.93       44.598     44.228     216.83      3     2.50     AB-08
-1844.41       44.760     44.383     215.54      2     1.26     AB-08
-1847.46       44.899     44.516     219.62      2     0.94     AB-08
-1855.09       45.229     44.831     221.00      2     0.60     AB-08
-1859.57       45.526     45.120     217.56      2     0.82     AB-08
-1861.17       45.633     45.223     219.39      2     0.53     AB-08
-1862.59       45.725     45.313     218.62      2     2.56     AB-08
-1864.56       45.852     45.436     217.23      2     2.04     AB-08
-1867.90       46.075     45.654     211.58      2     0.64     AB-08
-1871.26       46.298     45.872     206.99      2     0.29     AB-08
-1873.26       46.431     46.002     209.25      2     1.24     AB-08
-1880.36       46.889     46.448     205.61      2     1.63     AB-08
-1884.88       47.187     46.740     204.28      2     1.02     AB-08
-1892.21       47.687     47.228     205.36      2     1.00     AB-08
-1894.8        47.865     47.402     205.51      2     1.63     AB-07
-1903.72       48.450     47.973     201.79      2     2.79     AB-07
-1909.75       48.874     48.388     211.47      4     1.09     AB-07
-1911.29       48.984     48.495     207.15      4     1.93     AB-07
-1914.31       49.191     48.697     212.35      2     0.57     AB-07
-1920.25       49.596     49.092     213.91      4     2.43     AB-07
-1929.4        50.230     49.712     216.76      2     0.28     AB-07
-1938.5        50.857     50.325     215.07      2     0.30     AB-07
-1943.09       51.175     50.636     218.12      5     2.35     AB-07
-1945.98       51.394     50.850     221.08      3     0.35     AB-07
-1953.17       51.894     51.339     216.69      4     2.96     AB-07
-1956.34       52.193     51.633     217.93      2     2.81     AB-07
-1959.23       52.505     51.941     218.83      2     1.55     AB-07
-1962.18       52.812     52.259     219.08      4     2.10     AB-07
-1963.62       52.963     52.423     215.70      2     1.94     AB-07
-1968.07       53.422     52.923     212.28      2     2.52     AB-07
-1972.66       53.926     53.470     213.25      2     0.74     AB-07
-1978.74       54.577     54.177     205.57      2     0.58     AB-07
-1981.61       54.859     54.486     212.48      4     2.46     AB-07
-1988.98       55.644     55.339     215.94      2     0.96     AB-07
-1995.01       56.317     56.068     215.25      2     0.38     AB-07
-2001.46       57.022     56.833     218.27      2     3.65     AB-07
-2003.23       57.222     57.049     223.09      2     0.30     AB-07
-2013.21       58.096     58.016     222.69      3     2.59     AB-07
-2017.71       58.467     58.421     224.99      2     0.97     AB-07
-2022.42       59.125     59.072     220.11      2     1.49     AB-07
-2026.9        59.806     59.746     224.21      3     1.18     AB-07
-2028.47       60.039     59.976     217.96      2     1.39     AB-07
-2031.5        60.526     60.459     218.85      2     3.26     AB-07
-2037.68       61.451     61.374     210.28      2     1.65     AB-07
-2042.43       62.186     62.102     212.26      2     0.85     AB-07
-2048.32       63.079     62.986     204.65      2     0.39     AB-07
-2051.4        63.526     63.429     206.76      2     2.20     AB-07
-2055.9        64.152     64.048     204.06      2     0.84     AB-07
-2066.85       65.565     65.444     208.22      2     2.01     AB-08
-2069.64       65.938     65.813     207.08      2     2.09     AB-08
-2072.65       66.333     66.204     217.67      2     2.07     AB-08
-2075.59       66.779     66.644     211.79      2     0.25     AB-08
-2075.745      66.818    66.6833     219.64      3     1.17     AB-08
-2076.02       66.890     66.755     222.40      2     0.47     AB-08
-2076.43       66.997     66.861     223.63      2     0.27     AB-08
-2077.02       67.151     67.014     220.43      2     3.79     AB-08
-2080.12       67.959     67.818     244.03      2     5.52     AB-08
-2080.61       68.086     67.944     240.28      2     0.28     AB-08
-2081.10       68.213     68.071     246.47      2     0.93     AB-08
-2081.59       68.340     68.197     247.22      2     2.42     AB-08
-2082.54       68.582     68.435     249.96      3     3.97     AB-08
-2082.64       68.608     68.460     248.32      2     2.08     AB-08
-2083.085      68.721    68.5708     238.70      4     4.19     AB-08
-2083.54       68.837     68.685     238.61      2     0.33     AB-08
-2083.82       68.908     68.755     238.78      2     1.42     AB-08
-2084.14       68.989     68.834     238.84      2     0.02     AB-08
-2084.52       69.086     68.929     231.99      3     4.59     AB-08
-2085.44       69.314     69.149     237.98      2     0.97     AB-08
-2087.02       69.706     69.527     237.26      3     0.40     AB-08
-2087.75       69.886     69.700     233.74      2     0.93     AB-08
-2089.24       70.246     70.048     234.85      2     0.19     AB-08
-2090.16       70.469     70.262     234.35      2     3.03     AB-08
-2093.50       71.337     71.101     237.17      2     0.49     AB-08
-2093.71       71.395     71.158     236.62      3     1.43     AB-08
-2095.46       71.875     71.622     240.58      2     3.79     AB-08
-2097.91       72.515     72.240     246.81      3     2.23     AB-08
-2099.29       72.885     72.598     244.19      1              AB-08
-2100.05       73.073     72.783     246.30      2     0.85     AB-08
-2100.69       73.230     72.937     236.93      2     0.88     AB-08
-2101.27       73.369     73.079     242.80      2     3.41     AB-08
-2101.80       73.492     73.209     241.26      2     0.14     AB-08
-2101.97       73.531     73.251     237.79      4     2.31     AB-08
-2103.15       73.805     73.542     240.63      3     0.85     AB-08
-2103.60       73.909     73.653     235.11      2     0.58     AB-08
-2104.68       74.184     73.944     231.11      2     0.89     AB-08
-2105.52       74.410     74.182     228.82      2     2.08     AB-08
-2106.32       74.656     74.440     223.79      2     1.22     AB-08
-2107.63       75.055     74.858     230.49      2     0.28     AB-08
-2109.17       75.518     75.343     228.85      2     0.25     AB-08
-2110.06       75.783     75.621     226.25      1              AB-08
-2111.20       76.120     75.975     229.45      2     2.14     AB-08
-2113.37       76.765     76.651     229.56      2     1.56     AB-08
-2116.08       77.586     77.513     232.82      3     1.97     AB-08
-2116.73       77.785     77.721     240.83      3     1.24     AB-08
-2120.16       78.809     78.795     235.51      2     0.11     AB-08
-2122.78       79.604     79.628     238.65      2     4.76     AB-08
-2125.62       80.449     80.515     240.08      3     1.03     AB-08
-2126.13       80.635     80.708     233.00      3     1.69     AB-08
-2130.20       82.116     82.248     250.22      2     4.72     AB-08
-2130.67       82.399     82.539     246.47      2     0.04     AB-08
-2130.78       82.466     82.607     244.08      2     2.06     AB-08
-2131.99       83.195     83.354     250.70      2     0.33     AB-08
-2132.50       83.503     83.669     248.75      2     2.37     AB-08
-2132.66       83.600     83.766     237.44      2     2.38     AB-08
-2134.46       84.687     84.855     240.19      2     1.00     AB-08
-2134.70       84.828     84.996     240.36      2     1.19     AB-08
-2135.22       85.133     85.301     233.84      2     0.20     AB-08
-2135.97       85.572     85.740     241.73      2     1.76     AB-08
-2136.25       85.734     85.902     220.23      2     5.01     AB-08
-2136.93       86.127     86.295     225.72      2     1.15     AB-08
-2137.57       86.498     86.666     228.99      3     1.73     AB-08
-2138.02       86.764     86.932     229.26      2     1.58     AB-08
-2138.32       86.942     87.110     218.37      2     0.94     AB-08
-2138.79       87.221     87.389     222.25      2     1.43     AB-08
-2143.57       90.075     90.266     236.19      5     2.31     AB-08
-2144.02       90.342     90.534     235.65      2     2.86     AB-08
-2144.72       90.759     90.953     242.07      3     4.54     AB-08
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/chapters.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/chapters.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/chapters.tex	(revision 12143)
@@ -1,3 +1,2 @@
-\subfile{../subfiles/introduction}
 \subfile{../subfiles/model_description}
 \subfile{../subfiles/model_setup}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/definitions.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/definitions.tex	(revision 12062)
+++ 	(revision )
@@ -1,15 +1,0 @@
-%% Engine (folder name)
-\def \engine{TOP}
-
-%% Title (variable name already use by 'titling' pkg)
-\def \heading{Tracers in Ocean Paradigm (TOP) \\ The NEMO passive tracers engine}
-
-%% Authors (thanks will apply to the second author)
-\def \firstauthor{}
-\def \secondauthor{NEMO TOP Working Group}
-
-%% IPSL publication number
-\def \ipslnum{28}
-
-%% Zenodo ID, i.e. doi:10.5281/zenodo.\([0-9]*\)
-\def \zid{1471700}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/edc-co2.txt
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/edc-co2.txt	(revision 12062)
+++ 	(revision )
@@ -1,620 +1,0 @@
-EPICA Dome C Ice Core High Resolution Holocene and Transition CO2 Data
------------------------------------------------------------------------
-               World Data Center for Paleoclimatology, Boulder
-                                  and
-                     NOAA Paleoclimatology Program
------------------------------------------------------------------------
-NOTE: PLEASE CITE CONTRIBUTORS WHEN USING THIS DATA!!!!!
-
-
-NAME OF DATA SET: 
-EPICA Dome C Ice Core High Resolution Holocene and Transition CO2 Data
-LAST UPDATE: 9/2004 (Original receipt by WDC Paleo)
-CONTRIBUTOR:  Eric Monnin, University of Bern
-IGBP PAGES/WDCA CONTRIBUTION SERIES NUMBER: 2004-055
-
-
-SUGGESTED DATA CITATION: Monnin, E., et al.. 2004. 
-EPICA Dome C Ice Core High Resolution Holocene and Transition CO2 Data. 
-IGBP PAGES/World Data Center for Paleoclimatology 
-Data Contribution Series # 2004-055.
-NOAA/NGDC Paleoclimatology Program, Boulder CO, USA.
-
-
-ORIGINAL REFERENCE:  
-Monnin, E., E.J. Steig, U. Siegenthaler, K. Kawamura, J. Schwander, B. Stauffer, 
-T.F. Stocker, D.L. Morse, J.-M. Barnola, B. Bellier, D. Raynaud, and H. Fischer. 2004.  
-Evidence for substantial accumulation rate variability in Antarctica during the Holocene, 
-through synchronization of CO2 in the Taylor Dome, Dome C and DML ice cores. 
-Earth and Planetary Science Letters, 224, 45-54, doi: 10.1016/j.epsl.2004.05.007. 
-
-
-ADDITIONAL REFERENCES FOR DATA:
-Flückiger, J.,  E. Monnin, B. Stauffer, J. Schwander, T. F. Stocker, J. Chappellaz, 
-D. Raynaud and J.-M. Barnola.  2002.
-High resolution Holocene N2O ice core record and its relationship with CH4 and CO2. 
-Global Biogeochemical Cycles, 16 (1), 1010, doi:10.1029/2001GB001417.
-
-Monnin, E., A. Indermühle, A. Dällenbach, J. Flückiger, B. Stauffer, T. F. Stocker, 
-D. Raynaud, and J.-M. Barnola.  2001. 
-Atmospheric CO2 concentrations over the last glacial termination. 
-Science 291, 112-114.
-
- 
-ADDITIONAL REFERENCE FOR DATING:
-Schwander, J., J. Jouzel, C. U. Hammer, J.-R. Petit, R. Udisti, and E. Wolff. 2001.
-A tentative chronology for the EPICA Dome Concordia ice core. 
-Geophys. Res. Lett. Vol. 28, No. 22, p. 4243.
-
-
-ABSTRACT (Monnin et al. 2004):
-High resolution records of atmospheric CO2 concentration during the Holocene 
-are obtained from the Dome Concordia and Dronning Maud Land (Antarctica) ice cores. 
-These records confirm that the CO2 concentration varied between 260 and 280 ppmv in 
-the Holocene as measured in the Taylor Dome ice core. However, there are differences 
-in the CO2 records most likely caused by mismatches in timescales. Matching the 
-Taylor Dome timescale to the Dome C timescale by synchronization of CO2 indicates that 
-the accumulation rate at Taylor Dome increased through the Holocene by a factor of two 
-and bears little resemblance to the stable isotope record used as a proxy for temperature. 
-This result shows that different locations experienced substantially different 
-accumulation changes, and casts doubt on the often-used assumption that accumulation 
-rate scales with the saturation vapor pressure as a function of temperature, at least 
-for coastal locations. 
-
-
-GEOGRAPHIC REGION: Antarctica
-PERIOD OF RECORD:  22 KYrBP - present
-
-
-DESCRIPTION: High Resolution CO2 Data for the EPICA Dome C ice core, 
-and derived timescale for Taylor Dome Ice Core. 
-
-
-Core locations: 
-EPICA Dome C:  75° 06'S, 123° 21'E 
-Dronning Maud Land (DML): 75° 00'S, 00° 04'E 
-Taylor Dome:  77° 47'47" S,  158° 43'26" E
-
-
-
-
-Data:
-1. High-resolution EDC CO2 data
-
-Column 1: Depth (m)
-Column 2: Age (Years before 1950 AD, EDC1 Timescale)
-Column 3: CO2 mean (ppmv)
-Column 4: CO2 sigma mean (ppmv) sigma mean is one sigma of the mean value 
-          (of 6 neighboring samples)
-
-
-  Depth      Age    CO2      sigma
-  102.83     173   280.4     1.8
- 106.885     311   274.9     0.7
- 107.195     322   277.9     0.7
- 110.245     427   279.1     1.3
-   110.5     435   281.9     1.1
- 113.265     530   277.7     0.7
-  115.48     604   281.1     1.1
- 118.615     709   282.2     0.5
-   121.5     806   280.1     0.6
- 124.815     917   278.4     1.5
- 127.015     991   276.6     1.4
- 129.745    1083   279.1       1
-   132.5    1175   277.7     1.2
- 134.715    1249   278.7     1.2
- 138.015    1362   277.4     0.8
- 141.295    1477   279.2     0.9
-  144.05    1574     280     0.8
- 146.265    1653   278.9     0.8
- 149.015    1751   278.7     0.7
- 151.195    1830     278     1.2
-   154.5    1948   276.9     0.7
- 157.815    2069   276.7     0.8
-  160.03    2150   276.7     0.8
- 162.165    2228   277.6     1.3
- 165.515    2352   277.9     0.5
-  168.28    2453   273.9     1.1
-     171    2550   278.9     0.6
- 173.135    2625   275.3     1.6
- 176.515    2743   274.7     1.2
- 178.715    2820   276.3     0.9
- 181.445    2918   274.6     0.8
- 185.845    3078   276.3     1.5
- 187.515    3138   273.1     1.1
- 189.715    3219     274     0.3
-     193    3337     275     0.6
- 196.295    3454   273.4     1.3
- 198.515    3531     273     0.8
-  201.28    3628   271.5       1
-     204    3724   275.4     0.5
- 206.195    3802   274.9     1.3
- 209.515    3921   271.7       1
- 212.265    4019   271.6     0.7
-     215    4117   272.8     0.8
- 216.645    4176   271.5     0.9
-  221.05    4335   271.1     0.8
- 222.715    4395   269.1     0.6
-  225.48    4496   269.8       1
- 228.195    4596   271.5     0.8
-  232.05    4737   270.7     0.5
- 233.715    4797   269.3       1
- 236.465    4895   268.6     1.1
- 240.265    5033   269.8     1.2
-   242.5    5114   267.6     0.6
- 244.715    5196   265.3     1.7
- 248.015    5318   265.2     0.8
- 250.715    5419   267.6       2
-   253.5    5521   265.9     0.9
- 256.265    5621   265.5     0.8
- 259.015    5721   260.7     1.6
- 260.645    5780   266.7     0.9
-   264.5    5921   265.5     0.8
- 268.365    6064   263.2     0.6
- 269.415    6102   262.7     0.9
- 272.195    6205   261.2     0.7
- 276.065    6349   261.1     0.4
- 278.265    6430   259.4     0.6
-  280.53    6514   262.1     0.9
- 283.715    6631   262.9     0.5
- 285.965    6713   258.1     1.4
- 288.165    6792   257.6     0.9
-     292    6930   262.3     0.9
- 294.745    7031     263     0.7
- 297.515    7132   260.7     0.6
- 299.715    7211   258.4     0.8
-     303    7328   260.1     0.6
- 305.745    7424   260.4     0.4
- 308.515    7521   259.7     0.9
-  311.26    7617   259.2     0.7
- 313.995    7714   260.8     1.4
- 316.745    7813   259.6     0.5
- 319.515    7915   259.3     0.9
- 322.265    8017   258.3     1.2
-     325    8118   261.3     0.9
- 326.545    8174   260.7     0.4
-   330.5    8315   261.8       1
- 333.265    8412     259     1.1
- 336.015    8508   260.9     0.7
- 338.645    8599   260.4     0.6
-   341.5    8697   259.3       1
- 343.715    8772     262     0.8
- 347.015    8883   263.7     1.2
- 349.745    8974   263.8     0.8
-  352.58    9067   265.2     0.9
- 355.815    9171   260.6     1.7
- 357.465    9224   260.9     0.6
- 360.195    9310     263     0.4
-  362.98    9399   263.8     1.2
- 369.545    9604   264.4     0.4
-  371.23    9657   264.2     0.9
- 375.045    9776     264     0.3
- 377.265    9846   263.4     0.1
- 379.995    9931   265.7     0.5
- 382.215   10001   264.9     0.4
- 385.125   10093   267.5     0.4
- 388.225   10192   266.9     0.6
- 390.445   10263     266     1.1
-  393.78   10370   265.1     1.6
- 396.495   10458   267.6     0.7
-  399.28   10550   264.8     0.6
- 401.995   10640   264.8     0.4
- 404.185   10712     265     0.8
-  404.78   10732   265.3     0.4
- 406.385   10785   264.4     1.5
- 407.495   10822   264.1     0.7
-   409.7   10896   264.2     1.1
-  411.38   10952   264.5     0.4
-  413.03   11008     264     0.5
-  414.75   11066     263     1.3
-  415.73   11099   265.2     0.8
- 417.065   11144   258.8     0.7
-  418.53   11195   260.8     0.5
- 420.485   11263   255.4     0.3
- 421.795   11310   253.9     0.6
-   422.9   11349   253.8     0.8
-   426.1   11468   250.7     1.1
-  427.33   11515   249.7     0.4
-   428.3   11554   251.1     0.3
- 429.495   11602   250.7     0.9
-  431.73   11695   245.3     1.1
- 433.785   11784   245.3     0.6
- 434.995   11838   246.6     0.5
-  437.23   11941   243.2     0.4
-  438.85   12017   240.3     0.3
- 443.795   12258   237.5     0.5
-  446.03   12372   237.6     0.6
- 448.745   12511   234.2     0.3
-  450.98   12625   238.3     1.1
- 454.245   12789   237.3     0.5
-  457.03   12927   237.9     0.2
- 459.895   13068   237.6     0.6
-  463.63   13252   236.4     0.9
- 465.245   13332   239.2     0.5
-  467.45   13440   238.6     0.6
- 470.195   13574   238.6     0.3
- 473.055   13711   239.1     0.4
- 479.705   14022   228.5     0.6
-   484.1   14230   228.4     0.7
- 487.245   14387   226.1     0.6
-  490.03   14532   225.2     0.5
- 492.195   14647   224.5     0.6
-  496.07   14855     222     0.8
- 499.345   15037     221     0.8
-  501.58   15166   220.9     0.5
- 504.195   15323   219.4     0.6
-  506.53   15466     214     0.8
- 509.245   15637   207.5     0.9
-  512.03   15818   207.7     0.5
- 514.745   16002   202.9     0.7
-  517.53   16199   200.8       1
- 520.245   16400   195.2     0.3
-  523.03   16616   193.9     0.5
- 526.295   16883     191     0.5
-  528.53   17073   188.5     0.7
- 531.245   17311   188.5     0.7
-  532.93   17463   189.2     0.4
- 536.745   17815     187     0.2
-  539.53   18074   188.6     0.5
-   542.9   18391   189.4     0.4
- 543.345   18433   192.3     0.6
-  543.93   18487   188.3     0.6
- 548.845   18948   188.7     0.2
-  550.51   19104   188.8     0.5
- 553.245   19360     190     0.8
-  556.03   19621     188     0.9
-  557.89   19795   188.2     0.7
- 558.195   19824     195     0.7
-  561.53   20137   187.8     0.4
-  564.26   20390   186.9     0.3
-  567.03   20646   186.5     0.3
- 569.745   20897   184.7     1.2
-  572.53   21156   186.1     0.4
- 576.325   21511   185.7     1.3
- 578.105   21676   184.4     0.8
-
-
-2.  CO2 synchronization timescale for Taylor Dome Ice Core
-
-A. Gas age:
-
- depth(m)    gas age (yr BP 1950)
-      86       94.5
-      90      149.2
-      94      205.2
-      98      260.9
-     102      316.2
-     106        372
-     110      427.9
-     114      483.7
-     118      540.1
-     122      598.1
-     126      658.4
-     130      722.7
-     134      790.3
-     138      860.5
-   142.1      929.8
-   146.1      995.5
-   150.1     1058.1
-   154.1     1119.4
-   158.1     1180.7
-   162.1     1243.2
-   166.1       1308
-   170.1     1377.6
-   174.1     1454.7
-   178.1     1539.6
-   182.1       1633
-   186.1     1731.9
-   190.1     1835.6
-   194.1       1940
-   198.1     2045.1
-   202.1       2150
-   206.1     2254.5
-   210.1     2361.9
-   214.1     2475.5
-   218.1     2594.6
-   222.1     2715.6
-   226.1     2835.7
-   230.1     2954.2
-   234.1     3070.8
-   238.1     3188.2
-   242.1       3308
-   246.1     3429.6
-   250.1     3550.6
-   254.2     3670.1
-   258.2     3787.9
-   262.2     3905.9
-   266.2     4026.1
-   270.2     4153.3
-   274.2     4295.3
-   278.2     4454.1
-   282.2     4629.4
-   286.2       4814
-   290.2     4998.6
-   294.2     5174.8
-   298.2     5342.8
-   302.2     5507.9
-   306.2     5674.9
-   310.2     5846.8
-   314.2     6031.1
-   318.2     6242.5
-   322.2       6502
-   326.2     6830.5
-   330.2     7238.7
-   334.2     7710.2
-   338.2     8215.9
-   342.2     8735.9
-   346.2     9226.8
-   350.2     9762.8
-   354.2    10289.2
-   358.2    10720.5
-   362.3    11224.1
-
-
-
-B. Ice age:
-
- depth(m)    ice age (yr BP 1950)
-      86     730.1
-    87.3     746.9
-    88.5     763.6
-    89.7     780.4
-    90.9     797.2
-      92     813.9
-    93.2     830.5
-    94.4       847
-    95.5     863.4
-    96.7     879.7
-    97.8     895.9
-    98.9     912.1
-     100     928.3
-   101.2     944.6
-   102.3     961.1
-   103.4     977.6
-   104.6     994.2
-   105.7    1010.5
-   106.8    1026.6
-   107.9    1042.7
-     109      1059
-   110.1    1075.2
-   111.1    1091.5
-   112.2    1107.9
-   113.3    1124.3
-   114.4    1140.8
-   115.5    1157.4
-   116.5      1174
-   117.6    1190.8
-   118.6    1207.9
-   119.7      1225
-   120.8    1242.2
-   121.8    1259.8
-   122.9    1277.8
-   123.9    1295.9
-     125    1314.1
-     126    1332.7
-   127.1    1351.4
-   128.1      1370
-   129.2    1388.5
-   130.2    1407.3
-   131.2    1426.3
-   132.3      1445
-   133.3    1463.6
-   134.4    1482.2
-   135.4    1500.9
-   136.5    1519.5
-   137.5    1537.9
-   138.5      1556
-   139.6    1573.9
-   140.6    1591.7
-   141.6    1609.4
-   142.7    1626.8
-   143.7    1644.1
-   144.7    1661.2
-   145.7    1678.1
-   146.8    1694.6
-   147.8      1711
-   148.8    1727.5
-   149.8    1743.9
-   150.9    1760.3
-   151.9    1776.6
-   152.9    1793.1
-   153.9    1809.6
-   154.9    1826.2
-     156    1842.9
-     157    1859.6
-     158    1876.5
-     159    1893.5
-     160    1910.6
-     161    1927.7
-   162.1    1945.1
-   163.1    1962.8
-   164.1    1980.5
-   165.1    1998.3
-   166.1      2017
-   167.1    2036.8
-   168.1    2056.8
-   169.1    2077.2
-   170.2    2098.8
-   171.2    2121.7
-   172.2      2145
-   173.2    2168.6
-   174.2    2193.2
-   175.2      2219
-   176.2    2244.7
-   177.2    2270.3
-   178.2    2296.7
-   179.3    2323.9
-   180.3      2351
-   181.3    2378.2
-   182.3      2406
-   183.3    2434.1
-   184.3    2462.3
-   185.3    2490.5
-   186.3    2519.3
-   187.3    2548.5
-   188.3    2577.7
-   189.3    2606.7
-   190.4    2635.8
-   191.4      2665
-   192.4    2694.1
-   193.4    2723.2
-   194.4    2752.3
-   195.4    2781.6
-   196.4    2810.8
-   197.4    2839.9
-   198.4    2868.9
-   199.4    2897.8
-   200.4    2926.4
-   201.4    2954.9
-   202.4      2983
-   203.5    3010.9
-   204.5    3038.5
-   205.5      3066
-   206.5    3093.6
-   207.5    3121.2
-   208.5    3148.4
-   209.5    3175.7
-   210.5    3203.4
-   211.5    3231.3
-   212.5      3259
-   213.5    3286.9
-   214.5    3315.4
-   215.5    3344.4
-   216.5    3373.3
-   217.5    3402.5
-   218.6    3431.9
-   219.6    3461.4
-   220.6    3490.9
-   221.6    3520.3
-   222.6    3549.6
-   223.6      3579
-   224.6    3608.4
-   225.6    3637.6
-   226.6    3666.2
-   227.6    3694.6
-   228.6      3723
-   229.6      3751
-   230.6    3778.4
-   231.6    3805.5
-   232.6    3832.5
-   233.6    3859.3
-   234.6      3886
-   235.7    3912.7
-   236.7    3939.3
-   237.7      3966
-   238.7    3992.9
-   239.7    4020.1
-   240.7    4047.4
-   241.7    4074.9
-   242.7    4102.9
-   243.7    4130.9
-   244.7    4158.9
-   245.7    4186.9
-   246.7    4215.2
-   247.7    4243.7
-   248.7    4272.2
-   249.7    4300.6
-   250.8    4328.8
-   251.8    4357.3
-   252.8    4385.9
-   253.8    4414.9
-   254.8    4444.3
-   255.8    4474.3
-   256.8    4504.4
-   257.8    4534.8
-   258.8    4565.6
-   259.8    4596.7
-   260.8      4628
-   261.8    4659.4
-   262.8    4691.3
-   263.8    4723.4
-   264.8    4755.4
-   265.8    4788.2
-   266.8    4821.8
-   267.9    4855.7
-   268.9    4889.6
-   269.9    4924.9
-   270.9    4961.8
-   271.9    4999.1
-   272.9    5036.2
-   273.9    5074.7
-   274.9      5115
-   275.9    5155.8
-   276.9    5196.5
-   277.9    5238.6
-   278.9    5282.7
-   279.9    5327.3
-   280.9    5371.8
-   281.9    5417.1
-   282.9    5463.7
-   283.9    5510.6
-   284.9    5557.4
-   285.9    5604.1
-   286.9    5650.6
-     288    5697.3
-     289    5743.8
-     290    5789.3
-     291    5833.8
-     292    5878.1
-     293    5922.3
-     294    5965.5
-     295    6007.8
-     296    6050.3
-     297      6093
-     298    6135.2
-     299    6177.2
-     300    6219.5
-     301    6262.3
-     302    6305.5
-     303    6349.4
-     304    6393.8
-     305    6438.7
-     306    6484.6
-     307    6531.7
-     308    6579.1
-     309    6626.8
-     310    6676.5
-     311    6728.2
-     312    6780.3
-   313.1    6832.7
-   314.1    6888.4
-   315.1    6947.6
-   316.1    7007.4
-   317.1    7067.1
-   318.1    7132.1
-   319.1    7203.1
-   320.1    7274.9
-   321.1    7346.6
-   322.1      7426
-   323.1    7514.1
-   324.1    7603.5
-   325.1    7693.4
-   326.1    7792.7
-   327.1    7902.5
-   328.1    8013.9
-   329.1    8125.8
-   330.1    8245.7
-   331.1    8373.8
-   332.1    8502.4
-   333.1    8630.8
-   334.1    8761.6
-   335.1    8894.5
-   336.1    9026.4
-   337.1    9157.7
-   338.1    9290.6
-   339.1    9425.8
-   340.1    9561.1
-   341.2    9695.7
-   342.2    9826.2
-   343.2    9951.2
-   344.2   10075.6
-   345.2   10201.2
-   346.2   10331.7
-   347.2   10467.7
-   348.2   10603.6
-   349.2   10739.5
-   350.2   10873.8
-   351.2   11006.9
-   352.2   11139.9
-   353.2     11273
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/introduction.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/introduction.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/introduction.tex	(revision 12143)
@@ -0,0 +1,42 @@
+% ================================================================
+% INTRODUCTION
+% ================================================================
+
+\chapter*{Introduction}
+
+TOP (Tracers in the Ocean Paradigm) handles oceanic passive tracers in NEMO. At present, this component provides the physical constraints and boundaries conditions for oceanic tracers transport and represents a generalized, hardwired interface toward biogeochemical models to enable a seamless coupling.
+
+It includes three independent components :
+
+\begin{itemize}
+        \item a transport code TRP sharing the same advection/diffusion routines with the dynamics, with specific treatment of some features like the surface boundary
+conditions, or the positivity of passive tracers concentrations
+        \item sources and sinks - SMS - models that can be typically biogeochemical, biological or radioactive
+        \item an offline option which is a simplified OPA 9 model using fields of physics variables that are previously stored to disk
+\end{itemize}
+
+There is two ways of coupling TOP to the dynamics :
+
+\begin{itemize}
+        \item \textit{online coupling} : the evolution of passive tracers is computed along with the dynamics
+        \item \textit{offline coupling} : the fields of physics variables are read from files and interpolated at each model time step, with no constraints on the time sampling in the input files
+\end{itemize}
+
+TOP is designed to handle multiple oceanic tracers through a modular approach and it includes different sub-modules :
+
+\begin{itemize}
+        \item the ocean water age module (AGE) tracks down the time-dependent spread of surface waters into the ocean interior
+        \item inorganic carbon (e.g. CFCs, SF6) and radiocarbon (C14) passive tracers can be modeled to assess ocean absorption timescales of anthropogenic emissions and further address water masses ventilation
+        \item a built-in biogeochemical model (PISCES) to simulate lower trophic levels ecosystem dynamics in the global ocean
+        \item a prototype tracer module (MY\_TRC) to enable user-defined cases or the coupling with alternative biogeochemical models ( e.g. BFM, MEDUSA, ERSEM, BFM, ECO3M)
+\end{itemize}
+
+\begin{figure}[ht]
+\begin{center}
+\vspace{0cm}
+\includegraphics[width=0.80\textwidth]{Fig_TOP_design}
+%\includegraphics[height=6cm,angle=-00]{Fig_TOP_design}
+\caption{A schematic view of NEMO-TOP component}
+\label{topdesign}
+\end{center}
+\end{figure}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/settings.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/settings.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/settings.tex	(revision 12143)
@@ -0,0 +1,20 @@
+%% Engine (folder name)
+\def \engine{TOP}
+
+%% Title and cover page settings
+\def \spacetop{  \vspace*{1.3cm} }
+\def \heading{Tracers in Ocean Paradigm (TOP)}
+\def \subheading{The NEMO passive tracers engine}
+\def \spacedown{ \vspace*{  1cm} }
+\def \authorswidth{0.15\linewidth}
+\def \rulelenght{110pt}
+\def \abstractwidth{0.7\linewidth}
+
+%% Color for document (frontpage banner, links and chapter boxes)
+\def \setmanualcolor{ \definecolor{manualcolor}{cmyk}{1, 0, 1, .4} }
+
+%% IPSL publication number
+\def \ipslnum{28}
+
+%% Zenodo ID, i.e. doi:10.5281/zenodo.\([0-9]*\)
+\def \zid{1471700}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/thanks.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/main/thanks.tex	(revision 12062)
+++ 	(revision )
@@ -1,8 +1,0 @@
-\'{E}th\'{e} Christian, 
-Lovato Tomas, 
-Aumont Olivier, 
-Palmi\'{e}ri Julien, 
-Mouchet Anne, 
-Nurser Georges, 
-Yool Andrew
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/blocks.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/blocks.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/blocks.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/blocks.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/byrd-co2-2008.txt
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/byrd-co2-2008.txt	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/byrd-co2-2008.txt	(revision 12143)
@@ -0,0 +1,273 @@
+Byrd Ice Core CO2 Data for 20-90 KYrBP
+-----------------------------------------------------------------------
+               World Data Center for Paleoclimatology, Boulder
+                                  and
+                     NOAA Paleoclimatology Program
+-----------------------------------------------------------------------
+NOTE: PLEASE CITE ORIGINAL REFERENCE WHEN USING THIS DATA!!!!!
+
+
+NAME OF DATA SET: Byrd Ice Core CO2 Data for 20-90 KYrBP
+
+LAST UPDATE: 10/2008 (Original receipt by WDC Paleo)
+CONTRIBUTORS: Jinho Ahn and Edward J. Brook
+IGBP PAGES/WDCA CONTRIBUTION SERIES NUMBER: 2008-095
+
+WDC PALEO CONTRIBUTION SERIES CITATION: 
+Ahn, J. and E.J. Brook. 2008.
+Byrd Ice Core CO2 Data for 20-90 KYrBP. 
+IGBP PAGES/World Data Center for Paleoclimatology 
+Data Contribution Series # 2008-095. 
+NOAA/NCDC Paleoclimatology Program, Boulder CO, USA.
+
+
+ORIGINAL REFERENCES: 
+References for CO2 data: 
+ 
+Ahn, J. and E.J. Brook. 2008.
+Atmospheric CO2 and Climate on Millennial Time Scales During 
+the Last Glacial Period. 
+Science, 322, 83-85, doi: 10.1126/science.1160832.
+
+Ahn, J. and Brook, E.J.  2007.  
+Atmospheric CO2 and climate from 65 to 30 ka B.P.. 
+Geophysical Research Letters, 34, L10703, doi:10.1029/2007GL029551.
+
+ 
+References for CO2 age:	 
+  
+Blunier-01 age: 
+Blunier, T., and Brook, E.J.  2001. 
+Timing of millennial-scale climate change in Antarctica and Greenland 
+during the last glacial period.  
+Science, 291, 109-112.  
+	   
+Ahn-08 age: 
+Ahn, J. and E.J. Brook. 2008.
+Atmospheric CO2 and Climate on Millennial Time Scales During 
+the Last Glacial Period. 
+Science, 322, 83-85, doi: 10.1126/science.1160832.
+
+
+ABSTRACT (Ahn and Brook 2008):
+Reconstructions of ancient atmospheric carbon dioxide (CO2) variations 
+help us better understand how the global carbon cycle and climate are 
+linked.  We compared CO2 variations on millennial time scales between 
+20,000 and 90,000 years ago with an Antarctic temperature proxy and 
+records of abrupt climate change in the Northern Hemisphere. CO2 
+concentration and Antarctic temperature were positively correlated 
+over millennial-scale climate cycles, implying a strong connection 
+to Southern Ocean processes. Evidence from marine sediment proxies 
+indicates that CO2 concentration rose most rapidly when North Atlantic 
+Deep Water shoaled and stratification in the Southern Ocean was reduced. 
+These increases in CO2 concentration occurred during stadial (cold) 
+periods in the Northern Hemisphere, several thousand years before 
+abrupt warming events in Greenland.
+
+
+
+GEOGRAPHIC REGION: Antarctica
+PERIOD OF RECORD:  90 - 20 KYrBP
+
+FUNDING SOURCES: 
+Gary Comer Science and Education Foundation, and
+US National Science Foundation  grants OPP 0337891 and ATM 0602395.
+
+
+
+DESCRIPTION:  
+Byrd ice core carbon dioxide data for 20-90 KYrBP, analyzed at 
+Oregon State University.  
+
+Byrd Ice Core location: 
+80.01°S , 119.51°W; 1530 m elev. 
+  
+
+
+
+DATA:
+Byrd Ice Core CO2 Data for 20-90 KYrBP
+
+Column 1: Depth (m) 
+Column 2: Blunier 2001 Age (ka before 1950 AD)
+Column 3: Ahn 2008 Age (ka before 1950 AD)
+Column 4: Mean CO2 (ppm)
+Column 5: Number of replicates
+Column 6: Uncertainty (ppm)*
+Column 7: Reference
+
+*Uncertainty is estimated from the standard deviation of the mean for 2~5 ice samples
+
+Depth       Age Bl01  Age Ahn08   Mean CO2    Repl.  Uncert.    Ref.
+1315.91       19.460     19.286     194.36      2     0.97     AB-08
+1332.34       20.061     19.887     191.14      2     0.19     AB-08
+1334.20       20.152     19.978     192.54      2     0.09     AB-08
+1346.28       20.578     20.404     204.27      2     0.48     AB-08
+1353.02       20.759     20.585     195.37      2     0.02     AB-08
+1363.17       21.065     20.891     197.12      2     1.04     AB-08
+1381.14       21.731     21.557     195.81      2     1.66     AB-08
+1401.95       22.399     22.225     199.75      3     4.49     AB-08
+1410.30       22.729     22.555     194.62      2     0.31     AB-08
+1420.27       23.530     23.356     195.97      2     1.88     AB-08
+1430.78       24.824     24.650     194.74      2     1.94     AB-08
+1441.45       26.002     25.828     189.76      2     1.30     AB-08
+1460.20       26.711     26.537     192.21      2     1.28     AB-08
+1470.77       27.148     26.974     184.40      2     1.42     AB-08
+1480.48       27.619     27.445     188.07      2     1.48     AB-08
+1490.87       27.989     27.815     201.96      2     0.46     AB-08
+1496.52       28.135     27.961     204.98      2     1.71     AB-08
+1503.54       28.395     28.221     205.91      3     2.43     AB-08
+1512.46       28.660     28.486     207.48      2     1.73     AB-08
+1523.46       29.147     28.973     205.54      2     0.40     AB-08
+1533.76       29.568     29.396     201.49      2     1.84     AB-08
+1543.63       30.013     29.843     197.51      2     3.18     AB-08
+1552.76       30.412     30.245     195.36      2     0.89     AB-08
+1573.34       31.216     31.053     195.09      3     2.37     AB-08
+1581.93       31.738     31.577     202.29      2     0.38     AB-08
+1594.06       32.328     32.170     203.67      2     0.40     AB-08
+1615.15       33.450     33.297     208.11      2     0.11     AB-08
+1620.38       33.692     33.541     205.25      2     0.53     AB-08
+1631.11       34.183     34.033     201.53      2     1.67     AB-08
+1640.90       34.630     34.484     213.08      2     0.47     AB-08
+1650.56       35.097     34.953     206.62      2     1.72     AB-08
+1658.96       35.428     35.286     209.93      2     1.10     AB-08
+1677.79       36.249     36.111     207.76      2     0.00     AB-08
+1688.63       36.840     36.704     212.63      2     0.99     AB-08
+1693.68       37.167     37.033     213.98      2     1.37     AB-08
+1699.73       37.621     37.488     217.48      2     1.16     AB-08
+1708.70       38.122     37.992     216.21      2     1.03     AB-08
+1714.20       38.428     38.298     216.52      2     2.21     AB-08
+1717.20       38.545     38.415     212.50      2     1.51     AB-08
+1719.47       38.655     38.520     211.09      2     1.83     AB-08
+1723.22       38.850     38.708     214.78      2     2.64     AB-08
+1730.78       39.163     39.006     207.63      2     0.18     AB-08
+1740.51       39.539     39.364     214.06      2     0.14     AB-08
+1743.27       39.651     39.470     213.84      2     1.23     AB-08
+1747.69       39.811     39.621     203.03      2     1.03     AB-08
+1755.15       40.038     39.834     202.11      2     0.45     AB-08
+1760.29       40.172     39.958     203.78      2     2.59     AB-08
+1770.24       40.544     40.311     203.40      2     1.56     AB-08
+1779.99       40.966     40.714     201.30      2     1.46     AB-08
+1790.29       41.585     41.313     202.69      2     2.43     AB-08
+1802.03       42.320     42.025     204.64      2     0.56     AB-08
+1811.74       42.851     42.537     207.18      2     1.53     AB-08
+1821.19       43.591     43.259     210.31      2     0.60     AB-08
+1830.63       44.137     43.786     214.57      2     0.51     AB-08
+1840.93       44.598     44.228     216.83      3     2.50     AB-08
+1844.41       44.760     44.383     215.54      2     1.26     AB-08
+1847.46       44.899     44.516     219.62      2     0.94     AB-08
+1855.09       45.229     44.831     221.00      2     0.60     AB-08
+1859.57       45.526     45.120     217.56      2     0.82     AB-08
+1861.17       45.633     45.223     219.39      2     0.53     AB-08
+1862.59       45.725     45.313     218.62      2     2.56     AB-08
+1864.56       45.852     45.436     217.23      2     2.04     AB-08
+1867.90       46.075     45.654     211.58      2     0.64     AB-08
+1871.26       46.298     45.872     206.99      2     0.29     AB-08
+1873.26       46.431     46.002     209.25      2     1.24     AB-08
+1880.36       46.889     46.448     205.61      2     1.63     AB-08
+1884.88       47.187     46.740     204.28      2     1.02     AB-08
+1892.21       47.687     47.228     205.36      2     1.00     AB-08
+1894.8        47.865     47.402     205.51      2     1.63     AB-07
+1903.72       48.450     47.973     201.79      2     2.79     AB-07
+1909.75       48.874     48.388     211.47      4     1.09     AB-07
+1911.29       48.984     48.495     207.15      4     1.93     AB-07
+1914.31       49.191     48.697     212.35      2     0.57     AB-07
+1920.25       49.596     49.092     213.91      4     2.43     AB-07
+1929.4        50.230     49.712     216.76      2     0.28     AB-07
+1938.5        50.857     50.325     215.07      2     0.30     AB-07
+1943.09       51.175     50.636     218.12      5     2.35     AB-07
+1945.98       51.394     50.850     221.08      3     0.35     AB-07
+1953.17       51.894     51.339     216.69      4     2.96     AB-07
+1956.34       52.193     51.633     217.93      2     2.81     AB-07
+1959.23       52.505     51.941     218.83      2     1.55     AB-07
+1962.18       52.812     52.259     219.08      4     2.10     AB-07
+1963.62       52.963     52.423     215.70      2     1.94     AB-07
+1968.07       53.422     52.923     212.28      2     2.52     AB-07
+1972.66       53.926     53.470     213.25      2     0.74     AB-07
+1978.74       54.577     54.177     205.57      2     0.58     AB-07
+1981.61       54.859     54.486     212.48      4     2.46     AB-07
+1988.98       55.644     55.339     215.94      2     0.96     AB-07
+1995.01       56.317     56.068     215.25      2     0.38     AB-07
+2001.46       57.022     56.833     218.27      2     3.65     AB-07
+2003.23       57.222     57.049     223.09      2     0.30     AB-07
+2013.21       58.096     58.016     222.69      3     2.59     AB-07
+2017.71       58.467     58.421     224.99      2     0.97     AB-07
+2022.42       59.125     59.072     220.11      2     1.49     AB-07
+2026.9        59.806     59.746     224.21      3     1.18     AB-07
+2028.47       60.039     59.976     217.96      2     1.39     AB-07
+2031.5        60.526     60.459     218.85      2     3.26     AB-07
+2037.68       61.451     61.374     210.28      2     1.65     AB-07
+2042.43       62.186     62.102     212.26      2     0.85     AB-07
+2048.32       63.079     62.986     204.65      2     0.39     AB-07
+2051.4        63.526     63.429     206.76      2     2.20     AB-07
+2055.9        64.152     64.048     204.06      2     0.84     AB-07
+2066.85       65.565     65.444     208.22      2     2.01     AB-08
+2069.64       65.938     65.813     207.08      2     2.09     AB-08
+2072.65       66.333     66.204     217.67      2     2.07     AB-08
+2075.59       66.779     66.644     211.79      2     0.25     AB-08
+2075.745      66.818    66.6833     219.64      3     1.17     AB-08
+2076.02       66.890     66.755     222.40      2     0.47     AB-08
+2076.43       66.997     66.861     223.63      2     0.27     AB-08
+2077.02       67.151     67.014     220.43      2     3.79     AB-08
+2080.12       67.959     67.818     244.03      2     5.52     AB-08
+2080.61       68.086     67.944     240.28      2     0.28     AB-08
+2081.10       68.213     68.071     246.47      2     0.93     AB-08
+2081.59       68.340     68.197     247.22      2     2.42     AB-08
+2082.54       68.582     68.435     249.96      3     3.97     AB-08
+2082.64       68.608     68.460     248.32      2     2.08     AB-08
+2083.085      68.721    68.5708     238.70      4     4.19     AB-08
+2083.54       68.837     68.685     238.61      2     0.33     AB-08
+2083.82       68.908     68.755     238.78      2     1.42     AB-08
+2084.14       68.989     68.834     238.84      2     0.02     AB-08
+2084.52       69.086     68.929     231.99      3     4.59     AB-08
+2085.44       69.314     69.149     237.98      2     0.97     AB-08
+2087.02       69.706     69.527     237.26      3     0.40     AB-08
+2087.75       69.886     69.700     233.74      2     0.93     AB-08
+2089.24       70.246     70.048     234.85      2     0.19     AB-08
+2090.16       70.469     70.262     234.35      2     3.03     AB-08
+2093.50       71.337     71.101     237.17      2     0.49     AB-08
+2093.71       71.395     71.158     236.62      3     1.43     AB-08
+2095.46       71.875     71.622     240.58      2     3.79     AB-08
+2097.91       72.515     72.240     246.81      3     2.23     AB-08
+2099.29       72.885     72.598     244.19      1              AB-08
+2100.05       73.073     72.783     246.30      2     0.85     AB-08
+2100.69       73.230     72.937     236.93      2     0.88     AB-08
+2101.27       73.369     73.079     242.80      2     3.41     AB-08
+2101.80       73.492     73.209     241.26      2     0.14     AB-08
+2101.97       73.531     73.251     237.79      4     2.31     AB-08
+2103.15       73.805     73.542     240.63      3     0.85     AB-08
+2103.60       73.909     73.653     235.11      2     0.58     AB-08
+2104.68       74.184     73.944     231.11      2     0.89     AB-08
+2105.52       74.410     74.182     228.82      2     2.08     AB-08
+2106.32       74.656     74.440     223.79      2     1.22     AB-08
+2107.63       75.055     74.858     230.49      2     0.28     AB-08
+2109.17       75.518     75.343     228.85      2     0.25     AB-08
+2110.06       75.783     75.621     226.25      1              AB-08
+2111.20       76.120     75.975     229.45      2     2.14     AB-08
+2113.37       76.765     76.651     229.56      2     1.56     AB-08
+2116.08       77.586     77.513     232.82      3     1.97     AB-08
+2116.73       77.785     77.721     240.83      3     1.24     AB-08
+2120.16       78.809     78.795     235.51      2     0.11     AB-08
+2122.78       79.604     79.628     238.65      2     4.76     AB-08
+2125.62       80.449     80.515     240.08      3     1.03     AB-08
+2126.13       80.635     80.708     233.00      3     1.69     AB-08
+2130.20       82.116     82.248     250.22      2     4.72     AB-08
+2130.67       82.399     82.539     246.47      2     0.04     AB-08
+2130.78       82.466     82.607     244.08      2     2.06     AB-08
+2131.99       83.195     83.354     250.70      2     0.33     AB-08
+2132.50       83.503     83.669     248.75      2     2.37     AB-08
+2132.66       83.600     83.766     237.44      2     2.38     AB-08
+2134.46       84.687     84.855     240.19      2     1.00     AB-08
+2134.70       84.828     84.996     240.36      2     1.19     AB-08
+2135.22       85.133     85.301     233.84      2     0.20     AB-08
+2135.97       85.572     85.740     241.73      2     1.76     AB-08
+2136.25       85.734     85.902     220.23      2     5.01     AB-08
+2136.93       86.127     86.295     225.72      2     1.15     AB-08
+2137.57       86.498     86.666     228.99      3     1.73     AB-08
+2138.02       86.764     86.932     229.26      2     1.58     AB-08
+2138.32       86.942     87.110     218.37      2     0.94     AB-08
+2138.79       87.221     87.389     222.25      2     1.43     AB-08
+2143.57       90.075     90.266     236.19      5     2.31     AB-08
+2144.02       90.342     90.534     235.65      2     2.86     AB-08
+2144.72       90.759     90.953     242.07      3     4.54     AB-08
+
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/edc-co2.txt
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/edc-co2.txt	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/edc-co2.txt	(revision 12143)
@@ -0,0 +1,620 @@
+EPICA Dome C Ice Core High Resolution Holocene and Transition CO2 Data
+-----------------------------------------------------------------------
+               World Data Center for Paleoclimatology, Boulder
+                                  and
+                     NOAA Paleoclimatology Program
+-----------------------------------------------------------------------
+NOTE: PLEASE CITE CONTRIBUTORS WHEN USING THIS DATA!!!!!
+
+
+NAME OF DATA SET: 
+EPICA Dome C Ice Core High Resolution Holocene and Transition CO2 Data
+LAST UPDATE: 9/2004 (Original receipt by WDC Paleo)
+CONTRIBUTOR:  Eric Monnin, University of Bern
+IGBP PAGES/WDCA CONTRIBUTION SERIES NUMBER: 2004-055
+
+
+SUGGESTED DATA CITATION: Monnin, E., et al.. 2004. 
+EPICA Dome C Ice Core High Resolution Holocene and Transition CO2 Data. 
+IGBP PAGES/World Data Center for Paleoclimatology 
+Data Contribution Series # 2004-055.
+NOAA/NGDC Paleoclimatology Program, Boulder CO, USA.
+
+
+ORIGINAL REFERENCE:  
+Monnin, E., E.J. Steig, U. Siegenthaler, K. Kawamura, J. Schwander, B. Stauffer, 
+T.F. Stocker, D.L. Morse, J.-M. Barnola, B. Bellier, D. Raynaud, and H. Fischer. 2004.  
+Evidence for substantial accumulation rate variability in Antarctica during the Holocene, 
+through synchronization of CO2 in the Taylor Dome, Dome C and DML ice cores. 
+Earth and Planetary Science Letters, 224, 45-54, doi: 10.1016/j.epsl.2004.05.007. 
+
+
+ADDITIONAL REFERENCES FOR DATA:
+Flückiger, J.,  E. Monnin, B. Stauffer, J. Schwander, T. F. Stocker, J. Chappellaz, 
+D. Raynaud and J.-M. Barnola.  2002.
+High resolution Holocene N2O ice core record and its relationship with CH4 and CO2. 
+Global Biogeochemical Cycles, 16 (1), 1010, doi:10.1029/2001GB001417.
+
+Monnin, E., A. Indermühle, A. Dällenbach, J. Flückiger, B. Stauffer, T. F. Stocker, 
+D. Raynaud, and J.-M. Barnola.  2001. 
+Atmospheric CO2 concentrations over the last glacial termination. 
+Science 291, 112-114.
+
+ 
+ADDITIONAL REFERENCE FOR DATING:
+Schwander, J., J. Jouzel, C. U. Hammer, J.-R. Petit, R. Udisti, and E. Wolff. 2001.
+A tentative chronology for the EPICA Dome Concordia ice core. 
+Geophys. Res. Lett. Vol. 28, No. 22, p. 4243.
+
+
+ABSTRACT (Monnin et al. 2004):
+High resolution records of atmospheric CO2 concentration during the Holocene 
+are obtained from the Dome Concordia and Dronning Maud Land (Antarctica) ice cores. 
+These records confirm that the CO2 concentration varied between 260 and 280 ppmv in 
+the Holocene as measured in the Taylor Dome ice core. However, there are differences 
+in the CO2 records most likely caused by mismatches in timescales. Matching the 
+Taylor Dome timescale to the Dome C timescale by synchronization of CO2 indicates that 
+the accumulation rate at Taylor Dome increased through the Holocene by a factor of two 
+and bears little resemblance to the stable isotope record used as a proxy for temperature. 
+This result shows that different locations experienced substantially different 
+accumulation changes, and casts doubt on the often-used assumption that accumulation 
+rate scales with the saturation vapor pressure as a function of temperature, at least 
+for coastal locations. 
+
+
+GEOGRAPHIC REGION: Antarctica
+PERIOD OF RECORD:  22 KYrBP - present
+
+
+DESCRIPTION: High Resolution CO2 Data for the EPICA Dome C ice core, 
+and derived timescale for Taylor Dome Ice Core. 
+
+
+Core locations: 
+EPICA Dome C:  75° 06'S, 123° 21'E 
+Dronning Maud Land (DML): 75° 00'S, 00° 04'E 
+Taylor Dome:  77° 47'47" S,  158° 43'26" E
+
+
+
+
+Data:
+1. High-resolution EDC CO2 data
+
+Column 1: Depth (m)
+Column 2: Age (Years before 1950 AD, EDC1 Timescale)
+Column 3: CO2 mean (ppmv)
+Column 4: CO2 sigma mean (ppmv) sigma mean is one sigma of the mean value 
+          (of 6 neighboring samples)
+
+
+  Depth      Age    CO2      sigma
+  102.83     173   280.4     1.8
+ 106.885     311   274.9     0.7
+ 107.195     322   277.9     0.7
+ 110.245     427   279.1     1.3
+   110.5     435   281.9     1.1
+ 113.265     530   277.7     0.7
+  115.48     604   281.1     1.1
+ 118.615     709   282.2     0.5
+   121.5     806   280.1     0.6
+ 124.815     917   278.4     1.5
+ 127.015     991   276.6     1.4
+ 129.745    1083   279.1       1
+   132.5    1175   277.7     1.2
+ 134.715    1249   278.7     1.2
+ 138.015    1362   277.4     0.8
+ 141.295    1477   279.2     0.9
+  144.05    1574     280     0.8
+ 146.265    1653   278.9     0.8
+ 149.015    1751   278.7     0.7
+ 151.195    1830     278     1.2
+   154.5    1948   276.9     0.7
+ 157.815    2069   276.7     0.8
+  160.03    2150   276.7     0.8
+ 162.165    2228   277.6     1.3
+ 165.515    2352   277.9     0.5
+  168.28    2453   273.9     1.1
+     171    2550   278.9     0.6
+ 173.135    2625   275.3     1.6
+ 176.515    2743   274.7     1.2
+ 178.715    2820   276.3     0.9
+ 181.445    2918   274.6     0.8
+ 185.845    3078   276.3     1.5
+ 187.515    3138   273.1     1.1
+ 189.715    3219     274     0.3
+     193    3337     275     0.6
+ 196.295    3454   273.4     1.3
+ 198.515    3531     273     0.8
+  201.28    3628   271.5       1
+     204    3724   275.4     0.5
+ 206.195    3802   274.9     1.3
+ 209.515    3921   271.7       1
+ 212.265    4019   271.6     0.7
+     215    4117   272.8     0.8
+ 216.645    4176   271.5     0.9
+  221.05    4335   271.1     0.8
+ 222.715    4395   269.1     0.6
+  225.48    4496   269.8       1
+ 228.195    4596   271.5     0.8
+  232.05    4737   270.7     0.5
+ 233.715    4797   269.3       1
+ 236.465    4895   268.6     1.1
+ 240.265    5033   269.8     1.2
+   242.5    5114   267.6     0.6
+ 244.715    5196   265.3     1.7
+ 248.015    5318   265.2     0.8
+ 250.715    5419   267.6       2
+   253.5    5521   265.9     0.9
+ 256.265    5621   265.5     0.8
+ 259.015    5721   260.7     1.6
+ 260.645    5780   266.7     0.9
+   264.5    5921   265.5     0.8
+ 268.365    6064   263.2     0.6
+ 269.415    6102   262.7     0.9
+ 272.195    6205   261.2     0.7
+ 276.065    6349   261.1     0.4
+ 278.265    6430   259.4     0.6
+  280.53    6514   262.1     0.9
+ 283.715    6631   262.9     0.5
+ 285.965    6713   258.1     1.4
+ 288.165    6792   257.6     0.9
+     292    6930   262.3     0.9
+ 294.745    7031     263     0.7
+ 297.515    7132   260.7     0.6
+ 299.715    7211   258.4     0.8
+     303    7328   260.1     0.6
+ 305.745    7424   260.4     0.4
+ 308.515    7521   259.7     0.9
+  311.26    7617   259.2     0.7
+ 313.995    7714   260.8     1.4
+ 316.745    7813   259.6     0.5
+ 319.515    7915   259.3     0.9
+ 322.265    8017   258.3     1.2
+     325    8118   261.3     0.9
+ 326.545    8174   260.7     0.4
+   330.5    8315   261.8       1
+ 333.265    8412     259     1.1
+ 336.015    8508   260.9     0.7
+ 338.645    8599   260.4     0.6
+   341.5    8697   259.3       1
+ 343.715    8772     262     0.8
+ 347.015    8883   263.7     1.2
+ 349.745    8974   263.8     0.8
+  352.58    9067   265.2     0.9
+ 355.815    9171   260.6     1.7
+ 357.465    9224   260.9     0.6
+ 360.195    9310     263     0.4
+  362.98    9399   263.8     1.2
+ 369.545    9604   264.4     0.4
+  371.23    9657   264.2     0.9
+ 375.045    9776     264     0.3
+ 377.265    9846   263.4     0.1
+ 379.995    9931   265.7     0.5
+ 382.215   10001   264.9     0.4
+ 385.125   10093   267.5     0.4
+ 388.225   10192   266.9     0.6
+ 390.445   10263     266     1.1
+  393.78   10370   265.1     1.6
+ 396.495   10458   267.6     0.7
+  399.28   10550   264.8     0.6
+ 401.995   10640   264.8     0.4
+ 404.185   10712     265     0.8
+  404.78   10732   265.3     0.4
+ 406.385   10785   264.4     1.5
+ 407.495   10822   264.1     0.7
+   409.7   10896   264.2     1.1
+  411.38   10952   264.5     0.4
+  413.03   11008     264     0.5
+  414.75   11066     263     1.3
+  415.73   11099   265.2     0.8
+ 417.065   11144   258.8     0.7
+  418.53   11195   260.8     0.5
+ 420.485   11263   255.4     0.3
+ 421.795   11310   253.9     0.6
+   422.9   11349   253.8     0.8
+   426.1   11468   250.7     1.1
+  427.33   11515   249.7     0.4
+   428.3   11554   251.1     0.3
+ 429.495   11602   250.7     0.9
+  431.73   11695   245.3     1.1
+ 433.785   11784   245.3     0.6
+ 434.995   11838   246.6     0.5
+  437.23   11941   243.2     0.4
+  438.85   12017   240.3     0.3
+ 443.795   12258   237.5     0.5
+  446.03   12372   237.6     0.6
+ 448.745   12511   234.2     0.3
+  450.98   12625   238.3     1.1
+ 454.245   12789   237.3     0.5
+  457.03   12927   237.9     0.2
+ 459.895   13068   237.6     0.6
+  463.63   13252   236.4     0.9
+ 465.245   13332   239.2     0.5
+  467.45   13440   238.6     0.6
+ 470.195   13574   238.6     0.3
+ 473.055   13711   239.1     0.4
+ 479.705   14022   228.5     0.6
+   484.1   14230   228.4     0.7
+ 487.245   14387   226.1     0.6
+  490.03   14532   225.2     0.5
+ 492.195   14647   224.5     0.6
+  496.07   14855     222     0.8
+ 499.345   15037     221     0.8
+  501.58   15166   220.9     0.5
+ 504.195   15323   219.4     0.6
+  506.53   15466     214     0.8
+ 509.245   15637   207.5     0.9
+  512.03   15818   207.7     0.5
+ 514.745   16002   202.9     0.7
+  517.53   16199   200.8       1
+ 520.245   16400   195.2     0.3
+  523.03   16616   193.9     0.5
+ 526.295   16883     191     0.5
+  528.53   17073   188.5     0.7
+ 531.245   17311   188.5     0.7
+  532.93   17463   189.2     0.4
+ 536.745   17815     187     0.2
+  539.53   18074   188.6     0.5
+   542.9   18391   189.4     0.4
+ 543.345   18433   192.3     0.6
+  543.93   18487   188.3     0.6
+ 548.845   18948   188.7     0.2
+  550.51   19104   188.8     0.5
+ 553.245   19360     190     0.8
+  556.03   19621     188     0.9
+  557.89   19795   188.2     0.7
+ 558.195   19824     195     0.7
+  561.53   20137   187.8     0.4
+  564.26   20390   186.9     0.3
+  567.03   20646   186.5     0.3
+ 569.745   20897   184.7     1.2
+  572.53   21156   186.1     0.4
+ 576.325   21511   185.7     1.3
+ 578.105   21676   184.4     0.8
+
+
+2.  CO2 synchronization timescale for Taylor Dome Ice Core
+
+A. Gas age:
+
+ depth(m)    gas age (yr BP 1950)
+      86       94.5
+      90      149.2
+      94      205.2
+      98      260.9
+     102      316.2
+     106        372
+     110      427.9
+     114      483.7
+     118      540.1
+     122      598.1
+     126      658.4
+     130      722.7
+     134      790.3
+     138      860.5
+   142.1      929.8
+   146.1      995.5
+   150.1     1058.1
+   154.1     1119.4
+   158.1     1180.7
+   162.1     1243.2
+   166.1       1308
+   170.1     1377.6
+   174.1     1454.7
+   178.1     1539.6
+   182.1       1633
+   186.1     1731.9
+   190.1     1835.6
+   194.1       1940
+   198.1     2045.1
+   202.1       2150
+   206.1     2254.5
+   210.1     2361.9
+   214.1     2475.5
+   218.1     2594.6
+   222.1     2715.6
+   226.1     2835.7
+   230.1     2954.2
+   234.1     3070.8
+   238.1     3188.2
+   242.1       3308
+   246.1     3429.6
+   250.1     3550.6
+   254.2     3670.1
+   258.2     3787.9
+   262.2     3905.9
+   266.2     4026.1
+   270.2     4153.3
+   274.2     4295.3
+   278.2     4454.1
+   282.2     4629.4
+   286.2       4814
+   290.2     4998.6
+   294.2     5174.8
+   298.2     5342.8
+   302.2     5507.9
+   306.2     5674.9
+   310.2     5846.8
+   314.2     6031.1
+   318.2     6242.5
+   322.2       6502
+   326.2     6830.5
+   330.2     7238.7
+   334.2     7710.2
+   338.2     8215.9
+   342.2     8735.9
+   346.2     9226.8
+   350.2     9762.8
+   354.2    10289.2
+   358.2    10720.5
+   362.3    11224.1
+
+
+
+B. Ice age:
+
+ depth(m)    ice age (yr BP 1950)
+      86     730.1
+    87.3     746.9
+    88.5     763.6
+    89.7     780.4
+    90.9     797.2
+      92     813.9
+    93.2     830.5
+    94.4       847
+    95.5     863.4
+    96.7     879.7
+    97.8     895.9
+    98.9     912.1
+     100     928.3
+   101.2     944.6
+   102.3     961.1
+   103.4     977.6
+   104.6     994.2
+   105.7    1010.5
+   106.8    1026.6
+   107.9    1042.7
+     109      1059
+   110.1    1075.2
+   111.1    1091.5
+   112.2    1107.9
+   113.3    1124.3
+   114.4    1140.8
+   115.5    1157.4
+   116.5      1174
+   117.6    1190.8
+   118.6    1207.9
+   119.7      1225
+   120.8    1242.2
+   121.8    1259.8
+   122.9    1277.8
+   123.9    1295.9
+     125    1314.1
+     126    1332.7
+   127.1    1351.4
+   128.1      1370
+   129.2    1388.5
+   130.2    1407.3
+   131.2    1426.3
+   132.3      1445
+   133.3    1463.6
+   134.4    1482.2
+   135.4    1500.9
+   136.5    1519.5
+   137.5    1537.9
+   138.5      1556
+   139.6    1573.9
+   140.6    1591.7
+   141.6    1609.4
+   142.7    1626.8
+   143.7    1644.1
+   144.7    1661.2
+   145.7    1678.1
+   146.8    1694.6
+   147.8      1711
+   148.8    1727.5
+   149.8    1743.9
+   150.9    1760.3
+   151.9    1776.6
+   152.9    1793.1
+   153.9    1809.6
+   154.9    1826.2
+     156    1842.9
+     157    1859.6
+     158    1876.5
+     159    1893.5
+     160    1910.6
+     161    1927.7
+   162.1    1945.1
+   163.1    1962.8
+   164.1    1980.5
+   165.1    1998.3
+   166.1      2017
+   167.1    2036.8
+   168.1    2056.8
+   169.1    2077.2
+   170.2    2098.8
+   171.2    2121.7
+   172.2      2145
+   173.2    2168.6
+   174.2    2193.2
+   175.2      2219
+   176.2    2244.7
+   177.2    2270.3
+   178.2    2296.7
+   179.3    2323.9
+   180.3      2351
+   181.3    2378.2
+   182.3      2406
+   183.3    2434.1
+   184.3    2462.3
+   185.3    2490.5
+   186.3    2519.3
+   187.3    2548.5
+   188.3    2577.7
+   189.3    2606.7
+   190.4    2635.8
+   191.4      2665
+   192.4    2694.1
+   193.4    2723.2
+   194.4    2752.3
+   195.4    2781.6
+   196.4    2810.8
+   197.4    2839.9
+   198.4    2868.9
+   199.4    2897.8
+   200.4    2926.4
+   201.4    2954.9
+   202.4      2983
+   203.5    3010.9
+   204.5    3038.5
+   205.5      3066
+   206.5    3093.6
+   207.5    3121.2
+   208.5    3148.4
+   209.5    3175.7
+   210.5    3203.4
+   211.5    3231.3
+   212.5      3259
+   213.5    3286.9
+   214.5    3315.4
+   215.5    3344.4
+   216.5    3373.3
+   217.5    3402.5
+   218.6    3431.9
+   219.6    3461.4
+   220.6    3490.9
+   221.6    3520.3
+   222.6    3549.6
+   223.6      3579
+   224.6    3608.4
+   225.6    3637.6
+   226.6    3666.2
+   227.6    3694.6
+   228.6      3723
+   229.6      3751
+   230.6    3778.4
+   231.6    3805.5
+   232.6    3832.5
+   233.6    3859.3
+   234.6      3886
+   235.7    3912.7
+   236.7    3939.3
+   237.7      3966
+   238.7    3992.9
+   239.7    4020.1
+   240.7    4047.4
+   241.7    4074.9
+   242.7    4102.9
+   243.7    4130.9
+   244.7    4158.9
+   245.7    4186.9
+   246.7    4215.2
+   247.7    4243.7
+   248.7    4272.2
+   249.7    4300.6
+   250.8    4328.8
+   251.8    4357.3
+   252.8    4385.9
+   253.8    4414.9
+   254.8    4444.3
+   255.8    4474.3
+   256.8    4504.4
+   257.8    4534.8
+   258.8    4565.6
+   259.8    4596.7
+   260.8      4628
+   261.8    4659.4
+   262.8    4691.3
+   263.8    4723.4
+   264.8    4755.4
+   265.8    4788.2
+   266.8    4821.8
+   267.9    4855.7
+   268.9    4889.6
+   269.9    4924.9
+   270.9    4961.8
+   271.9    4999.1
+   272.9    5036.2
+   273.9    5074.7
+   274.9      5115
+   275.9    5155.8
+   276.9    5196.5
+   277.9    5238.6
+   278.9    5282.7
+   279.9    5327.3
+   280.9    5371.8
+   281.9    5417.1
+   282.9    5463.7
+   283.9    5510.6
+   284.9    5557.4
+   285.9    5604.1
+   286.9    5650.6
+     288    5697.3
+     289    5743.8
+     290    5789.3
+     291    5833.8
+     292    5878.1
+     293    5922.3
+     294    5965.5
+     295    6007.8
+     296    6050.3
+     297      6093
+     298    6135.2
+     299    6177.2
+     300    6219.5
+     301    6262.3
+     302    6305.5
+     303    6349.4
+     304    6393.8
+     305    6438.7
+     306    6484.6
+     307    6531.7
+     308    6579.1
+     309    6626.8
+     310    6676.5
+     311    6728.2
+     312    6780.3
+   313.1    6832.7
+   314.1    6888.4
+   315.1    6947.6
+   316.1    7007.4
+   317.1    7067.1
+   318.1    7132.1
+   319.1    7203.1
+   320.1    7274.9
+   321.1    7346.6
+   322.1      7426
+   323.1    7514.1
+   324.1    7603.5
+   325.1    7693.4
+   326.1    7792.7
+   327.1    7902.5
+   328.1    8013.9
+   329.1    8125.8
+   330.1    8245.7
+   331.1    8373.8
+   332.1    8502.4
+   333.1    8630.8
+   334.1    8761.6
+   335.1    8894.5
+   336.1    9026.4
+   337.1    9157.7
+   338.1    9290.6
+   339.1    9425.8
+   340.1    9561.1
+   341.2    9695.7
+   342.2    9826.2
+   343.2    9951.2
+   344.2   10075.6
+   345.2   10201.2
+   346.2   10331.7
+   347.2   10467.7
+   348.2   10603.6
+   349.2   10739.5
+   350.2   10873.8
+   351.2   11006.9
+   352.2   11139.9
+   353.2     11273
+
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/introduction.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/introduction.tex	(revision 12062)
+++ 	(revision )
@@ -1,47 +1,0 @@
-\documentclass[../../NEMO/main/NEMO_manual]{subfiles}
-\begin{document}
-% ================================================================
-% INTRODUCTION
-% ================================================================
-
-\chapter*{Introduction}
-
-TOP (Tracers in the Ocean Paradigm) handles oceanic passive tracers in NEMO. At present, this component provides the physical constraints and boundaries conditions for oceanic tracers transport and represents a generalized, hardwired interface toward biogeochemical models to enable a seamless coupling.
-
-It includes three independent components :  
-
-\begin{itemize}
-        \item a transport code TRP sharing the same advection/diffusion routines with the dynamics, with specific treatment of some features like the surface boundary
-conditions, or the positivity of passive tracers concentrations
-        \item sources and sinks - SMS - models that can be typically biogeochemical, biological or radioactive
-        \item an offline option which is a simplified OPA 9 model using fields of physics variables that are previously stored to disk
-\end{itemize}
-
-There is two ways of coupling TOP to the dynamics :
-
-\begin{itemize}
-        \item \textit{online coupling} : the evolution of passive tracers is computed along with the dynamics
-        \item \textit{offline coupling} : the fields of physics variables are read from files and interpolated at each model time step, with no constraints on the time sampling in the input files
-\end{itemize}
-
-TOP is designed to handle multiple oceanic tracers through a modular approach and it includes different sub-modules :
-
-\begin{itemize}
-        \item the ocean water age module (AGE) tracks down the time-dependent spread of surface waters into the ocean interior
-        \item inorganic carbon (e.g. CFCs, SF6) and radiocarbon (C14) passive tracers can be modeled to assess ocean absorption timescales of anthropogenic emissions and further address water masses ventilation
-        \item a built-in biogeochemical model (PISCES) to simulate lower trophic levels ecosystem dynamics in the global ocean
-        \item a prototype tracer module (MY\_TRC) to enable user-defined cases or the coupling with alternative biogeochemical models ( e.g. BFM, MEDUSA, ERSEM, BFM, ECO3M)
-\end{itemize}
-
-\begin{figure}[ht]        
-\begin{center}
-\vspace{0cm}
-\includegraphics[width=0.80\textwidth]{Fig_TOP_design}
-%\includegraphics[height=6cm,angle=-00]{Fig_TOP_design}
-\caption{A schematic view of NEMO-TOP component}
-\label{topdesign}
-\end{center}   
-\end{figure}
-
-\end{document}
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/keys.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/keys.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/keys.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/keys.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/miscellaneous.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/miscellaneous.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/miscellaneous.tex	(revision 12143)
@@ -1,3 +1,3 @@
-\documentclass[../../NEMO/main/NEMO_manual]{subfiles}
+\documentclass[../main/TOP_manual]{subfiles}
 
 \begin{document}
@@ -43,5 +43,5 @@
 \begin{minted}{bash}
    bld::tool::fppkeys   key_iomput key_mpp_mpi key_top
-   
+
    src::MYBGC::initialization         <MYBGCPATH>/initialization
    src::MYBGC::pelagic                <MYBGCPATH>/pelagic
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/model_description.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/model_description.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/model_description.tex	(revision 12143)
@@ -1,3 +1,3 @@
-\documentclass[../../NEMO/main/NEMO_manual]{subfiles}
+\documentclass[../main/TOP_manual]{subfiles}
 
 \newcommand{\cd}{\mathrm{CO_2}}
@@ -14,5 +14,5 @@
 \chapter{Model Description}
 \label{chap:ModDes}
-\minitoc
+\chaptertoc
 
 \section{Basics}
@@ -26,11 +26,11 @@
 \end{equation}
 
-where expressions of $D^{lC}$ and $D^{vC}$ depend on the choice for the lateral and vertical subgrid scale parameterizations, see equations 5.10 and 5.11 in \citep{nemo_manual} 
+where expressions of $D^{lC}$ and $D^{vC}$ depend on the choice for the lateral and vertical subgrid scale parameterizations, see equations 5.10 and 5.11 in \citep{nemo_manual}
 
 {S(C)} , the first term on the right hand side of \ref{Eq_tracer}; is the SMS - Source Minus Sink - inherent to the tracer.  In the case of biological tracer such as phytoplankton, {S(C)} is the balance between phytoplankton growth and its decay through mortality and grazing. In the case of a tracer comprising carbon,  {S(C)} accounts for gas exchange, river discharge, flux to the sediments, gravitational sinking and other biological processes. In the case of a radioactive tracer, {S(C)} is simply loss due to radioactive decay.
 
-The second term (within brackets) represents the advection of the tracer in the three directions. It can be interpreted as the budget between the incoming and outgoing tracer fluxes in a volume $T$-cells $b_t= e_{1t}\,e_{2t}\,e_{3t}$ 
-
-The third term  represents the change due to lateral diffusion. 
+The second term (within brackets) represents the advection of the tracer in the three directions. It can be interpreted as the budget between the incoming and outgoing tracer fluxes in a volume $T$-cells $b_t= e_{1t}\,e_{2t}\,e_{3t}$
+
+The third term  represents the change due to lateral diffusion.
 
 The fourth term is change due to vertical diffusion, parameterized as eddy diffusion to represent vertical turbulent fluxes :
@@ -68,5 +68,5 @@
 
 The passive tracer transport component  shares the same advection/diffusion routines with the dynamics, with specific treatment of some features like the surface boundary conditions, or the positivity of passive tracers concentrations.
- 
+
  \subsection{ Advection}
 %------------------------------------------namtrc_adv----------------------------------------------------
@@ -80,14 +80,14 @@
 \nlst{namtrc_ldf}
 %-------------------------------------------------------------------------------------------------------------
-In NEMO v4.0, the passive tracer diffusion has necessarily the same form as the active tracer diffusion, meaning that the numerical scheme must be the same. However the passive tracer mixing coefficient can be chosen as a multiple of the active ones by changing the value of \textit{rn\_ldf\_multi} in namelist \textit{namtrc\_ldf}. The choice of numerical scheme is then set  in the \ngn{namtra\_ldf} namelist for the dynamic described in section 5.2 of \citep{nemo_manual}. 
+In NEMO v4.0, the passive tracer diffusion has necessarily the same form as the active tracer diffusion, meaning that the numerical scheme must be the same. However the passive tracer mixing coefficient can be chosen as a multiple of the active ones by changing the value of \textit{rn\_ldf\_multi} in namelist \textit{namtrc\_ldf}. The choice of numerical scheme is then set  in the \nam{namtra_ldf}{namtra\_ldf} namelist for the dynamic described in section 5.2 of \citep{nemo_manual}.
 
 
 %-----------------We also offers the possibility to increase zonal equatorial diffusion for passive tracers by introducing an enhanced zonal diffusivity coefficent in the equatorial domain which can be defined by the equation below :
 %-----------------\begin{equation} \label{eq:traqsr_iradiance}
-%-----------------Aht  = Aht *  rn_fact_lap * \exp( - \max( 0., z -1000  ) / 1000}  \quad \text{for $L=1$ to $N$}  
+%-----------------Aht  = Aht *  rn_fact_lap * \exp( - \max( 0., z -1000  ) / 1000}  \quad \text{for $L=1$ to $N$}
 %-----------------\end{equation}
 
  \subsection{ Tracer damping}
- 
+
 %------------------------------------------namtrc_dmp----------------------------------------------------
 \nlst{namtrc_dmp}
@@ -95,8 +95,8 @@
 
 The use of newtonian damping  to climatological fields or observations is also coded, sharing the same routine dans active tracers. Boolean variables are defined in the namelist\_top\_ref to select the tracers on which restoring is applied
-Options are defined through the  \ngn{namtrc\_dmp} namelist variables. The restoring term is added when the namelist parameter \np{ln\_trcdmp} is set to true. The restoring coefficient is a three-dimensional array read in a file, which name is specified by the namelist variable \np{cn\_resto\_tr}. This netcdf file can be generated using the DMP\_TOOLS tool.
+Options are defined through the \nam{namtrc_dmp}{namtrc\_dmp} namelist variables. The restoring term is added when the namelist parameter \np{ln\_trcdmp} is set to true. The restoring coefficient is a three-dimensional array read in a file, which name is specified by the namelist variable \np{cn\_resto\_tr}. This netcdf file can be generated using the DMP\_TOOLS tool.
 
  \subsection{ Tracer positivity}
- 
+
 %------------------------------------------namtrc_rad----------------------------------------------------
 \nlst{namtrc_rad}
@@ -104,5 +104,5 @@
 
 Sometimes, numerical scheme can generates negative values of passive tracers concentration that must be positive. For exemple,  isopycnal diffusion can created extrema. The trcrad routine artificially corrects negative concentrations with a very crude solution that either sets negative concentration to zero without adjusting the tracer budget, or by removing negative concentration and keeping mass conservation.
-The treatment of negative concentrations is an option and can be selected in the namelist \ngn{namtrc\_rad} by setting the parameter \np{ln\_trcrad}  to true.
+The treatment of negative concentrations is an option and can be selected in the namelist \nam{namtrc_rad}{namtrc\_rad} by setting the parameter \np{ln\_trcrad}  to true.
 
 \section{The SMS modules}
@@ -160,5 +160,5 @@
 As can be seen in the figure, while the concentration of SF6 continues to rise to the present  day, the concentrations of both CFC-11 and CFC-12 have levelled off and declined since around the 1990s.
 These declines have been driven by the Montreal Protocol (effective since August 1989), which has banned the production of CFC-11 and CFC-12 (as well as other CFCs) because of their role in the depletion of
-stratospheric ozone (O$_{3}$), critical in decreasing the flux of ultraviolet radiation to the Earth's surface. Separate to this role in ozone-depletion, all three chemicals are significantly more potent greenhouse gases 
+stratospheric ozone (O$_{3}$), critical in decreasing the flux of ultraviolet radiation to the Earth's surface. Separate to this role in ozone-depletion, all three chemicals are significantly more potent greenhouse gases
 than CO$_{2}$ (especially SF6), although their relatively low atmospheric concentrations limit their role in climate change. \\
 
@@ -168,7 +168,7 @@
 % concentrations increased until around the late 1990s afterwhich they began to decline in
 % response to the Montreal Protocol.
-% In the case of SF6, release began in the 1950s 
+% In the case of SF6, release began in the 1950s
 % This release began in the 1930s for CFC-11 and CFC-12, and the 1950s for SF6, and
-% regularly increasing their atmospheric concentration until the 1090s, 2000s for respectively CFC11, CFC12, 
+% regularly increasing their atmospheric concentration until the 1090s, 2000s for respectively CFC11, CFC12,
 % and is still increasing, and SF6 (see Figure \ref{img_cfcatm}).  \\
 
@@ -177,5 +177,5 @@
 Because they only enter the ocean via surface air-sea exchange, and are almost completely chemically and biologically inert, their distribution within the ocean interior reveals its ventilation via transport and mixing.
 Measuring the dissolved concentrations of the gases -- as well as the mixing ratios between them -- shows circulation pathways within the ocean as well as water mass ages (i.e. the time since last contact with the
-atmosphere). This feature of the gases has made them valuable across a wide range of oceanographic problems. One use lies in ocean modelling, where they can be used to evaluate the realism of the circulation and 
+atmosphere). This feature of the gases has made them valuable across a wide range of oceanographic problems. One use lies in ocean modelling, where they can be used to evaluate the realism of the circulation and
 ventilation of models, key for understanding the behaviour of wider modelled marine biogeochemistry (e.g. \citep{dutay_2002,palmieri_2015}). \\
 
@@ -183,7 +183,7 @@
 
 Advection and diffusion of the CFCs in NEMO are calculated by the physical module, OPA,
-whereas sources and sinks are done by the CFC module within TOP. 
-The only source for CFCs in the ocean is via air-sea gas exchange at its surface, and since CFCs are generally 
-stable within the ocean, we assume that there are no sinks (i.e. no loss processes) within the ocean interior. 
+whereas sources and sinks are done by the CFC module within TOP.
+The only source for CFCs in the ocean is via air-sea gas exchange at its surface, and since CFCs are generally
+stable within the ocean, we assume that there are no sinks (i.e. no loss processes) within the ocean interior.
 Consequently, the sinks-minus-sources term for CFCs consists only of their air-sea fluxes, $F_{cfc}$, as
 described in the Ocean Model Inter-comparison Project (OMIP) protocol \citep{orr_2017}:
@@ -196,9 +196,9 @@
 F_{cfc} = K_{w} \, \cdot \, (C_{sat} - C_{surf}) \, \cdot  \, (1 - f_{i})
 \label{equ_CFC_flux}
-\end{eqnarray}  
-
-Where $K_{w}$ is the piston velocity (in m~s$^{-1}$), as defined in Equation \ref{equ_Kw}; 
-$C_{sat}$ is the saturation concentration of the CFC tracer, as defined in Equation \ref{equ_C_sat}; 
-$C_{surf}$ is the local surface concentration of the CFC tracer within the model (in mol~m$^{-3}$); 
+\end{eqnarray}
+
+Where $K_{w}$ is the piston velocity (in m~s$^{-1}$), as defined in Equation \ref{equ_Kw};
+$C_{sat}$ is the saturation concentration of the CFC tracer, as defined in Equation \ref{equ_C_sat};
+$C_{surf}$ is the local surface concentration of the CFC tracer within the model (in mol~m$^{-3}$);
 and $f_{i}$ is the fractional sea-ice cover of the local ocean (ranging between 0.0 for ice-free ocean,
 through to 1.0 for completely ice-covered ocean with no air-sea exchange).
@@ -209,15 +209,15 @@
 C_{sat} = Sol \, \cdot \, P_{cfc}
 \label{equ_C_sat}
-\end{eqnarray}  
-
-Where $Sol$ is the gas solubility in mol~m$^{-3}$~pptv$^{-1}$, as defined in Equation \ref{equ_Sol_CFC}; 
+\end{eqnarray}
+
+Where $Sol$ is the gas solubility in mol~m$^{-3}$~pptv$^{-1}$, as defined in Equation \ref{equ_Sol_CFC};
 and $P_{cfc}$ is the atmosphere concentration of the CFC (in parts per trillion by volume, pptv).
 This latter concentration is provided to the model by the historical time-series of \citet{bullister_2017}.
-This includes bulk atmospheric concentrations of the CFCs for both hemispheres -- this is necessary because of 
-the geographical asymmetry in the production and release of CFCs to the atmosphere. 
-Within the model, hemispheric concentrations are uniform, with the exception of the region between 
+This includes bulk atmospheric concentrations of the CFCs for both hemispheres -- this is necessary because of
+the geographical asymmetry in the production and release of CFCs to the atmosphere.
+Within the model, hemispheric concentrations are uniform, with the exception of the region between
 10$^{\circ}$N and 10$^{\circ}$ in which they are linearly interpolated.
 
-The piston velocity $K_{w}$ is a function of 10~m wind speed (in m~s$^{-1}$) and sea surface temperature, 
+The piston velocity $K_{w}$ is a function of 10~m wind speed (in m~s$^{-1}$) and sea surface temperature,
 $T$ (in $^{\circ}$C), and is calculated here following \citet{wanninkhof_1992}:
 
@@ -225,8 +225,8 @@
 K_{w} = X_{conv} \, \cdot \, a \, \cdot \, u^2 \, \cdot \, \sqrt{ \frac{Sc(T)}{660} }
 \label{equ_Kw}
-\end{eqnarray} 
-
-Where $X_{conv}$ = $\frac{0.01}{3600}$, a conversion factor that changes the piston velocity 
-from cm~h$^{-1}$ to m~s$^{-1}$; 
+\end{eqnarray}
+
+Where $X_{conv}$ = $\frac{0.01}{3600}$, a conversion factor that changes the piston velocity
+from cm~h$^{-1}$ to m~s$^{-1}$;
 $a$ is a constant re-estimated by \citet{wanninkhof_2014} to 0.251 (in $\frac{cm~h^{-1}}{(m~s^{-1})^{2}}$);
 and $u$ is the 10~m wind speed in m~s$^{-1}$ from either an atmosphere model or reanalysis atmospheric forcing.
@@ -236,9 +236,9 @@
 Sc =  a0 + (a1 \, \cdot \, T) + (a2  \, \cdot \, T^2) + (a3 \, \cdot \, T^3) + (a4 \, \cdot \, T^4)
 \label{equ_Sc}
-\end{eqnarray} 
-
-The solubility, $Sol$, used in Equation \ref{equ_C_sat} is calculated in mol~l$^{-1}$~atm$^{-1}$, 
-and is specific for each gas. 
-It has been experimentally estimated by \citet{warner_1985} as a function of temperature 
+\end{eqnarray}
+
+The solubility, $Sol$, used in Equation \ref{equ_C_sat} is calculated in mol~l$^{-1}$~atm$^{-1}$,
+and is specific for each gas.
+It has been experimentally estimated by \citet{warner_1985} as a function of temperature
 and salinity:
 
@@ -246,5 +246,5 @@
 % code version that I have to hand, although this might be out of date; in any case, I'dag
 % strongly suggest avoiding the use of the \frac{}{100}, and instead substitute a term that is
-% "degrees Kelvin divided by 100" (which is weird in itself); and make this term use Celcius 
+% "degrees Kelvin divided by 100" (which is weird in itself); and make this term use Celcius
 % so that you're not using T twice in different ways
 
@@ -252,15 +252,15 @@
 \ln{(Sol)} = a_1 + \frac{a_2}{ T_{X}} + a_3 \, \cdot \, \ln{ T_{X} } + a_4 \, \cdot \, T_{X}^2 + S \, \cdot \, ( b_1 + b_2 \, \cdot \, T_{X} + b_3 \, \cdot \, T_{X}^2 )
 \label{equ_Sol_CFC}
-\end{eqnarray}  
+\end{eqnarray}
 
 % \begin{eqnarray}
 % \ln{(Sol)} = a1 + a2 \, \frac{100}{T} + a3 \, \ln{ (\frac{T}{100}) } + a4 \, \frac{T}{100}^2 + S \, ( b1 + b2 \, \frac{T}{100} + b3 \, \frac{T}{100}^2 )
 % \label{equ_Sol_CFC}
-% \end{eqnarray}  
-
-Where $T_{X}$ is $\frac{T + 273.16}{100}$, a function of temperature; 
+% \end{eqnarray}
+
+Where $T_{X}$ is $\frac{T + 273.16}{100}$, a function of temperature;
 and the $a_{x}$ and $b_{x}$ coefficients are specific for each gas (see Table \ref{tab_ref_CFC}).
 This is then converted to mol~m$^{-3}$~pptv$^{-1}$ assuming a constant atmospheric surface pressure of 1~atm.
-The solubility of CFCs thus decreases with rising $T$ while being relatively insensitive to salinity changes. 
+The solubility of CFCs thus decreases with rising $T$ while being relatively insensitive to salinity changes.
 Consequently, this translates to a pattern of solubility where it is greatest in cold, polar regions (see Figure \ref{img_cfcsol}).
 
@@ -289,6 +289,6 @@
 \centering
 \begin{tabular}{l l l l l l l l l}
-\hline 
-Gas   & & a1 & a2 & a3 & a4 & b1 & b2 & b3 \\          
+\hline
+Gas   & & a1 & a2 & a3 & a4 & b1 & b2 & b3 \\
 \hline
 CFC-11 & & -218.0971 & 298.9702 & 113.8049 & -1.39165 & -0.143566  & 0.091015   & -0.0153924 \\
@@ -296,5 +296,5 @@
 SF6    & & -80.0343  & 117.232  & 29.5817  & 0.0      & 0.0335183  & -0.0373942 & 0.00774862 \\
 \hline
-\end{tabular} 
+\end{tabular}
 \label{tab_ref_CFC}
 \end{table}
@@ -306,6 +306,6 @@
 \centering
 \begin{tabular}{l l l l l l l }
-\hline 
-Gas  & & a0 & a1 & a2 & a3 & a4 \\          
+\hline
+Gas  & & a0 & a1 & a2 & a3 & a4 \\
 \hline
 CFC-11 & & 3579.2  & -222.63 & 7.5749 & -0.14595 & 0.0011874   \\
@@ -313,5 +313,5 @@
 SF6    & & 3177.5  & -200.57 & 6.8865 & -0.13335 & 0.0010877   \\
 \hline
-\end{tabular} 
+\end{tabular}
 \label{tab_Sc}
 \end{table}
@@ -353,5 +353,5 @@
 %----------------------------------------------------------------------------------------------------------
 
-The C14 package implemented in NEMO by Anne Mouchet models ocean $\Dcq$. It offers several possibilities: $\Dcq$ as a physical tracer of the ocean ventilation (natural $\cq$), assessment of bomb radiocarbon uptake, as well as transient studies of paleo-historical ocean radiocarbon distributions. 
+The C14 package implemented in NEMO by Anne Mouchet models ocean $\Dcq$. It offers several possibilities: $\Dcq$ as a physical tracer of the ocean ventilation (natural $\cq$), assessment of bomb radiocarbon uptake, as well as transient studies of paleo-historical ocean radiocarbon distributions.
 
 \subsubsection{Method}
@@ -368,5 +368,5 @@
 
 This simplified approach also neglects the effects of fractionation (e.g.,  air-sea exchange) and of biological processes. Previous studies by \cite{bacastow_1990} and \cite{joos_1997} resulted in nearly identical $\Dcq$ distributions among experiments considering biology or not.
-Since observed $\Rq$ ratios are corrected for the isotopic fractionation when converted to the standard $\Dcq$ notation \citep{stuiver_1977} the model results are directly comparable to observations. 
+Since observed $\Rq$ ratios are corrected for the isotopic fractionation when converted to the standard $\Dcq$ notation \citep{stuiver_1977} the model results are directly comparable to observations.
 
 Therefore the simplified approach is justified for the purpose of assessing the circulation and ventilation of OGCMs.
@@ -425,5 +425,5 @@
 %The sensitivity to this parametrization is discussed in section \ref{sec:result}.
 %
-\item Chemical enhancement (term $b$  in Eq. \ref{eq:wanchem}) may be set on/off by means of the logical variable \CODE{ln\_chemh}. 
+\item Chemical enhancement (term $b$  in Eq. \ref{eq:wanchem}) may be set on/off by means of the logical variable \CODE{ln\_chemh}.
 \end{itemize}
 
@@ -464,5 +464,5 @@
 \end{figure}
 
-Performing this type of experiment requires that a pre-industrial equilibrium run be performed beforehand (\CODE{ln\_rsttr} should be set to \texttt{.TRUE.}). 
+Performing this type of experiment requires that a pre-industrial equilibrium run be performed beforehand (\CODE{ln\_rsttr} should be set to \texttt{.TRUE.}).
 
 An exception to this rule is when wishing to perform a perturbation bomb experiment as was possible with the package \texttt{C14b}. It is still possible to easily set-up that type of transient experiment for which no previous run is needed.  In addition to the instructions as given in this section it is however necessary to adapt the \texttt{atmc14.dat} file so that it does no longer contain any negative $\Dcq$ values (Suess effect in the pre-bomb period).
@@ -476,5 +476,5 @@
 \begin{itemize}
 \item Specify the starting date of the experiment: \CODE{nn\_date0} in \texttt{namelist}.  \CODE{nn\_date0} is written as Year0101 where Year may take any positive value (AD).
-\item Then the parameters \CODE{nn\_rstctl} in  \texttt{namelist} (on-line) and \CODE{nn\_rsttr} in \texttt{namelist\_top} (off-line)  must be \textbf{set to 0} at the start of the experiment (force the date to \CODE{nn\_date0} for the \textbf{first} experiment year). 
+\item Then the parameters \CODE{nn\_rstctl} in  \texttt{namelist} (on-line) and \CODE{nn\_rsttr} in \texttt{namelist\_top} (off-line)  must be \textbf{set to 0} at the start of the experiment (force the date to \CODE{nn\_date0} for the \textbf{first} experiment year).
 \item These two parameters (\CODE{nn\_rstctl} and \CODE{nn\_rsttr}) have then to be \textbf{set to 2} for the following years (the date must be read in the restart file).
 \end{itemize}
@@ -497,5 +497,5 @@
 
 The file \texttt{intcal13.14c} \citep{reimer_2013} contains atmospheric $\Dcq$ from 0 to 50 kyr cal BP\footnote{cal BP: number of years before 1950 AD}.
-The $\cd$ forcing is provided in file \texttt{ByrdEdcCO2.txt}. The content of this file is based on  the high resolution record from EPICA Dome C \citep{monnin_2004} for the Holocene and the Transition, and on Byrd Ice Core CO2 Data for 20--90 kyr BP  \citep{ahn_2008}. These atmospheric values are reproduced in Fig. \ref{fig:paleo}. Dates in these files are expressed as yr BP. 
+The $\cd$ forcing is provided in file \texttt{ByrdEdcCO2.txt}. The content of this file is based on  the high resolution record from EPICA Dome C \citep{monnin_2004} for the Holocene and the Transition, and on Byrd Ice Core CO2 Data for 20--90 kyr BP  \citep{ahn_2008}. These atmospheric values are reproduced in Fig. \ref{fig:paleo}. Dates in these files are expressed as yr BP.
 
 To ensure that the atmospheric forcing is applied properly as well as that output files contain consistent dates and inventories the experiment should be set up carefully.
@@ -519,13 +519,13 @@
 Field & Type & Dim & Units & Description \\ \hline
 RC14 & ptrc & 3-D & -        & Radiocarbon ratio \\
-DeltaC14 & diad & 3-D & \textperthousand & $\Dcq$\\ 
+DeltaC14 & diad & 3-D & \textperthousand & $\Dcq$\\
 C14Age & diad & 3-D & yr &   Radiocarbon age \\
 RAge & diad & 2-D & yr & Reservoir age\\
 qtr\_c14 &  diad & 2-D & m$^{-2}$ yr$^{-1}$ & Air-to-sea net $\Rq$ flux\\
 qint\_c14 & diad & 2-D &   m$^{-2}$ &  Cumulative air-to-sea $\Rq$ flux \\
-AtmCO2 & scalar & 0-D & ppm & Global atmospheric $\cd$ \\ 
-AtmC14 & scalar & 0-D & \textperthousand  & Global atmospheric $\Dcq$\\ 
-K\_CO2 & scalar & 0-D & cm h$^{-1}$  & Global $\cd$ piston velocity ($ \overline{\kappa_{\cd}}$) \\ 
-K\_C14 & scalar & 0-D &m yr$^{-1}$ & Global $\Rq$ transfer velocity  ($ \overline{\kappa_R}$)\\ 
+AtmCO2 & scalar & 0-D & ppm & Global atmospheric $\cd$ \\
+AtmC14 & scalar & 0-D & \textperthousand  & Global atmospheric $\Dcq$\\
+K\_CO2 & scalar & 0-D & cm h$^{-1}$  & Global $\cd$ piston velocity ($ \overline{\kappa_{\cd}}$) \\
+K\_C14 & scalar & 0-D &m yr$^{-1}$ & Global $\Rq$ transfer velocity  ($ \overline{\kappa_R}$)\\
 C14Inv & scalar & 0-D & $10^{26}$ atoms & Ocean radiocarbon inventory \\ \hline
 \end{tabular}
@@ -534,8 +534,8 @@
 \end{table}
 %!   Standard ratio: 1.176E-12 ; Avogadro's nbr = 6.022E+23 at/mol ; bomb C14 traditionally reported as 1.E+26 atoms
-%   REAL(wp), PARAMETER            :: atomc14=1.176*6.022E-15   ! conversion factor 
+%   REAL(wp), PARAMETER            :: atomc14=1.176*6.022E-15   ! conversion factor
 % atomc14 * xdicsur * zdum
 
-The radiocarbon age is computed as  $(-1/\lambda) \ln{ \left( \Rq \right)}$, with zero age corresponding to $\Rq=1$. 
+The radiocarbon age is computed as  $(-1/\lambda) \ln{ \left( \Rq \right)}$, with zero age corresponding to $\Rq=1$.
 
 The reservoir age is the age difference between the ocean uppermost layer and the atmosphere. It is usually reported as conventional radiocarbon age; i.e., computed by means of the Libby radiocarbon mean life \cite[8033 yr;][]{stuiver_1977}
@@ -561,8 +561,8 @@
 \subsection{PISCES biogeochemical model}
 
-PISCES is a biogeochemical model which simulates the lower trophic levels of marine ecosystem (phytoplankton, microzooplankton and mesozooplankton) and the biogeochemical cycles of carbonand of the main nutrients (P, N, Fe, and Si). The  model is intended to be used for both regional and global configurations at high or low spatial resolutions as well as for  short-term (seasonal, interannual) and long-term (climate change, paleoceanography) analyses. 
+PISCES is a biogeochemical model which simulates the lower trophic levels of marine ecosystem (phytoplankton, microzooplankton and mesozooplankton) and the biogeochemical cycles of carbonand of the main nutrients (P, N, Fe, and Si). The  model is intended to be used for both regional and global configurations at high or low spatial resolutions as well as for  short-term (seasonal, interannual) and long-term (climate change, paleoceanography) analyses.
 Two versions of PISCES are available in NEMO v4.0 :
 
-PISCES-v2, by setting in namelist\_pisces\_ref  \np{ln\_p4z} to true,  can be seen as one of the many Monod models \citep{monod_1958}. It assumes a constant Redfield ratio and phytoplankton growth depends on the external concentration in nutrients. There are twenty-four prognostic variables (tracers) including two phytoplankton compartments  (diatoms and nanophytoplankton), two zooplankton size-classes (microzooplankton and  mesozooplankton) and a description of the carbonate chemistry. Formulations in PISCES-v2 are based on a mixed Monod/Quota formalism: On one hand, stoichiometry of C/N/P is fixed and growth rate of phytoplankton is limited by the external availability in N, P and Si. On the other hand, the iron and silicium quotas are variable and growth rate of phytoplankton is limited by the internal availability in Fe. Various parameterizations can be activated in PISCES-v2, setting for instance the complexity of iron chemistry or the description of particulate organic materials. 
+PISCES-v2, by setting in namelist\_pisces\_ref  \np{ln\_p4z} to true,  can be seen as one of the many Monod models \citep{monod_1958}. It assumes a constant Redfield ratio and phytoplankton growth depends on the external concentration in nutrients. There are twenty-four prognostic variables (tracers) including two phytoplankton compartments  (diatoms and nanophytoplankton), two zooplankton size-classes (microzooplankton and  mesozooplankton) and a description of the carbonate chemistry. Formulations in PISCES-v2 are based on a mixed Monod/Quota formalism: On one hand, stoichiometry of C/N/P is fixed and growth rate of phytoplankton is limited by the external availability in N, P and Si. On the other hand, the iron and silicium quotas are variable and growth rate of phytoplankton is limited by the internal availability in Fe. Various parameterizations can be activated in PISCES-v2, setting for instance the complexity of iron chemistry or the description of particulate organic materials.
 
 PISCES-QUOTA has been built on the PISCES-v2 model described in \citet{aumont_2015}. PISCES-QUOTA has thirty-nine prognostic compartments. Phytoplankton growth can be controlled by five modeled limiting nutrients: Nitrate and Ammonium, Phosphate, Silicate and Iron. Five living compartments are represented: Three phytoplankton size classes/groups corresponding to picophytoplankton, nanophytoplankton and diatoms, and two zooplankton size classes which are microzooplankton and mesozooplankton. For phytoplankton, the prognostic variables are the carbon, nitrogen, phosphorus,  iron, chlorophyll and silicon biomasses (the latter only for diatoms). This means that the N/C, P/C, Fe/C and Chl/C ratios of both phytoplankton groups as well as the Si/C ratio of diatoms are prognostically predicted  by the model. Zooplankton are assumed to be strictly homeostatic \citep[e.g.,][]{sterner_2003,woods_2013,meunier_2014}. As a consequence, the C/N/P/Fe ratios of these groups are maintained constant and are not allowed to vary. In PISCES, the Redfield ratios C/N/P are set to 122/16/1 \citep{takahashi_1985} and the -O/C ratio is set to 1.34 \citep{kortzinger_2001}. No silicified zooplankton is assumed. The bacterial pool is not yet explicitly modeled.
@@ -570,5 +570,5 @@
 There are three non-living compartments: Semi-labile dissolved organic matter, small sinking particles, and large sinking particles. As a consequence of the variable stoichiometric ratios of phytoplankton and of the stoichiometric regulation of zooplankton, elemental ratios in organic matter cannot be supposed constant anymore as that was the case in PISCES-v2. Indeed, the nitrogen, phosphorus, iron, silicon and calcite pools of the particles are now all explicitly modeled. The sinking speed of the particles is not altered by their content in calcite and biogenic silicate (''The ballast effect'', \citep{honjo_1996,armstrong_2001}). The latter particles are assumed to sink at the same speed as the large organic matter particles. All the non-living compartments experience aggregation due to turbulence and differential settling as well as Brownian coagulation for DOM.
 
- 
+
 \subsection{MY\_TRC interface for coupling external BGC models}
 \label{Mytrc}
@@ -597,5 +597,5 @@
 
 Coupling passive tracers offline with NEMO requires precomputed  physical fields from OGCM. Those fields are read from files and interpolated on-the-fly at each model time step
-At least the following dynamical parameters should be absolutely passed to the transport : ocean velocities, temperature, salinity, mixed layer depth and for ecosystem models like PISCES, sea ice concentration, short wave radiation at the ocean surface, wind speed (or at least, wind stress). 
+At least the following dynamical parameters should be absolutely passed to the transport : ocean velocities, temperature, salinity, mixed layer depth and for ecosystem models like PISCES, sea ice concentration, short wave radiation at the ocean surface, wind speed (or at least, wind stress).
 The so-called offline mode is useful since it has lower computational costs for example to perform very longer simulations - about 3000 years - to reach equilibrium of CO2 sinks for climate-carbon studies.
 
@@ -603,5 +603,5 @@
 
 \begin{itemize}
-   \item \textit{dtadyn.F90} :  this module allows to read and compute the dynamical fields at each model time-step 
+   \item \textit{dtadyn.F90} :  this module allows to read and compute the dynamical fields at each model time-step
    \item \textit{nemogcm.F90} :  a degraded version of the main nemogcm.F90 code of NEMO to manage the time-stepping
 \end{itemize}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/model_setup.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/model_setup.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/model_setup.tex	(revision 12143)
@@ -1,3 +1,3 @@
-\documentclass[../../NEMO/main/NEMO_manual]{subfiles}
+\documentclass[../main/TOP_manual]{subfiles}
 
 \begin{document}
@@ -10,5 +10,5 @@
 %-------------------------------------------------------------------------------------------------------------
 
-The usage of TOP is activated 
+The usage of TOP is activated
 
 \begin{itemize}
@@ -19,5 +19,5 @@
 As an example, the user can refer to already available configurations in the code, GYRE\_PISCES being the NEMO biogeochemical demonstrator and GYRE\_BFM to see the required configuration elements to couple with an external biogeochemical model (see also section \S\ref{SMS_models}) .
 
-Note that, since version 4.0, TOP interface core functionalities are activated by means of logical keys and all submodules preprocessing macros from previous versions were removed. 
+Note that, since version 4.0, TOP interface core functionalities are activated by means of logical keys and all submodules preprocessing macros from previous versions were removed.
 
 There are only three specific keys remaining in TOP
@@ -28,5 +28,5 @@
 \end{itemize}
 
-For a remind, the revisited structure of TOP interface now counts for five different modules handled in namelist\_top : 
+For a remind, the revisited structure of TOP interface now counts for five different modules handled in namelist\_top :
 
 \begin{itemize}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/modules.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/modules.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/modules.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/modules.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/parameters.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/parameters.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/parameters.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/parameters.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/subroutines.idx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/subroutines.idx	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/TOP/subfiles/subroutines.idx	(revision 12143)
@@ -0,0 +1,1 @@
+link ../build/subroutines.idx
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/ametsoc.bst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/ametsoc.bst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/ametsoc.bst	(revision 12143)
@@ -9,5 +9,5 @@
 %% *** Bibliography style file for ALL AMS Journals...version 1.0  ***
 %% *** Brian Papa - American Meteorological Society ***
-%% 
+%%
 %% Copyright 1994-2004 Patrick W Daly
  % ===============================================================
@@ -519,5 +519,5 @@
   duplicate$ empty$ 'skip$
     {
-      "\href{http://dx.doi.org/" swap$ * "}{DOI}" *
+      "\href{http://dx.doi.org/" swap$ * "}{\aiDoi}" *
     }
   if$
@@ -1192,5 +1192,5 @@
   crossref missing$
     { format.in.ed.booktitle "booktitle" output.check
-      format.publisher.address output      
+      format.publisher.address output
       format.bvolume output
       format.number.series output
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/annex_D.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/annex_D.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/annex_D.tex	(revision 12143)
@@ -31,5 +31,5 @@
 - flexible.
 
-To satisfy part of these aims, \NEMO is written with a coding standard which is close to the ECMWF rules,
+To satisfy part of these aims, \NEMO\ is written with a coding standard which is close to the ECMWF rules,
 named DOCTOR \citep{gibson_rpt86}. 
 These rules present some advantages like:
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/coding_rules.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/coding_rules.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/coding_rules.tex	(revision 12143)
@@ -1,54 +1,7 @@
-%\documentclass{article}
-
-%\usepackage{fancyhdr}
-%\usepackage{times}
-%\usepackage{graphicx}
-%\usepackage{hyperref}
-%\usepackage{minted}
-%\usepackage[normalem]{ulem}   % striketrough style with \sout{...}
-
-%\hypersetup{pdftitle={NEMO coding conventions}, pdfauthor={NEMO System Team}, colorlinks}
-%\setminted{style=emacs, breaklines, frame=leftline}
-%\newmintinline[forcode]{fortran}{fontsize=auto, frame=lines}   % \forcode{...}
-%\newminted[forlines]{fortran}{}                                % \begin{forlines}
-
-%\pagestyle{empty}
-%\setlength{\leftmargin}{1 cm}
-%\setlength{\rightmargin}{1 cm}
-%\setlength{\oddsidemargin}{0 cm}
-%\setlength{\evensidemargin}{0 cm}
-%\setlength{\topmargin}{-1cm}
-%\setlength{\textwidth}{16 cm}
-%\setlength{\textheight}{25cm}
-%\pagestyle{fancy}
-
-%\title{
-%  \includegraphics[width=0.3\textwidth]{../../../figures/NEMO_grey} \\
-%  \vspace{1.0cm} \rule{345pt}{1.5pt} \\
-%  \vspace{0.45cm} {\Huge NEMO coding conventions} \rule{345pt}{1.5pt} \\
-%}
-%\title{NEMO coding conventions}
-%\author{\Large NEMO System Team
-%  \thanks{
-%    To be completed
-%  }
-%}
-%\date{version X.X -- month year}
-
-%\begin{document}
-
-%\maketitle
-
-%\newpage
-
-%\tableofcontents
-
-%\newpage
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 \chapter{Coding Rules}
-\label{apdx:coding}
-
-\minitoc
+\label{apdx:CODING}
+
+\chaptertoc
 
 \newpage
@@ -61,24 +14,21 @@
 Therefore, it is essential that the model development follows some rules:
 
-- well planned and designed
-
-- well written
-
-- well documented (both on- and off-line)
-
-- maintainable
-
-- easily portable
-
-- flexible.
-
-To satisfy part of these aims, \NEMO is written with a coding standard which is close to the ECMWF rules,
-named DOCTOR \citep{gibson_rpt86}. 
+\begin{itemize}
+\item well planned and designed
+\item well written
+\item well documented (both on- and off-line)
+\item maintainable
+\item easily portable
+\item flexible.
+\end{itemize}
+
+To satisfy part of these aims, \NEMO\ is written with a coding standard which is close to the ECMWF rules,
+named DOCTOR \citep{gibson_rpt86}.
 These rules present some advantages like:
 
-- to provide a well presented program
-
-- to use rules for variable names which allow recognition of their type
-(integer, real, parameter, local or shared variables, etc. ). 
+\begin{itemize}
+\item to provide a well presented program
+\item to use rules for variable names which allow recognition of their type 	(integer, real, parameter, local or shared variables, etc. ).
+\end{itemize}
 
 This facilitates both the understanding and the debugging of an algorithm.
@@ -86,8 +36,8 @@
 \section{Introduction}
 
-This document describes conventions\index{conventions} used in NEMO coding and suggested for its development.
-The objectives are to offer a guide to all readers of the NEMO code, and to facilitate the work of
+This document describes conventions used in \NEMO\ coding and suggested for its development.
+The objectives are to offer a guide to all readers of the \NEMO\ code, and to facilitate the work of
 all the developers, including the validation of their developments, and
-eventually the implementation of these developments within the NEMO platform.
+eventually the implementation of these developments within the \NEMO\ platform.
 
 A first approach of these rules can be found in the code in \path{./src/OCE/module_example} where
@@ -96,23 +46,19 @@
 
 This work is based on the coding conventions in use for the Community Climate System Model
-\footnote {\href{http://www.cesm.ucar.edu/working_groups/Software/dev_guide/dev_guide/node7.html}{UCAR conventions}}, 
+\footnote {\href{http://www.cesm.ucar.edu/working_groups/Software/dev_guide/dev_guide/node7.html}{UCAR conventions}},
 the previous version of this document (``FORTRAN coding standard in the OPA System'') and
-the expertise of the NEMO System Team.
+the expertise of the \NEMO\ System Team.
 After a general overview below, this document will describe:
 
 \begin{itemize}
-\item
-  The style rules, $i.e.$ the syntax, appearance and naming conventions chosen to improve readability of the code;
-\item
-  The content rules, $i.e.$ the conventions to improve the reliability of the different parts of the code;
-\item
-  The package rules to go a step further by improving the reliability of the whole and
-  interfaces between routines and modules.
+\item The style rules, $i.e.$ the syntax, appearance and naming conventions chosen to improve readability of the code;
+\item The content rules, $i.e.$ the conventions to improve the reliability of the different parts of the code;
+\item The package rules to go a step further by improving the reliability of the whole and
+	interfaces between routines and modules.
 \end{itemize}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \section{Overview and general conventions}
 
-NEMO has 3 major components: ocean dynamics (\path{./src/OCE}), sea-ice (\path{./src/ICE}) and
+\NEMO\ has 3 major components: ocean dynamics (\path{./src/OCE}), sea-ice (\path{./src/ICE}) and
 marine biogeochemistry (\path{./src/MBG}).
 %, linear-tangent and adjoint of the dynamics ($TAM$) each of them corresponding to a directory.
@@ -126,11 +72,10 @@
 See \path{.src/OCE/DOM/phycst.F90} files for conversions.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \section{Architecture}
 
-Within each directory, organisation of files is driven by orthogonality\index{orthogonality},
+Within each directory, organisation of files is driven by orthogonality,
 $i.e.$ one functionality of the code is intended to be in one and only one directory, and
 one module and all its related routines are in one file.
-The functional modules\index{module} are:
+The functional modules are:
 
 \begin{itemize}
@@ -138,5 +83,5 @@
 \item \path{IOM}             management of the I/O
 \item \path{NST}             interface to AGRIF (nesting model) for dynamics and biogeochemistry
-\item \path{OBC}, \path{BDY} management of structured and unstructured open boundaries 
+\item \path{OBC}, \path{BDY} management of structured and unstructured open boundaries
 \item \path{C1D}             1D (vertical) configuration for dynamics, sea-ice and biogeochemistry
 \item \path{OFF}             off-line module: passive tracer or biogeochemistry alone
@@ -147,11 +92,9 @@
 this module (\texttt{dom\_init, dom\_nam, dom\_ctl}).
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \section{Style rules}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Argument list format}
 
-Routine argument lists will contain a maximum 5 variables\index{variable} per line,
+Routine argument lists will contain a maximum 5 variables per line,
 whilst continuation lines can be used.
 This applies both to the calling routine and the dummy argument list in the routine being called.
@@ -164,5 +107,4 @@
 \end{forlines}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Array syntax}
 
@@ -198,11 +140,9 @@
 \end{forlines}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Case}
 
 All FORTRAN keywords are in capital: \forcode{DIMENSION}, \forcode{WRITE}, \forcode{DO}, \forcode{END DO},
-\forcode{NAMELIST}, ... All other parts of the NEMO code will be written in lower case.
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\forcode{NAMELIST}, ... All other parts of the \NEMO\ code will be written in lower case.
+
 \subsection{Comments}
 
@@ -248,5 +188,4 @@
 \end{enumerate}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Continuation lines}
 
@@ -265,5 +204,4 @@
 use a ``\&'' as first character of the continuing lines to maintain the alignment.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Declaration of arguments and local variables}
 
@@ -277,12 +215,9 @@
 \end{forlines}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{F90 Standard}
 
-NEMO software adheres to the FORTRAN 95 language standard and does not rely on any specific language or
+\NEMO\ software adheres to the \fninety language standard and does not rely on any specific language or
 vendor extensions.
 
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Free-Form Source}
 
@@ -292,5 +227,4 @@
 Multi-line comments that extend to column 100 are unacceptable.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Indentation}
 
@@ -310,5 +244,4 @@
 \end{forlines}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Loops}
 
@@ -317,5 +250,4 @@
 In the case of a long loop, a self-descriptive label can be used ($i.e.$ not just a number).
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Naming Conventions: files}
 
@@ -331,5 +263,4 @@
 }
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Naming Conventions: modules}
 
@@ -338,15 +269,14 @@
 For example, zdftke, where ``zdf'' stands for vertical diffusion, and ``tke'' for turbulent kinetic energy. \\
 Note that by implication multiple modules are not allowed in a single file.
-The use of common blocks is deprecated in Fortran 90 and their use in NEMO is strongly discouraged.
+The use of common blocks is deprecated in \fortran 90 and their use in \NEMO\ is strongly discouraged.
 Modules are a better way to declare static data.
 Among the advantages of modules is the ability to freely mix data of various types, and
 to limit access to contained variables through the use of the \forcode{ONLY} and \forcode{PRIVATE} attributes.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Naming Conventions: variables}
 
 All variable should be named as explicitly as possible in English.
 The naming convention concerns prefix letters of these name, in order to identify the variable type and status. \\
-Never use a FORTRAN keyword as a routine or variable name. \\
+Never use a \fortran keyword as a routine or variable name. \\
 The table below lists the starting letter(s) to be used for variable naming, depending on their type and status:
 %--------------------------------------------------TABLE--------------------------------------------------
@@ -355,19 +285,67 @@
     \begin{tabular}{|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|}
       \hline
-      Type \par / Status &   integer&   real&   logical &   character&   double \par precision&   complex \\
+      Type \par / Status                                                                          &
+      integer                                                                                     &
+      real                                                                                        &
+      logical                                                                                     &
+      character                                                                                   &
+      double \par precision                                                                       &
+      complex                                                                                     \\
       \hline
-      public  \par or  \par module variable& \textbf{m n} \par \textit{but not } \par \textbf{nn\_}& \textbf{a b e f g h o} \textbf{q} \textit{to} \textbf{x} \par but not \par \textbf{fs rn\_}& \textbf{l} \par \textit{but not} \par \textbf{lp ld ll ln\_}& \textbf{c} \par \textit{but not} \par \textbf{cp cd cl cn\_}& \textbf{d} \par \textit{but not} \par \textbf{dp dd dl dn\_}& \textbf{y} \par \textit{but not} \par \textbf{yp yd yl} \\
+      public \par or \par module variable                                                         &
+      \textbf{m n} \par \textit{but not} \par \textbf{nn\_}                                       &
+      \textbf{a b e f g h o} \textbf{q} \textit{to} \textbf{x} \par but not \par \textbf{fs rn\_} &
+      \textbf{l} \par \textit{but not} \par \textbf{lp ld ll ln\_}                                &
+      \textbf{c} \par \textit{but not} \par \textbf{cp cd cl cn\_}                                &
+      \textbf{d} \par \textit{but not} \par \textbf{dp dd dl dn\_}                                &
+      \textbf{y} \par \textit{but not} \par \textbf{yp yd yl}                                     \\
       \hline
-      dummy \par argument& \textbf{k} \par \textit{but not} \par \textbf{kf}& \textbf{p} \par \textit{but not}  \par \textbf{pp pf}& \textbf{ld}& \textbf{cd}& \textbf{dd}& \textbf{yd} \\
+      dummy \par argument                                                                         &
+      \textbf{k} \par \textit{but not} \par \textbf{kf}                                           &
+      \textbf{p} \par \textit{but not} \par \textbf{pp pf}                                        &
+      \textbf{ld}                                                                                 &
+      \textbf{cd}                                                                                 &
+      \textbf{dd}                                                                                 &
+      \textbf{yd}                                                                                 \\
       \hline
-      local \par variable& \textbf{i}& \textbf{z}& \textbf{ll}& \textbf{cl}& \textbf{cd}& \textbf{yl} \\
+      local \par variable                                                                         &
+      \textbf{i}                                                                                  &
+      \textbf{z}                                                                                  &
+      \textbf{ll}                                                                                 &
+      \textbf{cl}                                                                                 &
+      \textbf{cd}                                                                                 &
+      \textbf{yl}                                                                                 \\
       \hline
-      loop \par control& \textbf{j} \par \textit{but not } \par \textbf{jp}& & & & &  \\
+      loop \par control                                                                           &
+      \textbf{j} \par \textit{but not} \par \textbf{jp}                                           &
+                                                                                                  &
+                                                                                                  &
+                                                                                                  &
+                                                                                                  &
+                                                                                                  \\
       \hline
-      parameter& \textbf{jp}& \textbf{pp}& \textbf{lp}& \textbf{cp}& \textbf{dp}& \textbf{yp} \\
+      parameter                                                                                   &
+      \textbf{jp}                                                                                 &
+      \textbf{pp}                                                                                 &
+      \textbf{lp}                                                                                 &
+      \textbf{cp}                                                                                 &
+      \textbf{dp}                                                                                 &
+      \textbf{yp}                                                                                 \\
       \hline
-      namelist& \textbf{nn\_}& \textbf{rn\_}& \textbf{ln\_}& \textbf{cn\_}& \textbf{dn\_}& \\
+      namelist                                                                                    &
+      \textbf{nn\_}                                                                               &
+      \textbf{rn\_}                                                                               &
+      \textbf{ln\_}                                                                               &
+      \textbf{cn\_}                                                                               &
+      \textbf{dn\_}                                                                               &
+                                                                                                  \\
       \hline
-      CPP \par macro& \textbf{kf}& \textbf{sf} \par & & & & \\
+      CPP \par macro                                                                              &
+      \textbf{kf}                                                                                 &
+      \textbf{sf}                                                                                 &
+                                                                                                  &
+                                                                                                  &
+                                                                                                  &
+                                                                                                  \\
       \hline
     \end{tabular}
@@ -377,5 +355,4 @@
 %--------------------------------------------------------------------------------------------------------------
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Operators}
 
@@ -385,5 +362,5 @@
 In general use the notation: \\
 $<Blank><Operator><Blank>$
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 \subsection{Pre processor}
 
@@ -412,5 +389,5 @@
 Is to be used rather than the \#ifdef abbreviate form since it may have conflicts with some Unix scripts.
 
-Tests on cpp keys included in NEMO at compilation step:
+Tests on cpp keys included in \NEMO\ at compilation step:
 
 \begin{itemize}
@@ -421,12 +398,11 @@
   If a change occurs in the CPP keys used for a given experiment, the whole compilation phase is done again.
 \end{itemize}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 \section{Content rules}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Configurations}
 
-The configuration defines the domain and the grid on which NEMO is running.
-It may be useful to associate a cpp key and some variables to a given configuration, although
+The configuration defines the domain and the grid on which \NEMO\ is running.
+It may be useful to associate a CPP key and some variables to a given configuration, although
 the part of the code changed under each of those keys should be minimized.
 As an example, the "ORCA2" configuration (global ocean, 2 degrees grid size) is associated with
@@ -438,10 +414,9 @@
 \end{forlines}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Constants}
 
-Physical constants ($e.g.$ $\pi$, gas constants) must never be hardwired into the executable portion of a code.
+Physical constants ($e.g.$ $\pi$, gas constants) must never be hard-wired into the executable portion of a code.
 Instead, a mnemonically named variable or parameter should be set to the appropriate value,
-in the setup routine for the package\index{package}.
+in the setup routine for the package.
 We realize than many parameterizations rely on empirically derived constants or fudge factors,
 which are not easy to name.
@@ -450,5 +425,4 @@
 Hard-coded numbers should never be passed through argument lists.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Declaration for variables and constants}
 
@@ -512,13 +486,11 @@
 improve control of variables in routine calls.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Headers}
 
-Prologues are not used in NEMO for now, although it may become an interesting tool in combination with
+Prologues are not used in \NEMO\ for now, although it may become an interesting tool in combination with
 ProTeX auto documentation script in the future.
 Rules to code the headers and layout of a module or a routine are illustrated in the example module available with
 the code: \path{./src/OCE/module_example}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Interface blocks}
 
@@ -528,5 +500,4 @@
 FORTRAN 95 compilers can automatically provide explicit interface blocks for routines contained in a module.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{I/O Error Conditions}
 
@@ -536,5 +507,4 @@
 a negative value means the end of record or end of file was encountered.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{PRINT - ASCII output files}
 
@@ -551,5 +521,4 @@
 \end{forlines}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Precision}
 
@@ -570,8 +539,7 @@
 \end{forlines}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Structures}
 
-The \forcode{TYPE} structure allowing to declare some variables is more often used in NEMO,
+The \forcode{TYPE} structure allowing to declare some variables is more often used in \NEMO,
 especially in the modules dealing with reading fields, or interfaces.
 For example:
@@ -592,11 +560,9 @@
 Missing rule on structure name??
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \section{Packages coding rules}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Bounds checking}
 
-NEMO is able to run when an array bounds checking option is enabled
+\NEMO\ is able to run when an array bounds checking option is enabled
 (provided the cpp key \texttt{key\_vectopt\_loop} is not defined). \\
 Thus, constructs of the following form are disallowed:
@@ -610,5 +576,4 @@
 it effectively disables array bounds checking.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Communication}
 
@@ -624,5 +589,4 @@
 }
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Error conditions}
 
@@ -634,9 +598,8 @@
 see \textit{stpctl.F90}.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Memory management}
 
 The main action is to identify and declare which arrays are \forcode{PUBLIC} and which are \forcode{PRIVATE}. \\
-As of version 3.3.1 of NEMO, the use of static arrays (size fixed at compile time) has been deprecated.
+As of version 3.3.1 of \NEMO, the use of static arrays (size fixed at compile time) has been deprecated.
 All module arrays are now declared \forcode{ALLOCATABLE} and
 allocated in either the \texttt{<module\_name>\_alloc()} or \texttt{<module\_name>\_init()} routines.
@@ -644,7 +607,7 @@
 the \texttt{stat=<integer\ variable>} optional argument. \\
 
-In addition to arrays contained within modules, many routines in NEMO require local, ``workspace'' arrays to
+In addition to arrays contained within modules, many routines in \NEMO\ require local, ``workspace'' arrays to
 hold the intermediate results of calculations.
-In previous versions of NEMO, these arrays were declared in such a way as to be automatically allocated on
+In previous versions of \NEMO, these arrays were declared in such a way as to be automatically allocated on
 the stack when the routine was called.
 An example of an automatic array is:
@@ -735,5 +698,5 @@
 It is then associated with a sub-array of \texttt{wrk\_3d\_5} once the call to
 \texttt{wrk\_in\_use()} has completed successfully.
-Note that in F95 (to which NEMO conforms) it is not possible for either the upper or lower array bounds of
+Note that in F95 (to which \NEMO\ conforms) it is not possible for either the upper or lower array bounds of
 the pointer object to differ from those of the target array. \\
 
@@ -748,19 +711,17 @@
 This should enable the developer to choose alternatives for use in the subroutine being worked on. \\
 
-When compiling NEMO for production runs,
+When compiling \NEMO\ for production runs,
 the calls to {\texttt{wrk\_in\_use()} / \texttt{wrk\_not\_released()} can be reduced to stubs that just
 return \forcode{.false.} by setting the cpp key \texttt{key\_no\_workspace\_check}.
-These stubs may then be inlined (and thus effectively removed altogether) by setting appropriate compiler flags
+These stubs may then be in-lined (and thus effectively removed altogether) by setting appropriate compiler flags
 ($e.g.$ ``-finline'' for the Intel compiler or ``-Q'' for the IBM compiler).
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Optimisation}
 
 Considering the new computer architecture, optimisation cannot be considered independently from the computer type.
-In NEMO, portability is a priority, before any too specific optimisation.
+In \NEMO, portability is a priority, before any too specific optimisation.
 
 Some tools are available to help: for vector computers, \texttt{key\_vectopt\_loop} allows to unroll a loop
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \subsection{Package attribute: \forcode{PRIVATE}, \forcode{PUBLIC}, \forcode{USE}, \forcode{ONLY}}
 
@@ -770,17 +731,15 @@
 defined in a module are to be made available to the using routine.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\subsection {Parallelism using MPI}
-
-NEMO is written in order to be able to run on one processor, or on one or more using MPI
+\subsection{Parallelism using MPI}
+
+\NEMO\ is written in order to be able to run on one processor, or on one or more using MPI
 ($i.e.$ activating the cpp key $key\_mpp\_mpi$).
-The domain decomposition divides the global domain in cubes (see NEMO reference manual).
+The domain decomposition divides the global domain in cubes (see \NEMO\ reference manual).
 Whilst coding a new development, the MPI compatibility has to be taken in account
 (see \path{./src/LBC/lib_mpp.F90}) and should be tested.
 By default, the $x$-$z$ part of the decomposition is chosen to be as square as possible.
-However, this may be overriden by specifying the number of subdomains in latitude and longitude in
+However, this may be overriden by specifying the number of sub-domains in latitude and longitude in
 the \texttt{nammpp} section of the namelist file.
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \section{Features to be avoided}
 
@@ -790,38 +749,26 @@
 Below is a list of features to avoid:
 \begin{itemize}
-\item
-  \forcode{COMMON} block
+\item \forcode{COMMON} block
   (use the declaration part of \forcode{MODULE} instead)
-\item
-  \forcode{EQUIVALENCE}
+\item \forcode{EQUIVALENCE}
   (use \forcode{POINTER} or derived data type instead to form data structure)
-\item
-  Assigned and computed \forcode{GOTO}
+\item Assigned and computed \forcode{GOTO}
   (use the \forcode{CASE} construct instead)
-\item
-  Arithmetic \forcode{IF} statement
+\item Arithmetic \forcode{IF} statement
   (use the block \forcode{IF}, \forcode{ELSE}, \forcode{ELSEIF}, \forcode{ENDIF} or
   \forcode{SELECT CASE} construct instead)
-\item
-  Labeled \forcode{DO} construct
-  (use unlabeled \forcode{END DO} instead)
-\item
-  \forcode{FORMAT} statement
+\item Labelled \forcode{DO} construct
+  (use unlabelled \forcode{END DO} instead)
+\item \forcode{FORMAT} statement
   (use character parameters or
   explicit format- specifiers inside the \forcode{READ} or \forcode{WRITE} statement instead)
-\item
-  \forcode{GOTO} and \forcode{CONTINUE} statements
+\item \forcode{GOTO} and \forcode{CONTINUE} statements
   (use \forcode{IF}, \forcode{CASE}, \forcode{DO WHILE}, \forcode{EXIT} or \forcode{CYCLE} statements or
   a contained ?)
-\item
-  \forcode{PAUSE}
-\item
-  \forcode{ENTRY} statement: a subprogram must only have one entry point.
-\item
-  \forcode{RETURN} is obsolete and so not necessary at the end of program units
-\item
-  \forcode{FUNCTION} statement
-\item
-  Avoid functions with side effects.
+\item \forcode{PAUSE}
+\item \forcode{ENTRY} statement: a sub-program must only have one entry point.
+\item \forcode{RETURN} is obsolete and so not necessary at the end of program units
+\item \forcode{FUNCTION} statement
+\item Avoid functions with side effects.
   \footnote{
     First, the code is easier to understand, if you can rely on
@@ -832,13 +779,66 @@
     This is especially important on massive parallel and as well on vector machines.
   }
-\item
-  \forcode{DATA} and \forcode{BLOCK DATA}
+\item \forcode{DATA} and \forcode{BLOCK DATA}
   (use initialisers)
 \end{itemize}
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-% \printindex
-% \input NEMO_coding.conv.ind
-
-%\end{document}
+%% Imported from introduction
+%%gm    To be put somewhere else ....
+%%nm    We should consider creating a glossary for all this kind of stuff (terms, acronyms and symbols)
+%%      http://en.wikibooks.org/wiki/LaTeX/Glossary
+%\noindent CPP keys and namelists are used as inputs to the code.
+
+%\noindent \index{CPP keys} CPP keys
+
+%Some CPP keys are implemented in the \fortran code to allow code selection at compiling step.
+%This selection of code at compilation time reduces the reliability of the whole platform since
+%it changes the code from one set of CPP keys to the other.
+%It is used only when the addition/suppression of the part of code highly changes the amount of memory at run time.
+%Usual coding looks like:
+
+%\begin{forlines}
+%#if defined key_option1
+%	! This part of the \fortran code will be active
+%	! only if key_option1 is activated at compiling step
+%#endif
+%\end{forlines}
+
+%\noindent \index{Namelist} Namelists
+
+%The namelist allows to input variables (character, logical, real and integer) into the code.
+%There is one namelist file for each component of \NEMO\ (dynamics, sea-ice, biogeochemistry...)
+%containing all the \fortran namelists needed.
+%The implementation in \NEMO\ uses a 2-step process.
+%For each \fortran namelist, two files are read:
+
+%\begin{enumerate}
+%\item
+%  A reference namelist (in \path{./cfgs/SHARED/namelist_ref}) is read first.
+%  This file contains all the namelist variables which are initialised to default values
+%\item
+%  A configuration namelist (in \path{./cfgs/CFG_NAME/EXP00/namelist_cfg}) is read aferwards.
+%  This file contains only the namelist variables which are changed from default values, and overwrites those.
+%\end{enumerate}
+%A template can be found in \path{NEMO/OPA_SRC/module.example}.
+%The effective namelist, taken in account during the run, is stored at execution time in
+%an \texttt{output\_namelist\_dyn} (or \texttt{\_ice} or \texttt{\_top}) file.
+%%gm  end
+
+%%nm: Add some words on the \NEMO\ dependencies
+%The model is implemented in \fninety, with preprocessing (C pre-processor).
+%It runs under UNIX.
+%It is optimized for vector computers and parallelised by domain decomposition with MPI.
+%All input and output is done in NetCDF (Network Common Data Format) with a optional direct access format for output.
+%To ensure the clarity and readability of the code it is necessary to follow coding rules.
+%The coding rules for OPA include conventions for naming variables,
+%with different starting letters for different types of variables (real, integer, parameter\ldots).
+%Those rules are briefly presented in \autoref{apdx:coding} and a more complete document is available .
+
+%The model is organized with a high internal modularity based on physics.
+%For example, each trend (\ie, a term in the RHS of the prognostic equation) for momentum and tracers
+%is computed in a dedicated module.
+%To make it easier for the user to find his way around the code, the module names follow a three-letter rule.
+%For example, \mdl{traldf} is a module related to the TRAcers equation, computing the Lateral DiFfussion.
+%The complete list of module names is presented in \autoref{apdx:coding}.      %====>>>> to be done !
+%Furthermore, modules are organized in a few directories that correspond to their category,
+%as indicated by the first three letters of their name (\autoref{tab:chapters}).
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/document.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/document.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/document.tex	(revision 12143)
@@ -1,76 +1,68 @@
 
-%% ==============================================================================
-%% Template structure for reference manual
-%% ==============================================================================
+%% =================================================================================================
+%% Template structure for reference manuals
+%% =================================================================================================
 
 %% NEMO release version
-\def \version{4.0rc~}
+\def \version{trunk}
 
 %% Preamble
-%% ==============================================================================
+%% =================================================================================================
 
 %% Document layout
-\documentclass[draft]{scrreprt}
+\documentclass[fontsize = 10pt, twoside, abstract]{scrreprt}
 
-%% Load the configuration of the manual
-\input{../main/definitions}
-
-%% Load global *.tex files
-\input{../../global/preamble}
-
-\dominitoc
-
-%% Launch the creation of the indexes
-\input{../../global/indexes}
-
+%% Load manual configuration
+\input{../../global/prologue}
 
 %% End of common preamble between main and sub-files
 %% Override custom cmds for full manual compilation
-\newcommand{\onlyinsubfile}[1]{#1}
-\newcommand{\notinsubfile}[1]{}
+\newcommand{\subinc}[1]{#1}
+\newcommand{\subexc}[1]{}
 
 \begin{document}
 
-\renewcommand{\onlyinsubfile}[1]{}
-\renewcommand{\notinsubfile}[1]{#1}
-
-\renewcommand{\biblio}{}
-\renewcommand{\pindex}{}
+\renewcommand{\subinc}[1]{}
+\renewcommand{\subexc}[1]{#1}
 
 
 %% Frontmatter
-%% ==============================================================================
+%% =================================================================================================
 
-\pagenumbering{gobble}
+\pagenumbering{gobble}   %% Disable page numbering temporarily
 
 %% Title page
 \input{../../global/frontpage}
 
-\maketitle
-\emptythanks
+%% Footer for introductory parts (no header by cleaning default)
+\ofoot[]{\engine\ Reference Manual} \ifoot[]{\pagemark}
 
 %% Information page (2nd page)
 \input{../../global/info_page}
 
-%% Foreword
-%\frontmatter   %% Chapter numbering off and Roman numerals for page numbers
+\listoffigures
+\listoflistings
+\listoftables
+
+\clearpage
+
 \pagenumbering{roman}
-\input{foreword}
+\ofoot[]{\engine\ Reference Manual} \ifoot[]{\pagemark}
+
+\input{introduction}
 
 %% Table of Contents
 \tableofcontents
-\listoffigures
-\listoftables
-\listoflistings
 
 \clearpage
-%\end{document}
 
 
 %% Mainmatter
-%% ==============================================================================
+%% =================================================================================================
 
-%\mainmatter   %% Chapter numbering on, page numbering is reset with Arabic numerals
+%% Headings for document body
 \pagenumbering{arabic}
+\lohead{Chap.\ \thechapter\ \leftmark} \rehead{Sect.\ \thesection\ \rightmark}
+\ifoot[]{Page\ \pagemark\ of \pageref*{LastPage}}
 
 \include{chapters}
@@ -78,9 +70,8 @@
 
 %% Appendix
-%% ==============================================================================
+%% =================================================================================================
 
-%% Chapter numbering is reset with letters now
-\appendix   
-
+\appendix   %% Chapter numbering with letters by now
+\lohead{Apdx\ \thechapter\ \leftmark}
 \include{appendices}
 
@@ -90,23 +81,8 @@
 
 %% Backmatter
-%% ==============================================================================
+%% =================================================================================================
 
-%\backmatter   %% Chapter numbering off
-
-%% Bibliography
-\phantomsection
-\addcontentsline{toc}{chapter}{Bibliography}
-\bibliography{../main/bibliography}
-
-%% Index
-\clearpage
-\phantomsection
-\addcontentsline{toc}{chapter}{Indexes}
-\printindex[keys]
-\printindex[modules]
-\printindex[blocks]
-\printindex[parameters]
-\printindex[subroutines]
+%% Bibliography and indexes
+\input{../../global/epilogue}
 
 \end{document}
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/epilogue.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/epilogue.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/epilogue.tex	(revision 12143)
@@ -0,0 +1,20 @@
+
+\clearpage
+
+%% Bibliography
+\phantomsection
+\addcontentsline{toc}{chapter}{Bibliography}
+\lohead{Bibliography} \rehead{Bibliography}
+\bibliography{../main/bibliography}
+
+\clearpage
+
+%% Indexes
+\phantomsection
+\addcontentsline{toc}{chapter}{Indexes}
+\lohead{Indexes} \rehead{Indexes}
+\printindex[blocks]
+\printindex[keys]
+\printindex[modules]
+\printindex[parameters]
+\printindex[subroutines]
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/frontpage.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/frontpage.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/frontpage.tex	(revision 12143)
@@ -1,49 +1,67 @@
 
-\title{\heading}
-\author{\firstauthor \and \secondauthor\thanks{\protect\input{thanks}}}
-\date{\today}
+\begin{titlepage}
+%  \newgeometry{hmargin = 1.5cm, vmargin = 3cm}
+  \setlength{\parindent}{0pt}
 
-\pretitle{
   \begin{center}
-\begin{figure}[H]
-  \begin{minipage}[c]{0.35\textwidth}
-    \href{http://www.nemo-ocean.eu}{\includegraphics[width=0.7\textwidth]{logos/NEMO_grey}}
+    \begin{minipage}{0.3\textwidth}
+      \includegraphics[height=1.5cm]{logos/NEMO_grey}
+    \end{minipage}\begin{minipage}{0.6\textwidth}
+      \begin{center}
+      \Large\slshape
+      \textbf{N}ucleus for \textbf{E}uropean \textbf{M}odelling of the \textbf{O}cean \\
+      \medskip
+      \hyperref[resources]{\textcolor{black}{
+          \faWordpress \hspace{0.75cm} \faCodeFork      \hspace{0.75cm}
+          \faGithub    \hspace{0.75cm} \faCloudDownload \hspace{0.75cm} \faEnvelope
+        }
+      }
+      \end{center}
+    \end{minipage}
+  \end{center}
+
+  \spacetop
+  \textcolor{white}{\fontsize{0.8cm}{0.8cm}\selectfont\textbf{\heading}}
+  \ifdef{\subheading}{
+    \medskip
+    \par
+    \textcolor{white}{\Huge \subheading}
+  }{}
+  \spacedown
+
+  \begin{center}
+    \LARGE Version \version\ -\ \today \\
+    \medskip
+    \href{http://doi.org/10.5281/zenodo.\zid}{ \includegraphics{badges/zenodo.\zid} }
+  \end{center}
+
+  \vfill
+
+  \begin{minipage}{\authorswidth}
+    \raggedleft
+    \input{authors}
+  \end{minipage}\hspace{15pt}\begin{minipage}{0.02\linewidth}
+    \rule{1pt}{\rulelenght}
+  \end{minipage}\hspace{ 5pt}\begin{minipage}{\abstractwidth}
+    \begin{abstract}
+      \input{abstract}
+    \end{abstract}
   \end{minipage}
-  \hfill
-  \begin{minipage}[c]{0.65\textwidth}
-    \centering
-    \large{\em{{N}ucleus for {E}uropean {M}odelling of the {O}cean}}
-  \end{minipage}
-\end{figure}
-\vfill
-    \Huge
-}
-\posttitle{\par\end{center}\vskip 0.5em}
-\preauthor{\begin{center}\Large\lineskip0.5em\begin{tabular}[t]{c}}
-\postauthor{\end{tabular}\par\end{center}}
-\predate{
+
   \vfill
+
   \begin{center}
-    \large Version \version ---
-}
-\postdate{
-    \par~\\
-    \href{http://doi.org/10.5281/zenodo.\zid}{\includegraphics{{badges/zenodo.\zid}.pdf}}
+    \Large
+    \href{http://www.cmcc.it          }{ \includegraphics[height=1cm]{logos/CMCC} } \hspace{0.25cm}
+    \href{http://www.cnrs.fr          }{ \includegraphics[height=1cm]{logos/CNRS} } \hspace{0.25cm}
+    \href{http://www.mercator-ocean.fr}{ \includegraphics[height=1cm]{logos/MOI}  } \hspace{0.25cm}
+    \href{http://www.metoffice.gov.uk }{ \includegraphics[height=1cm]{logos/UKMO} } \hspace{0.25cm}
+    \href{http://nerc.ukri.org        }{ \includegraphics[height=1cm]{logos/NERC} } \\
+    \medskip
+    \slshape
+    {C}ommunity \hspace{1.5em} {O}cean \hspace{1.5em} {M}odel \\
   \end{center}
-  \vfill
-  \begin{center}
-    \href{http://www.cmcc.it}{          \includegraphics[height=0.055\textheight]{logos/CMCC}}
-    \hspace{0.5em}
-    \href{http://www.cnrs.fr}{          \includegraphics[height=0.055\textheight]{logos/CNRS}}
-    \hspace{0.9em}
-    \href{http://www.mercator-ocean.fr}{\includegraphics[height=0.055\textheight]{logos/MOI} }
-    \hspace{0.45em}
-    \href{http://www.metoffice.gov.uk}{ \includegraphics[height=0.055\textheight]{logos/UKMO}}
-    \hspace{0.5em}
-    \href{http://nerc.ukri.org}{        \includegraphics[height=0.055\textheight]{logos/NERC}} \\
-    \large{{\em{C}ommunity \hspace{1.5em} {O}cean \hspace{1.5em} {M}odel}}
-  \end{center}
-}
 
-\thanksmarkseries{fnsymbol}
+\end{titlepage}
 
+\restoregeometry
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/highlighting.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/highlighting.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/highlighting.tex	(revision 12143)
@@ -2,10 +2,10 @@
 %% ==============================================================================
 
-\usepackage[outputdir=../build]{minted}
+\usepackage[outputdir=../build, chapter, newfloat]{minted}
 
 %% Global highlighting style
 \definecolor{bg}{HTML}{f8f8f8}
 \usemintedstyle{emacs}
-\setminted{bgcolor=bg, fontsize=\scriptsize, breaklines, frame=leftline}
+\setminted{bgcolor=bg, fontsize=\scriptsize, breaklines}
 \setminted[xml]{style=borland} %% Specific per language
 
@@ -22,12 +22,11 @@
 
 %% File
-\newmintedfile[forfile]{fortran}{}   % \forfile{../namelists/nam...}
+\newmintedfile[forfile]{fortran}{}
 
 %% Inline
-\newmintinline[forcode]{fortran}{bgcolor=, fontsize=auto, frame=lines}   % \forcode{...}
-\newmintinline[xmlcode]{xml}{    bgcolor=, fontsize=auto, frame=lines}   % \xmlcode{...}
-\newmintinline[snippet]{console}{bgcolor=, fontsize=auto, frame=lines}   % \snippet{...}
+\newmintinline[forcode]{fortran}{bgcolor=, fontsize=auto}   % \forcode{...}
+\newmintinline[xmlcode]{xml}{    bgcolor=, fontsize=auto}   % \xmlcode{...}
+\newmintinline[snippet]{console}{bgcolor=, fontsize=auto}   % \snippet{...}
 
 %% Namelists inclusion
 \newcommand{\nlst}[1]{\forfile{../../../namelists/#1}}
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/index.ist
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/index.ist	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/index.ist	(revision 12143)
@@ -1,8 +1,4 @@
 headings_flag 1
-heading_prefix "{\\medskip\\hfill\\large\\textsf{\\textbf{"
-heading_suffix "}}\\hfill}\\medskip\\nopagebreak\n"
-
+heading_prefix "\\medskip\\hfill\\textnormal{"
+heading_suffix "}\\hfill\\smallskip\n"
 delim_0 "\\dotfill~"
-delim_1 "\\dotfill~"
-delim_2 "\\dotfill~"
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/index.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/index.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/index.tex	(revision 12143)
@@ -0,0 +1,25 @@
+
+\usepackage{imakeidx}
+
+%% Naming customization
+\renewcommand{\listingname}{namelist}
+\renewcommand{\listlistingname}{List of Namelists}
+
+%% Index entries (italic font for files, preformat for code)
+\newcommand{\hf}[1]{   \index{h90 files!#1}             \textit{#1.h90}          }
+\newcommand{\ifile}[1]{\index{Input NetCDF files!#1.nc} \textit{#1.nc}           }
+\newcommand{\jp}[1]{   \index{Model parameters!#1}      \texttt{#1}              }
+\newcommand{\key}[1]{  \index[keys]{#1@\texttt{\textbf{key\_#1}}} \texttt{\textbf{key\_#1}}}
+\newcommand{\mdl}[1]{  \index[modules]{#1@\textit{#1.F90}}        \textit{#1.F90}          }
+\newcommand{\nam}[2]{  \index[blocks]{#1@\texttt{\&nam#2}}        \forcode{&nam#1} (\autoref{lst:nam#1})}
+\newcommand{\np}[3][]{ \index[parameters]{#3@\texttt{#3}}         \forcode{#2#1}           }
+\newcommand{\rou}[1]{  \index[subroutines]{#1@\texttt{#1}}        \texttt{#1}              }
+
+
+\indexsetup{toclevel=section, othercode=\small}
+
+\makeindex[intoc=true, name=blocks     , title=Namelist blocks      , columns=3]
+\makeindex[intoc=true, name=keys       , title=CPP keys                        ]
+\makeindex[intoc=true, name=modules    , title=\fortran\ modules    , columns=3]
+\makeindex[intoc=true, name=parameters , title=Namelist parameters  , columns=3]
+\makeindex[intoc=true, name=subroutines, title=\fortran\ subroutines           ]
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/indexes.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/indexes.tex	(revision 12062)
+++ 	(revision )
@@ -1,32 +1,0 @@
-
-\usepackage{imakeidx}
-
-%% Index entries (italic font for files, preformat for code)
-\newcommand{\hf}[1]{\textit{#1.h90}   \index{h90 files!#1}}
-\newcommand{\ifile}[1]{\textit{#1.nc} \index{Input NetCDF files!#1.nc}}
-\newcommand{\jp}[1]{\texttt{#1}       \index{Model parameters!#1}}
-\newcommand{\key}[1]{\index[keys]{#1}        \texttt{\textbf{key\_#1}}}
-\newcommand{\mdl}[1]{\index[modules]{#1}     \textit{#1.F90}          }
-\newcommand{\ngn}[1]{\index[blocks]{#1}      \texttt{#1}              }
-\newcommand{\np}[1]{ \index[parameters]{#1}  \texttt{#1}              }
-\newcommand{\rou}[1]{\index[subroutines]{#1} \texttt{#1}              }
-
-\indexsetup{toclevel=section, othercode=\small}
-
-\makeindex[intoc=true, name=keys       , title=CPP keys                      ]
-\makeindex[intoc=true, name=modules    , title=Modules                       ]
-\makeindex[intoc=true, name=blocks     , title=Namelist blocks               ]
-\makeindex[intoc=true, name=parameters , title=Namelist parameters, columns=3]
-\makeindex[intoc=true, name=subroutines, title=Subroutines                   ]
-
-
-%% Load hyperref at the end of the preamble to make it work with other pkgs
-\usepackage{hyperref}                    %% hyper
-\hypersetup{
-%  pdftitle={\heading},
-%  pdfauthor={\firstauthor and \secondauthor},
-  colorlinks,
-  citecolor=olive,
-  linkcolor=blue,
-  urlcolor=gray
-}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/info_page.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/info_page.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/info_page.tex	(revision 12143)
@@ -2,14 +2,14 @@
 \thispagestyle{plain}
 
-% ================================================================
-% Disclaimer
-% ================================================================
+%% ================================================================
+%% Disclaimer
+%% ================================================================
 \subsubsection*{Disclaimer}
 
 Like all components of the modelling framework,
-the \engine~core engine is developed under the \href{http://www.cecill.info}{CECILL license},
-which is a French adaptation of the GNU GPL (General Public License).
+the \engine\ core engine is developed under the \href{http://www.cecill.info}{CECILL license},
+which is a French adaptation of the GNU GPL (\textbf{G}eneral \textbf{P}ublic \textbf{L}icense).
 Anyone may use it freely for research purposes, and is encouraged to
-communicate back to the NEMO team its own developments and improvements.
+communicate back to the development team its own developments and improvements.
 
 The model and the present document have been made available as a service to the community.
@@ -18,20 +18,24 @@
 Users are encouraged to bring them to our attention.
 
-The authors assume no responsibility for problems, errors, or incorrect usage of NEMO.
+The authors assume no responsibility for problems, errors, or incorrect usage of \NEMO.
 
-% ================================================================
-% External resources
-% ================================================================
+%% ================================================================
+%% External resources
+%% ================================================================
 \subsubsection*{Other resources}
+\label{resources}
 
 Additional information can be found on:
 \begin{itemize}
-\item the \href{http://www.nemo-ocean.eu}{website} of the project detailing several
+\item \faWordpress\ the \href{http://www.nemo-ocean.eu}{website} of the project detailing several
   associated applications and an exhaustive users bibliography
-\item the \href{http://forge.ipsl.jussieu.fr/nemo}{development platform} of the model with
-  the code repository and some main resources (wiki, ticket system, forums, \ldots)
-\item the \href{http://zenodo.org/communities/nemo-ocean}{online archive}
-  delivering the publications issued by the consortium
-\item two mailing lists:
+\item \faCodeFork\ the \href{http://forge.ipsl.jussieu.fr/nemo}{development platform} of
+  the model with the code repository for the shared reference and some main resources
+  (wiki, ticket system, forums, \ldots) \\
+  \faGithub\ the \href{http://github.com/NEMO-ocean/NEMO-examples}
+  {repository of the demonstration cases} for research or training
+\item \faCloudDownload\ the \href{http://zenodo.org/communities/nemo-ocean}{online archive}
+  delivering the publications issued by the consortium (manuals, reports, datasets, \ldots)
+\item \faEnvelope\ two mailing lists:
   the \href{http://listes.ipsl.fr/sympa/info/nemo-newsletter}{newsletter} for
   top-down communications from the project
@@ -41,25 +45,26 @@
 \end{itemize}
 
-% ================================================================
-% Citation
-% ================================================================
+%% ================================================================
+%% Citation
+%% ================================================================
 \subsubsection*{Citation}
 
 Reference for papers and other publications is as follows:
 
-\vspace{0.5cm}
+\medskip
 
-%% \sloppy: workaround for breaking DOI URL
-\sloppy
-``{\bfseries \heading}'', 
-\firstauthor and \secondauthor, 
-{\em Scientific Notes of Climate Modelling Center}, \textbf{\ipslnum} --- ISSN 1288-1619, 
-Institut Pierre-Simon Laplace (IPSL), 
-\href{https://doi.org/10.5281/zenodo.\zid}{doi:10.5281/zenodo.\zid}
+\begin{sloppypar}
+  ``{\bfseries \heading}\ifdef{\subheading}{ -- \subheading}{}'',
+  {\em Scientific Notes of Climate Modelling Center}, \textbf{\ipslnum} --- ISSN 1288-1619,
+  Institut Pierre-Simon Laplace (IPSL),
+  \href{https://doi.org/10.5281/zenodo.\zid}{doi:10.5281/zenodo.\zid}
+\end{sloppypar}
 
 \begin{figure}[b]
-  \begin{minipage}[c]{0.72\textwidth}
-    \small\ttfamily{Scientific Notes of Climate Modelling Center \\
-      ISSN 1288-1619                                             \\
+  \begin{minipage}[c]{0.7\textwidth}
+    \small
+    \ttfamily{
+      Scientific Notes of Climate Modelling Center \\
+      ISSN 1288-1619                               \\
       Institut Pierre-Simon Laplace (IPSL)
     }
@@ -70,3 +75,2 @@
   \end{minipage}
 \end{figure}
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/latexmk.pl
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/latexmk.pl	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/latexmk.pl	(revision 12143)
@@ -0,0 +1,13 @@
+
+## Defaults
+$do_cd    = 1;   ## Change to the directory of the main source file
+$silent   = 1;   ## Less verbosity
+
+## Use of 'build' relative directory
+$ENV{'openout_any'}='a';
+$out_dir = '../build';
+
+## Global option
+set_tex_cmds( '-shell-escape' );
+
+$makeindex = "makeindex %O -s ../../global/index -o $out_dir/%D $out_dir/%S";
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/latexmkrc
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/latexmkrc	(revision 12062)
+++ 	(revision )
@@ -1,17 +1,0 @@
-
-## Defaults
-$silent   = 1;
-$pdf_mode = 1;
-
-## Using relative paths
-$ENV{'openout_any'}='a';
-$out_dir = '../build';
-
-## Custom cmds
-$makeindex = 'makeindex -s %R.ist %O -o %D %S';
-$pdflatex  = 'pdflatex -shell-escape %O %S';
-
-#@BIBINPUTS=('.', '../main');
-#$bibtex    = 'bibtex %O ../main/bibliography.bib';
-#$kpsewhich = 'kpsewhich bibliography.bib'
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/new_cmds.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/new_cmds.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/new_cmds.tex	(revision 12143)
@@ -2,13 +2,21 @@
 %% ==============================================================================
 
-%% Include references and index for compilation of single subfile 
-\newcommand{\mtoc}{\minitoc}
-\newcommand{\biblio}{\bibliography{../main/bibliography}}
-\newcommand{\pindex}{\printindex}
+%% Same slanted font for NEMO and its core engines
+\newcommand{\NEMO  }{\textsl{NEMO}}
+\newcommand{\OPA   }{\textsl{OPA}}
+\newcommand{\SIcube}{\textsl{SI$^3$}}
+\newcommand{\TOP   }{\textsl{TOP}}
+\newcommand{\PISCES}{\textsl{PISCES}}
+\newcommand{\NEMOVAR}{\textsl{NEMOVAR}}
 
-%% NEMO and Fortran in small capitals
-\newcommand{\NEMO}{\textsc{nemo}~}
-\newcommand{\fortran}{\textsc{Fortran}~}
-\newcommand{\fninety}{\textsc{Fortran 90}~}
+%% Links for external components
+\newcommand{\AGRIF}{\href{http://agrif.imag.fr}{AGRIF}}
+\newcommand{\CICE }{\href{http://github.com/CICE-Consortium/CICE}{CICE}}
+\newcommand{\OASIS}{\href{http://portal.enes.org/oasis}{OASIS}}
+\newcommand{\XIOS }{\href{http://forge.ipsl.jussieu.fr/ioserver}{XIOS}}
+
+%% Fortran in small capitals
+\newcommand{\fortran}{\textsc{Fortran}}
+\newcommand{\fninety}{\textsc{Fortran 90}}
 
 %% Common aliases
@@ -18,6 +26,6 @@
 \newcommand{\ztilde}{\ensuremath{\tilde z}}
 \newcommand{\stilde}{\ensuremath{\tilde s}}
-\newcommand{\ie}{\ensuremath{i.e.}~}
-\newcommand{\eg}{\ensuremath{e.g.}~}
+\newcommand{\ie}{\ensuremath{i.e.}}
+\newcommand{\eg}{\ensuremath{e.g.}}
 
 %% Inline maths
@@ -25,13 +33,37 @@
 \newcommand{\rdt}{\Delta t}
 
-%% Text env. for Gurvan
-\newcommand{\gmcomment}[1]{}
+%% Gurvan's comments
+\newcommand{\cmtgm}[1]{}
 
 %% Maths
 \newcommand{\lt}{\left}
 \newcommand{\rt}{\right}
-\newcommand{\vect}[1]{\ensuremath{\mathbf{#1}}}
+\newcommand{\vect}[1]{\ensuremath{ \mathbf{#1} }}
 \newcommand{\pd}[2][]{\ensuremath{\frac{\partial #1}{\partial #2}}}
 
-%% Workaround for issue with \listoffigures
-\DeclareRobustCommand{\triad}[6][]{\ensuremath{{}_{#2}^{#3}{\mathbb{#4}_{#1}}_{#5}^{\,#6}}}
+%% Convert chapter/section headings to lowercase
+\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
+\renewcommand{\sectionmark}[1]{\markright{#1}{}}
+
+%% Retrieve month name
+\renewcommand{\today}{
+  \ifcase \month\or January\or February\or March\or
+                    April\or   May\or      June\or
+                    July\or    August\or   September\or
+                    October\or November\or December
+  \fi, \number \year
+}
+
+%% Link to orcid profile
+\newcommand{\orcid}[1]{\href{http://orcid.org/#1}{\textcolor{orcidcolor}\aiOrcidSquare}}
+
+%% Workaround for \listoffigures
+\DeclareRobustCommand{\triad}[6][]{\ensuremath{ {}_{#2}^{#3} { \mathbb{#4}_{#1} }_{#5}^{\,#6} }}
+
+%% New command for ToC
+\newcommand{\chaptertoc}[1][Table of contents]{%
+  \thispagestyle{empty}
+  \etocsettocstyle{\addsec*{#1}}{}%
+  \localtableofcontents%
+  \vfill
+}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/packages.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/packages.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/packages.tex	(revision 12143)
@@ -3,24 +3,42 @@
 %% ==============================================================================
 
-\usepackage{natbib}                      %% bib
-\usepackage{caption}                     %% caption
-\usepackage{xcolor}                      %% color
-\usepackage{times}                       %% font
-\usepackage{enumitem}                    %% list
-\usepackage{amsmath}                     %% maths
-%\usepackage{fancyhdr}                    %% page
-\usepackage{minitoc}                     %% toc
-\usepackage{subfiles}                    %% subdocs
-\usepackage{draftwatermark}              %% watermark
-\usepackage{titling}                     %% titlepage
+%% 'hyperref' pkg is loaded at the end of the preamble for higher compatibility
 
-%% Extensions in bundle package
-\usepackage{amssymb, graphicx, tabularx, textcomp}
-\usepackage[utf8]{inputenc}              %% input encoding
+%% KOMA-script
+\usepackage[footsepline=0.25pt, headsepline=0.25pt]{scrlayer-scrpage}
+
+%% customization (layout, header/footer styles & contents, background)
+\usepackage{draftwatermark}
+\usepackage[margin = 2cm]{geometry}
+\usepackage[pages = some]{background}   %% 'some' for title page
+\usepackage[Bjornstrup]{fncychap}
+
+%% Fonts
+\usepackage{fontspec}
+%% Issue with fontawesome pkg: path to FontAwesome.otf has to be hard-coded
+\defaultfontfeatures{
+    Path = /usr/local/texlive/2019/texmf-dist/fonts/opentype/public/fontawesome/
+}
+\usepackage{academicons, fontawesome, newtxtext}
+
+%% Formatting
+\usepackage[inline]{enumitem}
+\usepackage{etoc, tabularx, xcolor}
+
+%% Graphics
+\usepackage{caption, graphicx, grffile}
+
+%% Labels
+\usepackage{lastpage, natbib}
+
+%% Mathematics
+\usepackage{amsmath, amssymb, mathtools}
+
+%% Versatility
+\usepackage{subfiles}
 
 %% Configuration
-\graphicspath{ {../../figures/} {../../figures/\engine/} }
-%\captionsetup{margin=10pt, font={small}, labelsep=colon, labelfont={bf}}
-\renewcommand{\bibfont}{\small}
-%\renewcommand{\bibsep}{3pt}
+\graphicspath{ {../../../} {../figures/} }
 
+%% Missing utmr8a font
+\usepackage{times}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/preamble.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/preamble.tex	(revision 12062)
+++ 	(revision )
@@ -1,7 +1,0 @@
-
-\input{../../global/packages}
-\input{../../global/highlighting}
-\input{../../global/new_cmds}
-\input{../../global/styles}
-%\input{../../global/todonotes}
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/prologue.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/prologue.tex	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/prologue.tex	(revision 12143)
@@ -0,0 +1,25 @@
+
+%% Specific configuration
+\input{../main/settings}
+
+%% Global configuration
+\input{../../global/packages}
+\input{../../global/highlighting}
+\input{../../global/index}
+\input{../../global/styles}
+\input{../../global/new_cmds}
+%\input{../../global/todonotes}
+
+%% Load hyperref at the end of the preamble to make it work with other pkgs
+\usepackage{hyperref}   %% links
+\hypersetup{
+  colorlinks,
+  citecolor = manualcolor, linkcolor = manualcolor, urlcolor = manualcolor,
+  final   %% Links even in draft mode
+}
+
+%% `\autoref` uncapitalization
+\renewcommand{\appendixautorefname}{appendix}
+\renewcommand{\equationautorefname}{equation}
+\renewcommand{\figureautorefname}{figure}
+\renewcommand{\tableautorefname}{table}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/styles.tex
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/styles.tex	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/latex/global/styles.tex	(revision 12143)
@@ -3,59 +3,83 @@
 %% ==============================================================================
 
-%\pagestyle{fancy}
-\bibliographystyle{../../global/ametsoc}
-\renewcommand{\bibpreamble}{\begin{multicols}{2}}
-\renewcommand{\bibpostamble}{\end{multicols}}
-
-%% Additional fonts
-\DeclareMathAlphabet{\mathpzc}{OT1}{pzc}{m}{it}
+%% Colors
+\setmanualcolor
+\colorlet{manualcolorshaded}{manualcolor!60}
+\definecolor{orcidcolor}{HTML}{A6CE39}
 
 %% Page layout
-%\fancyhf{}
-%\fancyhead[LE,RO]{\bfseries\thepage}
-%\fancyhead[LO]{\bfseries\hspace{-0em}\rightmark}
-%\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
-%\fancyhead[RE]{\bfseries\leftmark}
-%\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
-%\renewcommand{\headrulewidth}{0.5pt}
-%\renewcommand{\footrulewidth}{0pt  }
-%\addtolength{\headheight}{2.6pt}
+\pagestyle{scrheadings}
+\addtokomafont{pagehead}{  \sffamily              }
+\addtokomafont{pagefoot}{  \sffamily \footnotesize}
+\addtokomafont{pagenumber}{\sffamily \slshape     }
+\addtokomafont{chapter}{\color{white}}
+\ohead{} \ofoot{}   %% Clear defaults
 
+%% Caption
+\captionsetup{font = footnotesize, justification = justified}
+
+%% Footnote
+\renewcommand{\thefootnote}{\fnsymbol{footnote}}
+
+%% Bibliography
+\bibliographystyle{../../global/ametsoc}
+\renewcommand{\bibfont}{\small}
+\renewcommand{\bibpreamble }{\begin{multicols}{2}}
+\renewcommand{\bibpostamble}{  \end{multicols}   }
 
 %% Catcodes
-%\makeatletter
-%\def\LigneVerticale{\vrule height 5cm depth 2cm\hspace{0.1cm}\relax}
-%\def\LignesVerticales{\let\LV\LigneVerticale\LV\LV\LV\LV\LV\LV\LV\LV\LV\LV}
-%\def\GrosCarreAvecUnChiffre#1{
-%	\rlap{\vrule height 0.8cm width 1cm depth 0.2cm}
-%	\rlap{\hbox to 1cm{\hss\mbox{\color{white} #1}\hss}}
-% 	\vrule height 0pt width 1cm depth 0pt
-%}
-%\def\@makechapterhead#1{
-%	\hbox{
-%		\huge\LignesVerticales\hspace{-0.5cm}
-%		\GrosCarreAvecUnChiffre{\thechapter}\hspace{0.2cm}
-%		\hbox{#1}
-%	}
-%	\par\vskip
-%1cm
-%}
-%\def\@makeschapterhead#1{
-%	\hbox{
-%		\huge\LignesVerticales
-%		\hbox{#1}
-%	}
-%	\par\vskip
-%2cm
-%}
-%\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
-%  \hbox{}
-%  \vspace*{\fill}
-%  \vspace{\fill}
-%  \thispagestyle{empty}
-%  \newpage
-%  \if@twocolumn\hbox{}\newpage\fi\fi\fi}
-%\def\@seccntformat#1{\protect\makebox[0pt][r]{\csname the#1\endcsname\quad}}
-%\makeatother
+\makeatletter
 
+%% Prevent error with tikz and namelist inclusion
+\global\let\tikz@ensure@dollar@catcode=\relax
 
+%% First page
+\backgroundsetup{
+  firstpage = true,
+  scale = 1, angle = 0, opacity = 1,
+  contents = {
+    \begin{tikzpicture}[remember picture, overlay]
+      \path [fill = manualcolor] (-0.5\paperwidth, 7) rectangle (0.5\paperwidth, 10);
+    \end{tikzpicture}
+  }
+}
+
+%% Apply engine color for chapter headings: tweaking snippets from fncychap.sty
+\renewcommand{\DOCH}{%
+  \settowidth{\py}{\CNoV\thechapter}
+  \addtolength{\py}{-10pt}      % Amount of space by which the
+%                                  % number is shifted right
+  \fboxsep=0pt%
+  \colorbox{manualcolor}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}%
+  \kern-\py\raise20pt%
+  \hbox{\color{manualcolorshaded}\CNoV\thechapter}\\%
+}
+\renewcommand{\DOTI}[1]{%
+  \nointerlineskip\raggedright%
+  \fboxsep=\myhi%
+  \vskip-1ex%
+  \colorbox{manualcolor}{\parbox[t]{\mylen}{\color{white}\CTV\FmTi{#1}}}\par\nobreak%
+  \vskip 40\p@%
+}
+\renewcommand{\DOTIS}[1]{%
+  \fboxsep=0pt
+  \colorbox{manualcolor}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\%
+  \nointerlineskip\raggedright%
+  \fboxsep=\myhi%
+  \vskip-1ex% Remove white 1pt line
+  \colorbox{manualcolor}{\parbox[t]{\mylen}{\color{white}\CTV\FmTi{#1}}}\par\nobreak%
+  \vskip 40\p@%
+}
+
+%% Temporary fix
+\def\set@curr@file#1{%
+  \begingroup
+    \escapechar\m@ne
+    \xdef\@curr@file{\expandafter\string\csname #1\endcsname}%
+  \endgroup
+}
+\def\quote@name#1{"\quote@@name#1\@gobble""}
+\def\quote@@name#1"{#1\quote@@name}
+\def\unquote@name#1{\quote@@name#1\@gobble"}
+
+\makeatother
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/manual_build.sh
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/manual_build.sh	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/manual_build.sh	(revision 12143)
@@ -27,8 +27,8 @@
 
 ## Retrieve figures if not already there
-if [ ! -d latex/figures ]; then
-    printf "Downloading of shared figures and logos\n\n"
-    svn co https://forge.ipsl.jussieu.fr/nemo/svn/utils/figures latex/figures > /dev/null
-fi
+#if [ ! -d latex/figures ]; then
+#    printf "Downloading of shared figures and logos\n\n"
+#    svn co http://forge.ipsl.jussieu.fr/nemo/svn/utils/figures latex/figures > /dev/null
+#fi
 
 
@@ -38,5 +38,5 @@
 for model in $models; do
     echo $model
-    clean $model
+#    clean $model
     build $model
     printf "\t¤ End of building run\n"
@@ -45,3 +45,2 @@
 
 exit 0
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nam_diadct
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nam_diadct	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nam_diadct	(revision 12143)
@@ -0,0 +1,10 @@
+!-----------------------------------------------------------------------
+&nam_diadct    !   transports through some sections                     (default: OFF)
+!-----------------------------------------------------------------------
+    ln_diadct  = .false.   ! Calculate transport thru sections or not
+       nn_dct     = 15     !  time step frequency for transports computing
+       nn_dctwri  = 15     !  time step frequency for transports writing
+       nn_secdebug = 112   !      0 : no section to debug
+       !                   !     -1 : debug all section
+       !                   !  0 < n : debug section number n
+/
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nam_diaharm
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nam_diaharm	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nam_diaharm	(revision 12143)
@@ -1,9 +1,10 @@
 !-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents              ("key_diaharm")
+&nam_diaharm   !   Harmonic analysis of tidal constituents              (default: OFF)
 !-----------------------------------------------------------------------
-    nit000_han = 1         ! First time step used for harmonic analysis
-    nitend_han = 75        ! Last time step used for harmonic analysis
-    nstep_han  = 15        ! Time step frequency for harmonic analysis
-    tname(1)   = 'M2'      ! Name of tidal constituents
-    tname(2)   = 'K1'
+    ln_diaharm = .false.   ! Choose tidal harmonic output or not
+       nit000_han = 1      !    First time step used for harmonic analysis
+       nitend_han = 75     !    Last time step used for harmonic analysis
+       nstep_han  = 15     !    Time step frequency for harmonic analysis
+       tname(1)   = 'M2'   !    Name of tidal constituents
+       tname(2)   = 'K1'   !              ---
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nambdy
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nambdy	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nambdy	(revision 12143)
@@ -22,15 +22,11 @@
    nn_ice_dta    =  0         !  = 0, bdy data are equal to the initial state
    !                          !  = 1, bdy data are read in 'bdydata   .nc' files
-   rn_ice_tem    = 270.       !  si3 only: arbitrary temperature of incoming sea ice
-   rn_ice_sal    = 10.        !  si3 only:      --   salinity           --
-   rn_ice_age    = 30.        !  si3 only:      --   age                --
    !
    ln_tra_dmp    =.false.     !  open boudaries conditions for tracers
    ln_dyn3d_dmp  =.false.     !  open boundary condition for baroclinic velocities
    rn_time_dmp   =  1.        !  Damping time scale in days
-   rn_time_dmp_out = 1.        !  Outflow damping time scale
+   rn_time_dmp_out = 1.       !  Outflow damping time scale
    nn_rimwidth   = 10         !  width of the relaxation zone
    ln_vol        = .false.    !  total volume correction (see nn_volctl parameter)
    nn_volctl     =  1         !  = 0, the total water flux across open boundaries is zero
-   nb_jpk_bdy    = -1         ! number of levels in the bdy data (set < 0 if consistent with planned run)
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nambdy_dta
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nambdy_dta	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nambdy_dta	(revision 12143)
@@ -2,20 +2,36 @@
 &nambdy_dta    !  open boundaries - external data                       (see nam_bdy)
 !-----------------------------------------------------------------------
-   ln_full_vel = .false.      !  ???
-
+   ln_zinterp  = .false.      !  T if a vertical interpolation is required. Variables gdep[tuv] and e3[tuv] must exist in the file
+   !                          !  automatically defined to T if the number of vertical levels in bdy dta /= jpk
+   ln_full_vel = .false.      !  T if [uv]3d are "full" velocities and not only its baroclinic components
+   !                          !  in this case, baroclinic and barotropic velocities will be recomputed -> [uv]2d not needed
+   !
    cn_dir      = 'bdydta/'    !  root directory for the BDY data location
    !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   bn_ssh      = 'amm12_bdyT_u2d'        ,         24        , 'sossheig',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_u2d      = 'amm12_bdyU_u2d'        ,         24        , 'vobtcrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_v2d      = 'amm12_bdyV_u2d'        ,         24        , 'vobtcrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_u3d      = 'amm12_bdyU_u3d'        ,         24        , 'vozocrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_v3d      = 'amm12_bdyV_u3d'        ,         24        , 'vomecrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_tem      = 'amm12_bdyT_tra'        ,         24        , 'votemper',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-   bn_sal      = 'amm12_bdyT_tra'        ,         24        , 'vosaline',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_ssh      = 'amm12_bdyT_u2d'        ,         24.       , 'sossheig',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_u2d      = 'amm12_bdyU_u2d'        ,         24.       , 'vobtcrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_v2d      = 'amm12_bdyV_u2d'        ,         24.       , 'vobtcrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_u3d      = 'amm12_bdyU_u3d'        ,         24.       , 'vozocrtx',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_v3d      = 'amm12_bdyV_u3d'        ,         24.       , 'vomecrty',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_tem      = 'amm12_bdyT_tra'        ,         24.       , 'votemper',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_sal      = 'amm12_bdyT_tra'        ,         24.       , 'vosaline',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
 !* for si3
-!   bn_a_i     = 'amm12_bdyT_ice'        ,         24        , 'ileadfra',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-!   bn_h_i     = 'amm12_bdyT_ice'        ,         24        , 'iicethic',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
-!   bn_h_s     = 'amm12_bdyT_ice'        ,         24        , 'isnowthi',    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_a_i      = 'amm12_bdyT_ice'        ,         24.       , 'siconc'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_h_i      = 'amm12_bdyT_ice'        ,         24.       , 'sithic'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_h_s      = 'amm12_bdyT_ice'        ,         24.       , 'snthic'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_t_i      = 'NOT USED'              ,         24.       , 'sitemp'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_t_s      = 'NOT USED'              ,         24.       , 'sntemp'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_tsu      = 'NOT USED'              ,         24.       , 'sittop'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_s_i      = 'NOT USED'              ,         24.       , 'sisalt'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   ! melt ponds (be careful, bn_aip is the pond concentration (not fraction), so it differs from rn_iceapnd)
+   bn_aip      = 'NOT USED'              ,         24.       , 'siapnd'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   bn_hip      = 'NOT USED'              ,         24.       , 'sihpnd'  ,    .true.   , .false.,  'daily'  ,    ''            ,   ''     ,     ''
+   ! if bn_t_i etc are "not used", then define arbitrary temperatures and salinity and ponds
+   rn_ice_tem  = 270.         !  arbitrary temperature               of incoming sea ice
+   rn_ice_sal  = 10.          !       --   salinity                            --
+   rn_ice_age  = 30.          !       --   age                                 --
+   rn_ice_apnd = 0.2          !       --   pond fraction = a_ip/a_i            --
+   rn_ice_hpnd = 0.05         !       --   pond depth                          --
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namberg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namberg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namberg	(revision 12143)
@@ -37,4 +37,4 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_icb     =  'calving'              ,         -1         ,'calvingmask',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_icb     =  'calving'              ,         -1.        ,'calvingmask',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namc1d_uvd
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namc1d_uvd	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namc1d_uvd	(revision 12143)
@@ -10,5 +10,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_ucur     = 'ucurrent'              ,         -1        ,'u_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Ume'   , ''
-   sn_vcur     = 'vcurrent'              ,         -1        ,'v_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Vme'   , ''
+   sn_ucur     = 'ucurrent'              ,         -1.       ,'u_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Ume'   , ''
+   sn_vcur     = 'vcurrent'              ,         -1.       ,'v_current',   .false.   , .true. , 'monthly' ,  ''              ,  'Vme'   , ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdct
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdct	(revision 12062)
+++ 	(revision )
@@ -1,9 +1,0 @@
-!-----------------------------------------------------------------------
-&namdct        ! transports through some sections                       ("key_diadct")
-!-----------------------------------------------------------------------
-    nn_dct     = 15        !  time step frequency for transports computing
-    nn_dctwri  = 15        !  time step frequency for transports writing
-    nn_secdebug = 112       !      0 : no section to debug
-    !                      !     -1 : debug all section
-    !                      !  0 < n : debug section number n
-/
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdia
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdia	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdia	(revision 12143)
@@ -2,5 +2,8 @@
 &namdia         !   Diagnostics
 !------------------------------------------------------------------------------
-   ln_icediachk     = .false.         !  check online the heat, mass & salt budgets (T) or not (F)
+   ln_icediachk     = .false.         !  check online heat, mass & salt budgets
+      !                               !   rate of ice spuriously gained/lost at each time step => rn_icechk=1 <=> 1.e-6 m/hour
+      rn_icechk_cel =  100.           !     check at each gridcell          (1.e-4m/h)=> stops the code if violated (and writes a file)
+      rn_icechk_glo =  1.             !     check over the entire ice cover (1.e-6m/h)=> only prints warnings
    ln_icediahsb     = .false.         !  output the heat, mass & salt budgets (T) or not (F)
    ln_icectl        = .false.         !  ice points output for debug (T or F)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdom_domcfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdom_domcfg	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdom_domcfg	(revision 12143)
@@ -0,0 +1,39 @@
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_bathy    =    1      !  compute (=0) or read (=1) the bathymetry file
+   rn_bathy    =    0.     !  value of the bathymetry. if (=0) bottom flat at jpkm1
+   nn_closea   =    0      !  remove (=0) or keep (=1) closed seas and lakes (ORCA)
+   nn_msh      =    1      !  create (=1) a mesh file or not (=0)
+   rn_hmin     =   -3.     !  min depth of the ocean (>0) or min number of ocean level (<0)
+   rn_isfhmin  =    1.00   !  treshold (m) to discriminate grounding ice to floating ice
+   rn_e3zps_min=   20.     !  partial step thickness is set larger than the minimum of
+   rn_e3zps_rat=    0.1    !  rn_e3zps_min and rn_e3zps_rat*e3t, with 0<rn_e3zps_rat<1
+                           !
+   rn_rdt      = 5760.     !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_atfp     =    0.1    !  asselin time filter parameter
+   ln_crs      = .false.      !  Logical switch for coarsening module
+   jphgr_msh   =       0               !  type of horizontal mesh
+                                       !  = 0 curvilinear coordinate on the sphere read in coordinate.nc
+                                       !  = 1 geographical mesh on the sphere with regular grid-spacing
+                                       !  = 2 f-plane with regular grid-spacing
+                                       !  = 3 beta-plane with regular grid-spacing
+                                       !  = 4 Mercator grid with T/U point at the equator
+   ppglam0     =       0.0             !  longitude of first raw and column T-point (jphgr_msh = 1)
+   ppgphi0     =     -35.0             ! latitude  of first raw and column T-point (jphgr_msh = 1)
+   ppe1_deg    =       1.0             !  zonal      grid-spacing (degrees)
+   ppe2_deg    =       0.5             !  meridional grid-spacing (degrees)
+   ppe1_m      =    5000.0             !  zonal      grid-spacing (degrees)
+   ppe2_m      =    5000.0             !  meridional grid-spacing (degrees)
+   ppsur       =    -4762.96143546300  !  ORCA r4, r2 and r05 coefficients
+   ppa0        =      255.58049070440  ! (default coefficients)
+   ppa1        =      245.58132232490  !
+   ppkth       =       21.43336197938  !
+   ppacr       =        3.0            !
+   ppdzmin     =       10.             !  Minimum vertical spacing
+   pphmax      =     5000.             !  Maximum depth
+   ldbletanh   =    .TRUE.             !  Use/do not use double tanf function for vertical coordinates
+   ppa2        =      100.760928500000 !  Double tanh function parameters
+   ppkth2      =       48.029893720000 !
+   ppacr2      =       13.000000000000 !
+/
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdta_dyn
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdta_dyn	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdta_dyn	(revision 12143)
@@ -10,17 +10,17 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem      = 'dyna_grid_T'           ,       120         , 'votemper'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_sal      = 'dyna_grid_T'           ,       120         , 'vosaline'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_mld      = 'dyna_grid_T'           ,       120         , 'somixhgt'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_emp      = 'dyna_grid_T'           ,       120         , 'sowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_fmf      = 'dyna_grid_T'           ,       120         , 'iowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_ice      = 'dyna_grid_T'           ,       120         , 'soicecov'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_qsr      = 'dyna_grid_T'           ,       120         , 'soshfldo'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_wnd      = 'dyna_grid_T'           ,       120         , 'sowindsp'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_uwd      = 'dyna_grid_U'           ,       120         , 'uocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_vwd      = 'dyna_grid_V'           ,       120         , 'vocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_wwd      = 'dyna_grid_W'           ,       120         , 'wocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_avt      = 'dyna_grid_W'           ,       120         , 'voddmavs'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_ubl      = 'dyna_grid_U'           ,       120         , 'sobblcox'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_vbl      = 'dyna_grid_V'           ,       120         , 'sobblcoy'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_tem      = 'dyna_grid_T'           ,       120.        , 'votemper'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_sal      = 'dyna_grid_T'           ,       120.        , 'vosaline'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_mld      = 'dyna_grid_T'           ,       120.        , 'somixhgt'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_emp      = 'dyna_grid_T'           ,       120.        , 'sowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_fmf      = 'dyna_grid_T'           ,       120.        , 'iowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_ice      = 'dyna_grid_T'           ,       120.        , 'soicecov'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_qsr      = 'dyna_grid_T'           ,       120.        , 'soshfldo'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_wnd      = 'dyna_grid_T'           ,       120.        , 'sowindsp'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_uwd      = 'dyna_grid_U'           ,       120.        , 'uocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_vwd      = 'dyna_grid_V'           ,       120.        , 'vocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_wwd      = 'dyna_grid_W'           ,       120.        , 'wocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_avt      = 'dyna_grid_W'           ,       120.        , 'voddmavs'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_ubl      = 'dyna_grid_U'           ,       120.        , 'sobblcox'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_vbl      = 'dyna_grid_V'           ,       120.        , 'sobblcoy'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdyn
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdyn	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namdyn	(revision 12143)
@@ -10,11 +10,8 @@
    rn_ishlat        =   2.            !  lbc : free slip (0) ; partial slip (0-2) ; no slip (2) ; strong slip (>2)
    ln_landfast_L16  = .false.         !  landfast: parameterization from Lemieux 2016
-   ln_landfast_home = .false.         !  landfast: parameterization from "home made"
       rn_depfra     =   0.125         !        fraction of ocean depth that ice must reach to initiate landfast
-                                      !          recommended range: [0.1 ; 0.25] - L16=0.125 - home=0.15
-      rn_icebfr     =  15.            !        ln_landfast_L16:  maximum bottom stress per unit volume [N/m3]
-                                      !        ln_landfast_home: maximum bottom stress per unit area of contact [N/m2]
-                                      !          recommended range: ?? L16=15 - home=10
+                                      !          recommended range: [0.1 ; 0.25]
+      rn_icebfr     =  15.            !        maximum bottom stress per unit volume [N/m3]
       rn_lfrelax    =   1.e-5         !        relaxation time scale to reach static friction [s-1]
-      rn_tensile    =   0.2           !        ln_landfast_L16: isotropic tensile strength
+      rn_tensile    =   0.05          !        isotropic tensile strength [0-0.5??]
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namflo
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namflo	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namflo	(revision 12143)
@@ -1,14 +1,15 @@
 !-----------------------------------------------------------------------
-&namflo        !   float parameters                                     ("key_float")
+&namflo        !   float parameters                                     (default: OFF)
 !-----------------------------------------------------------------------
-   jpnfl       = 1         !  total number of floats during the run
-   jpnnewflo   = 0         !  number of floats for the restart
-   ln_rstflo   = .false.   !  float restart (T) or not (F)
-   nn_writefl  =      75   !  frequency of writing in float output file
-   nn_stockfl  =    5475   !  frequency of creation of the float restart file
-   ln_argo     = .false.   !  Argo type floats (stay at the surface each 10 days)
-   ln_flork4   = .false.   !  trajectories computed with a 4th order Runge-Kutta (T)
-   !                       !  or computed with Blanke' scheme (F)
-   ln_ariane   = .true.    !  Input with Ariane tool convention(T)
-   ln_flo_ascii = .true.    !  Output with Ariane tool netcdf convention(F) or ascii file (T)
+   ln_floats   = .false.      ! activate floats or not
+      jpnfl       = 1         !    total number of floats during the run
+      jpnnewflo   = 0         !    number of floats for the restart
+      ln_rstflo   = .false.   !    float restart (T) or not (F)
+      nn_writefl  =      75   !    frequency of writing in float output file
+      nn_stockfl  =    5475   !    frequency of creation of the float restart file
+      ln_argo     = .false.   !    Argo type floats (stay at the surface each 10 days)
+      ln_flork4   = .false.   !    trajectories computed with a 4th order Runge-Kutta (T)
+      !                       !    or computed with Blanke' scheme (F)
+      ln_ariane   = .true.    !    Input with Ariane tool convention(T)
+      ln_flo_ascii= .true.    !    Output with Ariane tool netcdf convention(F) or ascii file (T)
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namhsb
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namhsb	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namhsb	(revision 12143)
@@ -2,4 +2,4 @@
 &namhsb        !  Heat and salt budgets                                 (default: OFF)
 !-----------------------------------------------------------------------
-   ln_diahsb   = .false.   !  check the heat and salt budgets (T) or not (F)
+   ln_diahsb   = .false.   !  output the heat and salt budgets (T) or not (F)
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namini
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namini	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namini	(revision 12143)
@@ -4,22 +4,34 @@
    ln_iceini        = .true.          !  activate ice initialization (T) or not (F)
    ln_iceini_file   = .false.         !  netcdf file provided for initialization (T) or not (F)
-   rn_thres_sst     =   2.0           !  max delta temp. above Tfreeze with initial ice = (sst - tfreeze)
-   rn_hts_ini_n     =   0.3           !  initial real snow thickness (m), North
+   rn_thres_sst     =   2.0           !  max temp. above Tfreeze with initial ice = (sst - tfreeze)
+   rn_hti_ini_n     =   3.0           !  initial ice thickness       (m), North
+   rn_hti_ini_s     =   1.0           !        "            "             South
+   rn_hts_ini_n     =   0.3           !  initial snow thickness      (m), North
    rn_hts_ini_s     =   0.3           !        "            "             South
-   rn_hti_ini_n     =   3.0           !  initial real ice thickness  (m), North
-   rn_hti_ini_s     =   1.0           !        "            "             South
    rn_ati_ini_n     =   0.9           !  initial ice concentration   (-), North
    rn_ati_ini_s     =   0.9           !        "            "             South
    rn_smi_ini_n     =   6.3           !  initial ice salinity     (g/kg), North
    rn_smi_ini_s     =   6.3           !        "            "             South
-   rn_tmi_ini_n     = 270.            !  initial ice/snw temperature (K), North
+   rn_tmi_ini_n     = 270.            !  initial ice temperature     (K), North
    rn_tmi_ini_s     = 270.            !        "            "             South
-
+   rn_tsu_ini_n     = 270.            !  initial surface temperature (K), North
+   rn_tsu_ini_s     = 270.            !        "            "             South
+   rn_tms_ini_n     = 270.            !  initial snw temperature     (K), North
+   rn_tms_ini_s     = 270.            !        "            "             South
+   rn_apd_ini_n     =   0.2           !  initial pond fraction       (-), North
+   rn_apd_ini_s     =   0.2           !        "            "             South
+   rn_hpd_ini_n     =   0.05          !  initial pond depth          (m), North
+   rn_hpd_ini_s     =   0.05          !        "            "             South
+   ! -- for ln_iceini_file = T
    sn_hti = 'Ice_initialization'    , -12 ,'hti'   ,  .false.  , .true., 'yearly'  , '' , '', ''
    sn_hts = 'Ice_initialization'    , -12 ,'hts'   ,  .false.  , .true., 'yearly'  , '' , '', ''
    sn_ati = 'Ice_initialization'    , -12 ,'ati'   ,  .false.  , .true., 'yearly'  , '' , '', ''
+   sn_smi = 'Ice_initialization'    , -12 ,'smi'   ,  .false.  , .true., 'yearly'  , '' , '', ''
+   sn_tmi = 'Ice_initialization'    , -12 ,'tmi'   ,  .false.  , .true., 'yearly'  , '' , '', ''
    sn_tsu = 'Ice_initialization'    , -12 ,'tsu'   ,  .false.  , .true., 'yearly'  , '' , '', ''
-   sn_tmi = 'Ice_initialization'    , -12 ,'tmi'   ,  .false.  , .true., 'yearly'  , '' , '', ''
-   sn_smi = 'Ice_initialization'    , -12 ,'smi'   ,  .false.  , .true., 'yearly'  , '' , '', ''
+   sn_tms = 'NOT USED'              , -12 ,'tms'   ,  .false.  , .true., 'yearly'  , '' , '', ''
+   !      melt ponds (be careful, sn_apd is the pond concentration (not fraction), so it differs from rn_apd)
+   sn_apd = 'NOT USED'              , -12 ,'apd'   ,  .false.  , .true., 'yearly'  , '' , '', ''
+   sn_hpd = 'NOT USED'              , -12 ,'hpd'   ,  .false.  , .true., 'yearly'  , '' , '', ''
    cn_dir='./'
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nammpp
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nammpp	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nammpp	(revision 12143)
@@ -2,9 +2,8 @@
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
 !-----------------------------------------------------------------------
-   cn_mpi_send =  'I'      !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
-   !                       !  buffer blocking send or immediate non-blocking sends, resp.
-   nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
+   ln_listonly =  .false.  !  do nothing else than listing the best domain decompositions (with land domains suppression)
+   !                       !  if T: the largest number of cores tested is defined by max(mppsize, jpni*jpnj)
    ln_nnogather =  .true.  !  activate code to avoid mpi_allgather use at the northfold
-   jpni        =   0       !  jpni   number of processors following i (set automatically if < 1)
-   jpnj        =   0       !  jpnj   number of processors following j (set automatically if < 1)
+   jpni        =   0       !  number of processors following i (set automatically if < 1), see also ln_listonly = T
+   jpnj        =   0       !  number of processors following j (set automatically if < 1), see also ln_listonly = T
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nampisatm
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nampisatm	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nampisatm	(revision 12143)
@@ -4,6 +4,6 @@
 !              !  file name   ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !              !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_patm     = 'presatm'    ,     -1            , 'patm'    ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
-   sn_atmco2   = 'presatmco2' ,     -1            , 'xco2'    ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
+   sn_patm     = 'presatm'    ,     -1.           , 'patm'    ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
+   sn_atmco2   = 'presatmco2' ,     -1.           , 'xco2'    ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
    cn_dir      = './'     !  root directory for the location of the dynamical files
 !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nampisopt
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nampisopt	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nampisopt	(revision 12143)
@@ -4,5 +4,5 @@
 !              !  file name       ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                  !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_par      = 'par.orca'       ,     24            , 'fr_par'  ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
+   sn_par      = 'par.orca'       ,     24.           , 'fr_par'  ,  .true.      , .true. , 'yearly'  , ''       , ''       , ''
    cn_dir      = './'      !  root directory for the location of the dynamical files
    ln_varpar   =  .true.   ! boolean for PAR variable
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nampissbc
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nampissbc	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/nampissbc	(revision 12143)
@@ -4,16 +4,16 @@
 !              !  file name        ! frequency (hours) ! variable      ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                   !  (if <0  months)  !   name        !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_dust     = 'dust.orca'       ,     -1            , 'dust'        ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_solub    = 'solubility.orca' ,    -12            , 'solubility1' ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdic = 'river.orca'      ,    120            , 'riverdic'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdoc = 'river.orca'      ,    120            , 'riverdoc'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdin = 'river.orca'      ,    120            , 'riverdin'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdon = 'river.orca'      ,    120            , 'riverdon'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdip = 'river.orca'      ,    120            , 'riverdip'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdop = 'river.orca'      ,    120            , 'riverdop'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdsi = 'river.orca'      ,    120            , 'riverdsi'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_ndepo    = 'ndeposition.orca',    -12            , 'ndep'        ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
-   sn_ironsed  = 'bathy.orca'      ,    -12            , 'bathy'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
-   sn_hydrofe  = 'hydrofe.orca'    ,    -12            , 'epsdb'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+   sn_dust     = 'dust.orca'       ,     -1.           , 'dust'        ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_solub    = 'solubility.orca' ,    -12.           , 'solubility1' ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdic = 'river.orca'      ,    120.           , 'riverdic'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdoc = 'river.orca'      ,    120.           , 'riverdoc'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdin = 'river.orca'      ,    120.           , 'riverdin'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdon = 'river.orca'      ,    120.           , 'riverdon'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdip = 'river.orca'      ,    120.           , 'riverdip'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdop = 'river.orca'      ,    120.           , 'riverdop'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_riverdsi = 'river.orca'      ,    120.           , 'riverdsi'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_ndepo    = 'ndeposition.orca',    -12.           , 'ndep'        ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+   sn_ironsed  = 'bathy.orca'      ,    -12.           , 'bathy'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+   sn_hydrofe  = 'hydrofe.orca'    ,    -12.           , 'epsdb'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
 !
    cn_dir      = './'      !  root directory for the location of the dynamical files
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namrun
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namrun	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namrun	(revision 12143)
@@ -18,12 +18,16 @@
       cn_ocerst_indir = "."         !  directory from which to read input ocean restarts
       cn_ocerst_out   = "restart"   !  suffix of ocean restart name (output)
-      cn_ocerst_outdir = "."         !  directory in which to write output ocean restarts
+      cn_ocerst_outdir = "."        !  directory in which to write output ocean restarts
    ln_iscpl    = .false.   !  cavity evolution forcing or coupling to ice sheet model
    nn_istate   =       0   !  output the initial state (1) or not (0)
    ln_rst_list = .false.   !  output restarts at list of times using nn_stocklist (T) or at set frequency with nn_stock (F)
-   nn_stock    =    5840   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_stock    =       0   !  used only if ln_rst_list = F: output restart freqeuncy (modulo referenced to 1)
+      !                          !    =  0 force to write restart files only at the end of the run
+      !                          !    = -1 do not do any restart
    nn_stocklist = 0,0,0,0,0,0,0,0,0,0 ! List of timesteps when a restart file is to be written
-   nn_write    =    5840   !  frequency of write in the output file   (modulo referenced to nn_it000)
-   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   nn_write    =       0   !  used only if key_iomput is not defined: output frequency (modulo referenced to nn_it000)
+      !                          !    =  0 force to write output files only at the end of the run
+      !                          !    = -1 do not do any output file
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs
    ln_cfmeta   = .false.   !  output additional data to netCDF files required for compliance with the CF metadata standard
    ln_clobber  = .true.    !  clobber (overwrite) an existing file
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_apr
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_apr	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_apr	(revision 12143)
@@ -10,4 +10,4 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_apr      = 'patm'                  ,         -1        ,'somslpre' ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,      ''
+   sn_apr      = 'patm'                  ,         -1.       ,'somslpre' ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,      ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_blk
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_blk	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_blk	(revision 12143)
@@ -22,13 +22,13 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !       weights filename               ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
-   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6         , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
-   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6         , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
-   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24         , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_tair     = 't_10.15JUNE2009_fill'       ,    6         , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6         , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1         , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1         , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_slp      = 'slp.15JUNE2009_fill'        ,    6         , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6.        , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6.        , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,    6.        , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6.        , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_slp      = 'slp.15JUNE2009_fill'        ,    6.        , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
    sn_tdif     = 'taudif_core'                ,   24         , 'taudif'  ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_flx
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_flx	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_flx	(revision 12143)
@@ -6,8 +6,8 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_utau     = 'utau'                  ,        24         , 'utau'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
-   sn_vtau     = 'vtau'                  ,        24         , 'vtau'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
-   sn_qtot     = 'qtot'                  ,        24         , 'qtot'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
-   sn_qsr      = 'qsr'                   ,        24         , 'qsr'     , .false.     , .false., 'yearly'  , ''               , ''       , ''
-   sn_emp      = 'emp'                   ,        24         , 'emp'     , .false.     , .false., 'yearly'  , ''               , ''       , ''
+   sn_utau     = 'utau'                  ,        24.        , 'utau'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
+   sn_vtau     = 'vtau'                  ,        24.        , 'vtau'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
+   sn_qtot     = 'qtot'                  ,        24.        , 'qtot'    , .false.     , .false., 'yearly'  , ''               , ''       , ''
+   sn_qsr      = 'qsr'                   ,        24.        , 'qsr'     , .false.     , .false., 'yearly'  , ''               , ''       , ''
+   sn_emp      = 'emp'                   ,        24.        , 'emp'     , .false.     , .false., 'yearly'  , ''               , ''       , ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_isf
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_isf	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_isf	(revision 12143)
@@ -24,11 +24,11 @@
    !           !             !  (if <0  months)  !   name    !  (logical)  !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
 !* nn_isf = 4 case
-   sn_fwfisf   = 'rnfisf'    ,         -12       ,'sowflisf' ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+   sn_fwfisf   = 'rnfisf'    ,         -12.      ,'sowflisf' ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
 !* nn_isf = 3 case
-   sn_rnfisf   = 'rnfisf'    ,         -12       ,'sofwfisf' ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+   sn_rnfisf   = 'rnfisf'    ,         -12.      ,'sofwfisf' ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
 !* nn_isf = 2 and 3 cases 
-   sn_depmax_isf ='rnfisf'    ,         -12       ,'sozisfmax',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
-   sn_depmin_isf ='rnfisf'    ,         -12       ,'sozisfmin',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+   sn_depmax_isf ='rnfisf'   ,         -12.      ,'sozisfmax',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+   sn_depmin_isf ='rnfisf'   ,         -12.      ,'sozisfmin',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
 !* nn_isf = 2 case
-   sn_Leff_isf = 'rnfisf'    ,         -12       ,'Leff'     ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+   sn_Leff_isf = 'rnfisf'    ,         -12.      ,'Leff'     ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_rnf
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_rnf	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_rnf	(revision 12143)
@@ -18,8 +18,8 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_rnf      = 'runoff_core_monthly'   ,        -1         , 'sorunoff',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
-   sn_cnf      = 'runoff_core_monthly'   ,         0         , 'socoefr0',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_s_rnf    = 'runoffs'               ,        24         , 'rosaline',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
-   sn_t_rnf    = 'runoffs'               ,        24         , 'rotemper',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
-   sn_dep_rnf  = 'runoffs'               ,         0         , 'rodepth' ,   .false.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_rnf      = 'runoff_core_monthly'   ,        -1.        , 'sorunoff',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_cnf      = 'runoff_core_monthly'   ,         0.        , 'socoefr0',   .false.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_s_rnf    = 'runoffs'               ,        24.        , 'rosaline',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_t_rnf    = 'runoffs'               ,        24.        , 'rotemper',   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_dep_rnf  = 'runoffs'               ,         0.        , 'rodepth' ,   .false.   , .true. , 'yearly'  , ''               , ''       , ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_sas
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_sas	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_sas	(revision 12143)
@@ -10,10 +10,10 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_usp      = 'sas_grid_U'            ,       120         , 'uos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_vsp      = 'sas_grid_V'            ,       120         , 'vos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_tem      = 'sas_grid_T'            ,       120         , 'sosstsst',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_sal      = 'sas_grid_T'            ,       120         , 'sosaline',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_ssh      = 'sas_grid_T'            ,       120         , 'sossheig',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_e3t      = 'sas_grid_T'            ,       120         , 'e3t_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_frq      = 'sas_grid_T'            ,       120         , 'frq_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_usp      = 'sas_grid_U'            ,       120.        , 'uos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_vsp      = 'sas_grid_V'            ,       120.        , 'vos'     ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_tem      = 'sas_grid_T'            ,       120.        , 'sosstsst',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_sal      = 'sas_grid_T'            ,       120.        , 'sosaline',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_ssh      = 'sas_grid_T'            ,       120.        , 'sossheig',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_e3t      = 'sas_grid_T'            ,       120.        , 'e3t_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_frq      = 'sas_grid_T'            ,       120.        , 'frq_m'   ,   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_ssr
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_ssr	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_ssr	(revision 12143)
@@ -14,5 +14,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_sst      = 'sst_data'              ,        24         ,  'sst'    ,    .false.  , .false., 'yearly'  ,    ''            ,    ''    ,     ''
-   sn_sss      = 'sss_data'              ,        -1         ,  'sss'    ,    .true.   , .true. , 'yearly'  ,    ''            ,    ''    ,     ''
+   sn_sst      = 'sst_data'              ,        24.        ,  'sst'    ,    .false.  , .false., 'yearly'  ,    ''            ,    ''    ,     ''
+   sn_sss      = 'sss_data'              ,        -1.        ,  'sss'    ,    .true.   , .true. , 'yearly'  ,    ''            ,    ''    ,     ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_wave
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_wave	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namsbc_wave	(revision 12143)
@@ -6,13 +6,13 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_cdg      =  'sdw_ecwaves_orca2'    ,        6          , 'drag_coeff' ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_usd      =  'sdw_ecwaves_orca2'    ,        6          , 'u_sd2d'     ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_vsd      =  'sdw_ecwaves_orca2'    ,        6          , 'v_sd2d'     ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_hsw      =  'sdw_ecwaves_orca2'    ,        6          , 'hs'         ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_wmp      =  'sdw_ecwaves_orca2'    ,        6          , 'wmp'        ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_wfr      =  'sdw_ecwaves_orca2'    ,        6          , 'wfr'        ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_wnum     =  'sdw_ecwaves_orca2'    ,        6          , 'wave_num'   ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_tauwoc   =  'sdw_ecwaves_orca2'    ,        6          , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_tauwx    =  'sdw_ecwaves_orca2'    ,        6          , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
-   sn_tauwy    =  'sdw_ecwaves_orca2'    ,        6          , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_cdg      =  'sdw_ecwaves_orca2'    ,        6.         , 'drag_coeff' ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_usd      =  'sdw_ecwaves_orca2'    ,        6.         , 'u_sd2d'     ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_vsd      =  'sdw_ecwaves_orca2'    ,        6.         , 'v_sd2d'     ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_hsw      =  'sdw_ecwaves_orca2'    ,        6.         , 'hs'         ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_wmp      =  'sdw_ecwaves_orca2'    ,        6.         , 'wmp'        ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_wfr      =  'sdw_ecwaves_orca2'    ,        6.         , 'wfr'        ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_wnum     =  'sdw_ecwaves_orca2'    ,        6.         , 'wave_num'   ,  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_tauwoc   =  'sdw_ecwaves_orca2'    ,        6.         , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_tauwx    =  'sdw_ecwaves_orca2'    ,        6.         , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
+   sn_tauwy    =  'sdw_ecwaves_orca2'    ,        6.         , 'wave_stress',  .true.  , .true. , 'yearly'  ,  ''              , ''       , ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namthd_pnd
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namthd_pnd	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namthd_pnd	(revision 12143)
@@ -2,8 +2,9 @@
 &namthd_pnd     !   Melt ponds
 !------------------------------------------------------------------------------
-   ln_pnd_H12       = .false.         !  activate evolutive melt ponds (from Holland et al 2012)
-   ln_pnd_CST       = .false.         !  activate constant  melt ponds
-      rn_apnd       =   0.2           !     prescribed pond fraction, at Tsu=0 degC
-      rn_hpnd       =   0.05          !     prescribed pond depth,    at Tsu=0 degC
-   ln_pnd_alb       = .false.         !  melt ponds affect albedo or not
+   ln_pnd           = .false.         !  activate melt ponds or not
+     ln_pnd_H12     = .false.         !  activate evolutive melt ponds (from Holland et al 2012)
+     ln_pnd_CST     = .false.         !  activate constant  melt ponds
+       rn_apnd      =   0.2           !     prescribed pond fraction, at Tsu=0 degC
+       rn_hpnd      =   0.05          !     prescribed pond depth,    at Tsu=0 degC
+     ln_pnd_alb     = .false.         !  melt ponds affect albedo or not
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namtra_qsr
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namtra_qsr	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namtra_qsr	(revision 12143)
@@ -16,4 +16,4 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_chl      ='chlorophyll'            ,        -1         , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+   sn_chl      ='chlorophyll'            ,        -1.        , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namtrc_dta
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namtrc_dta	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namtrc_dta	(revision 12143)
@@ -4,5 +4,5 @@
 !                !  file name        ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !                !                   !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_trcdta(1)  = 'data_TRC_nomask' ,        -12        ,  'TRC'    ,    .false.   , .true. , 'yearly'  , ''       , ''       , ''
+   sn_trcdta(1)  = 'data_TRC_nomask' ,        -12.       ,  'TRC'    ,    .false.   , .true. , 'yearly'  , ''       , ''       , ''
    !
    cn_dir        =  './'     !  root directory for the location of the data files
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namtsd
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namtsd	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namtsd	(revision 12143)
@@ -10,5 +10,5 @@
    !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem = 'data_1m_potential_temperature_nomask',  -1      , 'votemper',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
-   sn_sal = 'data_1m_salinity_nomask'             ,  -1      , 'vosaline',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_tem = 'data_1m_potential_temperature_nomask',  -1.     , 'votemper',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_sal = 'data_1m_salinity_nomask'             ,  -1.     , 'vosaline',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
 /
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namzgr_domcfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namzgr_domcfg	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namzgr_domcfg	(revision 12143)
@@ -0,0 +1,9 @@
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate                                  (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_zco      = .false.   !  z-coordinate - full    steps
+   ln_zps      = .false.   !  z-coordinate - partial steps
+   ln_sco      = .false.   !  s- or hybrid z-s-coordinate
+   ln_isfcav   = .false.   !  ice shelf cavity
+   ln_linssh   = .false.   !  linear free surface
+/
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namzgr_sco_domcfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namzgr_sco_domcfg	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/namelists/namzgr_sco_domcfg	(revision 12143)
@@ -0,0 +1,25 @@
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate                (default F)
+!-----------------------------------------------------------------------
+   ln_s_sh94   = .false.    !  Song & Haidvogel 1994 hybrid S-sigma   (T)|
+   ln_s_sf12   = .false.   !  Siddorn & Furner 2012 hybrid S-z-sigma (T)| if both are false the NEMO tanh stretching is applied
+   ln_sigcrit  = .false.   !  use sigma coordinates below critical depth (T) or Z coordinates (F) for Siddorn & Furner stretch
+                           !  stretching coefficients for all functions
+   rn_sbot_min =   10.0    !  minimum depth of s-bottom surface (>0) (m)
+   rn_sbot_max = 7000.0    !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   rn_hc       =  150.0    !  critical depth for transition to stretched coordinates
+                        !!!!!!!  Envelop bathymetry
+   rn_rmax     =    0.3    !  maximum cut-off r-value allowed (0<r_max<1)
+                        !!!!!!!  SH94 stretching coefficients  (ln_s_sh94 = .true.)
+   rn_theta    =    6.0    !  surface control parameter (0<=theta<=20)
+   rn_bb       =    0.8    !  stretching with SH94 s-sigma
+                        !!!!!!!  SF12 stretching coefficient  (ln_s_sf12 = .true.)
+   rn_alpha    =    4.4    !  stretching with SF12 s-sigma
+   rn_efold    =    0.0    !  efold length scale for transition to stretched coord
+   rn_zs       =    1.0    !  depth of surface grid box
+                           !  bottom cell depth (Zb) is a linear function of water depth Zb = H*a + b
+   rn_zb_a     =    0.024  !  bathymetry scaling factor for calculating Zb
+   rn_zb_b     =   -0.2    !  offset for calculating Zb
+                        !!!!!!!! Other stretching (not SH94 or SF12) [also uses rn_theta above]
+   rn_thetb    =    1.0    !  bottom control parameter  (0<=thetb<= 1)
+/
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/Makefile
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/Makefile	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/Makefile	(revision 12143)
@@ -1,3 +1,3 @@
-# Minimal makefile for Sphinx documentation
+# Makefile for Sphinx documentation
 #
 
@@ -5,21 +5,155 @@
 SPHINXOPTS    =
 SPHINXBUILD   = sphinx-build
-SPHINXPROJ    = NEMO
-SOURCEDIR     = source
+PAPER         =
 BUILDDIR      = build
 
-# Put it first so that "make" without argument is like "make help".
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+
+.PHONY: help clean html dirhtml drafthtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
 help:
-	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  drafthtml  to make an autoupdate HTML export while editing (todo list included)"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
 
-.PHONY: help Makefile
+clean:
+	-rm -rf $(BUILDDIR)/*
 
-# Catch-all target: route all unknown targets to Sphinx using the new
-# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
-%: Makefile
-	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+html:
+	$(SPHINXBUILD)   -b html          $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
 
-# Watch source directory and rebuild the documentation when a change is detected
-# Browse to 127.0.0.1:8000/NEMO_guide.html
-htmllive:
-	sphinx-autobuild $(SPHINXOPTS) $(SOURCEDIR) $(BUILDDIR)/htmllive
+dirhtml:
+	$(SPHINXBUILD)   -b dirhtml       $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+drafthtml:
+	sphinx-autobuild -b html -t draft $(ALLSPHINXOPTS) $(BUILDDIR)/drafthtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/drafthtml."
+
+singlehtml:
+	$(SPHINXBUILD)   -b singlehtml    $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD)   -b pickle        $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD)   -b json          $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD)   -b htmlhelp      $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD)   -b qthelp        $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/NEMO.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/NEMO.qhc"
+
+devhelp:
+	$(SPHINXBUILD)   -b devhelp       $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/NEMO"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/NEMO"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD)   -b epub          $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD)   -b latex         $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD)   -b latex         $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD)   -b text          $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD)   -b man           $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD)   -b texinfo       $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD)   -b texinfo       $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD)   -b gettext      $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD)   -b changes       $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD)   -b linkcheck     $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD)   -b doctest       $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/README.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/README.rst	(revision 12143)
@@ -3,5 +3,7 @@
 **********************
 
-| The NEMO guide is made up of several files written in `ReStructuredText <http://docutils.sourceforge.net/rst.html>`_ (`.rst` extension), a WYSIWYG markup language used in the Python community, and scattered all over the NEMO sources.
+| The NEMO guide is made up of several files written in
+  `ReStructuredText <http://docutils.sourceforge.net/rst.html>`_ (`.rst` extension),
+  a WYSIWYG markup language used in the Python community, and scattered all over the NEMO sources.
 | You can view them one by one in plain text from `./source` folder, or export all to a user-friendly guide under `./build` (only HTML format at the moment, PDF expected later).
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/NEMO_guide.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/NEMO_guide.rst	(revision 12062)
+++ 	(revision )
@@ -1,70 +1,0 @@
-#################
-Quick Start Guide
-#################
-
-..
-	For headings markup, this convention is recommended from Python’s Style Guide
-	# with overline, for parts
-	* with overline, for chapters
-	=, for sections
-	-, for subsections
-	^, for subsubsections
-	", for paragraphs
-
-	'global.rst' contains a list of common directives (roles, substitutions and URL links)
-	It is loaded for each file thanks to 'rst_epilog' setting in 'conf.py'
-
-.. toctree::
-   :hidden:
-   :caption: Getting started
-
-   install
-   configurations
-   test_cases
-
-.. toctree::
-   :hidden:
-   :caption: Setup your configuration
-
-   setup
-   diagnostics
-   tools
-
-.. toctree::
-   :hidden:
-   :caption: Advanced use
-
-   zooms
-   coupling
-   data_assimilation
-   tracers
-
-.. toctree::
-   :hidden:
-   :caption: Miscellaneous
-
-   contributing
-   release_notes
-   Glossary<definitions>
-
-.. include:: readme.rst
-
-.. Next headings markup acording to readme.rst
-
-References
-==========
-
-.. bibliography:: references.bib
-   :all:
-   :style: unsrt
-   :labelprefix: R
-
-Disclaimer
-==========
-
-The NEMO source code is freely available and distributed under CeCILL license
-(GNU GPL compatible - see ``./LICENSE``).
-
-You can use, modify and/or redistribute the software under its terms,
-but users are provided only with a limited warranty and the software's authors and
-the successive licensor's have only limited liability.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/_static/style.css
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/_static/style.css	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/_static/style.css	(revision 12143)
@@ -1,5 +1,5 @@
-.rstblue               { color: blue    ; }
-.rstgrey , .rstgreysup { color: grey    ; }
-.rstgreen              { color: seagreen; }
+.blue            { color: blue    ; }
+.grey , .greysup { color: grey    ; }
+.green           { color: seagreen; }
 
 .logo { filter: invert(1) !important; }
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/acro.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/acro.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/acro.rst	(revision 12143)
@@ -0,0 +1,39 @@
+********
+Acronyms
+********
+
+.. todo::
+
+
+
+.. glossary::
+
+   `AGRIF`_
+      *Adaptive Grid Refinement In Fortran*,
+      package for the integration of full adaptive mesh refinement features within
+      an existing multidimensional finite difference model
+
+   SI\ :sup:`3`\
+      *Sea Ice Integrated Initiative*,
+      unified sea ice model merging functionalities from CICE, GELATO and LIM into the NEMO framework
+
+   `OASIS`_
+      *Ocean Atmosphere Sea Ice Soil*,
+      coupling software to synchronise numerical codes representing different components of the climate system
+
+   PISCES
+      *Pelagic Interactions Scheme for Carbon and Ecosystem Studies*,
+      biogeochemical model simulating marine ecosystems, cycles of carbon and the main nutrients
+
+   TAM
+      *Tangent linear and Adjoint Model*,
+      tools to analyse and control the NEMO dynamical core for a wide range of applications such as
+      sensitivity analysis, parameter estimation, vectors computation or data assimilation.
+
+   TOP
+      *Tracers in Ocean Paradigm*,
+      on/off-line oceanic tracers transport and biogeochemistry models
+
+   `XIOS`_
+      *XML Input Output Server*,
+      library dedicated to input/output management of climate code
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cfgs.bib
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cfgs.bib	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cfgs.bib	(revision 12143)
@@ -0,0 +1,25 @@
+@article{ODEA2012,
+author = {E J O’Dea and A K Arnold and K P Edwards and R Furner and P Hyder and M J Martin and J R Siddorn and D Storkey and J While and J T Holt and H Liu},
+title = {An operational ocean forecast system incorporating NEMO and SST data assimilation for the tidally driven European North-West shelf},
+journal = {Journal of Operational Oceanography},
+volume = {5},
+number = {1},
+pages = {3-17},
+year  = {2012},
+publisher = {Taylor & Francis},
+doi = {10.1080/1755876X.2012.11020128},
+URL = {https://doi.org/10.1080/1755876X.2012.11020128},
+eprint = {https://doi.org/10.1080/1755876X.2012.11020128}
+}
+
+@Article{gmd-8-2465-2015,
+AUTHOR = {Aumont, O. and Eth\'e, C. and Tagliabue, A. and Bopp, L. and Gehlen, M.},
+TITLE = {PISCES-v2: an ocean biogeochemical model for carbon and ecosystem studies},
+JOURNAL = {Geoscientific Model Development},
+VOLUME = {8},
+YEAR = {2015},
+NUMBER = {8},
+PAGES = {2465--2513},
+URL = {https://www.geosci-model-dev.net/8/2465/2015/},
+DOI = {10.5194/gmd-8-2465-2015}
+}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cfgs.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cfgs.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cfgs.rst	(revision 12143)
@@ -0,0 +1,1 @@
+link ../../../cfgs/README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/changes.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/changes.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/changes.rst	(revision 12143)
@@ -0,0 +1,1 @@
+link ../../../CHANGES.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cite.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cite.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cite.rst	(revision 12143)
@@ -0,0 +1,48 @@
+***********
+How to cite
+***********
+
+.. todo::
+
+
+
+|NEMO-OCE|
+   :title:`NEMO ocean engine`,
+   NEMO System Team,
+   Scientific Notes of Climate Modelling Center, 27,
+   ISSN 1288-1619 Institut Pierre-Simon Laplace (IPSL),
+   :doi:`10.5281/zenodo.1464816`
+
+.. literalinclude:: ref.bib
+   :language: bibtex
+   :lines:    1-9
+   :caption:  BibTeX source for NEMO manual
+
+|NEMO-ICE|
+   :title:`Sea Ice modelling Integrated Initiative (SI`\ :sup:`3`\ :title:`) --
+   The NEMO sea ice engine`,
+   NEMO Sea Ice Working Group,
+   Scientific Notes of Climate Modelling Center, 31,
+   ISSN 1288-1619 Institut Pierre-Simon Laplace (IPSL),
+   :doi:`10.5281/zenodo.1471689`
+
+.. warning::  No official publication yet
+
+.. literalinclude:: ref.bib
+   :language: bibtex
+   :lines:    13-21
+   :caption:  BibTeX source for SI\ :sup:`3` manual
+
+|NEMO-MBG|
+   :title:`Tracer in Ocean Paradigm (TOP) -- The NEMO passive tracer engine`,
+   NEMO TOP Working Group,
+   Scientific Notes of Climate Modelling Center, 28,
+   ISSN 1288-1619 Institut Pierre-Simon Laplace (IPSL),
+   :doi:`10.5281/zenodo.1471700`
+
+.. warning::  No official publication yet
+
+.. literalinclude:: ref.bib
+   :language: bibtex
+   :lines:    25-33
+   :caption:  BibTeX source for TOP manual
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/coarsening.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/coarsening.rst	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../../src/OCE/CRS/README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/conf.py
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/conf.py	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/conf.py	(revision 12143)
@@ -1,48 +1,96 @@
 # -*- coding: utf-8 -*-
 #
-# Configuration file for the Sphinx documentation builder.
-#
-# This file does only contain a selection of the most common options. For a
-# full list see the documentation:
-# http://www.sphinx-doc.org/en/master/config
-
-# -- Project information -----------------------------------------------------
-
-project = 'NEMO'
-author = 'NEMO System Team'
-
-# The short X.Y version
-version = 'trk'
-# The full version, including alpha/beta/rc tags
-release = 'trunk'
-
-
-# -- General configuration ---------------------------------------------------
-
-# Add any Sphinx extension module names here, as strings. They can be
-# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
-# ones.
-extensions = ['sphinx.ext.extlinks', 'sphinxcontrib.bibtex']
+# NEMO documentation build configuration file, created by
+# sphinx-quickstart on Tue Oct 15 20:13:55 2019.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.extlinks', 'sphinxcontrib.bibtex',
+              'sphinx.ext.todo'    , 'sphinx.ext.autosectionlabel']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
 # The master toctree document.
-master_doc = 'NEMO_guide'
+master_doc = 'guide'
+
+# General information about the project.
+project = u'NEMO'
+copyright = u'2019, NEMO Consortium'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = 'trk'
+# The full version, including alpha/beta/rc tags.
+release = 'trunk'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
-# This pattern also affects html_static_path and html_extra_path .
-exclude_patterns = ['global.rst', 'coarsening.rst']
+exclude_patterns = ['global.rst', 'readme.rst']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
 
 # The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-
-# -- Options for HTML output -------------------------------------------------
+pygments_style = 'emacs'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
 
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
-#
 html_theme = 'sphinx_rtd_theme'
 
@@ -50,6 +98,24 @@
 # further.  For a list of options available for each theme, see the
 # documentation.
-#
-html_theme_options = {}
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+html_favicon = '_static/ORCA.ico'
 
 # Add any paths that contain custom static files (such as style sheets) here,
@@ -58,37 +124,124 @@
 html_static_path = ['_static']
 
-html_favicon = '_static/ORCA.ico'
-
-
-# -- Options for LaTeX output ------------------------------------------------
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'NEMOdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
 
 latex_elements = {
-    # The paper size ('letterpaper' or 'a4paper').
-    #
-    # 'papersize': 'letterpaper',
-
-    # The font size ('10pt', '11pt' or '12pt').
-    #
-    # 'pointsize': '10pt',
-
-    # Additional stuff for the LaTeX preamble.
-    #
-    # 'preamble': '',
-
-    # Latex figure (float) alignment
-    #
-    # 'figure_align': 'htbp',
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
 }
 
 # Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title,
-#  author, documentclass [howto, manual, or own class]).
+# (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-    (master_doc, 'NEMO_guide.tex', 'NEMO Quick Start Guide',
-     'NEMO System Team', 'howto'),
+  ('guide', 'guide.tex', u'NEMO Quick Start Guide',
+   u'NEMO Consortium', 'howto'),
 ]
 
-
-# -- Customisation -----------------------------------------------------------
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('guide', 'nemo', u'NEMO Documentation',
+     [u'NEMO System Team'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('guide', 'NEMO', u'NEMO Documentation',
+   u'NEMO System Team', 'NEMO', 'Community Ocean Model',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# -- Customisation -------------------------------------------------------------
 
 # Timestamping
@@ -99,10 +252,12 @@
 # Link aliases
 extlinks = {
-	'doi'    : ('https://doi.org/%s'                       , None),
-	'forge'  : ('https://forge.ipsl.jussieu.fr/nemo/%s'    , None),
-	'github' : ('https://github.com/%s'                    , None),
-	'xios'   : ('https://forge.ipsl.jussieu.fr/ioserver/%s', None),
-	'website': ('https://www.nemo-ocean.eu/%s'             , None),
-	'zenodo' : ('https://zenodo.org/publication/%s'        , None)
+   'doi'    : ('https://doi.org/%s'                                                    , 'doi:'),
+   'manhtml': ('https://forge.ipsl.jussieu.fr/nemo/chrome/site/doc/NEMO/manual/html/%s', None  ),
+   'forge'  : ('https://forge.ipsl.jussieu.fr/nemo/%s'                                 , None  ),
+   'gmd'    : ('https://www.geosci-model-dev.net/%s'                                   , None  ),
+   'github' : ('https://github.com/NEMO-ocean/%s'                                      , None  ),
+   'xios'   : ('https://forge.ipsl.jussieu.fr/ioserver/%s'                             , None  ),
+   'website': ('https://www.nemo-ocean.eu/%s'                                          , None  ),
+   'zenodo' : ('https://zenodo.org/publication/%s'                                     , None  )
 }
 
@@ -112,4 +267,14 @@
 # SVN revision
 import subprocess
-revision = subprocess.check_output("svnversion").decode("utf-8")
-rst_prolog = '.. |revision| replace:: %s' % revision
+rev = subprocess.check_output("svnversion").decode("utf-8")
+rst_prolog = '.. |revision| replace:: %s' % rev
+
+# 'draft' build tag: DRAFT watermark and TODO list
+if tags.has('draft'):
+   todo_include_todos = True
+   todo_emit_warnings = True
+else:
+   exclude_patterns = ['global.rst', 'readme.rst', 'todos.rst', 'unpub*']
+
+# Default language to highlight set to fortran
+highlight_language = 'fortran'
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/configurations.bib
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/configurations.bib	(revision 12062)
+++ 	(revision )
@@ -1,25 +1,0 @@
-@article{ODEA2012,
-author = {E J O’Dea and A K Arnold and K P Edwards and R Furner and P Hyder and M J Martin and J R Siddorn and D Storkey and J While and J T Holt and H Liu},
-title = {An operational ocean forecast system incorporating NEMO and SST data assimilation for the tidally driven European North-West shelf},
-journal = {Journal of Operational Oceanography},
-volume = {5},
-number = {1},
-pages = {3-17},
-year  = {2012},
-publisher = {Taylor & Francis},
-doi = {10.1080/1755876X.2012.11020128},
-URL = {https://doi.org/10.1080/1755876X.2012.11020128},
-eprint = {https://doi.org/10.1080/1755876X.2012.11020128}
-}
-
-@Article{gmd-8-2465-2015,
-AUTHOR = {Aumont, O. and Eth\'e, C. and Tagliabue, A. and Bopp, L. and Gehlen, M.},
-TITLE = {PISCES-v2: an ocean biogeochemical model for carbon and ecosystem studies},
-JOURNAL = {Geoscientific Model Development},
-VOLUME = {8},
-YEAR = {2015},
-NUMBER = {8},
-PAGES = {2465--2513},
-URL = {https://www.geosci-model-dev.net/8/2465/2015/},
-DOI = {10.5194/gmd-8-2465-2015}
-}
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/configurations.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/configurations.rst	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../../cfgs/README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/contrib.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/contrib.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/contrib.rst	(revision 12143)
@@ -0,0 +1,1 @@
+link ../../../CONTRIBUTING.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/contributing.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/contributing.rst	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../../CONTRIBUTING.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/coupling.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/coupling.rst	(revision 12062)
+++ 	(revision )
@@ -1,12 +1,0 @@
-********
-Coupling
-********
-
-NEMO currently exploits OASIS-3-MCT (versions 1 to 4) to implement a generalised coupled interface
-(`Coupled Formulation <http://forge.ipsl.jussieu.fr/nemo/doxygen/node50.html?doc=NEMO>`_).
-It can be used to interface with most of the European atmospheric GCM (ARPEGE, ECHAM, ECMWF, Ha- dAM, HadGAM, LMDz), as well as to regional atmospheric models (WRF, COSMO, Meso-NH, AROME).
-To implement the coupling of two independent NEMO components, ocean on one hand and sea-ice plus other surface processes on the other hand
-(`Standalone Surface Module - SAS <http://forge.ipsl.jussieu.fr/nemo/doxygen/node46.html?doc=NEMO>`_).
-
-To enable the OASIS interface the required compilation key is ``key_oasis3``. You must also add ``key_oasis3_v1v2`` if you use OASIS-3-MCT version 1 and 2.
-The parameters to set are in sections ``namsbc_cpl`` and in case of using of SAS also in section ``namsbc_sas``.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cplg.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cplg.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/cplg.rst	(revision 12143)
@@ -0,0 +1,21 @@
+********
+Coupling
+********
+
+.. todo::
+
+   The ‘Coupling’ chapter needs to be enriched
+
+NEMO currently exploits OASIS-3-MCT (versions 1 to 4) to implement a generalised coupled interface
+(:manhtml:`Coupled Formulation <node50.html>`).
+It can be used to interface with most of the European atmospheric GCM
+(ARPEGE, ECHAM, ECMWF, Ha- dAM, HadGAM, LMDz), as well as to regional atmospheric models
+(WRF, COSMO, Meso-NH, AROME).
+To implement the coupling of two independent NEMO components,
+ocean on one hand and sea-ice plus other surface processes on the other hand
+(:manhtml:`Standalone Surface Module - SAS <node46.html>`).
+
+To enable the OASIS interface the required compilation key is ``key_oasis3``.
+You must also add ``key_oasis3_v1v2`` if you use OASIS-3-MCT version 1 and 2.
+The parameters to set are in sections ``&namsbc_cpl`` and
+in case of using of SAS also in section ``&namsbc_sas``.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/da.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/da.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/da.rst	(revision 12143)
@@ -0,0 +1,68 @@
+*****************
+Data assimilation
+*****************
+
+.. todo::
+
+
+
+.. contents::
+   :local:
+
+The assimilation interface to NEMO is split into three modules.
+
+- ``OBS`` for the observation operator
+- ``ASM`` for the application of increments and model bias correction
+  (based on the assimilation increments).
+- ``TAM`` the tangent linear and adjoint model.
+
+Please see :doc:`NEMO manual <cite>` for more details including
+information about the input file formats and the namelist settings.
+
+Observation and model comparison (``OBS``)
+==========================================
+
+The observation and model comparison code (OBS) reads in observation files
+(profile temperature and salinity, sea surface temperature, sea level anomaly, sea ice concentration,
+and velocity) and calculates an interpolated model equivalent value at
+the observation location and nearest model timestep.
+The resulting data are saved in a feedback file (or files).
+The code was originally developed for use with the NEMOVAR data assimilation code, but
+can be used for validation or verification of model or any other data assimilation system.
+This is all controlled by the namelist.
+To build with the OBS code active ``key_diaobs`` must be set.
+
+More details in :manhtml:`"Observation and Model Comparison (OBS)" chapter <node83.html>`.
+
+Standalone observation operator (``SAO``)
+-----------------------------------------
+
+The OBS code can also be run after a model run using saved NEMO model data.
+This is accomplished using the standalone observation operator (SAO)
+(previously known the offline observation operator).
+
+To build the SAO use :file:`makenemo`.
+This means compiling NEMO once (in the normal way) for the chosen configuration.
+Then include ``SAO`` at the end of the relevant line in :file:`cfg.txt` file.
+Then recompile with the replacement main program in :file:`./src/SAO`.
+This is a special version of :file:`nemogcm.F90` (which doesn't run the model,
+but reads in the model fields, and observations and runs the OBS code.
+See :manhtml:`"Standalone observation operator (SAO)" section <node88.html>`.
+
+Apply assimilation increments (``ASM``)
+=======================================
+
+The ASM code adds the functionality to apply increments to the model variables:
+temperature, salinity, sea surface height, velocity and sea ice concentration.
+These are read into the model from a NetCDF file which
+may be produced by separate data assimilation code.
+The code can also output model background fields which are used as an input to data assimilation code.
+This is all controlled by the namelist ``&nam_asminc``.
+To build the ASM code ``key asminc`` must be set.
+
+More details in :manhtml:`"Apply Assimilation Increments (ASM)" chapter <node89.html>`.
+
+Tangent linear and adjoint (``TAM``)
+====================================
+
+This is the tangent linear and adjoint code of NEMO which is useful to 4D VAR assimilation.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/data_assimilation.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/data_assimilation.rst	(revision 12062)
+++ 	(revision )
@@ -1,60 +1,0 @@
-*****************
-Data assimilation
-*****************
-
-.. contents::
-   :local:
-
-The assimilation interface to NEMO is split into three modules.
-- OBS for the observation operator
-- ASM for the application of increments and model bias correction (based on the assimilation increments).
-- TAM the tangent linear and adjoint model.
-
-Please see the `NEMO manual`_ for more details including information about the input file formats and
-the namelist settings.
-
-Observation and model comparison (OBS)
-======================================
-
-The observation and model comparison code (OBS) reads in observation files (profile temperature and salinity,
-sea surface temperature, sea level anomaly, sea ice concentration, and velocity) and
-calculates an interpolated model equivalent value at the observation location and nearest model timestep.
-The resulting data are saved in a feedback file (or files).
-The code was originally developed for use with the NEMOVAR data assimilation code, but
-can be used for validation or verification of model or any other data assimilation system.
-This is all controlled by the namelist.
-To build with the OBS code active ``key_diaobs`` must be set. 
-
-More details in the `NEMO manual`_ chapter 12.
-
-Standalone observation operator (SAO)
--------------------------------------
-
-The OBS code can also be run after a model run using saved NEMO model data.
-This is accomplished using the standalone observation operator (SAO)
-(previously known the offline observation operator).
-
-To build the SAO use makenemo.
-This means compiling NEMO once (in the normal way) for the chosen configuration.
-Then include ``SAO`` at the end of the relevant line in ``cfg.txt`` file.
-Then recompile with the replacement main program in ``./src/SAO``.
-This is a special version of ``nemogcm.F90`` (which doesn't run the model, but reads in the model fields, and
-observations and runs the OBS code.
-See section 12.4 of the `NEMO manual`_.
-
-Apply assimilation increments (ASM)
-===================================
-
-The ASM code adds the functionality to apply increments to the model variables:
-temperature, salinity, sea surface height, velocity and sea ice concentration.
-These are read into the model from a NetCDF file which may be produced by separate data assimilation code.
-The code can also output model background fields which are used as an input to data assimilation code.
-This is all controlled by the namelist nam_asminc.
-To build the ASM code ``key asminc`` must be set.
-
-More details in the `NEMO manual`_ chapter 13.
-
-Tangent linear and adjoint (TAM)
-================================
-
-This is the tangent linear and adjoint code of NEMO which is useful to 4D VAR assimilation.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/definitions.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/definitions.rst	(revision 12062)
+++ 	(revision )
@@ -1,33 +1,0 @@
-***********
-Definitions
-***********
-
-`AGRIF`_
-	*Adaptive Grid Refinement In Fortran*, 
-	package for the integration of full adaptive mesh refinement features within 
-	an existing multidimensional finite difference model
-
-SI\ :sup:`3`\ 
-	*Sea Ice Integrated Initiative*, 
-	unified sea ice model merging functionalities from CICE, GELATO and LIM into the NEMO framework
-
-`OASIS`_
-	*Ocean Atmosphere Sea Ice Soil*, 
-	coupling software to synchronise numerical codes representing different components of the climate system
-
-PISCES
-	*Pelagic Interactions Scheme for Carbon and Ecosystem Studies*, 
-	biogeochemical model simulating marine ecosystems, cycles of carbon and the main nutrients
-
-TAM
-	*Tangent linear and Adjoint Model*, 
-	tools to analyse and control the NEMO dynamical core for a wide range of applications such as
-	sensitivity analysis, parameter estimation, vectors computation or data assimilation.
-
-TOP
-	*Tracers in Ocean Paradigm*, 
-	on/off-line oceanic tracers transport and biogeochemistry models
-
-`XIOS`_
-	*XML Input Output Server*, 
-	library dedicated to input/output management of climate code
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/diagnostics.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/diagnostics.rst	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../../cfgs/SHARED/README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/diags.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/diags.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/diags.rst	(revision 12143)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/docutils.conf
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/docutils.conf	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/docutils.conf	(revision 12143)
@@ -0,0 +1,2 @@
+[restructuredtext parser]
+syntax_highlight = short
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/global.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/global.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/global.rst	(revision 12143)
@@ -1,39 +1,79 @@
-.. Roles (custom styles related to CSS classes in 'source/_static/style.css')
+.. Roles
 
-.. role:: rstblue
-.. role:: rstgreen
-.. role:: rstgrey
-.. role:: rstgreysup(sup)
-.. role:: underline 
-   :class: underline
+.. custom styles related to CSS classes in './_static/style.css'
+
+.. role:: blue
+.. role:: green
+.. role:: grey
+.. role:: greysup(sup)
+
+.. inline code snippets
+
+.. role:: python(code)
+   :language: python
+   :class: highlight
+
+.. role:: fortran(code)
+   :language: fortran
+   :class: highlight
+
+.. role:: console(code)
+   :language: console
+   :class: highlight
 
 .. Substitutions
 
-.. |OPA| replace:: :rstblue:`NEMO-OPA`
-.. |SI3| replace:: :rstgrey:`NEMO-SI`\ :rstgreysup:`3`
-.. |TOP| replace:: :rstgreen:`NEMO-TOP/PISCES`
+.. |NEMO-OCE| replace::  :blue:`NEMO-OCE (Ocean dynamics)`
+.. |OCE|      replace::  :blue:`NEMO-OCE`
+.. |NEMO-ICE| replace::  :grey:`NEMO-SI`\ :greysup:`3`  :grey:`(Sea Ice)`
+.. |ICE|      replace::  :grey:`NEMO-SI`\ :greysup:`3`
+.. |NEMO-MBG| replace:: :green:`NEMO-TOP/PISCES (Tracers)`
+.. |MBG|      replace:: :green:`NEMO-TOP/PISCES`
 
-.. Institutes
+.. External links
 
-.. _CMCC:           https://www.cmcc.it 
-.. _CNRS:           https://www.cnrs.fr
-.. _Mercator Ocean: https://www.mercator-ocean.fr
-.. _Met Office:     https://www.metoffice.gov.uk
-.. _MOI:            https://www.mercator-ocean.fr
-.. _NERC:           https://nerc.ukri.org
+   .. Consortium institutes
 
-.. Models / Softwares
+.. _CMCC:       https://www.cmcc.it
+.. _CNRS:       https://www.cnrs.fr
+.. _Met Office: https://www.metoffice.gov.uk
+.. _MOI:        https://www.mercator-ocean.fr
+.. _NERC:       https://nerc.ukri.org
+
+   .. Models / Libraries / Dependencies
 
 .. _AGRIF:  http://agrif.imag.fr
-.. _FCM:    https://metomi.github.io/fcm/doc/
+.. _BFM:    http://www.bfm-community.eu
+.. _FCM:    https://metomi.github.io/fcm
 .. _IOIPSL: https://forge.ipsl.jussieu.fr/igcmg/browser/IOIPSL
+.. _NEMO:   https://www.nemo-ocean.eu
 .. _OASIS:  https://portal.enes.org/oasis
+.. _XIOS:   https://forge.ipsl.jussieu.fr/ioserver
 
-.. NEMO
+   .. Misc.
 
-.. _NEMO:          https://www.nemo-ocean.eu
-.. _NEMO strategy: https://doi.org/10.5281/zenodo.1471663
-.. _NEMO guide:    :samp: https://doi.org/10.5281/zenodo.1475325
-.. _NEMO manual:   https://doi.org/10.5281/zenodo.1464816
-.. _SI3 manual:    :samp: https://doi.org/10.5281/zenodo.1471689
-.. _TOP manual:    :samp: https://doi.org/10.5281/zenodo.1471700
+.. _EGU: http://www.egu.eu
+.. _Special Issue: https://www.geosci-model-dev.net/special_issue40.html
+.. _BFM man: https://cmcc-foundation.github.io/www.bfm-community.eu/files/bfm-nemo-manual_r1.0_201508.pdf
+.. _RST man: https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html
+.. _PAPA station: http://www.pmel.noaa.gov/OCS/Papa/index-Papa.shtml
+.. _ISOMIP: http://staff.acecrc.org.au/~bkgalton/ISOMIP/test_cavities.pdf
+
+.. DOI
+
+   .. Publications (`:samp:` to deactivate link for unpublished documents)
+
+.. _DOI man OCE:          https://doi.org/10.5281/zenodo.1464816
+.. _DOI man ICE:   :samp: https://doi.org/10.5281/zenodo.1471689
+.. _DOI man MBG:   :samp: https://doi.org/10.5281/zenodo.1471700
+.. _DOI qsg:       :samp: https://doi.org/10.5281/zenodo.1475325
+.. _DOI dev  stgy:        https://doi.org/10.5281/zenodo.1471663
+.. _DOI data:             https://doi.org/10.5281/zenodo.1472245
+
+   .. Badges (same labels as previously, substitution to link images)
+
+.. |DOI man OCE| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1464816.svg
+.. |DOI man ICE| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1471689.svg
+.. |DOI man MBG| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1471700.svg
+.. |DOI qsg|     image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1475325.svg
+.. |DOI data|    image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1472245.svg
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/guide.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/guide.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/guide.rst	(revision 12143)
@@ -0,0 +1,76 @@
+#################
+Quick Start Guide
+#################
+
+.. For headings markup, this convention is recommended from Python’s Style Guide
+   # with overline, for parts
+   * with overline, for chapters
+   =, for sections
+   -, for subsections
+   ^, for subsubsections
+   ", for paragraphs
+
+   'global.rst' contains a list of roles, substitutions and URL links for the guide.
+   It is loaded for each file with the 'rst_epilog' setting in 'conf.py'
+
+.. toctree::
+   :hidden:
+
+   todos
+
+.. Only displayed with 'make drafthtml'
+
+.. toctree::
+   :hidden:
+   :caption: Unpublished READMEs
+   :glob:
+   :titlesonly:
+
+   unpub/*
+
+.. Only displayed with 'make drafthtml'
+
+.. toctree::
+   :hidden:
+   :caption: Getting started
+
+   install
+   cfgs
+   tests
+
+.. toctree::
+   :hidden:
+   :caption: Setup your configuration
+
+   setup
+   diags
+   tools
+
+.. toctree::
+   :hidden:
+   :caption: Advanced use
+
+   zooms
+   cplg
+   da
+   tracers
+
+.. toctree::
+   :hidden:
+   :caption: Miscellaneous
+
+   cite
+   contrib
+   changes
+   acro
+
+:Release:  |release|
+
+.. only:: draft
+
+   .. Only on draft
+
+   :*Date*:     |today|
+   :*SVN rev*:  |revision|
+
+.. include:: readme.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/ref.bib
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/ref.bib	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/ref.bib	(revision 12143)
@@ -0,0 +1,1 @@
+link ../../../REFERENCES.bib
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/references.bib
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/references.bib	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../../REFERENCES.bib
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/release_notes.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/release_notes.rst	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../../RELEASE_NOTES.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/setup.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/setup.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/setup.rst	(revision 12143)
@@ -1,249 +1,1 @@
-******************************
-Setting up a new configuration
-******************************
-
-.. contents::
-
-Starting from an existing configuration
-=======================================
-
-There are three options to build a new configuration from an existing one:
-
-Option 1: Duplicate an existing configuration
----------------------------------------------
-
-The NEMO so-called Reference Configurations cover a number of major features for NEMO setup
-(global, regional, 1D, using embeded zoom with AGRIF...)
-
-One can create a new configuration by duplicating one of the reference configurations
-(``ORCA2_ICE_PISCES`` in the following example)
-
-.. code-block:: sh
-
-	makenemo –n 'ORCA2_ICE_PISCES_MINE' -r 'ORCA2_ICE_PISCES'
-
-Option 2: Duplicate with differences
-------------------------------------
-
-Create and compile a new configuration based on a reference configuration
-(``ORCA2_ICE_PISCES`` in the following example) but with different pre-processor options.
-For this either add ``add_key`` or ``del_key`` keys as required; e.g.
-
-.. code-block:: sh
-
-	makenemo –n 'ORCA2_ICE_PISCES_MINE' -r 'ORCA2_ICE_PISCES' del_key 'key_iomput' add_key 'key_diahth'
-
-Option 3: Use the SIREN tools to subset an existing model
----------------------------------------------------------
-
-Define a regional configuration which is a sub- or super-set of an existing configuration.
-
-This last option employs the SIREN software tools that are included in the standard distribution.
-The software is written in Fortran 95 and available in the ``./tools/SIREN`` directory.
-SIREN allows you to create your own regional configuration embedded in a wider one.
-
-SIREN is a set of programs to create all the input files you need to run a NEMO regional configuration.
-As a basic demonstrator, a set of GLORYS files (GLObal ReanalYSis on the ORCA025 grid),
-as well as examples of namelists are available `here`_.
-
-`SIREN documentation`_
-
-Any questions or comments regarding the use of SIREN should be posted in `the corresponding forum`_.
-
-Creating a completely new configuration
-=======================================
-
-From NEMO version 4.0 there are two ways to build configurations from scratch.
-The appropriate method to use depends largely on the target configuration.
-Method 1 is for more complex/realistic global or regional configurations and
-method 2 is intended for simpler, idealised configurations whose
-domains and characteristics can be described in simple geometries and formulae.
-
-Option 1: Create and use a domain configuration file
-----------------------------------------------------
-
-This method is used by each of the reference configurations,
-so that downloading their input files linked to their description can help.
-Although starting from scratch, it is advisable to create the directory structure to house your new configuration by
-duplicating the closest reference configuration to your target application.
-For example, if your application requires both ocean ice and passive tracers,
-then use the ``ORCA2_ICE_PISCES`` as template,
-and execute following command to build your ``MY_NEW_CONFIG`` configuration:
-
-.. code-block:: sh
-
-	makenemo –n 'MY_NEW_CONFIG' -r 'ORCA2_ICE_PISCES'
-
-where ``MY_NEW_CONFIG`` can be substituted with a suitably descriptive name for your new configuration.  
-
-The purpose of this step is simply to create and populate the appropriate ``WORK``, ``MY_SRC`` and
-``EXP00`` subdirectories for your new configuration.
-Other choices for the base reference configuration might be
-
-- ``GYRE``  - If your target application is ocean-only
-- ``AMM12`` - If your target application is regional with open boundaries
-
-All the domain information for your new configuration will be contained within
-a netcdf file called ``domain_cfg.nc`` which you will need to create and
-place in the ``./cfgs/MY_NEW_CONFIG/EXP00`` sub-directory.
-Firstly though, ensure that your configuration is set to use such a file by checking that
-
-.. code-block:: fortran
-
-	ln_read_cfg = .true.
-
-in	``./cfgs/MY_NEW_CONFIG/EXP00/namelist_cfg``
-
-Create the domain_cfg.nc file which must contain the following fields
-
-.. code-block:: c++
-
-	int    ORCA, ORCA_index                  /* configuration name, configuration resolution                 */
-	int    jpiglo, jpjglo, jpkglo            /* global domain sizes                                          */
-	int    jperio                            /* lateral global domain b.c.                                   */
-	int    ln_zco, ln_zps, ln_sco            /* flags for z-coord, z-coord with partial steps and s-coord    */
-	int    ln_isfcav                         /* flag  for ice shelf cavities                                 */
-	double glamt, glamu, glamv, glamf        /* geographic position                                          */
-	double gphit, gphiu, gphiv, gphif        /* geographic position                                          */
-	double iff, ff_f, ff_t                   /* Coriolis parameter (if not on the sphere)                    */
-	double e1t, e1u, e1v, e1f                /* horizontal scale factors                                     */
-	double e2t, e2u, e2v, e2f                /* horizontal scale factors                                     */
-	double ie1e2u_v, e1e2u, e1e2v            /* U and V surfaces (if grid size reduction in some straits)    */
-	double e3t_1d, e3w_1d                    /* reference vertical scale factors at T and W points           */
-	double e3t_0, e3u_0, e3v_0, e3f_0, e3w_0 /* vertical scale factors 3D coordinate at T,U,V,F and W points */
-	double e3uw_0, e3vw_0                    /* vertical scale factors 3D coordinate at UW and VW points     */
-	int    bottom_level, top_level           /* last wet T-points, 1st wet T-points (for ice shelf cavities) */
-
-There are two options for creating a domain_cfg.nc file:
-
-- Users can use tools of their own choice to build a ``domain_cfg.nc`` with all mandatory fields.
-- Users can adapt and apply the supplied tool available in ``./tools/DOMAINcfg``.
-  This tool is based on code extracted from NEMO version 3.6 and will allow similar choices for
-  the horizontal and vertical grids that were available internally to that version.
-  See ``./tools/DOMAINcfg/README`` for details.
-
-Option 2: Adapt the usr_def configuration module of NEMO for you own purposes
------------------------------------------------------------------------------
-
-This method is intended for configuring easily simple/idealised configurations which
-are often used as demonstrators or for process evaluation and comparison.
-This method can be used whenever the domain geometry has a simple mathematical description and
-the ocean initial state and boundary forcing is described analytically. 
-As a start, consider the case of starting a completely new ocean-only test case based on
-the ``LOCK_EXCHANGE`` example.
-.. [Note: we probably need an even more basic example than this with only one namelist and
-minimal changes to the usrdef modules]
-
-Firstly, construct the directory structure, starting in the ``cfgs`` directory:
-
-.. code-block:: sh
-
-	./makenemo -n 'MY_NEW_TEST' -t 'LOCK_EXCHANGE'
-
-where the ``-t`` option has been used to locate the new configuration in the ``tests`` subdirectory
-(it is recommended practice to keep full configurations and idealised cases clearly distinguishable).
-This command will create (amongst others) the following files and directories::
-
-	./tests/MY_NEW_TEST:
-	BLD	  MY_SRC cpp_MY_NEW_TEST.fcm
-	EXP00   WORK
-	#
-	./tests/MY_NEW_TEST/EXP00:
-	context_nemo.xml       domain_def_nemo.xml
-	field_def_nemo-opa.xml file_def_nemo-opa.xml
-	iodef.xml
-	namelist_cfg
-	namelist_ref
-	#
-	./tests/MY_NEW_TEST/MY_SRC:
-	usrdef_hgr.F90    usrdef_nam.F90 usrdef_zgr.F90
-	usrdef_istate.F90 usrdef_sbc.F90 zdfini.F90
-
-The key to setting up an idealised configuration lies in adapting a small set of short Fortran 90 modules which
-should be dropped into the ``MY_SRC`` directory.
-Here the ``LOCK_EXCHANGE`` example is using 5 such routines but the full set that is available in
-the ``src/OCE/USR`` directory is::
-
-	./src/OCE/USR:
-	usrdef_closea.F90 usrdef_istate.F90 usrdef_zgr.F90
-	usrdef_fmask.F90  usrdef_nam.F90
-	usrdef_hgr.F90    usrdef_sbc.F90
-
-Before discussing these in more detail it is worth noting the various namelist controls that
-engage the different user-defined aspects.
-These controls are set using two new logical switches or are implied by the settings of existing ones.
-For example, the mandatory requirement for an idealised configuration is to provide routines which
-define the horizontal and vertical domains.
-Templates for these are provided in the ``usrdef_hgr.F90`` and ``usrdef_zgr.F90`` modules.
-The application of these modules is activated whenever:
-
-.. code-block:: fortran
-
-	ln_read_cfg = .false.
-
-in any configuration's ``namelist_cfg`` file.
-This setting also activates the reading of an optional ``nam_usrdef`` namelist which can be used to
-supply configuration specific settings.
-These need to be declared and read in the ``usrdef_nam.F90`` module.
-
-Another explicit control is available in the ``namsbc`` namelist which activates the use of analytical forcing.
-With
-
-.. code-block:: fortran
-
-	ln_usr = .true.
-
-Other usrdef modules are activated by less explicit means.
-For example, code in ``usrdef_istate.F90`` is used to define initial temperature and salinity fields if
-
-.. code-block:: fortran
-
-	ln_tsd_init   = .false.
-
-in the ``namtsd`` namelist.
-The remaining modules, namely::
-
-	usrdef_closea.F90 usrdef_fmask.F90
-
-are specific to ORCA configurations and set local variations of some specific fields for
-the various resolutions of the global models.
-They do not need to be considered here in the context of idealised cases but it is worth noting that all
-configuration specific code has now been isolated in the usrdef modules.
-In the case of these last two modules, they are activated only if an ORCA configuration is detected.
-Currently, this requires a specific integer variable named ``ORCA`` to be set in a ``domain_cfg.nc`` file.
-.. [Note: this would be less confusing if the cn_cfg string is read directly as a character attribue from
-the ``domain_cfg.nc`` ]
-
-So, in most cases, the set up of idealised model configurations can be completed by
-copying the template routines from ``./src/OCE/USR`` into
-your new ``./cfgs/MY_NEW_TEST/MY_SRC`` directory and editing the appropriate modules as needed.
-The default set are those used for the GYRE reference configuration.
-The contents of ``MY_SRC`` directories from other idealised configurations may provide more convenient templates if
-they share common characteristics with your target application.
-
-Whatever the starting point, it should not require too many changes or additional lines of code to
-produce routines in ``./src/OCE/USR`` that define analytically the domain,
-the initial state and the surface boundary conditions for your new configuration.
-
-To summarize, the base set of modules is:
-
-- ``usrdef_hgr.F90``   : define horizontal grid
-- ``usrdef_zgr.F90``   : define vertical grid
-- ``usrdef_sbc.F90``   : provides at each time-step the surface boundary condition, i.e. the momentum, heat and freshwater fluxes
-- ``usrdef_istate.F90``: defines initialization of the dynamics and tracers
-- ``usrdef_nam.F90``   : configuration-specific namelist processing to set any associated run-time parameters
-
-with two specialised ORCA modules
-(not related to idealised configurations but used to isolate configuration specific code that is used in
-ORCA2 reference configurations and established global configurations using the ORCA tripolar grid):
-
-- ``usrdef_fmask.F90`` : only used in ORCA CONFIGURATIONS for alteration of f-point land/ocean mask in some straits
-- ``usrdef_closea.F90``: only used in ORCA CONFIGURATIONS for specific treatments associated with closed seas
-
-From version 4.0, the NEMO release includes a ``tests`` subdirectory containing available and
-up to date test cases build by the community.
-These will not be fully supported as are NEMO reference configurations, but should provide a source of raw material.
-
-.. _here:                     http://prodn.idris.fr/thredds/catalog/ipsl_public/rron463/catalog.html?dataset=DatasetScanipsl_public/rron463/INPUT_SIREN.tar
-.. _the corresponding forum:  http://forge.ipsl.jussieu.fr/nemo/discussion/forum/2
-.. _SIREN documentation:      http://forge.ipsl.jussieu.fr/nemo/doxygen/index.html
+link ../../../src/OCE/USR/README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/test_cases.bib
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/test_cases.bib	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../../tests/test_cases.bib
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/test_cases.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/test_cases.rst	(revision 12062)
+++ 	(revision )
@@ -1,1 +1,0 @@
-link ../../../tests/README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/tests.bib
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/tests.bib	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/tests.bib	(revision 12143)
@@ -0,0 +1,1 @@
+link ../../../tests/test_cases.bib
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/tests.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/tests.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/tests.rst	(revision 12143)
@@ -0,0 +1,1 @@
+link ../../../tests/README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/todos.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/todos.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/todos.rst	(revision 12143)
@@ -0,0 +1,5 @@
+*********************
+List of editing tasks
+*********************
+
+.. todolist::
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/unpub/crs.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/unpub/crs.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/unpub/crs.rst	(revision 12143)
@@ -0,0 +1,1 @@
+link ../../../../src/OCE/CRS/README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/unpub/doc.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/unpub/doc.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/unpub/doc.rst	(revision 12143)
@@ -0,0 +1,1 @@
+link ../../../README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/unpub/src.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/unpub/src.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/rst/source/unpub/src.rst	(revision 12143)
@@ -0,0 +1,1 @@
+link ../../../../src/README.rst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/tools/shr_func.sh
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/tools/shr_func.sh	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/doc/tools/shr_func.sh	(revision 12143)
@@ -2,11 +2,6 @@
 
 clean() {
-    ## Not sure if this step is needed, guess latexmk should be able to detect a change
     printf "\t¤ Clean previous build"
-    find latex/$1/build -mindepth 1 -prune -not -name $1_manual.pyg -exec rm -rf {} \;
-
-    ## HTML exports
-    #printf '   - possible HTML export'
-    #find latex/$1 -type d -name 'html*'    -exec rm -r {} \;
+    find latex/$1/build -mindepth 1 -delete
 
     echo
@@ -15,9 +10,7 @@
 build() {
     printf "\t¤ Generation of the PDF format\n"
-    latexmk -r  ./latex/global/latexmkrc  \
-	    -cd ./latex/$1/main/$1_manual \
-	    1> /dev/null
+    latexmk -r  ./latex/global/latexmk.pl -pdfxe ./latex/$1/main/$1_manual \
+#	1> /dev/null
     [ -f ./latex/$1/build/$1_manual.pdf ] && mv ./latex/$1/build/$1_manual.pdf .
     echo
 }
-
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/ice.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/ice.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/ice.F90	(revision 12143)
@@ -102,4 +102,5 @@
    !! vt_i        |      -      |    Total ice vol. per unit area | m     |
    !! vt_s        |      -      |    Total snow vol. per unit ar. | m     |
+   !! st_i        |      -      |    Total Sea ice salt content   | pss.m |
    !! sm_i        |      -      |    Mean sea ice salinity        | pss   |
    !! tm_i        |      -      |    Mean sea ice temperature     | K     |
@@ -109,4 +110,5 @@
    !! bv_i        |      -      |    relative brine volume        | ???   | 
    !! at_ip       |      -      |    Total ice pond concentration |       |
+   !! hm_ip       |      -      |    Mean ice pond depth          | m     |
    !! vt_ip       |      -      |    Total ice pond vol. per unit area| m |
    !!=====================================================================
@@ -135,5 +137,4 @@
    REAL(wp), PUBLIC ::   rn_ishlat        !: lateral boundary condition for sea-ice
    LOGICAL , PUBLIC ::   ln_landfast_L16  !: landfast ice parameterizationfrom lemieux2016 
-   LOGICAL , PUBLIC ::   ln_landfast_home !: landfast ice parameterizationfrom home made 
    REAL(wp), PUBLIC ::   rn_depfra        !:    fraction of ocean depth that ice must reach to initiate landfast ice
    REAL(wp), PUBLIC ::   rn_icebfr        !:    maximum bottom stress per unit area of contact (lemieux2016) or per unit volume (home) 
@@ -188,4 +189,5 @@
 
    !                                     !!** ice-ponds namelist (namthd_pnd)
+   LOGICAL , PUBLIC ::   ln_pnd           !: Melt ponds (T) or not (F)
    LOGICAL , PUBLIC ::   ln_pnd_H12       !: Melt ponds scheme from Holland et al 2012
    LOGICAL , PUBLIC ::   ln_pnd_CST       !: Melt ponds scheme with constant fraction and depth
@@ -196,4 +198,6 @@
    !                                     !!** ice-diagnostics namelist (namdia) **
    LOGICAL , PUBLIC ::   ln_icediachk     !: flag for ice diag (T) or not (F)
+   REAL(wp), PUBLIC ::   rn_icechk_cel    !: rate of ice spuriously gained/lost (at any gridcell)
+   REAL(wp), PUBLIC ::   rn_icechk_glo    !: rate of ice spuriously gained/lost (globally)
    LOGICAL , PUBLIC ::   ln_icediahsb     !: flag for ice diag (T) or not (F)
    LOGICAL , PUBLIC ::   ln_icectl        !: flag for sea-ice points output (T) or not (F)
@@ -213,7 +217,4 @@
    REAL(wp), PUBLIC, PARAMETER ::   epsi20 = 1.e-20_wp  !: small number 
 
-   !                                     !!** some other parameters for advection using the ULTIMATE-MACHO scheme
-   LOGICAL, PUBLIC, DIMENSION(2) :: l_split_advumx = .FALSE.    ! force one iteration at the first time-step
-
    !                                     !!** define arrays
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   u_oce,v_oce !: surface ocean velocity used in ice dynamics
@@ -251,6 +252,4 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_res     !: mass flux from residual component of wfx_ice             [kg.m-2.s-1]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wfx_err_sub !: mass flux error after sublimation                        [kg.m-2.s-1]
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   afx_tot     !: ice concentration tendency (total)        [s-1]
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sfx_bog     !: salt flux due to ice bottom growth                   [pss.kg.m-2.s-1 => g.m-2.s-1]
@@ -309,4 +308,5 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   u_ice, v_ice !: components of the ice velocity                          (m/s)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   vt_i , vt_s  !: ice and snow total volume per unit area                 (m)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   st_i         !: Total ice salinity content                              (pss.m)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   at_i         !: ice total fractional area (ice concentration)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ato_i        !: =1-at_i ; total open water fractional area
@@ -328,11 +328,12 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   sz_i     !: ice salinity          [PSS]
 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   a_ip       !: melt pond fraction per grid cell area
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   a_ip       !: melt pond concentration
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   v_ip       !: melt pond volume per grid cell area      [m]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   a_ip_frac  !: melt pond volume per ice area
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   h_ip       !: melt pond thickness                      [m]
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   at_ip      !: total melt pond fraction
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   vt_ip      !: total melt pond volume per unit area     [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   a_ip_frac  !: melt pond fraction (a_ip/a_i)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   h_ip       !: melt pond depth                          [m]
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   at_ip      !: total melt pond concentration
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   hm_ip      !: mean melt pond depth                     [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   vt_ip      !: total melt pond volume per gridcell area [m]
 
    !!----------------------------------------------------------------------
@@ -355,7 +356,4 @@
    !! * Ice diagnostics
    !!----------------------------------------------------------------------
-   ! thd refers to changes induced by thermodynamics
-   ! trp   ''         ''     ''       advection (transport of ice)
-   !
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   diag_trp_vi   !: transport of ice volume
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   diag_trp_vs   !: transport of snw volume
@@ -369,4 +367,13 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   diag_vsnw     !: snw volume variation   [m/s] 
 
+   !!----------------------------------------------------------------------
+   !! * Ice conservation
+   !!----------------------------------------------------------------------
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   diag_v        !: conservation of ice volume
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   diag_s        !: conservation of ice salt
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   diag_t        !: conservation of ice heat
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   diag_fv       !: conservation of ice volume
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   diag_fs       !: conservation of ice salt
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   diag_ft       !: conservation of ice heat
    !
    !!----------------------------------------------------------------------
@@ -393,5 +400,5 @@
       INTEGER :: ice_alloc
       !
-      INTEGER :: ierr(15), ii
+      INTEGER :: ierr(16), ii
       !!-----------------------------------------------------------------
       ierr(:) = 0
@@ -409,5 +416,5 @@
          &      wfx_bog    (jpi,jpj) , wfx_dyn   (jpi,jpj) , wfx_bom(jpi,jpj) , wfx_sum(jpi,jpj) ,           &
          &      wfx_res    (jpi,jpj) , wfx_sni   (jpi,jpj) , wfx_opw(jpi,jpj) , wfx_spr(jpi,jpj) ,           &
-         &      afx_tot    (jpi,jpj) , rn_amax_2d(jpi,jpj),                                                  &
+         &      rn_amax_2d (jpi,jpj) ,                                                                       &
          &      qsb_ice_bot(jpi,jpj) , qlead     (jpi,jpj) ,                                                 &
          &      sfx_res    (jpi,jpj) , sfx_bri   (jpi,jpj) , sfx_dyn(jpi,jpj) , sfx_sub(jpi,jpj) , sfx_lam(jpi,jpj) ,  &
@@ -429,7 +436,7 @@
       ii = ii + 1
       ALLOCATE( u_ice(jpi,jpj) , v_ice(jpi,jpj) ,                                   &
-         &      vt_i (jpi,jpj) , vt_s (jpi,jpj) , at_i(jpi,jpj) , ato_i(jpi,jpj) ,  &
-         &      et_i (jpi,jpj) , et_s (jpi,jpj) , tm_i(jpi,jpj) , tm_s (jpi,jpj) ,  &
-         &      sm_i (jpi,jpj) , tm_su(jpi,jpj) , hm_i(jpi,jpj) , hm_s (jpi,jpj) ,  &
+         &      vt_i (jpi,jpj) , vt_s (jpi,jpj) , st_i(jpi,jpj) , at_i(jpi,jpj) , ato_i(jpi,jpj) ,  &
+         &      et_i (jpi,jpj) , et_s (jpi,jpj) , tm_i(jpi,jpj) , tm_s(jpi,jpj) ,  &
+         &      sm_i (jpi,jpj) , tm_su(jpi,jpj) , hm_i(jpi,jpj) , hm_s(jpi,jpj) ,  &
          &      om_i (jpi,jpj) , bvm_i(jpi,jpj) , tau_icebfr(jpi,jpj)            , STAT=ierr(ii) )
 
@@ -444,5 +451,5 @@
 
       ii = ii + 1
-      ALLOCATE( at_ip(jpi,jpj) , vt_ip(jpi,jpj) , STAT = ierr(ii) )
+      ALLOCATE( at_ip(jpi,jpj) , hm_ip(jpi,jpj) , vt_ip(jpi,jpj) , STAT = ierr(ii) )
 
       ! * Old values of global variables
@@ -465,4 +472,9 @@
          &      diag_sice  (jpi,jpj) , diag_vice   (jpi,jpj) , diag_vsnw  (jpi,jpj), STAT=ierr(ii) )
 
+      ! * Ice conservation
+      ii = ii + 1
+      ALLOCATE( diag_v (jpi,jpj) , diag_s (jpi,jpj) , diag_t (jpi,jpj),   & 
+         &      diag_fv(jpi,jpj) , diag_fs(jpi,jpj) , diag_ft(jpi,jpj), STAT=ierr(ii) )
+      
       ! * SIMIP diagnostics
       ii = ii + 1
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icealb.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icealb.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icealb.F90	(revision 12143)
@@ -192,8 +192,8 @@
       REWIND( numnam_ice_ref )              ! Namelist namalb in reference namelist : Albedo parameters
       READ  ( numnam_ice_ref, namalb, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namalb in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namalb in reference namelist' )
       REWIND( numnam_ice_cfg )              ! Namelist namalb in configuration namelist : Albedo parameters
       READ  ( numnam_ice_cfg, namalb, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namalb in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namalb in configuration namelist' )
       IF(lwm) WRITE( numoni, namalb )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icecor.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icecor.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icecor.F90	(revision 12143)
@@ -17,5 +17,5 @@
    USE phycst         ! physical constants
    USE ice            ! sea-ice: variable
-   USE ice1D          ! sea-ice: thermodynamic sea-ice variables
+   USE ice1D          ! sea-ice: thermodynamic variables
    USE iceitd         ! sea-ice: rebining
    USE icevar         ! sea-ice: operations
@@ -60,4 +60,5 @@
       IF( ln_timing    )   CALL timing_start('icecor')                                                             ! timing
       IF( ln_icediachk )   CALL ice_cons_hsm(0, 'icecor', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
+      IF( ln_icediachk )   CALL ice_cons2D  (0, 'icecor',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
       !
       IF( kt == nit000 .AND. lwp .AND. kn == 2 ) THEN
@@ -78,5 +79,5 @@
       !                             !-----------------------------------------------------
       at_i(:,:) = SUM( a_i(:,:,:), dim=3 )
-      DO jl  = 1, jpl
+      DO jl = 1, jpl
          WHERE( at_i(:,:) > rn_amax_2d(:,:) )   a_i(:,:,jl) = a_i(:,:,jl) * rn_amax_2d(:,:) / at_i(:,:)
       END DO
@@ -84,5 +85,5 @@
       !                             !-----------------------------------------------------
       IF ( nn_icesal == 2 ) THEN    !  salinity must stay in bounds [Simin,Simax]        !
-      !                             !-----------------------------------------------------
+         !                          !-----------------------------------------------------
          zzc = rhoi * r1_rdtice
          DO jl = 1, jpl
@@ -117,12 +118,7 @@
             END DO
          END DO
-         CALL lbc_lnk_multi( 'icecor', u_ice, 'U', -1., v_ice, 'V', -1. )            ! lateral boundary conditions
+         CALL lbc_lnk_multi( 'icecor', u_ice, 'U', -1., v_ice, 'V', -1. )
       ENDIF
 
-!!gm I guess the trends are only out on demand 
-!!   So please, only do this is it exite an iom_use of on a these variables
-!!   furthermore, only allocate the diag_ arrays in this case 
-!!   and do the iom_put here so that it is only a local allocation
-!!gm 
       !                             !-----------------------------------------------------
       SELECT CASE( kn )             !  Diagnostics                                       !
@@ -130,20 +126,16 @@
       CASE( 1 )                        !--- dyn trend diagnostics
          !
-!!gm   here I think the number of ice cat is too small to use a SUM instruction...
-         DO jj = 1, jpj
-            DO ji = 1, jpi            
-               !                 ! heat content variation (W.m-2)
-               diag_heat(ji,jj) = - (  SUM( e_i(ji,jj,1:nlay_i,:) - e_i_b(ji,jj,1:nlay_i,:) )    & 
-                  &                  + SUM( e_s(ji,jj,1:nlay_s,:) - e_s_b(ji,jj,1:nlay_s,:) )  ) * r1_rdtice
-               !                 ! salt, volume
-               diag_sice(ji,jj) = SUM( sv_i(ji,jj,:) - sv_i_b(ji,jj,:) ) * rhoi * r1_rdtice
-               diag_vice(ji,jj) = SUM( v_i (ji,jj,:) - v_i_b (ji,jj,:) ) * rhoi * r1_rdtice
-               diag_vsnw(ji,jj) = SUM( v_s (ji,jj,:) - v_s_b (ji,jj,:) ) * rhos * r1_rdtice
-            END DO
-         END DO
+         IF( ln_icediachk .OR. iom_use('hfxdhc') ) THEN
+            diag_heat(:,:) = - SUM(SUM( e_i (:,:,1:nlay_i,:) - e_i_b (:,:,1:nlay_i,:), dim=4 ), dim=3 ) * r1_rdtice &      ! W.m-2
+               &             - SUM(SUM( e_s (:,:,1:nlay_s,:) - e_s_b (:,:,1:nlay_s,:), dim=4 ), dim=3 ) * r1_rdtice
+            diag_sice(:,:) =   SUM(     sv_i(:,:,:)          - sv_i_b(:,:,:)                  , dim=3 ) * r1_rdtice * rhoi
+            diag_vice(:,:) =   SUM(     v_i (:,:,:)          - v_i_b (:,:,:)                  , dim=3 ) * r1_rdtice * rhoi
+            diag_vsnw(:,:) =   SUM(     v_s (:,:,:)          - v_s_b (:,:,:)                  , dim=3 ) * r1_rdtice * rhos
+         ENDIF
          !                       ! concentration tendency (dynamics)
-         zafx   (:,:) = SUM( a_i(:,:,:) - a_i_b(:,:,:), dim=3 ) * r1_rdtice 
-         afx_tot(:,:) = zafx(:,:)
-         IF( iom_use('afxdyn') )   CALL iom_put( 'afxdyn' , zafx(:,:) )
+         IF( iom_use('afxdyn') .OR. iom_use('afxthd') .OR. iom_use('afxtot') ) THEN 
+            zafx(:,:) = SUM( a_i(:,:,:) - a_i_b(:,:,:), dim=3 ) * r1_rdtice 
+            CALL iom_put( 'afxdyn' , zafx )
+         ENDIF
          !
       CASE( 2 )                        !--- thermo trend diagnostics & ice aging
@@ -151,29 +143,32 @@
          oa_i(:,:,:) = oa_i(:,:,:) + a_i(:,:,:) * rdt_ice   ! ice natural aging incrementation
          !
-!!gm   here I think the number of ice cat is too small to use a SUM instruction...
-         DO jj = 1, jpj
-            DO ji = 1, jpi            
-               !                 ! heat content variation (W.m-2)
-               diag_heat(ji,jj) = diag_heat(ji,jj) - (  SUM( e_i(ji,jj,1:nlay_i,:) - e_i_b(ji,jj,1:nlay_i,:) )    & 
-                  &                                   + SUM( e_s(ji,jj,1:nlay_s,:) - e_s_b(ji,jj,1:nlay_s,:) )  ) * r1_rdtice
-               !                 ! salt, volume
-               diag_sice(ji,jj) = diag_sice(ji,jj) + SUM( sv_i(ji,jj,:) - sv_i_b(ji,jj,:) ) * rhoi * r1_rdtice
-               diag_vice(ji,jj) = diag_vice(ji,jj) + SUM( v_i (ji,jj,:) - v_i_b (ji,jj,:) ) * rhoi * r1_rdtice
-               diag_vsnw(ji,jj) = diag_vsnw(ji,jj) + SUM( v_s (ji,jj,:) - v_s_b (ji,jj,:) ) * rhos * r1_rdtice
-            END DO
-         END DO
+         IF( ln_icediachk .OR. iom_use('hfxdhc') ) THEN
+            diag_heat(:,:) = diag_heat(:,:) &
+               &             - SUM(SUM( e_i (:,:,1:nlay_i,:) - e_i_b (:,:,1:nlay_i,:), dim=4 ), dim=3 ) * r1_rdtice &
+               &             - SUM(SUM( e_s (:,:,1:nlay_s,:) - e_s_b (:,:,1:nlay_s,:), dim=4 ), dim=3 ) * r1_rdtice
+            diag_sice(:,:) = diag_sice(:,:) &
+               &             + SUM(     sv_i(:,:,:)          - sv_i_b(:,:,:)                  , dim=3 ) * r1_rdtice * rhoi
+            diag_vice(:,:) = diag_vice(:,:) &
+               &             + SUM(     v_i (:,:,:)          - v_i_b (:,:,:)                  , dim=3 ) * r1_rdtice * rhoi
+            diag_vsnw(:,:) = diag_vsnw(:,:) &
+               &             + SUM(     v_s (:,:,:)          - v_s_b (:,:,:)                  , dim=3 ) * r1_rdtice * rhos
+            CALL iom_put ( 'hfxdhc' , diag_heat ) 
+         ENDIF
          !                       ! concentration tendency (total + thermo)
-         zafx   (:,:) = SUM( a_i(:,:,:) - a_i_b(:,:,:), dim=3 ) * r1_rdtice
-         afx_tot(:,:) = afx_tot(:,:) + zafx(:,:)
-         IF( iom_use('afxthd') )   CALL iom_put( 'afxthd' , zafx(:,:) )
-         IF( iom_use('afxtot') )   CALL iom_put( 'afxtot' , afx_tot(:,:) )
+         IF( iom_use('afxdyn') .OR. iom_use('afxthd') .OR. iom_use('afxtot') ) THEN 
+            zafx(:,:) = zafx(:,:) + SUM( a_i(:,:,:) - a_i_b(:,:,:), dim=3 ) * r1_rdtice
+            CALL iom_put( 'afxthd' , SUM( a_i(:,:,:) - a_i_b(:,:,:), dim=3 ) * r1_rdtice )
+            CALL iom_put( 'afxtot' , zafx )
+         ENDIF
          !
       END SELECT
       !
       ! controls
-      IF( ln_icediachk   )   CALL ice_cons_hsm(1, 'icecor', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
-      IF( ln_ctl         )   CALL ice_prt3D   ('icecor')                                                             ! prints
-      IF( ln_icectl .AND. kn == 2 )   CALL ice_prt( kt, iiceprt, jiceprt, 2, ' - Final state - ' )                   ! prints
-      IF( ln_timing      )   CALL timing_stop ('icecor')                                                             ! timing
+      IF( ln_ctl       )   CALL ice_prt3D   ('icecor')                                                             ! prints
+      IF( ln_icectl .AND. kn == 2 ) &
+         &                 CALL ice_prt     ( kt, iiceprt, jiceprt, 2, ' - Final state - ' )                       ! prints
+      IF( ln_icediachk )   CALL ice_cons_hsm(1, 'icecor', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
+      IF( ln_icediachk )   CALL ice_cons2D  (1, 'icecor',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
+      IF( ln_timing    )   CALL timing_stop ('icecor')                                                             ! timing
       !
    END SUBROUTINE ice_cor
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icectl.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icectl.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icectl.F90	(revision 12143)
@@ -12,6 +12,7 @@
    !!   'key_si3'                                       SI3 sea-ice model
    !!----------------------------------------------------------------------
-   !!    ice_cons_hsm     : conservation tests on heat, salt and mass
-   !!    ice_cons_final   : conservation tests on heat, salt and mass at end of time step
+   !!    ice_cons_hsm     : conservation tests on heat, salt and mass during a  time step (global) 
+   !!    ice_cons_final   : conservation tests on heat, salt and mass at end of time step (global)
+   !!    ice_cons2D       : conservation tests on heat, salt and mass at each gridcell
    !!    ice_ctl          : control prints in case of crash
    !!    ice_prt          : control prints at a given grid point
@@ -27,4 +28,5 @@
    !
    USE in_out_manager ! I/O manager
+   USE iom            ! I/O manager library
    USE lib_mpp        ! MPP library
    USE lib_fortran    ! fortran utilities (glob_sum + no signed zero)
@@ -37,8 +39,15 @@
    PUBLIC   ice_cons_hsm
    PUBLIC   ice_cons_final
+   PUBLIC   ice_cons2D
    PUBLIC   ice_ctl
    PUBLIC   ice_prt
    PUBLIC   ice_prt3D
 
+   ! thresold rates for conservation
+   !    these values are changed by the namelist parameter rn_icechk, so that threshold = zchk * rn_icechk
+   REAL(wp), PARAMETER ::   zchk_m   = 2.5e-7   ! kg/m2/s <=> 1e-6 m of ice per hour spuriously gained/lost
+   REAL(wp), PARAMETER ::   zchk_s   = 2.5e-6   ! g/m2/s  <=> 1e-6 m of ice per hour spuriously gained/lost (considering s=10g/kg)
+   REAL(wp), PARAMETER ::   zchk_t   = 7.5e-2   ! W/m2    <=> 1e-6 m of ice per hour spuriously gained/lost (considering Lf=3e5J/kg)
+   
    !! * Substitutions
 #  include "vectopt_loop_substitute.h90"
@@ -59,6 +68,5 @@
       !! ** Method  : This is an online diagnostics which can be activated with ln_icediachk=true
       !!              It prints in ocean.output if there is a violation of conservation at each time-step
-      !!              The thresholds (zv_sill, zs_sill, zt_sill) which determine violations are set to
-      !!              a minimum of 1 mm of ice (over the ice area) that is lost/gained spuriously during 100 years.
+      !!              The thresholds (zchk_m, zchk_s, zchk_t) determine violations
       !!              For salt and heat thresholds, ice is considered to have a salinity of 10 
       !!              and a heat content of 3e5 J/kg (=latent heat of fusion) 
@@ -68,109 +76,89 @@
       REAL(wp)        , INTENT(inout) ::   pdiag_v, pdiag_s, pdiag_t, pdiag_fv, pdiag_fs, pdiag_ft
       !!
-      REAL(wp) ::   zv, zs, zt, zfs, zfv, zft
-      REAL(wp) ::   zvmin, zamin, zamax, zeimin, zesmin, zsmin
+      REAL(wp) ::   zdiag_mass, zdiag_salt, zdiag_heat, &
+         &          zdiag_vmin, zdiag_amin, zdiag_amax, zdiag_eimin, zdiag_esmin, zdiag_smin
       REAL(wp) ::   zvtrp, zetrp
-      REAL(wp) ::   zarea, zv_sill, zs_sill, zt_sill
-      REAL(wp), PARAMETER ::   zconv = 1.e-9 ! convert W to GW and kg to Mt
+      REAL(wp) ::   zarea
       !!-------------------------------------------------------------------
       !
       IF( icount == 0 ) THEN
-         !                          ! water flux
-         pdiag_fv = glob_sum( 'icectl',                                                                       &
-            &                 -( wfx_bog(:,:) + wfx_bom(:,:) + wfx_sum(:,:) + wfx_sni(:,:) +                  &
-            &                    wfx_opw(:,:) + wfx_res(:,:) + wfx_dyn(:,:) + wfx_lam(:,:) + wfx_pnd(:,:)  +  &
-            &                    wfx_snw_sni(:,:) + wfx_snw_sum(:,:) + wfx_snw_dyn(:,:) + wfx_snw_sub(:,:) +  &
-            &                    wfx_ice_sub(:,:) + wfx_spr(:,:)  &
-            &                  ) * e1e2t(:,:) ) * zconv
+
+         pdiag_v = glob_sum( 'icectl',   SUM( v_i * rhoi + v_s * rhos, dim=3 ) * e1e2t )
+         pdiag_s = glob_sum( 'icectl',   SUM( sv_i * rhoi            , dim=3 ) * e1e2t )
+         pdiag_t = glob_sum( 'icectl', ( SUM( SUM( e_i, dim=4 ), dim=3 ) + SUM( SUM( e_s, dim=4 ), dim=3 ) ) * e1e2t )
+
+         ! mass flux
+         pdiag_fv = glob_sum( 'icectl',  &
+            &                         ( wfx_bog + wfx_bom + wfx_sum + wfx_sni + wfx_opw + wfx_res + wfx_dyn + wfx_lam + wfx_pnd + &
+            &                           wfx_snw_sni + wfx_snw_sum + wfx_snw_dyn + wfx_snw_sub + wfx_ice_sub + wfx_spr ) * e1e2t )
+         ! salt flux
+         pdiag_fs = glob_sum( 'icectl',  &
+            &                         ( sfx_bri + sfx_bog + sfx_bom + sfx_sum + sfx_sni + &
+            &                           sfx_opw + sfx_res + sfx_dyn + sfx_sub + sfx_lam ) * e1e2t )
+         ! heat flux
+         pdiag_ft = glob_sum( 'icectl',  &
+            &                         (   hfx_sum + hfx_bom + hfx_bog + hfx_dif + hfx_opw + hfx_snw  &
+            &                           - hfx_thd - hfx_dyn - hfx_res - hfx_sub - hfx_spr ) * e1e2t )
+
+      ELSEIF( icount == 1 ) THEN
+
+         ! -- mass diag -- !
+         zdiag_mass = ( glob_sum( 'icectl', SUM( v_i * rhoi + v_s * rhos, dim=3 ) * e1e2t ) - pdiag_v ) * r1_rdtice       &
+            &         + glob_sum( 'icectl', ( wfx_bog + wfx_bom + wfx_sum + wfx_sni + wfx_opw + wfx_res + wfx_dyn +       &
+            &                                 wfx_lam + wfx_pnd + wfx_snw_sni + wfx_snw_sum + wfx_snw_dyn + wfx_snw_sub + &
+            &                                 wfx_ice_sub + wfx_spr ) * e1e2t )                                           &
+            &         - pdiag_fv
          !
-         !                          ! salt flux
-         pdiag_fs = glob_sum( 'icectl',                                                                     &
-            &                  ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
-            &                    sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:) + sfx_sub(:,:) + sfx_lam(:,:)    &
-            &                  ) *  e1e2t(:,:) ) * zconv 
+         ! -- salt diag -- !
+         zdiag_salt = ( glob_sum( 'icectl', SUM( sv_i * rhoi , dim=3 ) * e1e2t ) - pdiag_s ) * r1_rdtice  &
+            &         + glob_sum( 'icectl', ( sfx_bri + sfx_bog + sfx_bom + sfx_sum + sfx_sni +           &
+            &                                 sfx_opw + sfx_res + sfx_dyn + sfx_sub + sfx_lam ) * e1e2t ) &
+            &         - pdiag_fs
          !
-         !                          ! heat flux
-         pdiag_ft = glob_sum( 'icectl',                                                                    &
-            &                  ( hfx_sum(:,:) + hfx_bom(:,:) + hfx_bog(:,:) + hfx_dif(:,:) + hfx_opw(:,:) + hfx_snw(:,:)  & 
-            &                  - hfx_thd(:,:) - hfx_dyn(:,:) - hfx_res(:,:) - hfx_sub(:,:) - hfx_spr(:,:)   &
-            &                  ) *  e1e2t(:,:) ) * zconv
-
-         pdiag_v = glob_sum( 'icectl', SUM( v_i * rhoi + v_s * rhos, dim=3 ) * e1e2t * zconv )
-
-         pdiag_s = glob_sum( 'icectl', SUM( sv_i * rhoi            , dim=3 ) * e1e2t * zconv )
-
-         pdiag_t = glob_sum( 'icectl', (  SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 )     &
-            &                 + SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 ) ) * e1e2t ) * zconv
-
-      ELSEIF( icount == 1 ) THEN
-
-         ! water flux
-         zfv = glob_sum( 'icectl',                                                                        &
-            &             -( wfx_bog(:,:) + wfx_bom(:,:) + wfx_sum(:,:) + wfx_sni(:,:) +                  &
-            &                wfx_opw(:,:) + wfx_res(:,:) + wfx_dyn(:,:) + wfx_lam(:,:) + wfx_pnd(:,:)  +  &
-            &                wfx_snw_sni(:,:) + wfx_snw_sum(:,:) + wfx_snw_dyn(:,:) + wfx_snw_sub(:,:) +  &
-            &                wfx_ice_sub(:,:) + wfx_spr(:,:)  &
-            &              ) * e1e2t(:,:) ) * zconv - pdiag_fv
-
-         ! salt flux
-         zfs = glob_sum( 'icectl',                                                                       &
-            &              ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
-            &                sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:) + sfx_sub(:,:) + sfx_lam(:,:)    & 
-            &              ) * e1e2t(:,:) ) * zconv - pdiag_fs
-
-         ! heat flux
-         zft = glob_sum( 'icectl',                                                                      &
-            &              ( hfx_sum(:,:) + hfx_bom(:,:) + hfx_bog(:,:) + hfx_dif(:,:) + hfx_opw(:,:) + hfx_snw(:,:)  & 
-            &              - hfx_thd(:,:) - hfx_dyn(:,:) - hfx_res(:,:) - hfx_sub(:,:) - hfx_spr(:,:)   &
-            &              ) * e1e2t(:,:) ) * zconv - pdiag_ft
- 
-         ! outputs
-         zv = ( ( glob_sum( 'icectl', SUM( v_i * rhoi + v_s * rhos, dim=3 ) * e1e2t ) * zconv  &
-            &     - pdiag_v ) * r1_rdtice - zfv ) * rday
-
-         zs = ( ( glob_sum( 'icectl', SUM( sv_i * rhoi            , dim=3 ) * e1e2t ) * zconv  &
-            &     - pdiag_s ) * r1_rdtice + zfs ) * rday
-
-         zt = ( glob_sum( 'icectl',                                                                &
-            &             (  SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 )                       &
-            &              + SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 ) ) * e1e2t ) * zconv   &
-            &   - pdiag_t ) * r1_rdtice + zft
-
-         ! zvtrp and zetrp must be close to 0 if the advection scheme is conservative
-         zvtrp = glob_sum( 'icectl', ( diag_trp_vi * rhoi + diag_trp_vs * rhos ) * e1e2t  ) * zconv * rday 
-         zetrp = glob_sum( 'icectl', ( diag_trp_ei        + diag_trp_es        ) * e1e2t  ) * zconv
-
-         zamax  = glob_max( 'icectl', SUM( a_i, dim=3 ) )
-         zvmin  = glob_min( 'icectl', v_i )
-         zamin  = glob_min( 'icectl', a_i )
-         zsmin  = glob_min( 'icectl', sv_i )
-         zeimin = glob_min( 'icectl', SUM( e_i, dim=3 ) )
-         zesmin = glob_min( 'icectl', SUM( e_s, dim=3 ) )
-
-         ! set threshold values and calculate the ice area (+epsi10 to set a threshold > 0 when there is no ice) 
-         zarea   = glob_sum( 'icectl', SUM( a_i + epsi10, dim=3 ) * e1e2t ) * zconv ! in 1.e9 m2
-         zv_sill = zarea * 2.5e-5
-         zs_sill = zarea * 25.e-5
-         zt_sill = zarea * 10.e-5
-
-         IF(lwp) THEN
+         ! -- heat diag -- !
+         zdiag_heat = ( glob_sum( 'icectl', ( SUM(SUM(e_i, dim=4), dim=3) + SUM(SUM(e_s, dim=4), dim=3) ) * e1e2t ) - pdiag_t &
+            &         ) * r1_rdtice                                                                                           &
+            &         + glob_sum( 'icectl', (  hfx_sum + hfx_bom + hfx_bog + hfx_dif + hfx_opw + hfx_snw                      &
+            &                                - hfx_thd - hfx_dyn - hfx_res - hfx_sub - hfx_spr ) * e1e2t )                    &
+            &         - pdiag_ft
+
+         ! -- min/max diag -- !
+         zdiag_amax  = glob_max( 'icectl', SUM( a_i, dim=3 ) )
+         zdiag_vmin  = glob_min( 'icectl', v_i )
+         zdiag_amin  = glob_min( 'icectl', a_i )
+         zdiag_smin  = glob_min( 'icectl', sv_i )
+         zdiag_eimin = glob_min( 'icectl', SUM( e_i, dim=3 ) )
+         zdiag_esmin = glob_min( 'icectl', SUM( e_s, dim=3 ) )
+
+         ! -- advection scheme is conservative? -- !
+         zvtrp = glob_sum( 'icectl', ( diag_trp_vi * rhoi + diag_trp_vs * rhos ) * e1e2t ) ! must be close to 0 (only for Prather)
+         zetrp = glob_sum( 'icectl', ( diag_trp_ei        + diag_trp_es        ) * e1e2t ) ! must be close to 0 (only for Prather)
+
+         ! ice area (+epsi10 to set a threshold > 0 when there is no ice) 
+         zarea = glob_sum( 'icectl', SUM( a_i + epsi10, dim=3 ) * e1e2t )
+
+         IF( lwp ) THEN
             ! check conservation issues
-            IF ( ABS( zv ) > zv_sill )   WRITE(numout,*) 'violation volume [Mt/day]     (',cd_routine,') = ',zv
-            IF ( ABS( zs ) > zs_sill )   WRITE(numout,*) 'violation saline [psu*Mt/day] (',cd_routine,') = ',zs
-            IF ( ABS( zt ) > zt_sill )   WRITE(numout,*) 'violation enthalpy [GW]       (',cd_routine,') = ',zt
+            IF( ABS(zdiag_mass) > zchk_m * rn_icechk_glo * zarea ) &
+               &                   WRITE(numout,*)   cd_routine,' : violation mass cons. [kg] = ',zdiag_mass * rdt_ice
+            IF( ABS(zdiag_salt) > zchk_s * rn_icechk_glo * zarea ) &
+               &                   WRITE(numout,*)   cd_routine,' : violation salt cons. [g]  = ',zdiag_salt * rdt_ice
+            IF( ABS(zdiag_heat) > zchk_t * rn_icechk_glo * zarea ) &
+               &                   WRITE(numout,*)   cd_routine,' : violation heat cons. [J]  = ',zdiag_heat * rdt_ice
+            ! check negative values
+            IF( zdiag_vmin  < 0. ) WRITE(numout,*)   cd_routine,' : violation v_i < 0         = ',zdiag_vmin
+            IF( zdiag_amin  < 0. ) WRITE(numout,*)   cd_routine,' : violation a_i < 0         = ',zdiag_amin
+            IF( zdiag_smin  < 0. ) WRITE(numout,*)   cd_routine,' : violation s_i < 0         = ',zdiag_smin
+            IF( zdiag_eimin < 0. ) WRITE(numout,*)   cd_routine,' : violation e_i < 0         = ',zdiag_eimin
+            IF( zdiag_esmin < 0. ) WRITE(numout,*)   cd_routine,' : violation e_s < 0         = ',zdiag_esmin
             ! check maximum ice concentration
-            IF ( zamax > MAX( rn_amax_n,rn_amax_s)+epsi10 .AND. cd_routine /= 'icedyn_adv' .AND. cd_routine /= 'icedyn_rdgrft' )  &
-               &                         WRITE(numout,*) 'violation a_i>amax            (',cd_routine,') = ',zamax
-            ! check negative values
-            IF ( zvmin  < 0. )           WRITE(numout,*) 'violation v_i<0  [m]          (',cd_routine,') = ',zvmin
-            IF ( zamin  < 0. )           WRITE(numout,*) 'violation a_i<0               (',cd_routine,') = ',zamin
-            IF ( zsmin  < 0. )           WRITE(numout,*) 'violation s_i<0               (',cd_routine,') = ',zsmin
-            IF ( zeimin < 0. )           WRITE(numout,*) 'violation e_i<0               (',cd_routine,') = ',zeimin
-            IF ( zesmin < 0. )           WRITE(numout,*) 'violation e_s<0               (',cd_routine,') = ',zesmin
-!clem: the following check fails (I think...)
-!            IF ( ABS(zvtrp ) > zv_sill .AND. cd_routine == 'icedyn_adv' ) THEN
-!                                           WRITE(numout,*) 'violation vtrp [Mt/day]       (',cd_routine,') = ',zvtrp
-!                                           WRITE(numout,*) 'violation etrp [GW]           (',cd_routine,') = ',zetrp
-!            ENDIF
+            IF( zdiag_amax > MAX(rn_amax_n,rn_amax_s)+epsi10 .AND. cd_routine /= 'icedyn_adv' .AND. cd_routine /= 'icedyn_rdgrft' ) &
+               &                   WRITE(numout,*)   cd_routine,' : violation a_i > amax      = ',zdiag_amax
+            ! check if advection scheme is conservative
+            !    only check for Prather because Ultimate-Macho uses corrective fluxes (wfx etc)
+            !    so the formulation for conservation is different (and not coded) 
+            !    it does not mean UM is not conservative (it is checked with above prints) => update (09/2019): same for Prather now
+            !IF( ln_adv_Pra .AND. ABS(zvtrp) > zchk_m * rn_icechk_glo * zarea .AND. cd_routine == 'icedyn_adv' ) &
+            !   &                   WRITE(numout,*)   cd_routine,' : violation adv scheme [kg] = ',zvtrp * rdt_ice
          ENDIF
          !
@@ -179,5 +167,4 @@
    END SUBROUTINE ice_cons_hsm
 
-
    SUBROUTINE ice_cons_final( cd_routine )
       !!-------------------------------------------------------------------
@@ -188,40 +175,174 @@
       !! ** Method  : This is an online diagnostics which can be activated with ln_icediachk=true
       !!              It prints in ocean.output if there is a violation of conservation at each time-step
-      !!              The thresholds (zv_sill, zs_sill, zt_sill) which determine the violation are set to
-      !!              a minimum of 1 mm of ice (over the ice area) that is lost/gained spuriously during 100 years.
+      !!              The thresholds (zchk_m, zchk_s, zchk_t) determine the violations
       !!              For salt and heat thresholds, ice is considered to have a salinity of 10 
       !!              and a heat content of 3e5 J/kg (=latent heat of fusion) 
       !!-------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(in)    :: cd_routine    ! name of the routine
-      REAL(wp)                        :: zqmass, zhfx, zsfx, zvfx
-      REAL(wp)                        :: zarea, zv_sill, zs_sill, zt_sill
-      REAL(wp), PARAMETER             :: zconv = 1.e-9 ! convert W to GW and kg to Mt
+      CHARACTER(len=*), INTENT(in) ::   cd_routine    ! name of the routine
+      REAL(wp) ::   zdiag_mass, zdiag_salt, zdiag_heat
+      REAL(wp) ::   zarea
       !!-------------------------------------------------------------------
 
       ! water flux
-      zvfx  = glob_sum( 'icectl', ( wfx_ice + wfx_snw + wfx_spr + wfx_sub + diag_vice + diag_vsnw ) * e1e2t ) * zconv * rday
-
-      ! salt flux
-      zsfx  = glob_sum( 'icectl', ( sfx + diag_sice ) * e1e2t ) * zconv * rday
-
-      ! heat flux
+      ! -- mass diag -- !
+      zdiag_mass = glob_sum( 'icectl', ( wfx_ice + wfx_snw + wfx_spr + wfx_sub + diag_vice + diag_vsnw ) * e1e2t )
+
+      ! -- salt diag -- !
+      zdiag_salt = glob_sum( 'icectl', ( sfx + diag_sice ) * e1e2t )
+
+      ! -- heat diag -- !
       ! clem: not the good formulation
-      !!zhfx  = glob_sum( 'icectl', ( qt_oce_ai - qt_atm_oi + diag_heat + hfx_thd + hfx_dyn + hfx_res + hfx_sub + hfx_spr  &
-      !!   &                        ) * e1e2t ) * zconv
-
-      ! set threshold values and calculate the ice area (+epsi10 to set a threshold > 0 when there is no ice) 
-      zarea   = glob_sum( 'icectl', SUM( a_i + epsi10, dim=3 ) * e1e2t ) * zconv ! in 1.e9 m2
-      zv_sill = zarea * 2.5e-5
-      zs_sill = zarea * 25.e-5
-      zt_sill = zarea * 10.e-5
-
-      IF(lwp) THEN
-         IF( ABS( zvfx ) > zv_sill )   WRITE(numout,*) 'violation vfx  [Mt/day]       (',cd_routine,') = ',zvfx
-         IF( ABS( zsfx ) > zs_sill )   WRITE(numout,*) 'violation sfx  [psu*Mt/day]   (',cd_routine,') = ',zsfx
-         !!IF( ABS( zhfx ) > zt_sill )   WRITE(numout,*) 'violation hfx  [GW]           (',cd_routine,') = ',zhfx
+      !!zdiag_heat  = glob_sum( 'icectl', ( qt_oce_ai - qt_atm_oi + diag_heat + hfx_thd + hfx_dyn + hfx_res + hfx_sub + hfx_spr  &
+      !!   &                              ) * e1e2t )
+
+      ! ice area (+epsi10 to set a threshold > 0 when there is no ice) 
+      zarea = glob_sum( 'icectl', SUM( a_i + epsi10, dim=3 ) * e1e2t )
+
+      IF( lwp ) THEN
+         IF( ABS(zdiag_mass) > zchk_m * rn_icechk_glo * zarea ) &
+            &                   WRITE(numout,*) cd_routine,' : violation mass cons. [kg] = ',zdiag_mass * rdt_ice
+         IF( ABS(zdiag_salt) > zchk_s * rn_icechk_glo * zarea ) &
+            &                   WRITE(numout,*) cd_routine,' : violation salt cons. [g]  = ',zdiag_salt * rdt_ice
+         !!IF( ABS(zdiag_heat) > zchk_t * rn_icechk_glo * zarea ) WRITE(numout,*) cd_routine,' : violation heat cons. [J]  = ',zdiag_heat * rdt_ice
       ENDIF
       !
    END SUBROUTINE ice_cons_final
 
+   SUBROUTINE ice_cons2D( icount, cd_routine, pdiag_v, pdiag_s, pdiag_t, pdiag_fv, pdiag_fs, pdiag_ft )
+      !!-------------------------------------------------------------------
+      !!                       ***  ROUTINE ice_cons2D ***
+      !!
+      !! ** Purpose : Test the conservation of heat, salt and mass for each ice routine
+      !!                     + test if ice concentration and volume are > 0
+      !!
+      !! ** Method  : This is an online diagnostics which can be activated with ln_icediachk=true
+      !!              It stops the code if there is a violation of conservation at any gridcell
+      !!-------------------------------------------------------------------
+      INTEGER         , INTENT(in) ::   icount        ! called at: =0 the begining of the routine, =1  the end
+      CHARACTER(len=*), INTENT(in) ::   cd_routine    ! name of the routine
+      REAL(wp)        , DIMENSION(jpi,jpj), INTENT(inout) ::   pdiag_v, pdiag_s, pdiag_t, pdiag_fv, pdiag_fs, pdiag_ft
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   zdiag_mass, zdiag_salt, zdiag_heat, &
+         &                              zdiag_amin, zdiag_vmin, zdiag_smin, zdiag_emin !!, zdiag_amax  
+      INTEGER ::   jl, jk
+      LOGICAL ::   ll_stop_m = .FALSE.
+      LOGICAL ::   ll_stop_s = .FALSE.
+      LOGICAL ::   ll_stop_t = .FALSE.
+      CHARACTER(len=120) ::   clnam   ! filename for the output
+      !!-------------------------------------------------------------------
+      !
+      IF( icount == 0 ) THEN
+
+         pdiag_v = SUM( v_i  * rhoi + v_s * rhos, dim=3 )
+         pdiag_s = SUM( sv_i * rhoi             , dim=3 )
+         pdiag_t = SUM( SUM( e_i, dim=4 ), dim=3 ) + SUM( SUM( e_s, dim=4 ), dim=3 )
+
+         ! mass flux
+         pdiag_fv = wfx_bog + wfx_bom + wfx_sum + wfx_sni + wfx_opw + wfx_res + wfx_dyn + wfx_lam + wfx_pnd  +  &
+            &       wfx_snw_sni + wfx_snw_sum + wfx_snw_dyn + wfx_snw_sub + wfx_ice_sub + wfx_spr
+         ! salt flux
+         pdiag_fs = sfx_bri + sfx_bog + sfx_bom + sfx_sum + sfx_sni + sfx_opw + sfx_res + sfx_dyn + sfx_sub + sfx_lam 
+         ! heat flux
+         pdiag_ft =   hfx_sum + hfx_bom + hfx_bog + hfx_dif + hfx_opw + hfx_snw  & 
+            &       - hfx_thd - hfx_dyn - hfx_res - hfx_sub - hfx_spr
+
+      ELSEIF( icount == 1 ) THEN
+
+         ! -- mass diag -- !
+         zdiag_mass =   ( SUM( v_i * rhoi + v_s * rhos, dim=3 ) - pdiag_v ) * r1_rdtice                             &
+            &         + ( wfx_bog + wfx_bom + wfx_sum + wfx_sni + wfx_opw + wfx_res + wfx_dyn + wfx_lam + wfx_pnd + &
+            &             wfx_snw_sni + wfx_snw_sum + wfx_snw_dyn + wfx_snw_sub + wfx_ice_sub + wfx_spr )           &
+            &         - pdiag_fv
+         IF( MAXVAL( ABS(zdiag_mass) ) > zchk_m * rn_icechk_cel )   ll_stop_m = .TRUE.
+         !
+         ! -- salt diag -- !
+         zdiag_salt =   ( SUM( sv_i * rhoi , dim=3 ) - pdiag_s ) * r1_rdtice                                                  &
+            &         + ( sfx_bri + sfx_bog + sfx_bom + sfx_sum + sfx_sni + sfx_opw + sfx_res + sfx_dyn + sfx_sub + sfx_lam ) &
+            &         - pdiag_fs
+         IF( MAXVAL( ABS(zdiag_salt) ) > zchk_s * rn_icechk_cel )   ll_stop_s = .TRUE.
+         !
+         ! -- heat diag -- !
+         zdiag_heat =   ( SUM( SUM( e_i, dim=4 ), dim=3 ) + SUM( SUM( e_s, dim=4 ), dim=3 ) - pdiag_t ) * r1_rdtice &
+            &         + (  hfx_sum + hfx_bom + hfx_bog + hfx_dif + hfx_opw + hfx_snw                                & 
+            &            - hfx_thd - hfx_dyn - hfx_res - hfx_sub - hfx_spr )                                        &
+            &         - pdiag_ft
+         IF( MAXVAL( ABS(zdiag_heat) ) > zchk_t * rn_icechk_cel )   ll_stop_t = .TRUE.
+         !
+         ! -- other diags -- !
+         ! a_i < 0
+         zdiag_amin(:,:) = 0._wp
+         DO jl = 1, jpl
+            WHERE( a_i(:,:,jl) < 0._wp )   zdiag_amin(:,:) = 1._wp
+         ENDDO
+         ! v_i < 0
+         zdiag_vmin(:,:) = 0._wp
+         DO jl = 1, jpl
+            WHERE( v_i(:,:,jl) < 0._wp )   zdiag_vmin(:,:) = 1._wp
+         ENDDO
+         ! s_i < 0
+         zdiag_smin(:,:) = 0._wp
+         DO jl = 1, jpl
+            WHERE( s_i(:,:,jl) < 0._wp )   zdiag_smin(:,:) = 1._wp
+         ENDDO
+         ! e_i < 0
+         zdiag_emin(:,:) = 0._wp
+         DO jl = 1, jpl
+            DO jk = 1, nlay_i
+               WHERE( e_i(:,:,jk,jl) < 0._wp )   zdiag_emin(:,:) = 1._wp
+            ENDDO
+         ENDDO
+         ! a_i > amax
+         !WHERE( SUM( a_i, dim=3 ) > ( MAX( rn_amax_n, rn_amax_s ) + epsi10 )   ;   zdiag_amax(:,:) = 1._wp
+         !ELSEWHERE                                                             ;   zdiag_amax(:,:) = 0._wp
+         !END WHERE
+
+         IF( ll_stop_m .OR. ll_stop_s .OR. ll_stop_t ) THEN
+            clnam = 'diag_ice_conservation_'//cd_routine
+            CALL ice_cons_wri( clnam, zdiag_mass, zdiag_salt, zdiag_heat, zdiag_amin, zdiag_vmin, zdiag_smin, zdiag_emin )
+         ENDIF
+
+         IF( ll_stop_m )   CALL ctl_stop( 'STOP', cd_routine//': ice mass conservation issue' )
+         IF( ll_stop_s )   CALL ctl_stop( 'STOP', cd_routine//': ice salt conservation issue' )
+         IF( ll_stop_t )   CALL ctl_stop( 'STOP', cd_routine//': ice heat conservation issue' )
+         
+      ENDIF
+
+   END SUBROUTINE ice_cons2D
+
+   SUBROUTINE ice_cons_wri( cdfile_name, pdiag_mass, pdiag_salt, pdiag_heat, pdiag_amin, pdiag_vmin, pdiag_smin, pdiag_emin )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE ice_cons_wri  ***
+      !!        
+      !! ** Purpose :   create a NetCDF file named cdfile_name which contains 
+      !!                the instantaneous fields when conservation issue occurs
+      !!
+      !! ** Method  :   NetCDF files using ioipsl
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT( in ) ::   cdfile_name      ! name of the file created
+      REAL(wp), DIMENSION(:,:), INTENT( in ) ::   pdiag_mass, pdiag_salt, pdiag_heat, &
+         &                                        pdiag_amin, pdiag_vmin, pdiag_smin, pdiag_emin !!, pdiag_amax  
+      !!
+      INTEGER ::   inum
+      !!----------------------------------------------------------------------
+      ! 
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'ice_cons_wri : single instantaneous ice state'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~  named :', cdfile_name, '...nc'
+      IF(lwp) WRITE(numout,*)                
+
+      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl )
+      
+      CALL iom_rstput( 0, 0, inum, 'cons_mass', pdiag_mass(:,:) , ktype = jp_r8 )    ! ice mass spurious lost/gain
+      CALL iom_rstput( 0, 0, inum, 'cons_salt', pdiag_salt(:,:) , ktype = jp_r8 )    ! ice salt spurious lost/gain
+      CALL iom_rstput( 0, 0, inum, 'cons_heat', pdiag_heat(:,:) , ktype = jp_r8 )    ! ice heat spurious lost/gain
+      ! other diags
+      CALL iom_rstput( 0, 0, inum, 'aneg_count', pdiag_amin(:,:) , ktype = jp_r8 )    ! 
+      CALL iom_rstput( 0, 0, inum, 'vneg_count', pdiag_vmin(:,:) , ktype = jp_r8 )    ! 
+      CALL iom_rstput( 0, 0, inum, 'sneg_count', pdiag_smin(:,:) , ktype = jp_r8 )    ! 
+      CALL iom_rstput( 0, 0, inum, 'eneg_count', pdiag_emin(:,:) , ktype = jp_r8 )    ! 
+      
+      CALL iom_close( inum )
+
+   END SUBROUTINE ice_cons_wri
    
    SUBROUTINE ice_ctl( kt )
@@ -246,14 +367,9 @@
       ialert_id = 2 ! reference number of this alert
       cl_alname(ialert_id) = ' Incompat vol and con         '    ! name of the alert
-
       DO jl = 1, jpl
          DO jj = 1, jpj
             DO ji = 1, jpi
                IF(  v_i(ji,jj,jl) /= 0._wp   .AND.   a_i(ji,jj,jl) == 0._wp   ) THEN
-                  !WRITE(numout,*) ' ALERTE 2 :   Incompatible volume and concentration '
-                  !WRITE(numout,*) ' at_i     ', at_i(ji,jj)
-                  !WRITE(numout,*) ' Point - category', ji, jj, jl
-                  !WRITE(numout,*) ' a_i *** a_i_b   ', a_i      (ji,jj,jl), a_i_b  (ji,jj,jl)
-                  !WRITE(numout,*) ' v_i *** v_i_b   ', v_i      (ji,jj,jl), v_i_b  (ji,jj,jl)
+                  WRITE(numout,*) ' ALERTE 2 :   Incompatible volume and concentration '
                   inb_alp(ialert_id) = inb_alp(ialert_id) + 1
                ENDIF
@@ -269,4 +385,5 @@
          DO ji = 1, jpi
             IF(   h_i(ji,jj,jl)  >  50._wp   ) THEN
+               WRITE(numout,*) ' ALERTE 3 :   Very thick ice'
                !CALL ice_prt( kt, ji, jj, 2, ' ALERTE 3 :   Very thick ice ' )
                inb_alp(ialert_id) = inb_alp(ialert_id) + 1
@@ -280,15 +397,21 @@
       DO jj = 1, jpj
          DO ji = 1, jpi
-            IF(   MAX( ABS( u_ice(ji,jj) ), ABS( v_ice(ji,jj) ) ) > 1.5  .AND.  &
+            IF(   MAX( ABS( u_ice(ji,jj) ), ABS( v_ice(ji,jj) ) ) > 2.  .AND.  &
                &  at_i(ji,jj) > 0._wp   ) THEN
+               WRITE(numout,*) ' ALERTE 4 :   Very fast ice'
                !CALL ice_prt( kt, ji, jj, 1, ' ALERTE 4 :   Very fast ice ' )
-               !WRITE(numout,*) ' ice strength             : ', strength(ji,jj)
-               !WRITE(numout,*) ' oceanic stress utau      : ', utau(ji,jj) 
-               !WRITE(numout,*) ' oceanic stress vtau      : ', vtau(ji,jj)
-               !WRITE(numout,*) ' sea-ice stress utau_ice  : ', utau_ice(ji,jj) 
-               !WRITE(numout,*) ' sea-ice stress vtau_ice  : ', vtau_ice(ji,jj)
-               !WRITE(numout,*) ' sst                      : ', sst_m(ji,jj)
-               !WRITE(numout,*) ' sss                      : ', sss_m(ji,jj)
-               !WRITE(numout,*) 
+               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+            ENDIF
+         END DO
+      END DO
+
+      ! Alert on salt flux
+      ialert_id = 5 ! reference number of this alert
+      cl_alname(ialert_id) = ' High salt flux               ' ! name of the alert
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( ABS( sfx (ji,jj) ) > 1.0e-2 ) THEN  ! = 1 psu/day for 1m ocean depth
+               WRITE(numout,*) ' ALERTE 5 :   High salt flux'
+               !CALL ice_prt( kt, ji, jj, 3, ' ALERTE 5 :   High salt flux ' )
                inb_alp(ialert_id) = inb_alp(ialert_id) + 1
             ENDIF
@@ -302,14 +425,6 @@
          DO ji = 1, jpi
             IF(   tmask(ji,jj,1) <= 0._wp   .AND.   at_i(ji,jj) > 0._wp   ) THEN 
+               WRITE(numout,*) ' ALERTE 6 :   Ice on continents'
                !CALL ice_prt( kt, ji, jj, 1, ' ALERTE 6 :   Ice on continents ' )
-               !WRITE(numout,*) ' masks s, u, v        : ', tmask(ji,jj,1), umask(ji,jj,1), vmask(ji,jj,1) 
-               !WRITE(numout,*) ' sst                  : ', sst_m(ji,jj)
-               !WRITE(numout,*) ' sss                  : ', sss_m(ji,jj)
-               !WRITE(numout,*) ' at_i(ji,jj)          : ', at_i(ji,jj)
-               !WRITE(numout,*) ' v_ice(ji,jj)         : ', v_ice(ji,jj)
-               !WRITE(numout,*) ' v_ice(ji,jj-1)       : ', v_ice(ji,jj-1)
-               !WRITE(numout,*) ' u_ice(ji-1,jj)       : ', u_ice(ji-1,jj)
-               !WRITE(numout,*) ' u_ice(ji,jj)         : ', v_ice(ji,jj)
-               !
                inb_alp(ialert_id) = inb_alp(ialert_id) + 1
             ENDIF
@@ -325,8 +440,6 @@
             DO ji = 1, jpi
                IF( s_i(ji,jj,jl) < 0.1 .AND. a_i(ji,jj,jl) > 0._wp ) THEN
+                  WRITE(numout,*) ' ALERTE 7 :   Very fresh ice'
 !                 CALL ice_prt(kt,ji,jj,1, ' ALERTE 7 :   Very fresh ice ' )
-!                 WRITE(numout,*) ' sst                  : ', sst_m(ji,jj)
-!                 WRITE(numout,*) ' sss                  : ', sss_m(ji,jj)
-!                 WRITE(numout,*) 
                   inb_alp(ialert_id) = inb_alp(ialert_id) + 1
                ENDIF
@@ -335,4 +448,19 @@
       END DO
 !
+      ! Alert if qns very big
+      ialert_id = 8 ! reference number of this alert
+      cl_alname(ialert_id) = ' fnsolar very big             ' ! name of the alert
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( ABS( qns(ji,jj) ) > 1500._wp .AND. at_i(ji,jj) > 0._wp ) THEN
+               !
+               WRITE(numout,*) ' ALERTE 8 :   Very high non-solar heat flux'
+               !CALL ice_prt( kt, ji, jj, 2, '   ')
+               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+               !
+            ENDIF
+         END DO
+      END DO
+      !+++++
 
 !     ! Alert if too old ice
@@ -345,4 +473,5 @@
                       ( ABS( o_i(ji,jj,jl) ) < 0._wp) ) .AND. &
                              ( a_i(ji,jj,jl) > 0._wp ) ) THEN
+                  WRITE(numout,*) ' ALERTE 9 :   Wrong ice age'
                   !CALL ice_prt( kt, ji, jj, 1, ' ALERTE 9 :   Wrong ice age ')
                   inb_alp(ialert_id) = inb_alp(ialert_id) + 1
@@ -351,44 +480,5 @@
          END DO
       END DO
- 
-      ! Alert on salt flux
-      ialert_id = 5 ! reference number of this alert
-      cl_alname(ialert_id) = ' High salt flux               ' ! name of the alert
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            IF( ABS( sfx (ji,jj) ) > 1.0e-2 ) THEN  ! = 1 psu/day for 1m ocean depth
-               !CALL ice_prt( kt, ji, jj, 3, ' ALERTE 5 :   High salt flux ' )
-               !DO jl = 1, jpl
-                  !WRITE(numout,*) ' Category no: ', jl
-                  !WRITE(numout,*) ' a_i        : ', a_i      (ji,jj,jl) , ' a_i_b      : ', a_i_b  (ji,jj,jl)   
-                  !WRITE(numout,*) ' v_i        : ', v_i      (ji,jj,jl) , ' v_i_b      : ', v_i_b  (ji,jj,jl)   
-                  !WRITE(numout,*) ' '
-               !END DO
-               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
-            ENDIF
-         END DO
-      END DO
-
-      ! Alert if qns very big
-      ialert_id = 8 ! reference number of this alert
-      cl_alname(ialert_id) = ' fnsolar very big             ' ! name of the alert
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            IF( ABS( qns(ji,jj) ) > 1500._wp .AND. at_i(ji,jj) > 0._wp ) THEN
-               !
-               !WRITE(numout,*) ' ALERTE 8 :   Very high non-solar heat flux'
-               !WRITE(numout,*) ' ji, jj    : ', ji, jj
-               !WRITE(numout,*) ' qns       : ', qns(ji,jj)
-               !WRITE(numout,*) ' sst       : ', sst_m(ji,jj)
-               !WRITE(numout,*) ' sss       : ', sss_m(ji,jj)
-               !
-               !CALL ice_prt( kt, ji, jj, 2, '   ')
-               inb_alp(ialert_id) = inb_alp(ialert_id) + 1
-               !
-            ENDIF
-         END DO
-      END DO
-      !+++++
- 
+  
       ! Alert if very warm ice
       ialert_id = 10 ! reference number of this alert
@@ -400,13 +490,8 @@
                DO ji = 1, jpi
                   ztmelts    =  -rTmlt * sz_i(ji,jj,jk,jl) + rt0
-                  IF( t_i(ji,jj,jk,jl) >= ztmelts  .AND.  v_i(ji,jj,jl) > 1.e-10   &
-                     &                             .AND.  a_i(ji,jj,jl) > 0._wp   ) THEN
-                     !WRITE(numout,*) ' ALERTE 10 :   Very warm ice'
-                     !WRITE(numout,*) ' ji, jj, jk, jl : ', ji, jj, jk, jl
-                     !WRITE(numout,*) ' t_i : ', t_i(ji,jj,jk,jl)
-                     !WRITE(numout,*) ' e_i : ', e_i(ji,jj,jk,jl)
-                     !WRITE(numout,*) ' sz_i: ', sz_i(ji,jj,jk,jl)
-                     !WRITE(numout,*) ' ztmelts : ', ztmelts
-                     inb_alp(ialert_id) = inb_alp(ialert_id) + 1
+                  IF( t_i(ji,jj,jk,jl) > ztmelts  .AND.  v_i(ji,jj,jl) > 1.e-10   &
+                     &                            .AND.  a_i(ji,jj,jl) > 0._wp   ) THEN
+                     WRITE(numout,*) ' ALERTE 10 :   Very warm ice'
+                    inb_alp(ialert_id) = inb_alp(ialert_id) + 1
                   ENDIF
                END DO
@@ -435,5 +520,4 @@
    END SUBROUTINE ice_ctl
  
-   
    SUBROUTINE ice_prt( kt, ki, kj, kn, cd1 )
       !!-------------------------------------------------------------------
@@ -443,5 +527,5 @@
       !!                in ocean.ouput 
       !!                3 possibilities exist 
-      !!                n = 1/-1 -> simple ice state (plus Mechanical Check if -1)
+      !!                n = 1/-1 -> simple ice state
       !!                n = 2    -> exhaustive state
       !!                n = 3    -> ice/ocean salt fluxes
@@ -482,6 +566,6 @@
                WRITE(numout,*) ' - Cell values '
                WRITE(numout,*) '   ~~~~~~~~~~~ '
-               WRITE(numout,*) ' cell area     : ', e1e2t(ji,jj)
                WRITE(numout,*) ' at_i          : ', at_i(ji,jj)       
+               WRITE(numout,*) ' ato_i         : ', ato_i(ji,jj)       
                WRITE(numout,*) ' vt_i          : ', vt_i(ji,jj)       
                WRITE(numout,*) ' vt_s          : ', vt_s(ji,jj)       
@@ -503,13 +587,4 @@
                END DO
             ENDIF
-            IF( kn == -1 ) THEN
-               WRITE(numout,*) ' Mechanical Check ************** '
-               WRITE(numout,*) ' Check what means ice divergence '
-               WRITE(numout,*) ' Total ice concentration ', at_i (ji,jj)
-               WRITE(numout,*) ' Total lead fraction     ', ato_i(ji,jj)
-               WRITE(numout,*) ' Sum of both             ', ato_i(ji,jj) + at_i(ji,jj)
-               WRITE(numout,*) ' Sum of both minus 1     ', ato_i(ji,jj) + at_i(ji,jj) - 1.00
-            ENDIF
-            
 
             !--------------------
@@ -525,5 +600,4 @@
                WRITE(numout,*) ' - Cell values '
                WRITE(numout,*) '   ~~~~~~~~~~~ '
-               WRITE(numout,*) ' cell area     : ', e1e2t(ji,jj)
                WRITE(numout,*) ' at_i          : ', at_i(ji,jj)       
                WRITE(numout,*) ' vt_i          : ', vt_i(ji,jj)       
@@ -624,6 +698,6 @@
       !!
       !!-------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(in)  :: cd_routine    ! name of the routine
-      INTEGER                       :: jk, jl        ! dummy loop indices
+      CHARACTER(len=*), INTENT(in) ::   cd_routine    ! name of the routine
+      INTEGER                      ::   jk, jl        ! dummy loop indices
       
       CALL prt_ctl_info(' ========== ')
@@ -684,5 +758,5 @@
       
    END SUBROUTINE ice_prt3D
-
+      
 #else
    !!----------------------------------------------------------------------
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedia.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedia.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedia.F90	(revision 12143)
@@ -34,5 +34,6 @@
    PUBLIC   ice_dia_init   ! called in icestp.F90
 
-   REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   vol_loc_ini, sal_loc_ini, tem_loc_ini ! initial volume, salt and heat contents
+   REAL(wp), SAVE ::   z1_e1e2  ! inverse of the ocean area
+   REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   vol_loc_ini, sal_loc_ini, tem_loc_ini                    ! initial volume, salt and heat contents
    REAL(wp)                              ::   frc_sal, frc_voltop, frc_volbot, frc_temtop, frc_tembot  ! global forcing trends
    
@@ -80,19 +81,34 @@
       ENDIF
 
-!!gm glob_sum includes a " * tmask_i ", so remove  " * tmask(:,:,1) "
-
+      IF( kt == nit000 ) THEN
+         z1_e1e2 = 1._wp / glob_sum( 'icedia', e1e2t(:,:) )
+      ENDIF
+      
       ! ----------------------- !
-      ! 1 -  Contents !
+      ! 1 -  Contents           !
       ! ----------------------- !
-      zbg_ivol = glob_sum( 'icedia', vt_i(:,:) * e1e2t(:,:) ) * 1.e-9                  ! ice volume (km3)
-      zbg_svol = glob_sum( 'icedia', vt_s(:,:) * e1e2t(:,:) ) * 1.e-9                  ! snow volume (km3)
-      zbg_area = glob_sum( 'icedia', at_i(:,:) * e1e2t(:,:) ) * 1.e-6                  ! area (km2)
-      zbg_isal = glob_sum( 'icedia', SUM( sv_i(:,:,:), dim=3 ) * e1e2t(:,:) ) * 1.e-9  ! salt content (pss*km3)
-      zbg_item = glob_sum( 'icedia', et_i * e1e2t(:,:) ) * 1.e-20                      ! heat content (1.e20 J)
-      zbg_stem = glob_sum( 'icedia', et_s * e1e2t(:,:) ) * 1.e-20                      ! heat content (1.e20 J)
-      
+      IF(  iom_use('ibgvol_tot' ) .OR. iom_use('sbgvol_tot' ) .OR. iom_use('ibgarea_tot') .OR. &
+         & iom_use('ibgsalt_tot') .OR. iom_use('ibgheat_tot') .OR. iom_use('sbgheat_tot') ) THEN
+
+         zbg_ivol = glob_sum( 'icedia', vt_i(:,:) * e1e2t(:,:) ) * 1.e-9  ! ice volume (km3)
+         zbg_svol = glob_sum( 'icedia', vt_s(:,:) * e1e2t(:,:) ) * 1.e-9  ! snow volume (km3)
+         zbg_area = glob_sum( 'icedia', at_i(:,:) * e1e2t(:,:) ) * 1.e-6  ! area (km2)
+         zbg_isal = glob_sum( 'icedia', st_i(:,:) * e1e2t(:,:) ) * 1.e-9  ! salt content (pss*km3)
+         zbg_item = glob_sum( 'icedia', et_i(:,:) * e1e2t(:,:) ) * 1.e-20 ! heat content (1.e20 J)
+         zbg_stem = glob_sum( 'icedia', et_s(:,:) * e1e2t(:,:) ) * 1.e-20 ! heat content (1.e20 J)
+
+         CALL iom_put( 'ibgvol_tot'  , zbg_ivol ) 
+         CALL iom_put( 'sbgvol_tot'  , zbg_svol ) 
+         CALL iom_put( 'ibgarea_tot' , zbg_area ) 
+         CALL iom_put( 'ibgsalt_tot' , zbg_isal ) 
+         CALL iom_put( 'ibgheat_tot' , zbg_item ) 
+         CALL iom_put( 'sbgheat_tot' , zbg_stem ) 
+ 
+      ENDIF
+
       ! ---------------------------!
       ! 2 - Trends due to forcing  !
       ! ---------------------------!
+      ! they must be kept outside an IF(iom_use) because of the call to dia_rst below
       z_frc_volbot = r1_rau0 * glob_sum( 'icedia', -( wfx_ice(:,:) + wfx_snw(:,:) + wfx_err_sub(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! freshwater flux ice/snow-ocean 
       z_frc_voltop = r1_rau0 * glob_sum( 'icedia', -( wfx_sub(:,:) + wfx_spr(:,:) )                    * e1e2t(:,:) ) * 1.e-9   ! freshwater flux ice/snow-atm
@@ -106,52 +122,36 @@
       frc_temtop  = frc_temtop  + z_frc_temtop  * rdt_ice ! 1.e20 J
       frc_tembot  = frc_tembot  + z_frc_tembot  * rdt_ice ! 1.e20 J
+
+      CALL iom_put( 'ibgfrcvoltop' , frc_voltop )   ! vol  forcing ice/snw-atm          (km3 equivalent ocean water) 
+      CALL iom_put( 'ibgfrcvolbot' , frc_volbot )   ! vol  forcing ice/snw-ocean        (km3 equivalent ocean water) 
+      CALL iom_put( 'ibgfrcsal'    , frc_sal    )   ! sal - forcing                     (psu*km3 equivalent ocean water)   
+      CALL iom_put( 'ibgfrctemtop' , frc_temtop )   ! heat on top of ice/snw/ocean      (1.e20 J)   
+      CALL iom_put( 'ibgfrctembot' , frc_tembot )   ! heat on top of ocean(below ice)   (1.e20 J)   
+
+      IF(  iom_use('ibgfrchfxtop') .OR. iom_use('ibgfrchfxbot') ) THEN
+         CALL iom_put( 'ibgfrchfxtop' , frc_temtop * z1_e1e2 * 1.e-20 * kt*rdt ) ! heat on top of ice/snw/ocean      (W/m2)
+         CALL iom_put( 'ibgfrchfxbot' , frc_tembot * z1_e1e2 * 1.e-20 * kt*rdt ) ! heat on top of ocean(below ice)   (W/m2) 
+      ENDIF
+      
+      ! ---------------------------------- !
+      ! 3 -  Content variations and drifts !
+      ! ---------------------------------- !
+      IF(  iom_use('ibgvolume') .OR. iom_use('ibgsaltco') .OR. iom_use('ibgheatco') .OR. iom_use('ibgheatfx') ) THEN
             
-      ! ----------------------- !
-      ! 3 -  Content variations !
-      ! ----------------------- !
-      zdiff_vol = r1_rau0 * glob_sum( 'icedia', ( rhoi*vt_i(:,:) + rhos*vt_s(:,:) - vol_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! freshwater trend (km3) 
-      zdiff_sal = r1_rau0 * glob_sum( 'icedia', ( rhoi* SUM( sv_i(:,:,:), dim=3 ) - sal_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! salt content trend (km3*pss)
-      zdiff_tem =           glob_sum( 'icedia', ( et_i(:,:) + et_s(:,:)           - tem_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-20  ! heat content trend (1.e20 J)
-      !                               + SUM( qevap_ice * a_i_b, dim=3 )       !! clem: I think this term should not be there (but needs a check)
-
-      ! ----------------------- !
-      ! 4 -  Drifts             !
-      ! ----------------------- !
-      zdiff_vol = zdiff_vol - ( frc_voltop + frc_volbot )
-      zdiff_sal = zdiff_sal - frc_sal
-      zdiff_tem = zdiff_tem - ( frc_tembot - frc_temtop )
-
-      ! ----------------------- !
-      ! 5 - Diagnostics writing !
-      ! ----------------------- !
-!!gm I don't understand the division by the ocean surface (i.e. glob_sum( 'icedia', e1e2t(:,:) ) * 1.e-20 * kt*rdt )
-!!   and its multiplication bu kt ! is it really what we want ? what is this quantity ?
-!!   IF it is really what we want, compute it at kt=nit000, not 3 time by time-step !
-!!   kt*rdt  : you mean rdtice ?
-!!gm
-      !
-      IF( iom_use('ibgvolume')    )   CALL iom_put( 'ibgvolume' , zdiff_vol     )   ! ice/snow volume  drift            (km3 equivalent ocean water)         
-      IF( iom_use('ibgsaltco')    )   CALL iom_put( 'ibgsaltco' , zdiff_sal     )   ! ice salt content drift            (psu*km3 equivalent ocean water)
-      IF( iom_use('ibgheatco')    )   CALL iom_put( 'ibgheatco' , zdiff_tem     )   ! ice/snow heat content drift       (1.e20 J)
-      IF( iom_use('ibgheatfx')    )   CALL iom_put( 'ibgheatfx' ,               &   ! ice/snow heat flux drift          (W/m2)
-         &                                                     zdiff_tem /glob_sum( 'icedia', e1e2t(:,:) * 1.e-20 * kt*rdt ) )
-
-      IF( iom_use('ibgfrcvoltop') )   CALL iom_put( 'ibgfrcvoltop' , frc_voltop )   ! vol  forcing ice/snw-atm          (km3 equivalent ocean water) 
-      IF( iom_use('ibgfrcvolbot') )   CALL iom_put( 'ibgfrcvolbot' , frc_volbot )   ! vol  forcing ice/snw-ocean        (km3 equivalent ocean water) 
-      IF( iom_use('ibgfrcsal')    )   CALL iom_put( 'ibgfrcsal'    , frc_sal    )   ! sal - forcing                     (psu*km3 equivalent ocean water)   
-      IF( iom_use('ibgfrctemtop') )   CALL iom_put( 'ibgfrctemtop' , frc_temtop )   ! heat on top of ice/snw/ocean      (1.e20 J)   
-      IF( iom_use('ibgfrctembot') )   CALL iom_put( 'ibgfrctembot' , frc_tembot )   ! heat on top of ocean(below ice)   (1.e20 J)   
-      IF( iom_use('ibgfrchfxtop') )   CALL iom_put( 'ibgfrchfxtop' ,            &   ! heat on top of ice/snw/ocean      (W/m2) 
-         &                                                          frc_temtop / glob_sum( 'icedia', e1e2t(:,:) ) * 1.e-20 * kt*rdt  )
-      IF( iom_use('ibgfrchfxbot') )   CALL iom_put( 'ibgfrchfxbot' ,            &   ! heat on top of ocean(below ice)   (W/m2) 
-         &                                                          frc_tembot / glob_sum( 'icedia', e1e2t(:,:) ) * 1.e-20 * kt*rdt  )
-
-      IF( iom_use('ibgvol_tot' )  )   CALL iom_put( 'ibgvol_tot'  , zbg_ivol     )   ! ice volume                       (km3)
-      IF( iom_use('sbgvol_tot' )  )   CALL iom_put( 'sbgvol_tot'  , zbg_svol     )   ! snow volume                      (km3)
-      IF( iom_use('ibgarea_tot')  )   CALL iom_put( 'ibgarea_tot' , zbg_area     )   ! ice area                         (km2)
-      IF( iom_use('ibgsalt_tot')  )   CALL iom_put( 'ibgsalt_tot' , zbg_isal     )   ! ice salinity content             (pss*km3)
-      IF( iom_use('ibgheat_tot')  )   CALL iom_put( 'ibgheat_tot' , zbg_item     )   ! ice heat content                 (1.e20 J)
-      IF( iom_use('sbgheat_tot')  )   CALL iom_put( 'sbgheat_tot' , zbg_stem     )   ! snow heat content                (1.e20 J)
-      !
+         zdiff_vol = r1_rau0 * glob_sum( 'icedia', ( rhoi*vt_i(:,:) + rhos*vt_s(:,:) - vol_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! freshwater trend (km3) 
+         zdiff_sal = r1_rau0 * glob_sum( 'icedia', ( rhoi*st_i(:,:)                  - sal_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-9   ! salt content trend (km3*pss)
+         zdiff_tem =           glob_sum( 'icedia', ( et_i(:,:) + et_s(:,:)           - tem_loc_ini(:,:) ) * e1e2t(:,:) ) * 1.e-20  ! heat content trend (1.e20 J)
+         !                               + SUM( qevap_ice * a_i_b, dim=3 )       !! clem: I think this term should not be there (but needs a check)
+         
+         zdiff_vol = zdiff_vol - ( frc_voltop + frc_volbot )
+         zdiff_sal = zdiff_sal - frc_sal
+         zdiff_tem = zdiff_tem - ( frc_tembot - frc_temtop )
+         
+         CALL iom_put( 'ibgvolume' , zdiff_vol )   ! ice/snow volume  drift            (km3 equivalent ocean water)         
+         CALL iom_put( 'ibgsaltco' , zdiff_sal )   ! ice salt content drift            (psu*km3 equivalent ocean water)
+         CALL iom_put( 'ibgheatco' , zdiff_tem )   ! ice/snow heat content drift       (1.e20 J)
+         !
+      ENDIF
+      
       IF( lrst_ice )   CALL ice_dia_rst( 'WRITE', kt_ice )
       !
@@ -175,13 +175,13 @@
       INTEGER            ::   ios, ierror   ! local integer
       !!
-      NAMELIST/namdia/ ln_icediachk, ln_icediahsb, ln_icectl, iiceprt, jiceprt  
+      NAMELIST/namdia/ ln_icediachk, rn_icechk_cel, rn_icechk_glo, ln_icediahsb, ln_icectl, iiceprt, jiceprt  
       !!----------------------------------------------------------------------
       !
       REWIND( numnam_ice_ref )      ! Namelist namdia in reference namelist : Parameters for ice
       READ  ( numnam_ice_ref, namdia, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdia in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdia in reference namelist' )
       REWIND( numnam_ice_cfg )      ! Namelist namdia in configuration namelist : Parameters for ice
       READ  ( numnam_ice_cfg, namdia, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdia in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdia in configuration namelist' )
       IF(lwm) WRITE ( numoni, namdia )
       !
@@ -191,8 +191,10 @@
          WRITE(numout,*) ' ~~~~~~~~~~~'
          WRITE(numout,*) '   Namelist namdia:'
-         WRITE(numout,*) '      Diagnose online heat/mass/salt budget      ln_icediachk = ', ln_icediachk
-         WRITE(numout,*) '      Output          heat/mass/salt budget      ln_icediahsb = ', ln_icediahsb
-         WRITE(numout,*) '      control prints for a given grid point      ln_icectl    = ', ln_icectl
-         WRITE(numout,*) '         chosen grid point position         (iiceprt,jiceprt) = (', iiceprt,',', jiceprt,')'
+         WRITE(numout,*) '      Diagnose online heat/mass/salt conservation ln_icediachk  = ', ln_icediachk
+         WRITE(numout,*) '         threshold for conservation (gridcell)    rn_icechk_cel = ', rn_icechk_cel
+         WRITE(numout,*) '         threshold for conservation (global)      rn_icechk_glo = ', rn_icechk_glo
+         WRITE(numout,*) '      Output          heat/mass/salt budget       ln_icediahsb  = ', ln_icediahsb
+         WRITE(numout,*) '      control prints for a given grid point       ln_icectl     = ', ln_icectl
+         WRITE(numout,*) '         chosen grid point position          (iiceprt,jiceprt)  = (', iiceprt,',', jiceprt,')'
       ENDIF
       !      
@@ -248,5 +250,5 @@
             vol_loc_ini(:,:) = rhoi * vt_i(:,:) + rhos * vt_s(:,:)  ! ice/snow volume (kg/m2)
             tem_loc_ini(:,:) = et_i(:,:) + et_s(:,:)                ! ice/snow heat content (J)
-            sal_loc_ini(:,:) = rhoi * SUM( sv_i(:,:,:), dim=3 )     ! ice salt content (pss*kg/m2)
+            sal_loc_ini(:,:) = rhoi * st_i(:,:)                     ! ice salt content (pss*kg/m2)
          ENDIF
          !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn.F90	(revision 12143)
@@ -163,5 +163,7 @@
             END DO
             CALL lbc_lnk( 'icedyn', zdivu_i, 'T', 1. )
-            CALL iom_put( "icediv" , zdivu_i(:,:) )
+            ! output
+            CALL iom_put( 'icediv' , zdivu_i )
+
             DEALLOCATE( zdivu_i )
 
@@ -219,13 +221,13 @@
       NAMELIST/namdyn/ ln_dynALL, ln_dynRHGADV, ln_dynADV1D, ln_dynADV2D, rn_uice, rn_vice,  &
          &             rn_ishlat ,                                                           &
-         &             ln_landfast_L16, ln_landfast_home, rn_depfra, rn_icebfr, rn_lfrelax, rn_tensile
+         &             ln_landfast_L16, rn_depfra, rn_icebfr, rn_lfrelax, rn_tensile
       !!-------------------------------------------------------------------
       !
       REWIND( numnam_ice_ref )         ! Namelist namdyn in reference namelist : Ice dynamics
       READ  ( numnam_ice_ref, namdyn, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn in reference namelist' )
       REWIND( numnam_ice_cfg )         ! Namelist namdyn in configuration namelist : Ice dynamics
       READ  ( numnam_ice_cfg, namdyn, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn in configuration namelist' )
       IF(lwm) WRITE( numoni, namdyn )
       !
@@ -242,5 +244,4 @@
          WRITE(numout,*) '      lateral boundary condition for sea ice dynamics        rn_ishlat       = ', rn_ishlat
          WRITE(numout,*) '      Landfast: param from Lemieux 2016                      ln_landfast_L16 = ', ln_landfast_L16
-         WRITE(numout,*) '      Landfast: param from home made                         ln_landfast_home= ', ln_landfast_home
          WRITE(numout,*) '         fraction of ocean depth that ice must reach         rn_depfra       = ', rn_depfra
          WRITE(numout,*) '         maximum bottom stress per unit area of contact      rn_icebfr       = ', rn_icebfr
@@ -269,9 +270,5 @@
       ENDIF
       !                                      !--- Landfast ice
-      IF( .NOT.ln_landfast_L16 .AND. .NOT.ln_landfast_home )   tau_icebfr(:,:) = 0._wp
-      !
-      IF ( ln_landfast_L16 .AND. ln_landfast_home ) THEN
-         CALL ctl_stop( 'ice_dyn_init: choose one and only one landfast parameterization (ln_landfast_L16 or ln_landfast_home)' )
-      ENDIF
+      IF( .NOT.ln_landfast_L16 )   tau_icebfr(:,:) = 0._wp
       !
       CALL ice_dyn_rdgrft_init          ! set ice ridging/rafting parameters
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_adv.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_adv.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_adv.F90	(revision 12143)
@@ -100,9 +100,9 @@
       diag_trp_vi(:,:) = SUM(     v_i (:,:,:)          - v_i_b (:,:,:)                  , dim=3 ) * r1_rdtice
       diag_trp_vs(:,:) = SUM(     v_s (:,:,:)          - v_s_b (:,:,:)                  , dim=3 ) * r1_rdtice
-      IF( iom_use('icemtrp') )   CALL iom_put( "icemtrp" , diag_trp_vi * rhoi          )   ! ice mass transport
-      IF( iom_use('snwmtrp') )   CALL iom_put( "snwmtrp" , diag_trp_vs * rhos          )   ! snw mass transport
-      IF( iom_use('salmtrp') )   CALL iom_put( "salmtrp" , diag_trp_sv * rhoi * 1.e-03 )   ! salt mass transport (kg/m2/s)
-      IF( iom_use('dihctrp') )   CALL iom_put( "dihctrp" , -diag_trp_ei                )   ! advected ice heat content (W/m2)
-      IF( iom_use('dshctrp') )   CALL iom_put( "dshctrp" , -diag_trp_es                )   ! advected snw heat content (W/m2)
+      IF( iom_use('icemtrp') )   CALL iom_put( 'icemtrp' ,  diag_trp_vi * rhoi          )   ! ice mass transport
+      IF( iom_use('snwmtrp') )   CALL iom_put( 'snwmtrp' ,  diag_trp_vs * rhos          )   ! snw mass transport
+      IF( iom_use('salmtrp') )   CALL iom_put( 'salmtrp' ,  diag_trp_sv * rhoi * 1.e-03 )   ! salt mass transport (kg/m2/s)
+      IF( iom_use('dihctrp') )   CALL iom_put( 'dihctrp' , -diag_trp_ei                 )   ! advected ice heat content (W/m2)
+      IF( iom_use('dshctrp') )   CALL iom_put( 'dshctrp' , -diag_trp_es                 )   ! advected snw heat content (W/m2)
 
       ! controls
@@ -133,8 +133,8 @@
       REWIND( numnam_ice_ref )         ! Namelist namdyn_adv in reference namelist : Ice dynamics
       READ  ( numnam_ice_ref, namdyn_adv, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_adv in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_adv in reference namelist' )
       REWIND( numnam_ice_cfg )         ! Namelist namdyn_adv in configuration namelist : Ice dynamics
       READ  ( numnam_ice_cfg, namdyn_adv, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_adv in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_adv in configuration namelist' )
       IF(lwm) WRITE( numoni, namdyn_adv )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_adv_pra.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_adv_pra.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_adv_pra.F90	(revision 12143)
@@ -16,7 +16,9 @@
    !!   adv_pra_rst     : read/write Prather field in ice restart file, or initialized to zero
    !!----------------------------------------------------------------------
+   USE phycst         ! physical constant
    USE dom_oce        ! ocean domain
    USE ice            ! sea-ice variables
    USE sbc_oce , ONLY : nn_fsbc   ! frequency of sea-ice call
+   USE icevar         ! sea-ice: operations
    !
    USE in_out_manager ! I/O manager
@@ -25,5 +27,4 @@
    USE lib_fortran    ! fortran utilities (glob_sum + no signed zero)
    USE lbclnk         ! lateral boundary conditions (or mpp links)
-   USE prtctl         ! Print control
 
    IMPLICIT NONE
@@ -36,8 +37,7 @@
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   sxice, syice, sxxice, syyice, sxyice   ! ice thickness 
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   sxsn , sysn , sxxsn , syysn , sxysn    ! snow thickness
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   sxa  , sya  , sxxa  , syya  , sxya     ! lead fraction
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   sxa  , sya  , sxxa  , syya  , sxya     ! ice concentration
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   sxsal, sysal, sxxsal, syysal, sxysal   ! ice salinity
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   sxage, syage, sxxage, syyage, sxyage   ! ice age
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)     ::   sxopw, syopw, sxxopw, syyopw, sxyopw   ! open water in sea ice
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   sxc0 , syc0 , sxxc0 , syyc0 , sxyc0    ! snow layers heat content
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   sxe  , sye  , sxxe  , syye  , sxye     ! ice layers heat content
@@ -81,184 +81,167 @@
       REAL(wp), DIMENSION(:,:,:,:), INTENT(inout) ::   pe_i       ! ice heat content
       !
-      INTEGER  ::   jk, jl, jt              ! dummy loop indices
-      INTEGER  ::   initad                  ! number of sub-timestep for the advection
-      REAL(wp) ::   zcfl , zusnit           !   -      -
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     ::   zarea
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   z0opw
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   z0ice, z0snw, z0ai, z0smi, z0oi
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   z0ap , z0vp
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) ::   z0es
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) ::   z0ei
+      INTEGER  ::   ji,jj, jk, jl, jt       ! dummy loop indices
+      INTEGER  ::   icycle                  ! number of sub-timestep for the advection
+      REAL(wp) ::   zdt                     !   -      -
+      REAL(wp), DIMENSION(1)                  ::   zcflprv, zcflnow   ! for global communication
+      REAL(wp), DIMENSION(jpi,jpj)            ::   zati1, zati2
+      REAL(wp), DIMENSION(jpi,jpj)            ::   zudy, zvdx
+      REAL(wp), DIMENSION(jpi,jpj,jpl)        ::   zarea
+      REAL(wp), DIMENSION(jpi,jpj,jpl)        ::   z0ice, z0snw, z0ai, z0smi, z0oi
+      REAL(wp), DIMENSION(jpi,jpj,jpl)        ::   z0ap , z0vp
+      REAL(wp), DIMENSION(jpi,jpj,nlay_s,jpl) ::   z0es
+      REAL(wp), DIMENSION(jpi,jpj,nlay_i,jpl) ::   z0ei
       !!----------------------------------------------------------------------
       !
       IF( kt == nit000 .AND. lwp )   WRITE(numout,*) '-- ice_dyn_adv_pra: Prather advection scheme'
       !
-      ALLOCATE( zarea(jpi,jpj)    , z0opw(jpi,jpj, 1 ) , z0ice(jpi,jpj,jpl) , z0snw(jpi,jpj,jpl) ,                       &
-         &      z0ai(jpi,jpj,jpl) , z0smi(jpi,jpj,jpl) , z0oi (jpi,jpj,jpl) , z0ap (jpi,jpj,jpl) , z0vp(jpi,jpj,jpl) ,   &
-         &      z0es (jpi,jpj,nlay_s,jpl), z0ei(jpi,jpj,nlay_i,jpl) )
-      !
-      ! --- If ice drift field is too fast, use an appropriate time step for advection (CFL test for stability) --- !        
-      zcfl  =            MAXVAL( ABS( pu_ice(:,:) ) * rdt_ice * r1_e1u(:,:) )
-      zcfl  = MAX( zcfl, MAXVAL( ABS( pv_ice(:,:) ) * rdt_ice * r1_e2v(:,:) ) )
-      CALL mpp_max( 'icedyn_adv_pra', zcfl )
+      ! --- If ice drift is too fast, use  subtime steps for advection (CFL test for stability) --- !
+      !        Note: the advection split is applied at the next time-step in order to avoid blocking global comm.
+      !              this should not affect too much the stability
+      zcflnow(1) =                  MAXVAL( ABS( pu_ice(:,:) ) * rdt_ice * r1_e1u(:,:) )
+      zcflnow(1) = MAX( zcflnow(1), MAXVAL( ABS( pv_ice(:,:) ) * rdt_ice * r1_e2v(:,:) ) )
       
-      IF( zcfl > 0.5 ) THEN   ;   initad = 2   ;   zusnit = 0.5_wp
-      ELSE                    ;   initad = 1   ;   zusnit = 1.0_wp
+      ! non-blocking global communication send zcflnow and receive zcflprv
+      CALL mpp_delay_max( 'icedyn_adv_pra', 'cflice', zcflnow(:), zcflprv(:), kt == nitend - nn_fsbc + 1 )
+
+      IF( zcflprv(1) > .5 ) THEN   ;   icycle = 2
+      ELSE                         ;   icycle = 1
       ENDIF
+      zdt = rdt_ice / REAL(icycle)
       
-      zarea(:,:) = e1e2t(:,:)
-      !-------------------------
-      ! transported fields                                        
-      !-------------------------
-      z0opw(:,:,1) = pato_i(:,:) * e1e2t(:,:)              ! Open water area 
-      DO jl = 1, jpl
-         z0snw(:,:,jl) = pv_s (:,:,  jl) * e1e2t(:,:)     ! Snow volume
-         z0ice(:,:,jl) = pv_i (:,:,  jl) * e1e2t(:,:)     ! Ice  volume
-         z0ai (:,:,jl) = pa_i (:,:,  jl) * e1e2t(:,:)     ! Ice area
-         z0smi(:,:,jl) = psv_i(:,:,  jl) * e1e2t(:,:)     ! Salt content
-         z0oi (:,:,jl) = poa_i(:,:,  jl) * e1e2t(:,:)     ! Age content
-         DO jk = 1, nlay_s
-            z0es(:,:,jk,jl) = pe_s(:,:,jk,jl) * e1e2t(:,:) ! Snow heat content
-         END DO
-         DO jk = 1, nlay_i
-            z0ei(:,:,jk,jl) = pe_i(:,:,jk,jl) * e1e2t(:,:) ! Ice  heat content
-         END DO
-         IF ( ln_pnd_H12 ) THEN
-            z0ap(:,:,jl)  = pa_ip(:,:,jl) * e1e2t(:,:)     ! Melt pond fraction
-            z0vp(:,:,jl)  = pv_ip(:,:,jl) * e1e2t(:,:)     ! Melt pond volume
+      ! --- transport --- !
+      zudy(:,:) = pu_ice(:,:) * e2u(:,:)
+      zvdx(:,:) = pv_ice(:,:) * e1v(:,:)
+
+      DO jt = 1, icycle
+
+         ! record at_i before advection (for open water)
+         zati1(:,:) = SUM( pa_i(:,:,:), dim=3 )
+         
+         ! --- transported fields --- !                                        
+         DO jl = 1, jpl
+            zarea(:,:,jl) = e1e2t(:,:)
+            z0snw(:,:,jl) = pv_s (:,:,jl) * e1e2t(:,:)        ! Snow volume
+            z0ice(:,:,jl) = pv_i (:,:,jl) * e1e2t(:,:)        ! Ice  volume
+            z0ai (:,:,jl) = pa_i (:,:,jl) * e1e2t(:,:)        ! Ice area
+            z0smi(:,:,jl) = psv_i(:,:,jl) * e1e2t(:,:)        ! Salt content
+            z0oi (:,:,jl) = poa_i(:,:,jl) * e1e2t(:,:)        ! Age content
+            DO jk = 1, nlay_s
+               z0es(:,:,jk,jl) = pe_s(:,:,jk,jl) * e1e2t(:,:) ! Snow heat content
+            END DO
+            DO jk = 1, nlay_i
+               z0ei(:,:,jk,jl) = pe_i(:,:,jk,jl) * e1e2t(:,:) ! Ice  heat content
+            END DO
+            IF ( ln_pnd_H12 ) THEN
+               z0ap(:,:,jl)  = pa_ip(:,:,jl) * e1e2t(:,:)     ! Melt pond fraction
+               z0vp(:,:,jl)  = pv_ip(:,:,jl) * e1e2t(:,:)     ! Melt pond volume
+            ENDIF
+         END DO
+         !
+         !                                                                  !--------------------------------------------!
+         IF( MOD( (kt - 1) / nn_fsbc , 2 ) ==  MOD( (jt - 1) , 2 ) ) THEN   !==  odd ice time step:  adv_x then adv_y  ==!
+            !                                                               !--------------------------------------------!
+            CALL adv_x( zdt , zudy , 1._wp , zarea , z0ice , sxice , sxxice , syice , syyice , sxyice ) !--- ice volume
+            CALL adv_y( zdt , zvdx , 0._wp , zarea , z0ice , sxice , sxxice , syice , syyice , sxyice )
+            CALL adv_x( zdt , zudy , 1._wp , zarea , z0snw , sxsn  , sxxsn  , sysn  , syysn  , sxysn  ) !--- snow volume
+            CALL adv_y( zdt , zvdx , 0._wp , zarea , z0snw , sxsn  , sxxsn  , sysn  , syysn  , sxysn  )
+            CALL adv_x( zdt , zudy , 1._wp , zarea , z0smi , sxsal , sxxsal , sysal , syysal , sxysal ) !--- ice salinity
+            CALL adv_y( zdt , zvdx , 0._wp , zarea , z0smi , sxsal , sxxsal , sysal , syysal , sxysal )
+            CALL adv_x( zdt , zudy , 1._wp , zarea , z0ai  , sxa   , sxxa   , sya   , syya   , sxya   ) !--- ice concentration
+            CALL adv_y( zdt , zvdx , 0._wp , zarea , z0ai  , sxa   , sxxa   , sya   , syya   , sxya   )
+            CALL adv_x( zdt , zudy , 1._wp , zarea , z0oi  , sxage , sxxage , syage , syyage , sxyage ) !--- ice age
+            CALL adv_y( zdt , zvdx , 0._wp , zarea , z0oi  , sxage , sxxage , syage , syyage , sxyage )
+            !
+            DO jk = 1, nlay_s                                                                           !--- snow heat content
+               CALL adv_x( zdt, zudy, 1._wp, zarea, z0es (:,:,jk,:), sxc0(:,:,jk,:),   &
+                  &                                 sxxc0(:,:,jk,:), syc0(:,:,jk,:), syyc0(:,:,jk,:), sxyc0(:,:,jk,:) )
+               CALL adv_y( zdt, zvdx, 0._wp, zarea, z0es (:,:,jk,:), sxc0(:,:,jk,:),   &
+                  &                                 sxxc0(:,:,jk,:), syc0(:,:,jk,:), syyc0(:,:,jk,:), sxyc0(:,:,jk,:) )
+            END DO
+            DO jk = 1, nlay_i                                                                           !--- ice heat content
+               CALL adv_x( zdt, zudy, 1._wp, zarea, z0ei(:,:,jk,:), sxe(:,:,jk,:),   & 
+                  &                                 sxxe(:,:,jk,:), sye(:,:,jk,:), syye(:,:,jk,:), sxye(:,:,jk,:) )
+               CALL adv_y( zdt, zvdx, 0._wp, zarea, z0ei(:,:,jk,:), sxe(:,:,jk,:),   & 
+                  &                                 sxxe(:,:,jk,:), sye(:,:,jk,:), syye(:,:,jk,:), sxye(:,:,jk,:) )
+            END DO
+            !
+            IF ( ln_pnd_H12 ) THEN
+               CALL adv_x( zdt , zudy , 1._wp , zarea , z0ap , sxap , sxxap , syap , syyap , sxyap )    !--- melt pond fraction
+               CALL adv_y( zdt , zvdx , 0._wp , zarea , z0ap , sxap , sxxap , syap , syyap , sxyap ) 
+               CALL adv_x( zdt , zudy , 1._wp , zarea , z0vp , sxvp , sxxvp , syvp , syyvp , sxyvp )    !--- melt pond volume
+               CALL adv_y( zdt , zvdx , 0._wp , zarea , z0vp , sxvp , sxxvp , syvp , syyvp , sxyvp ) 
+            ENDIF
+            !                                                               !--------------------------------------------!
+         ELSE                                                               !== even ice time step:  adv_y then adv_x  ==!
+            !                                                               !--------------------------------------------!
+            CALL adv_y( zdt , zvdx , 1._wp , zarea , z0ice , sxice , sxxice , syice , syyice , sxyice ) !--- ice volume
+            CALL adv_x( zdt , zudy , 0._wp , zarea , z0ice , sxice , sxxice , syice , syyice , sxyice )
+            CALL adv_y( zdt , zvdx , 1._wp , zarea , z0snw , sxsn  , sxxsn  , sysn  , syysn  , sxysn  ) !--- snow volume
+            CALL adv_x( zdt , zudy , 0._wp , zarea , z0snw , sxsn  , sxxsn  , sysn  , syysn  , sxysn  )
+            CALL adv_y( zdt , zvdx , 1._wp , zarea , z0smi , sxsal , sxxsal , sysal , syysal , sxysal ) !--- ice salinity
+            CALL adv_x( zdt , zudy , 0._wp , zarea , z0smi , sxsal , sxxsal , sysal , syysal , sxysal )
+            CALL adv_y( zdt , zvdx , 1._wp , zarea , z0ai  , sxa   , sxxa   , sya   , syya   , sxya   ) !--- ice concentration
+            CALL adv_x( zdt , zudy , 0._wp , zarea , z0ai  , sxa   , sxxa   , sya   , syya   , sxya   )
+            CALL adv_y( zdt , zvdx , 1._wp , zarea , z0oi  , sxage , sxxage , syage , syyage , sxyage ) !--- ice age
+            CALL adv_x( zdt , zudy , 0._wp , zarea , z0oi  , sxage , sxxage , syage , syyage , sxyage )
+            DO jk = 1, nlay_s                                                                           !--- snow heat content
+               CALL adv_y( zdt, zvdx, 1._wp, zarea, z0es (:,:,jk,:), sxc0(:,:,jk,:),   &
+                  &                                 sxxc0(:,:,jk,:), syc0(:,:,jk,:), syyc0(:,:,jk,:), sxyc0(:,:,jk,:) )
+               CALL adv_x( zdt, zudy, 0._wp, zarea, z0es (:,:,jk,:), sxc0(:,:,jk,:),   &
+                  &                                 sxxc0(:,:,jk,:), syc0(:,:,jk,:), syyc0(:,:,jk,:), sxyc0(:,:,jk,:) )
+            END DO
+            DO jk = 1, nlay_i                                                                           !--- ice heat content
+               CALL adv_y( zdt, zvdx, 1._wp, zarea, z0ei(:,:,jk,:), sxe(:,:,jk,:),   & 
+                  &                                 sxxe(:,:,jk,:), sye(:,:,jk,:), syye(:,:,jk,:), sxye(:,:,jk,:) )
+               CALL adv_x( zdt, zudy, 0._wp, zarea, z0ei(:,:,jk,:), sxe(:,:,jk,:),   & 
+                  &                                 sxxe(:,:,jk,:), sye(:,:,jk,:), syye(:,:,jk,:), sxye(:,:,jk,:) )
+            END DO
+            IF ( ln_pnd_H12 ) THEN
+               CALL adv_y( zdt , zvdx , 1._wp , zarea , z0ap , sxap , sxxap , syap , syyap , sxyap )    !--- melt pond fraction
+               CALL adv_x( zdt , zudy , 0._wp , zarea , z0ap , sxap , sxxap , syap , syyap , sxyap )
+               CALL adv_y( zdt , zvdx , 1._wp , zarea , z0vp , sxvp , sxxvp , syvp , syyvp , sxyvp )    !--- melt pond volume
+               CALL adv_x( zdt , zudy , 0._wp , zarea , z0vp , sxvp , sxxvp , syvp , syyvp , sxyvp )
+            ENDIF
+            !
          ENDIF
+
+         ! --- Recover the properties from their contents --- !
+         DO jl = 1, jpl
+            pv_i (:,:,jl) = z0ice(:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
+            pv_s (:,:,jl) = z0snw(:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
+            psv_i(:,:,jl) = z0smi(:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
+            poa_i(:,:,jl) = z0oi (:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
+            pa_i (:,:,jl) = z0ai (:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
+            DO jk = 1, nlay_s
+               pe_s(:,:,jk,jl) = z0es(:,:,jk,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
+            END DO
+            DO jk = 1, nlay_i
+               pe_i(:,:,jk,jl) = z0ei(:,:,jk,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
+            END DO
+            IF ( ln_pnd_H12 ) THEN
+               pa_ip(:,:,jl) = z0ap(:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
+               pv_ip(:,:,jl) = z0vp(:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
+            ENDIF
+         END DO
+         !
+         ! derive open water from ice concentration
+         zati2(:,:) = SUM( pa_i(:,:,:), dim=3 )
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               pato_i(ji,jj) = pato_i(ji,jj) - ( zati2(ji,jj) - zati1(ji,jj) ) &                        !--- open water
+                  &                          - ( zudy(ji,jj) - zudy(ji-1,jj) + zvdx(ji,jj) - zvdx(ji,jj-1) ) * r1_e1e2t(ji,jj) * zdt
+            END DO
+         END DO
+         CALL lbc_lnk( 'icedyn_adv_pra', pato_i, 'T',  1. )
+         !
+         ! --- Ensure non-negative fields --- !
+         !     Remove negative values (conservation is ensured)
+         !     (because advected fields are not perfectly bounded and tiny negative values can occur, e.g. -1.e-20)
+         CALL ice_var_zapneg( zdt, pato_i, pv_i, pv_s, psv_i, poa_i, pa_i, pa_ip, pv_ip, pe_s, pe_i )
+         !
+         ! --- Ensure snow load is not too big --- !
+         CALL Hsnow( zdt, pv_i, pv_s, pa_i, pa_ip, pe_s )
+         !
       END DO
-
-      !                                                    !--------------------------------------------!
-      IF( MOD( ( kt - 1) / nn_fsbc , 2 ) == 0 ) THEN       !==  odd ice time step:  adv_x then adv_y  ==!
-         !                                                 !--------------------------------------------!
-         DO jt = 1, initad
-            CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0opw (:,:,1), sxopw(:,:),   &             !--- ice open water area
-               &                                      sxxopw(:,:)  , syopw(:,:), syyopw(:,:), sxyopw(:,:)  )
-            CALL adv_y( zusnit, pv_ice, 0._wp, zarea, z0opw (:,:,1), sxopw(:,:),   &
-               &                                      sxxopw(:,:)  , syopw(:,:), syyopw(:,:), sxyopw(:,:)  )
-            DO jl = 1, jpl
-               CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0ice (:,:,jl), sxice(:,:,jl),   &    !--- ice volume  ---
-                  &                                      sxxice(:,:,jl), syice(:,:,jl), syyice(:,:,jl), sxyice(:,:,jl)  )
-               CALL adv_y( zusnit, pv_ice, 0._wp, zarea, z0ice (:,:,jl), sxice(:,:,jl),   &
-                  &                                      sxxice(:,:,jl), syice(:,:,jl), syyice(:,:,jl), sxyice(:,:,jl)  )
-               CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0snw (:,:,jl), sxsn (:,:,jl),   &    !--- snow volume  ---
-                  &                                      sxxsn (:,:,jl), sysn (:,:,jl), syysn (:,:,jl), sxysn (:,:,jl)  )
-               CALL adv_y( zusnit, pv_ice, 0._wp, zarea, z0snw (:,:,jl), sxsn (:,:,jl),   &
-                  &                                      sxxsn (:,:,jl), sysn (:,:,jl), syysn (:,:,jl), sxysn (:,:,jl)  )
-               CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0smi (:,:,jl), sxsal(:,:,jl),   &    !--- ice salinity ---
-                  &                                      sxxsal(:,:,jl), sysal(:,:,jl), syysal(:,:,jl), sxysal(:,:,jl)  )
-               CALL adv_y( zusnit, pv_ice, 0._wp, zarea, z0smi (:,:,jl), sxsal(:,:,jl),   &
-                  &                                      sxxsal(:,:,jl), sysal(:,:,jl), syysal(:,:,jl), sxysal(:,:,jl)  )
-               CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0oi  (:,:,jl), sxage(:,:,jl),   &    !--- ice age      ---     
-                  &                                      sxxage(:,:,jl), syage(:,:,jl), syyage(:,:,jl), sxyage(:,:,jl)  )
-               CALL adv_y( zusnit, pv_ice, 0._wp, zarea, z0oi  (:,:,jl), sxage(:,:,jl),   &
-                  &                                      sxxage(:,:,jl), syage(:,:,jl), syyage(:,:,jl), sxyage(:,:,jl)  )
-               CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0ai  (:,:,jl), sxa  (:,:,jl),   &    !--- ice concentrations ---
-                  &                                      sxxa  (:,:,jl), sya  (:,:,jl), syya  (:,:,jl), sxya  (:,:,jl)  )
-               CALL adv_y( zusnit, pv_ice, 0._wp, zarea, z0ai  (:,:,jl), sxa  (:,:,jl),   & 
-                  &                                      sxxa  (:,:,jl), sya  (:,:,jl), syya  (:,:,jl), sxya  (:,:,jl)  )
-               DO jk = 1, nlay_s                                                               !--- snow heat contents ---
-                  CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0es (:,:,jk,jl), sxc0(:,:,jk,jl),   &
-                     &                                      sxxc0(:,:,jk,jl), syc0(:,:,jk,jl), syyc0(:,:,jk,jl), sxyc0(:,:,jk,jl) )
-                  CALL adv_y( zusnit, pv_ice, 0._wp, zarea, z0es (:,:,jk,jl), sxc0(:,:,jk,jl),   &
-                     &                                      sxxc0(:,:,jk,jl), syc0(:,:,jk,jl), syyc0(:,:,jk,jl), sxyc0(:,:,jk,jl) )
-               END DO
-               DO jk = 1, nlay_i                                                               !--- ice heat contents ---
-                  CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0ei(:,:,jk,jl), sxe(:,:,jk,jl),   & 
-                     &                                      sxxe(:,:,jk,jl), sye(:,:,jk,jl), syye(:,:,jk,jl), sxye(:,:,jk,jl) )
-                  CALL adv_y( zusnit, pv_ice, 0._wp, zarea, z0ei(:,:,jk,jl), sxe(:,:,jk,jl),   & 
-                     &                                      sxxe(:,:,jk,jl), sye(:,:,jk,jl), syye(:,:,jk,jl), sxye(:,:,jk,jl) )
-               END DO
-               IF ( ln_pnd_H12 ) THEN
-                  CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0ap  (:,:,jl), sxap (:,:,jl),   &    !--- melt pond fraction --
-                     &                                      sxxap (:,:,jl), syap (:,:,jl), syyap (:,:,jl), sxyap (:,:,jl)  )
-                  CALL adv_y( zusnit, pv_ice, 0._wp, zarea, z0ap  (:,:,jl), sxap (:,:,jl),   & 
-                     &                                      sxxap (:,:,jl), syap (:,:,jl), syyap (:,:,jl), sxyap (:,:,jl)  )
-                  CALL adv_x( zusnit, pu_ice, 1._wp, zarea, z0vp  (:,:,jl), sxvp (:,:,jl),   &    !--- melt pond volume   --
-                     &                                      sxxvp (:,:,jl), syvp (:,:,jl), syyvp (:,:,jl), sxyvp (:,:,jl)  )
-                  CALL adv_y( zusnit, pv_ice, 0._wp, zarea, z0vp  (:,:,jl), sxvp (:,:,jl),   & 
-                     &                                      sxxvp (:,:,jl), syvp (:,:,jl), syyvp (:,:,jl), sxyvp (:,:,jl)  )
-               ENDIF
-            END DO
-         END DO
-      !                                                    !--------------------------------------------!
-      ELSE                                                 !== even ice time step:  adv_y then adv_x  ==!
-         !                                                 !--------------------------------------------!
-         DO jt = 1, initad
-            CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0opw (:,:,1), sxopw(:,:),   &             !--- ice open water area
-               &                                      sxxopw(:,:)  , syopw(:,:), syyopw(:,:), sxyopw(:,:)  )
-            CALL adv_x( zusnit, pu_ice, 0._wp, zarea, z0opw (:,:,1), sxopw(:,:),   &
-               &                                      sxxopw(:,:)  , syopw(:,:), syyopw(:,:), sxyopw(:,:)  )
-            DO jl = 1, jpl
-               CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0ice (:,:,jl), sxice(:,:,jl),   &    !--- ice volume  ---
-                  &                                      sxxice(:,:,jl), syice(:,:,jl), syyice(:,:,jl), sxyice(:,:,jl)  )
-               CALL adv_x( zusnit, pu_ice, 0._wp, zarea, z0ice (:,:,jl), sxice(:,:,jl),   &
-                  &                                      sxxice(:,:,jl), syice(:,:,jl), syyice(:,:,jl), sxyice(:,:,jl)  )
-               CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0snw (:,:,jl), sxsn (:,:,jl),   &    !--- snow volume  ---
-                  &                                      sxxsn (:,:,jl), sysn (:,:,jl), syysn (:,:,jl), sxysn (:,:,jl)  )
-               CALL adv_x( zusnit, pu_ice, 0._wp, zarea, z0snw (:,:,jl), sxsn (:,:,jl),   &
-                  &                                      sxxsn (:,:,jl), sysn (:,:,jl), syysn (:,:,jl), sxysn (:,:,jl)  )
-               CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0smi (:,:,jl), sxsal(:,:,jl),   &    !--- ice salinity ---
-                  &                                      sxxsal(:,:,jl), sysal(:,:,jl), syysal(:,:,jl), sxysal(:,:,jl)  )
-               CALL adv_x( zusnit, pu_ice, 0._wp, zarea, z0smi (:,:,jl), sxsal(:,:,jl),   &
-                  &                                      sxxsal(:,:,jl), sysal(:,:,jl), syysal(:,:,jl), sxysal(:,:,jl)  )
-               CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0oi  (:,:,jl), sxage(:,:,jl),   &   !--- ice age      ---
-                  &                                      sxxage(:,:,jl), syage(:,:,jl), syyage(:,:,jl), sxyage(:,:,jl)  )
-               CALL adv_x( zusnit, pu_ice, 0._wp, zarea, z0oi  (:,:,jl), sxage(:,:,jl),   &
-                  &                                      sxxage(:,:,jl), syage(:,:,jl), syyage(:,:,jl), sxyage(:,:,jl)  )
-               CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0ai  (:,:,jl), sxa  (:,:,jl),   &   !--- ice concentrations ---
-                  &                                      sxxa  (:,:,jl), sya  (:,:,jl), syya  (:,:,jl), sxya  (:,:,jl)  )
-               CALL adv_x( zusnit, pu_ice, 0._wp, zarea, z0ai  (:,:,jl), sxa  (:,:,jl),   &
-                  &                                      sxxa  (:,:,jl), sya  (:,:,jl), syya  (:,:,jl), sxya  (:,:,jl)  )
-               DO jk = 1, nlay_s                                                             !--- snow heat contents ---
-                  CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0es (:,:,jk,jl), sxc0(:,:,jk,jl),   &
-                     &                                      sxxc0(:,:,jk,jl), syc0(:,:,jk,jl), syyc0(:,:,jk,jl), sxyc0(:,:,jk,jl) )
-                  CALL adv_x( zusnit, pu_ice, 0._wp, zarea, z0es (:,:,jk,jl), sxc0(:,:,jk,jl),   &
-                     &                                      sxxc0(:,:,jk,jl), syc0(:,:,jk,jl), syyc0(:,:,jk,jl), sxyc0(:,:,jk,jl) )
-               END DO
-               DO jk = 1, nlay_i                                                             !--- ice heat contents ---
-                  CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0ei(:,:,jk,jl), sxe(:,:,jk,jl),   & 
-                     &                                      sxxe(:,:,jk,jl), sye(:,:,jk,jl), syye(:,:,jk,jl), sxye(:,:,jk,jl) )
-                  CALL adv_x( zusnit, pu_ice, 0._wp, zarea, z0ei(:,:,jk,jl), sxe(:,:,jk,jl),   & 
-                     &                                      sxxe(:,:,jk,jl), sye(:,:,jk,jl), syye(:,:,jk,jl), sxye(:,:,jk,jl) )
-               END DO
-               IF ( ln_pnd_H12 ) THEN
-                  CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0ap  (:,:,jl), sxap (:,:,jl),   &   !--- melt pond fraction ---
-                     &                                      sxxap (:,:,jl), syap (:,:,jl), syyap (:,:,jl), sxyap (:,:,jl)  )
-                  CALL adv_x( zusnit, pu_ice, 0._wp, zarea, z0ap  (:,:,jl), sxap (:,:,jl),   &
-                     &                                      sxxap (:,:,jl), syap (:,:,jl), syyap (:,:,jl), sxyap (:,:,jl)  )
-                  CALL adv_y( zusnit, pv_ice, 1._wp, zarea, z0vp  (:,:,jl), sxvp (:,:,jl),   &   !--- melt pond volume   ---
-                     &                                      sxxvp (:,:,jl), syvp (:,:,jl), syyvp (:,:,jl), sxyvp (:,:,jl)  )
-                  CALL adv_x( zusnit, pu_ice, 0._wp, zarea, z0vp  (:,:,jl), sxvp (:,:,jl),   &
-                     &                                      sxxvp (:,:,jl), syvp (:,:,jl), syyvp (:,:,jl), sxyvp (:,:,jl)  )
-               ENDIF
-            END DO
-         END DO
-      ENDIF
-
-      !-------------------------------------------
-      ! Recover the properties from their contents
-      !-------------------------------------------
-      pato_i(:,:) = z0opw(:,:,1) * r1_e1e2t(:,:) * tmask(:,:,1)
-      DO jl = 1, jpl
-         pv_i (:,:,  jl) = z0ice(:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
-         pv_s (:,:,  jl) = z0snw(:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
-         psv_i(:,:,  jl) = z0smi(:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
-         poa_i(:,:,  jl) = z0oi (:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
-         pa_i (:,:,  jl) = z0ai (:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
-         DO jk = 1, nlay_s
-            pe_s(:,:,jk,jl) = z0es(:,:,jk,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
-         END DO
-         DO jk = 1, nlay_i
-            pe_i(:,:,jk,jl) = z0ei(:,:,jk,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
-         END DO
-         IF ( ln_pnd_H12 ) THEN
-            pa_ip  (:,:,jl) = z0ap (:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
-            pv_ip  (:,:,jl) = z0vp (:,:,jl) * r1_e1e2t(:,:) * tmask(:,:,1)
-         ENDIF
-      END DO
-      !
-      DEALLOCATE( zarea , z0opw , z0ice, z0snw , z0ai , z0smi , z0oi , z0ap , z0vp , z0es, z0ei )
       !
       IF( lrst_ice )   CALL adv_pra_rst( 'WRITE', kt )   !* write Prather fields in the restart file
@@ -267,5 +250,5 @@
    
    
-   SUBROUTINE adv_x( pdf, put , pcrh, psm , ps0 ,   &
+   SUBROUTINE adv_x( pdt, put , pcrh, psm , ps0 ,   &
       &              psx, psxx, psy , psyy, psxy )
       !!----------------------------------------------------------------------
@@ -275,14 +258,14 @@
       !!                variable on x axis
       !!----------------------------------------------------------------------
-      REAL(wp)                    , INTENT(in   ) ::   pdf                ! reduction factor for the time step
-      REAL(wp)                    , INTENT(in   ) ::   pcrh               ! call adv_x then adv_y (=1) or the opposite (=0)
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   put                ! i-direction ice velocity at U-point [m/s]
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psm                ! area
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   ps0                ! field to be advected
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psx , psy          ! 1st moments 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psxx, psyy, psxy   ! 2nd moments
+      REAL(wp)                  , INTENT(in   ) ::   pdt                ! the time step
+      REAL(wp)                  , INTENT(in   ) ::   pcrh               ! call adv_x then adv_y (=1) or the opposite (=0)
+      REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   put                ! i-direction ice velocity at U-point [m/s]
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   psm                ! area
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   ps0                ! field to be advected
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   psx , psy          ! 1st moments 
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   psxx, psyy, psxy   ! 2nd moments
       !! 
-      INTEGER  ::   ji, jj                               ! dummy loop indices
-      REAL(wp) ::   zs1max, zrdt, zslpmax, ztemp         ! local scalars
+      INTEGER  ::   ji, jj, jl, jcat                     ! dummy loop indices
+      REAL(wp) ::   zs1max, zslpmax, ztemp               ! local scalars
       REAL(wp) ::   zs1new, zalf , zalfq , zbt           !   -      -
       REAL(wp) ::   zs2new, zalf1, zalf1q, zbt1          !   -      -
@@ -291,154 +274,150 @@
       REAL(wp), DIMENSION(jpi,jpj) ::   zalg, zalg1, zalg1q         !  -      -
       !-----------------------------------------------------------------------
-
-      ! Limitation of moments.                                           
-
-      zrdt = rdt_ice * pdf      ! If ice drift field is too fast, use an appropriate time step for advection.
-
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            zslpmax = MAX( 0._wp, ps0(ji,jj) )
-            zs1max  = 1.5 * zslpmax
-            zs1new  = MIN( zs1max, MAX( -zs1max, psx(ji,jj) ) )
-            zs2new  = MIN(  2.0 * zslpmax - 0.3334 * ABS( zs1new ),      &
-               &            MAX( ABS( zs1new ) - zslpmax, psxx(ji,jj) )  )
-            rswitch = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zslpmax) ) ) * tmask(ji,jj,1)   ! Case of empty boxes & Apply mask
-
-            ps0 (ji,jj) = zslpmax  
-            psx (ji,jj) = zs1new      * rswitch
-            psxx(ji,jj) = zs2new      * rswitch
-            psy (ji,jj) = psy (ji,jj) * rswitch
-            psyy(ji,jj) = psyy(ji,jj) * rswitch
-            psxy(ji,jj) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj) ) ) * rswitch
-         END DO
+      !
+      jcat = SIZE( ps0 , 3 )   ! size of input arrays
+      !
+      DO jl = 1, jcat   ! loop on categories
+         !
+         ! Limitation of moments.                                           
+         DO jj = 2, jpjm1
+            DO ji = 1, jpi
+               !  Initialize volumes of boxes  (=area if adv_x first called, =psm otherwise)                                     
+               psm (ji,jj,jl) = MAX( pcrh * e1e2t(ji,jj) + ( 1.0 - pcrh ) * psm(ji,jj,jl) , epsi20 )
+               !
+               zslpmax = MAX( 0._wp, ps0(ji,jj,jl) )
+               zs1max  = 1.5 * zslpmax
+               zs1new  = MIN( zs1max, MAX( -zs1max, psx(ji,jj,jl) ) )
+               zs2new  = MIN(  2.0 * zslpmax - 0.3334 * ABS( zs1new ),      &
+                  &            MAX( ABS( zs1new ) - zslpmax, psxx(ji,jj,jl) )  )
+               rswitch = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zslpmax) ) ) * tmask(ji,jj,1)   ! Case of empty boxes & Apply mask
+
+               ps0 (ji,jj,jl) = zslpmax  
+               psx (ji,jj,jl) = zs1new         * rswitch
+               psxx(ji,jj,jl) = zs2new         * rswitch
+               psy (ji,jj,jl) = psy (ji,jj,jl) * rswitch
+               psyy(ji,jj,jl) = psyy(ji,jj,jl) * rswitch
+               psxy(ji,jj,jl) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj,jl) ) ) * rswitch
+            END DO
+         END DO
+
+         !  Calculate fluxes and moments between boxes i<-->i+1              
+         DO jj = 2, jpjm1                      !  Flux from i to i+1 WHEN u GT 0 
+            DO ji = 1, jpi
+               zbet(ji,jj)  =  MAX( 0._wp, SIGN( 1._wp, put(ji,jj) ) )
+               zalf         =  MAX( 0._wp, put(ji,jj) ) * pdt / psm(ji,jj,jl)
+               zalfq        =  zalf * zalf
+               zalf1        =  1.0 - zalf
+               zalf1q       =  zalf1 * zalf1
+               !
+               zfm (ji,jj)  =  zalf  *   psm (ji,jj,jl)
+               zf0 (ji,jj)  =  zalf  * ( ps0 (ji,jj,jl) + zalf1 * ( psx(ji,jj,jl) + (zalf1 - zalf) * psxx(ji,jj,jl) ) )
+               zfx (ji,jj)  =  zalfq * ( psx (ji,jj,jl) + 3.0 * zalf1 * psxx(ji,jj,jl) )
+               zfxx(ji,jj)  =  zalf  *   psxx(ji,jj,jl) * zalfq
+               zfy (ji,jj)  =  zalf  * ( psy (ji,jj,jl) + zalf1 * psxy(ji,jj,jl) )
+               zfxy(ji,jj)  =  zalfq *   psxy(ji,jj,jl)
+               zfyy(ji,jj)  =  zalf  *   psyy(ji,jj,jl)
+
+               !  Readjust moments remaining in the box.
+               psm (ji,jj,jl)  =  psm (ji,jj,jl) - zfm(ji,jj)
+               ps0 (ji,jj,jl)  =  ps0 (ji,jj,jl) - zf0(ji,jj)
+               psx (ji,jj,jl)  =  zalf1q * ( psx(ji,jj,jl) - 3.0 * zalf * psxx(ji,jj,jl) )
+               psxx(ji,jj,jl)  =  zalf1  * zalf1q * psxx(ji,jj,jl)
+               psy (ji,jj,jl)  =  psy (ji,jj,jl) - zfy(ji,jj)
+               psyy(ji,jj,jl)  =  psyy(ji,jj,jl) - zfyy(ji,jj)
+               psxy(ji,jj,jl)  =  zalf1q * psxy(ji,jj,jl)
+            END DO
+         END DO
+
+         DO jj = 2, jpjm1                      !  Flux from i+1 to i when u LT 0.
+            DO ji = 1, fs_jpim1
+               zalf          = MAX( 0._wp, -put(ji,jj) ) * pdt / psm(ji+1,jj,jl) 
+               zalg  (ji,jj) = zalf
+               zalfq         = zalf * zalf
+               zalf1         = 1.0 - zalf
+               zalg1 (ji,jj) = zalf1
+               zalf1q        = zalf1 * zalf1
+               zalg1q(ji,jj) = zalf1q
+               !
+               zfm   (ji,jj) = zfm (ji,jj) + zalf  *    psm (ji+1,jj,jl)
+               zf0   (ji,jj) = zf0 (ji,jj) + zalf  * (  ps0 (ji+1,jj,jl) &
+                  &                                   - zalf1 * ( psx(ji+1,jj,jl) - (zalf1 - zalf ) * psxx(ji+1,jj,jl) ) )
+               zfx   (ji,jj) = zfx (ji,jj) + zalfq * (  psx (ji+1,jj,jl) - 3.0 * zalf1 * psxx(ji+1,jj,jl) )
+               zfxx  (ji,jj) = zfxx(ji,jj) + zalf  *    psxx(ji+1,jj,jl) * zalfq
+               zfy   (ji,jj) = zfy (ji,jj) + zalf  * (  psy (ji+1,jj,jl) - zalf1 * psxy(ji+1,jj,jl) )
+               zfxy  (ji,jj) = zfxy(ji,jj) + zalfq *    psxy(ji+1,jj,jl)
+               zfyy  (ji,jj) = zfyy(ji,jj) + zalf  *    psyy(ji+1,jj,jl)
+            END DO
+         END DO
+
+         DO jj = 2, jpjm1                     !  Readjust moments remaining in the box. 
+            DO ji = fs_2, fs_jpim1
+               zbt  =       zbet(ji-1,jj)
+               zbt1 = 1.0 - zbet(ji-1,jj)
+               !
+               psm (ji,jj,jl) = zbt * psm(ji,jj,jl) + zbt1 * ( psm(ji,jj,jl) - zfm(ji-1,jj) )
+               ps0 (ji,jj,jl) = zbt * ps0(ji,jj,jl) + zbt1 * ( ps0(ji,jj,jl) - zf0(ji-1,jj) )
+               psx (ji,jj,jl) = zalg1q(ji-1,jj) * ( psx(ji,jj,jl) + 3.0 * zalg(ji-1,jj) * psxx(ji,jj,jl) )
+               psxx(ji,jj,jl) = zalg1 (ji-1,jj) * zalg1q(ji-1,jj) * psxx(ji,jj,jl)
+               psy (ji,jj,jl) = zbt * psy (ji,jj,jl) + zbt1 * ( psy (ji,jj,jl) - zfy (ji-1,jj) )
+               psyy(ji,jj,jl) = zbt * psyy(ji,jj,jl) + zbt1 * ( psyy(ji,jj,jl) - zfyy(ji-1,jj) )
+               psxy(ji,jj,jl) = zalg1q(ji-1,jj) * psxy(ji,jj,jl)
+            END DO
+         END DO
+
+         !   Put the temporary moments into appropriate neighboring boxes.    
+         DO jj = 2, jpjm1                     !   Flux from i to i+1 IF u GT 0.
+            DO ji = fs_2, fs_jpim1
+               zbt  =       zbet(ji-1,jj)
+               zbt1 = 1.0 - zbet(ji-1,jj)
+               psm(ji,jj,jl) = zbt * ( psm(ji,jj,jl) + zfm(ji-1,jj) ) + zbt1 * psm(ji,jj,jl)
+               zalf          = zbt * zfm(ji-1,jj) / psm(ji,jj,jl)
+               zalf1         = 1.0 - zalf
+               ztemp         = zalf * ps0(ji,jj,jl) - zalf1 * zf0(ji-1,jj)
+               !
+               ps0 (ji,jj,jl) =  zbt  * ( ps0(ji,jj,jl) + zf0(ji-1,jj) ) + zbt1 * ps0(ji,jj,jl)
+               psx (ji,jj,jl) =  zbt  * ( zalf * zfx(ji-1,jj) + zalf1 * psx(ji,jj,jl) + 3.0 * ztemp ) + zbt1 * psx(ji,jj,jl)
+               psxx(ji,jj,jl) =  zbt  * ( zalf * zalf * zfxx(ji-1,jj) + zalf1 * zalf1 * psxx(ji,jj,jl)                             &
+                  &                     + 5.0 * ( zalf * zalf1 * ( psx (ji,jj,jl) - zfx(ji-1,jj) ) - ( zalf1 - zalf ) * ztemp )  ) &
+                  &            + zbt1 * psxx(ji,jj,jl)
+               psxy(ji,jj,jl) =  zbt  * ( zalf * zfxy(ji-1,jj) + zalf1 * psxy(ji,jj,jl)             &
+                  &                     + 3.0 * (- zalf1*zfy(ji-1,jj)  + zalf * psy(ji,jj,jl) ) )   &
+                  &            + zbt1 * psxy(ji,jj,jl)
+               psy (ji,jj,jl) =  zbt  * ( psy (ji,jj,jl) + zfy (ji-1,jj) ) + zbt1 * psy (ji,jj,jl)
+               psyy(ji,jj,jl) =  zbt  * ( psyy(ji,jj,jl) + zfyy(ji-1,jj) ) + zbt1 * psyy(ji,jj,jl)
+            END DO
+         END DO
+
+         DO jj = 2, jpjm1                      !  Flux from i+1 to i IF u LT 0.
+            DO ji = fs_2, fs_jpim1
+               zbt  =       zbet(ji,jj)
+               zbt1 = 1.0 - zbet(ji,jj)
+               psm(ji,jj,jl) = zbt * psm(ji,jj,jl) + zbt1 * ( psm(ji,jj,jl) + zfm(ji,jj) )
+               zalf          = zbt1 * zfm(ji,jj) / psm(ji,jj,jl)
+               zalf1         = 1.0 - zalf
+               ztemp         = - zalf * ps0(ji,jj,jl) + zalf1 * zf0(ji,jj)
+               !
+               ps0 (ji,jj,jl) = zbt * ps0 (ji,jj,jl) + zbt1 * ( ps0(ji,jj,jl) + zf0(ji,jj) )
+               psx (ji,jj,jl) = zbt * psx (ji,jj,jl) + zbt1 * ( zalf * zfx(ji,jj) + zalf1 * psx(ji,jj,jl) + 3.0 * ztemp )
+               psxx(ji,jj,jl) = zbt * psxx(ji,jj,jl) + zbt1 * ( zalf * zalf * zfxx(ji,jj) + zalf1 * zalf1 * psxx(ji,jj,jl) &
+                  &                                           + 5.0 * ( zalf * zalf1 * ( - psx(ji,jj,jl) + zfx(ji,jj) )    &
+                  &                                           + ( zalf1 - zalf ) * ztemp ) )
+               psxy(ji,jj,jl) = zbt * psxy(ji,jj,jl) + zbt1 * ( zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj,jl)  &
+                  &                                           + 3.0 * ( zalf1 * zfy(ji,jj) - zalf * psy(ji,jj,jl) ) )
+               psy (ji,jj,jl) = zbt * psy (ji,jj,jl) + zbt1 * ( psy (ji,jj,jl) + zfy (ji,jj) )
+               psyy(ji,jj,jl) = zbt * psyy(ji,jj,jl) + zbt1 * ( psyy(ji,jj,jl) + zfyy(ji,jj) )
+            END DO
+         END DO
+
       END DO
 
-      !  Initialize volumes of boxes  (=area if adv_x first called, =psm otherwise)                                     
-      psm (:,:)  = MAX( pcrh * e1e2t(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20 )
-
-      !  Calculate fluxes and moments between boxes i<-->i+1              
-      DO jj = 1, jpj                      !  Flux from i to i+1 WHEN u GT 0 
-         DO ji = 1, jpi
-            zbet(ji,jj)  =  MAX( 0._wp, SIGN( 1._wp, put(ji,jj) ) )
-            zalf         =  MAX( 0._wp, put(ji,jj) ) * zrdt * e2u(ji,jj) / psm(ji,jj)
-            zalfq        =  zalf * zalf
-            zalf1        =  1.0 - zalf
-            zalf1q       =  zalf1 * zalf1
-            !
-            zfm (ji,jj)  =  zalf  *   psm (ji,jj)
-            zf0 (ji,jj)  =  zalf  * ( ps0 (ji,jj) + zalf1 * ( psx(ji,jj) + (zalf1 - zalf) * psxx(ji,jj) )  )
-            zfx (ji,jj)  =  zalfq * ( psx (ji,jj) + 3.0 * zalf1 * psxx(ji,jj) )
-            zfxx(ji,jj)  =  zalf  *   psxx(ji,jj) * zalfq
-            zfy (ji,jj)  =  zalf  * ( psy (ji,jj) + zalf1 * psxy(ji,jj) )
-            zfxy(ji,jj)  =  zalfq *   psxy(ji,jj)
-            zfyy(ji,jj)  =  zalf  *   psyy(ji,jj)
-
-            !  Readjust moments remaining in the box.
-            psm (ji,jj)  =  psm (ji,jj) - zfm(ji,jj)
-            ps0 (ji,jj)  =  ps0 (ji,jj) - zf0(ji,jj)
-            psx (ji,jj)  =  zalf1q * ( psx(ji,jj) - 3.0 * zalf * psxx(ji,jj) )
-            psxx(ji,jj)  =  zalf1  * zalf1q * psxx(ji,jj)
-            psy (ji,jj)  =  psy (ji,jj) - zfy(ji,jj)
-            psyy(ji,jj)  =  psyy(ji,jj) - zfyy(ji,jj)
-            psxy(ji,jj)  =  zalf1q * psxy(ji,jj)
-         END DO
-      END DO
-
-      DO jj = 1, jpjm1                      !  Flux from i+1 to i when u LT 0.
-         DO ji = 1, fs_jpim1
-            zalf          = MAX( 0._wp, -put(ji,jj) ) * zrdt * e2u(ji,jj) / psm(ji+1,jj) 
-            zalg  (ji,jj) = zalf
-            zalfq         = zalf * zalf
-            zalf1         = 1.0 - zalf
-            zalg1 (ji,jj) = zalf1
-            zalf1q        = zalf1 * zalf1
-            zalg1q(ji,jj) = zalf1q
-            !
-            zfm   (ji,jj) = zfm (ji,jj) + zalf  *   psm (ji+1,jj)
-            zf0   (ji,jj) = zf0 (ji,jj) + zalf  * ( ps0 (ji+1,jj) - zalf1 * ( psx(ji+1,jj) - (zalf1 - zalf ) * psxx(ji+1,jj) ) )
-            zfx   (ji,jj) = zfx (ji,jj) + zalfq * ( psx (ji+1,jj) - 3.0 * zalf1 * psxx(ji+1,jj) )
-            zfxx  (ji,jj) = zfxx(ji,jj) + zalf  *   psxx(ji+1,jj) * zalfq
-            zfy   (ji,jj) = zfy (ji,jj) + zalf  * ( psy (ji+1,jj) - zalf1 * psxy(ji+1,jj) )
-            zfxy  (ji,jj) = zfxy(ji,jj) + zalfq *   psxy(ji+1,jj)
-            zfyy  (ji,jj) = zfyy(ji,jj) + zalf  *   psyy(ji+1,jj)
-         END DO
-      END DO
-
-      DO jj = 2, jpjm1                     !  Readjust moments remaining in the box. 
-         DO ji = fs_2, fs_jpim1
-            zbt  =       zbet(ji-1,jj)
-            zbt1 = 1.0 - zbet(ji-1,jj)
-            !
-            psm (ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) - zfm(ji-1,jj) )
-            ps0 (ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) - zf0(ji-1,jj) )
-            psx (ji,jj) = zalg1q(ji-1,jj) * ( psx(ji,jj) + 3.0 * zalg(ji-1,jj) * psxx(ji,jj) )
-            psxx(ji,jj) = zalg1 (ji-1,jj) * zalg1q(ji-1,jj) * psxx(ji,jj)
-            psy (ji,jj) = zbt * psy (ji,jj) + zbt1 * ( psy (ji,jj) - zfy (ji-1,jj) )
-            psyy(ji,jj) = zbt * psyy(ji,jj) + zbt1 * ( psyy(ji,jj) - zfyy(ji-1,jj) )
-            psxy(ji,jj) = zalg1q(ji-1,jj) * psxy(ji,jj)
-         END DO
-      END DO
-
-      !   Put the temporary moments into appropriate neighboring boxes.    
-      DO jj = 2, jpjm1                     !   Flux from i to i+1 IF u GT 0.
-         DO ji = fs_2, fs_jpim1
-            zbt  =       zbet(ji-1,jj)
-            zbt1 = 1.0 - zbet(ji-1,jj)
-            psm(ji,jj)  = zbt * ( psm(ji,jj) + zfm(ji-1,jj) ) + zbt1 * psm(ji,jj)
-            zalf        = zbt * zfm(ji-1,jj) / psm(ji,jj)
-            zalf1       = 1.0 - zalf
-            ztemp       = zalf * ps0(ji,jj) - zalf1 * zf0(ji-1,jj)
-            !
-            ps0 (ji,jj) = zbt * ( ps0(ji,jj) + zf0(ji-1,jj) ) + zbt1 * ps0(ji,jj)
-            psx (ji,jj) = zbt * ( zalf * zfx(ji-1,jj) + zalf1 * psx(ji,jj) + 3.0 * ztemp ) + zbt1 * psx(ji,jj)
-            psxx(ji,jj) = zbt * ( zalf * zalf * zfxx(ji-1,jj) + zalf1 * zalf1 * psxx(ji,jj)                               &
-               &                + 5.0 * ( zalf * zalf1 * ( psx (ji,jj) - zfx(ji-1,jj) ) - ( zalf1 - zalf ) * ztemp )  )   &
-               &                                                + zbt1 * psxx(ji,jj)
-            psxy(ji,jj) = zbt * ( zalf * zfxy(ji-1,jj) + zalf1 * psxy(ji,jj)             &
-               &                + 3.0 * (- zalf1*zfy(ji-1,jj)  + zalf * psy(ji,jj) ) )   &
-               &                                                + zbt1 * psxy(ji,jj)
-            psy (ji,jj) = zbt * ( psy (ji,jj) + zfy (ji-1,jj) ) + zbt1 * psy (ji,jj)
-            psyy(ji,jj) = zbt * ( psyy(ji,jj) + zfyy(ji-1,jj) ) + zbt1 * psyy(ji,jj)
-         END DO
-      END DO
-
-      DO jj = 2, jpjm1                     !  Flux from i+1 to i IF u LT 0.
-         DO ji = fs_2, fs_jpim1
-            zbt  =       zbet(ji,jj)
-            zbt1 = 1.0 - zbet(ji,jj)
-            psm(ji,jj)  = zbt * psm(ji,jj)  + zbt1 * ( psm(ji,jj) + zfm(ji,jj) )
-            zalf        = zbt1 * zfm(ji,jj) / psm(ji,jj)
-            zalf1       = 1.0 - zalf
-            ztemp       = - zalf * ps0(ji,jj) + zalf1 * zf0(ji,jj)
-            !
-            ps0(ji,jj)  = zbt * ps0 (ji,jj) + zbt1 * ( ps0(ji,jj) + zf0(ji,jj) )
-            psx(ji,jj)  = zbt * psx (ji,jj) + zbt1 * ( zalf * zfx(ji,jj) + zalf1 * psx(ji,jj) + 3.0 * ztemp )
-            psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( zalf * zalf * zfxx(ji,jj)  + zalf1 * zalf1 * psxx(ji,jj)  &
-               &                                      + 5.0 *( zalf * zalf1 * ( - psx(ji,jj) + zfx(ji,jj) )      &
-               &                                      + ( zalf1 - zalf ) * ztemp ) )
-            psxy(ji,jj) = zbt * psxy(ji,jj) + zbt1 * (  zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj)  &
-               &                                      + 3.0 * ( zalf1 * zfy(ji,jj) - zalf * psy(ji,jj) )  )
-            psy(ji,jj)  = zbt * psy (ji,jj)  + zbt1 * ( psy (ji,jj) + zfy (ji,jj) )
-            psyy(ji,jj) = zbt * psyy(ji,jj)  + zbt1 * ( psyy(ji,jj) + zfyy(ji,jj) )
-         END DO
-      END DO
-
       !-- Lateral boundary conditions
-      CALL lbc_lnk_multi( 'icedyn_adv_pra', psm , 'T',  1., ps0 , 'T',  1.   &
-         &              , psx , 'T', -1., psy , 'T', -1.   &   ! caution gradient ==> the sign changes
-         &              , psxx, 'T',  1., psyy, 'T',  1.   &
-         &              , psxy, 'T',  1. )
-
-      IF(ln_ctl) THEN
-         CALL prt_ctl(tab2d_1=psm  , clinfo1=' adv_x: psm  :', tab2d_2=ps0 , clinfo2=' ps0  : ')
-         CALL prt_ctl(tab2d_1=psx  , clinfo1=' adv_x: psx  :', tab2d_2=psxx, clinfo2=' psxx : ')
-         CALL prt_ctl(tab2d_1=psy  , clinfo1=' adv_x: psy  :', tab2d_2=psyy, clinfo2=' psyy : ')
-         CALL prt_ctl(tab2d_1=psxy , clinfo1=' adv_x: psxy :')
-      ENDIF
+      CALL lbc_lnk_multi( 'icedyn_adv_pra', psm(:,:,1:jcat) , 'T',  1., ps0 , 'T',  1.   &
+         &                                , psx             , 'T', -1., psy , 'T', -1.   &   ! caution gradient ==> the sign changes
+         &                                , psxx            , 'T',  1., psyy, 'T',  1. , psxy, 'T',  1. )
       !
    END SUBROUTINE adv_x
 
 
-   SUBROUTINE adv_y( pdf, pvt , pcrh, psm , ps0 ,   &
+   SUBROUTINE adv_y( pdt, pvt , pcrh, psm , ps0 ,   &
       &              psx, psxx, psy , psyy, psxy )
       !!---------------------------------------------------------------------
@@ -448,14 +427,14 @@
       !!                variable on y axis
       !!---------------------------------------------------------------------
-      REAL(wp)                    , INTENT(in   ) ::   pdf                ! reduction factor for the time step
-      REAL(wp)                    , INTENT(in   ) ::   pcrh               ! call adv_x then adv_y (=1) or the opposite (=0)
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pvt                ! j-direction ice velocity at V-point [m/s]
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psm                ! area
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   ps0                ! field to be advected
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psx , psy          ! 1st moments 
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   psxx, psyy, psxy   ! 2nd moments
+      REAL(wp)                  , INTENT(in   ) ::   pdt                ! time step
+      REAL(wp)                  , INTENT(in   ) ::   pcrh               ! call adv_x then adv_y (=1) or the opposite (=0)
+      REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   pvt                ! j-direction ice velocity at V-point [m/s]
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   psm                ! area
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   ps0                ! field to be advected
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   psx , psy          ! 1st moments 
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   psxx, psyy, psxy   ! 2nd moments
       !!
-      INTEGER  ::   ji, jj                               ! dummy loop indices
-      REAL(wp) ::   zs1max, zrdt, zslpmax, ztemp         ! temporary scalars
+      INTEGER  ::   ji, jj, jl, jcat                     ! dummy loop indices
+      REAL(wp) ::   zs1max, zslpmax, ztemp               ! temporary scalars
       REAL(wp) ::   zs1new, zalf , zalfq , zbt           !    -         -
       REAL(wp) ::   zs2new, zalf1, zalf1q, zbt1          !    -         -
@@ -464,152 +443,203 @@
       REAL(wp), DIMENSION(jpi,jpj) ::   zalg, zalg1, zalg1q     !  -      -
       !---------------------------------------------------------------------
-
-      ! Limitation of moments.
-
-      zrdt = rdt_ice * pdf ! If ice drift field is too fast, use an appropriate time step for advection.
-
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            zslpmax = MAX( 0._wp, ps0(ji,jj) )
-            zs1max  = 1.5 * zslpmax
-            zs1new  = MIN( zs1max, MAX( -zs1max, psy(ji,jj) ) )
-            zs2new  = MIN(  ( 2.0 * zslpmax - 0.3334 * ABS( zs1new ) ),   &
-               &             MAX( ABS( zs1new )-zslpmax, psyy(ji,jj) )  )
-            rswitch = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zslpmax) ) ) * tmask(ji,jj,1)   ! Case of empty boxes & Apply mask
-            !
-            ps0 (ji,jj) = zslpmax  
-            psx (ji,jj) = psx (ji,jj) * rswitch
-            psxx(ji,jj) = psxx(ji,jj) * rswitch
-            psy (ji,jj) = zs1new * rswitch
-            psyy(ji,jj) = zs2new * rswitch
-            psxy(ji,jj) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj) ) ) * rswitch
-         END DO
+      !
+      jcat = SIZE( ps0 , 3 )   ! size of input arrays
+      !      
+      DO jl = 1, jcat   ! loop on categories
+         !
+         ! Limitation of moments.
+         DO jj = 1, jpj
+            DO ji = fs_2, fs_jpim1
+               !  Initialize volumes of boxes (=area if adv_x first called, =psm otherwise)
+               psm(ji,jj,jl) = MAX(  pcrh * e1e2t(ji,jj) + ( 1.0 - pcrh ) * psm(ji,jj,jl) , epsi20  )
+               !
+               zslpmax = MAX( 0._wp, ps0(ji,jj,jl) )
+               zs1max  = 1.5 * zslpmax
+               zs1new  = MIN( zs1max, MAX( -zs1max, psy(ji,jj,jl) ) )
+               zs2new  = MIN(  ( 2.0 * zslpmax - 0.3334 * ABS( zs1new ) ),   &
+                  &             MAX( ABS( zs1new )-zslpmax, psyy(ji,jj,jl) )  )
+               rswitch = ( 1.0 - MAX( 0._wp, SIGN( 1._wp, -zslpmax) ) ) * tmask(ji,jj,1)   ! Case of empty boxes & Apply mask
+               !
+               ps0 (ji,jj,jl) = zslpmax  
+               psx (ji,jj,jl) = psx (ji,jj,jl) * rswitch
+               psxx(ji,jj,jl) = psxx(ji,jj,jl) * rswitch
+               psy (ji,jj,jl) = zs1new         * rswitch
+               psyy(ji,jj,jl) = zs2new         * rswitch
+               psxy(ji,jj,jl) = MIN( zslpmax, MAX( -zslpmax, psxy(ji,jj,jl) ) ) * rswitch
+            END DO
+         END DO
+ 
+         !  Calculate fluxes and moments between boxes j<-->j+1              
+         DO jj = 1, jpj                     !  Flux from j to j+1 WHEN v GT 0   
+            DO ji = fs_2, fs_jpim1
+               zbet(ji,jj)  =  MAX( 0._wp, SIGN( 1._wp, pvt(ji,jj) ) )
+               zalf         =  MAX( 0._wp, pvt(ji,jj) ) * pdt / psm(ji,jj,jl)
+               zalfq        =  zalf * zalf
+               zalf1        =  1.0 - zalf
+               zalf1q       =  zalf1 * zalf1
+               !
+               zfm (ji,jj)  =  zalf  * psm(ji,jj,jl)
+               zf0 (ji,jj)  =  zalf  * ( ps0(ji,jj,jl) + zalf1 * ( psy(ji,jj,jl)  + (zalf1-zalf) * psyy(ji,jj,jl) ) ) 
+               zfy (ji,jj)  =  zalfq *( psy(ji,jj,jl) + 3.0*zalf1*psyy(ji,jj,jl) )
+               zfyy(ji,jj)  =  zalf  * zalfq * psyy(ji,jj,jl)
+               zfx (ji,jj)  =  zalf  * ( psx(ji,jj,jl) + zalf1 * psxy(ji,jj,jl) )
+               zfxy(ji,jj)  =  zalfq * psxy(ji,jj,jl)
+               zfxx(ji,jj)  =  zalf  * psxx(ji,jj,jl)
+               !
+               !  Readjust moments remaining in the box.
+               psm (ji,jj,jl)  =  psm (ji,jj,jl) - zfm(ji,jj)
+               ps0 (ji,jj,jl)  =  ps0 (ji,jj,jl) - zf0(ji,jj)
+               psy (ji,jj,jl)  =  zalf1q * ( psy(ji,jj,jl) -3.0 * zalf * psyy(ji,jj,jl) )
+               psyy(ji,jj,jl)  =  zalf1 * zalf1q * psyy(ji,jj,jl)
+               psx (ji,jj,jl)  =  psx (ji,jj,jl) - zfx(ji,jj)
+               psxx(ji,jj,jl)  =  psxx(ji,jj,jl) - zfxx(ji,jj)
+               psxy(ji,jj,jl)  =  zalf1q * psxy(ji,jj,jl)
+            END DO
+         END DO
+         !
+         DO jj = 1, jpjm1                   !  Flux from j+1 to j when v LT 0.
+            DO ji = fs_2, fs_jpim1
+               zalf          = MAX( 0._wp, -pvt(ji,jj) ) * pdt / psm(ji,jj+1,jl) 
+               zalg  (ji,jj) = zalf
+               zalfq         = zalf * zalf
+               zalf1         = 1.0 - zalf
+               zalg1 (ji,jj) = zalf1
+               zalf1q        = zalf1 * zalf1
+               zalg1q(ji,jj) = zalf1q
+               !
+               zfm   (ji,jj) = zfm (ji,jj) + zalf  *    psm (ji,jj+1,jl)
+               zf0   (ji,jj) = zf0 (ji,jj) + zalf  * (  ps0 (ji,jj+1,jl) &
+                  &                                   - zalf1 * (psy(ji,jj+1,jl) - (zalf1 - zalf ) * psyy(ji,jj+1,jl) ) )
+               zfy   (ji,jj) = zfy (ji,jj) + zalfq * (  psy (ji,jj+1,jl) - 3.0 * zalf1 * psyy(ji,jj+1,jl) )
+               zfyy  (ji,jj) = zfyy(ji,jj) + zalf  *    psyy(ji,jj+1,jl) * zalfq
+               zfx   (ji,jj) = zfx (ji,jj) + zalf  * (  psx (ji,jj+1,jl) - zalf1 * psxy(ji,jj+1,jl) )
+               zfxy  (ji,jj) = zfxy(ji,jj) + zalfq *    psxy(ji,jj+1,jl)
+               zfxx  (ji,jj) = zfxx(ji,jj) + zalf  *    psxx(ji,jj+1,jl)
+            END DO
+         END DO
+
+         !  Readjust moments remaining in the box. 
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zbt  =         zbet(ji,jj-1)
+               zbt1 = ( 1.0 - zbet(ji,jj-1) )
+               !
+               psm (ji,jj,jl) = zbt * psm(ji,jj,jl) + zbt1 * ( psm(ji,jj,jl) - zfm(ji,jj-1) )
+               ps0 (ji,jj,jl) = zbt * ps0(ji,jj,jl) + zbt1 * ( ps0(ji,jj,jl) - zf0(ji,jj-1) )
+               psy (ji,jj,jl) = zalg1q(ji,jj-1) * ( psy(ji,jj,jl) + 3.0 * zalg(ji,jj-1) * psyy(ji,jj,jl) )
+               psyy(ji,jj,jl) = zalg1 (ji,jj-1) * zalg1q(ji,jj-1) * psyy(ji,jj,jl)
+               psx (ji,jj,jl) = zbt * psx (ji,jj,jl) + zbt1 * ( psx (ji,jj,jl) - zfx (ji,jj-1) )
+               psxx(ji,jj,jl) = zbt * psxx(ji,jj,jl) + zbt1 * ( psxx(ji,jj,jl) - zfxx(ji,jj-1) )
+               psxy(ji,jj,jl) = zalg1q(ji,jj-1) * psxy(ji,jj,jl)
+            END DO
+         END DO
+
+         !   Put the temporary moments into appropriate neighboring boxes.    
+         DO jj = 2, jpjm1                    !   Flux from j to j+1 IF v GT 0.
+            DO ji = fs_2, fs_jpim1
+               zbt  =       zbet(ji,jj-1)
+               zbt1 = 1.0 - zbet(ji,jj-1)
+               psm(ji,jj,jl) = zbt * ( psm(ji,jj,jl) + zfm(ji,jj-1) ) + zbt1 * psm(ji,jj,jl) 
+               zalf          = zbt * zfm(ji,jj-1) / psm(ji,jj,jl) 
+               zalf1         = 1.0 - zalf
+               ztemp         = zalf * ps0(ji,jj,jl) - zalf1 * zf0(ji,jj-1)
+               !
+               ps0(ji,jj,jl)  =   zbt  * ( ps0(ji,jj,jl) + zf0(ji,jj-1) ) + zbt1 * ps0(ji,jj,jl)
+               psy(ji,jj,jl)  =   zbt  * ( zalf * zfy(ji,jj-1) + zalf1 * psy(ji,jj,jl) + 3.0 * ztemp )  &
+                  &             + zbt1 * psy(ji,jj,jl)  
+               psyy(ji,jj,jl) =   zbt  * ( zalf * zalf * zfyy(ji,jj-1) + zalf1 * zalf1 * psyy(ji,jj,jl)                           &
+                  &                      + 5.0 * ( zalf * zalf1 * ( psy(ji,jj,jl) - zfy(ji,jj-1) ) - ( zalf1 - zalf ) * ztemp ) ) & 
+                  &             + zbt1 * psyy(ji,jj,jl)
+               psxy(ji,jj,jl) =   zbt  * (  zalf * zfxy(ji,jj-1) + zalf1 * psxy(ji,jj,jl)            &
+                  &                      + 3.0 * (- zalf1 * zfx(ji,jj-1) + zalf * psx(ji,jj,jl) ) )  &
+                  &             + zbt1 * psxy(ji,jj,jl)
+               psx (ji,jj,jl) =   zbt * ( psx (ji,jj,jl) + zfx (ji,jj-1) ) + zbt1 * psx (ji,jj,jl)
+               psxx(ji,jj,jl) =   zbt * ( psxx(ji,jj,jl) + zfxx(ji,jj-1) ) + zbt1 * psxx(ji,jj,jl)
+            END DO
+         END DO
+
+         DO jj = 2, jpjm1                      !  Flux from j+1 to j IF v LT 0.
+            DO ji = fs_2, fs_jpim1
+               zbt  =       zbet(ji,jj)
+               zbt1 = 1.0 - zbet(ji,jj)
+               psm(ji,jj,jl) = zbt * psm(ji,jj,jl) + zbt1 * ( psm(ji,jj,jl) + zfm(ji,jj) )
+               zalf          = zbt1 * zfm(ji,jj) / psm(ji,jj,jl)
+               zalf1         = 1.0 - zalf
+               ztemp         = - zalf * ps0(ji,jj,jl) + zalf1 * zf0(ji,jj)
+               !
+               ps0 (ji,jj,jl) = zbt * ps0 (ji,jj,jl) + zbt1 * (  ps0(ji,jj,jl) + zf0(ji,jj) )
+               psy (ji,jj,jl) = zbt * psy (ji,jj,jl) + zbt1 * (  zalf * zfy(ji,jj) + zalf1 * psy(ji,jj,jl) + 3.0 * ztemp )
+               psyy(ji,jj,jl) = zbt * psyy(ji,jj,jl) + zbt1 * (  zalf * zalf * zfyy(ji,jj) + zalf1 * zalf1 * psyy(ji,jj,jl) &
+                  &                                            + 5.0 * ( zalf * zalf1 * ( - psy(ji,jj,jl) + zfy(ji,jj) )    &
+                  &                                            + ( zalf1 - zalf ) * ztemp ) )
+               psxy(ji,jj,jl) = zbt * psxy(ji,jj,jl) + zbt1 * (  zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj,jl)  &
+                  &                                            + 3.0 * ( zalf1 * zfx(ji,jj) - zalf * psx(ji,jj,jl) ) )
+               psx (ji,jj,jl) = zbt * psx (ji,jj,jl) + zbt1 * ( psx (ji,jj,jl) + zfx (ji,jj) )
+               psxx(ji,jj,jl) = zbt * psxx(ji,jj,jl) + zbt1 * ( psxx(ji,jj,jl) + zfxx(ji,jj) )
+            END DO
+         END DO
+
       END DO
 
-      !  Initialize volumes of boxes (=area if adv_x first called, =psm otherwise)
-      psm(:,:)  = MAX(  pcrh * e1e2t(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20  )
-
-      !  Calculate fluxes and moments between boxes j<-->j+1              
-      DO jj = 1, jpj                     !  Flux from j to j+1 WHEN v GT 0   
-         DO ji = 1, jpi
-            zbet(ji,jj)  =  MAX( 0._wp, SIGN( 1._wp, pvt(ji,jj) ) )
-            zalf         =  MAX( 0._wp, pvt(ji,jj) ) * zrdt * e1v(ji,jj) / psm(ji,jj)
-            zalfq        =  zalf * zalf
-            zalf1        =  1.0 - zalf
-            zalf1q       =  zalf1 * zalf1
-            !
-            zfm (ji,jj)  =  zalf  * psm(ji,jj)
-            zf0 (ji,jj)  =  zalf  * ( ps0(ji,jj) + zalf1 * ( psy(ji,jj)  + (zalf1-zalf) * psyy(ji,jj)  ) ) 
-            zfy (ji,jj)  =  zalfq *( psy(ji,jj) + 3.0*zalf1*psyy(ji,jj) )
-            zfyy(ji,jj)  =  zalf  * zalfq * psyy(ji,jj)
-            zfx (ji,jj)  =  zalf  * ( psx(ji,jj) + zalf1 * psxy(ji,jj) )
-            zfxy(ji,jj)  =  zalfq * psxy(ji,jj)
-            zfxx(ji,jj)  =  zalf  * psxx(ji,jj)
-            !
-            !  Readjust moments remaining in the box.
-            psm (ji,jj)  =  psm (ji,jj) - zfm(ji,jj)
-            ps0 (ji,jj)  =  ps0 (ji,jj) - zf0(ji,jj)
-            psy (ji,jj)  =  zalf1q * ( psy(ji,jj) -3.0 * zalf * psyy(ji,jj) )
-            psyy(ji,jj)  =  zalf1 * zalf1q * psyy(ji,jj)
-            psx (ji,jj)  =  psx (ji,jj) - zfx(ji,jj)
-            psxx(ji,jj)  =  psxx(ji,jj) - zfxx(ji,jj)
-            psxy(ji,jj)  =  zalf1q * psxy(ji,jj)
+      !-- Lateral boundary conditions
+      CALL lbc_lnk_multi( 'icedyn_adv_pra', psm(:,:,1:jcat) , 'T',  1., ps0 , 'T',  1.   &
+         &                                , psx             , 'T', -1., psy , 'T', -1.   &   ! caution gradient ==> the sign changes
+         &                                , psxx            , 'T',  1., psyy, 'T',  1. , psxy, 'T',  1. )
+      !
+   END SUBROUTINE adv_y
+
+
+   SUBROUTINE Hsnow( pdt, pv_i, pv_s, pa_i, pa_ip, pe_s )
+      !!-------------------------------------------------------------------
+      !!                  ***  ROUTINE Hsnow  ***
+      !!
+      !! ** Purpose : 1- Check snow load after advection
+      !!              2- Correct pond concentration to avoid a_ip > a_i
+      !!
+      !! ** Method :  If snow load makes snow-ice interface to deplet below the ocean surface
+      !!              then put the snow excess in the ocean
+      !!
+      !! ** Notes :   This correction is crucial because of the call to routine icecor afterwards
+      !!              which imposes a mini of ice thick. (rn_himin). This imposed mini can artificially
+      !!              make the snow very thick (if concentration decreases drastically)
+      !!              This behavior has been seen in Ultimate-Macho and supposedly it can also be true for Prather
+      !!-------------------------------------------------------------------
+      REAL(wp)                    , INTENT(in   ) ::   pdt   ! tracer time-step
+      REAL(wp), DIMENSION(:,:,:)  , INTENT(inout) ::   pv_i, pv_s, pa_i, pa_ip
+      REAL(wp), DIMENSION(:,:,:,:), INTENT(inout) ::   pe_s
+      !
+      INTEGER  ::   ji, jj, jl   ! dummy loop indices
+      REAL(wp) ::   z1_dt, zvs_excess, zfra
+      !!-------------------------------------------------------------------
+      !
+      z1_dt = 1._wp / pdt
+      !
+      ! -- check snow load -- !
+      DO jl = 1, jpl
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( pv_i(ji,jj,jl) > 0._wp ) THEN
+                  !
+                  zvs_excess = MAX( 0._wp, pv_s(ji,jj,jl) - pv_i(ji,jj,jl) * (rau0-rhoi) * r1_rhos )
+                  !
+                  IF( zvs_excess > 0._wp ) THEN   ! snow-ice interface deplets below the ocean surface
+                     ! put snow excess in the ocean
+                     zfra = ( pv_s(ji,jj,jl) - zvs_excess ) / MAX( pv_s(ji,jj,jl), epsi20 )
+                     wfx_res(ji,jj) = wfx_res(ji,jj) + zvs_excess * rhos * z1_dt
+                     hfx_res(ji,jj) = hfx_res(ji,jj) - SUM( pe_s(ji,jj,1:nlay_s,jl) ) * ( 1._wp - zfra ) * z1_dt ! W.m-2 <0
+                     ! correct snow volume and heat content
+                     pe_s(ji,jj,1:nlay_s,jl) = pe_s(ji,jj,1:nlay_s,jl) * zfra
+                     pv_s(ji,jj,jl)          = pv_s(ji,jj,jl) - zvs_excess
+                  ENDIF
+                  !
+               ENDIF
+            END DO
          END DO
       END DO
       !
-      DO jj = 1, jpjm1                   !  Flux from j+1 to j when v LT 0.
-         DO ji = 1, jpi
-            zalf          = ( MAX(0._wp, -pvt(ji,jj) ) * zrdt * e1v(ji,jj) ) / psm(ji,jj+1) 
-            zalg  (ji,jj) = zalf
-            zalfq         = zalf * zalf
-            zalf1         = 1.0 - zalf
-            zalg1 (ji,jj) = zalf1
-            zalf1q        = zalf1 * zalf1
-            zalg1q(ji,jj) = zalf1q
-            !
-            zfm   (ji,jj) = zfm (ji,jj) + zalf  *   psm (ji,jj+1)
-            zf0   (ji,jj) = zf0 (ji,jj) + zalf  * ( ps0 (ji,jj+1) - zalf1 * (psy(ji,jj+1) - (zalf1 - zalf ) * psyy(ji,jj+1) ) )
-            zfy   (ji,jj) = zfy (ji,jj) + zalfq * ( psy (ji,jj+1) - 3.0 * zalf1 * psyy(ji,jj+1) )
-            zfyy  (ji,jj) = zfyy(ji,jj) + zalf  *   psyy(ji,jj+1) * zalfq
-            zfx   (ji,jj) = zfx (ji,jj) + zalf  * ( psx (ji,jj+1) - zalf1 * psxy(ji,jj+1) )
-            zfxy  (ji,jj) = zfxy(ji,jj) + zalfq *   psxy(ji,jj+1)
-            zfxx  (ji,jj) = zfxx(ji,jj) + zalf  *   psxx(ji,jj+1)
-         END DO
-      END DO
-
-      !  Readjust moments remaining in the box. 
-      DO jj = 2, jpj
-         DO ji = 1, jpi
-            zbt  =         zbet(ji,jj-1)
-            zbt1 = ( 1.0 - zbet(ji,jj-1) )
-            !
-            psm (ji,jj) = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) - zfm(ji,jj-1) )
-            ps0 (ji,jj) = zbt * ps0(ji,jj) + zbt1 * ( ps0(ji,jj) - zf0(ji,jj-1) )
-            psy (ji,jj) = zalg1q(ji,jj-1) * ( psy(ji,jj) + 3.0 * zalg(ji,jj-1) * psyy(ji,jj) )
-            psyy(ji,jj) = zalg1 (ji,jj-1) * zalg1q(ji,jj-1) * psyy(ji,jj)
-            psx (ji,jj) = zbt * psx (ji,jj) + zbt1 * ( psx (ji,jj) - zfx (ji,jj-1) )
-            psxx(ji,jj) = zbt * psxx(ji,jj) + zbt1 * ( psxx(ji,jj) - zfxx(ji,jj-1) )
-            psxy(ji,jj) = zalg1q(ji,jj-1) * psxy(ji,jj)
-         END DO
-      END DO
-
-      !   Put the temporary moments into appropriate neighboring boxes.    
-      DO jj = 2, jpjm1                    !   Flux from j to j+1 IF v GT 0.
-         DO ji = 1, jpi
-            zbt  =         zbet(ji,jj-1)
-            zbt1 = ( 1.0 - zbet(ji,jj-1) )
-            psm(ji,jj)  = zbt * ( psm(ji,jj) + zfm(ji,jj-1) ) + zbt1 * psm(ji,jj) 
-            zalf        = zbt * zfm(ji,jj-1) / psm(ji,jj) 
-            zalf1       = 1.0 - zalf
-            ztemp       = zalf * ps0(ji,jj) - zalf1 * zf0(ji,jj-1)
-            !
-            ps0(ji,jj)  = zbt  * ( ps0(ji,jj) + zf0(ji,jj-1) ) + zbt1 * ps0(ji,jj)
-            psy(ji,jj)  = zbt  * ( zalf * zfy(ji,jj-1) + zalf1 * psy(ji,jj) + 3.0 * ztemp )   &
-               &                                               + zbt1 * psy(ji,jj)  
-            psyy(ji,jj) = zbt  * ( zalf * zalf * zfyy(ji,jj-1) + zalf1 * zalf1 * psyy(ji,jj)                             &
-               &                 + 5.0 * ( zalf * zalf1 * ( psy(ji,jj) - zfy(ji,jj-1) ) - ( zalf1 - zalf ) * ztemp ) )   & 
-               &                                               + zbt1 * psyy(ji,jj)
-            psxy(ji,jj) = zbt  * (  zalf * zfxy(ji,jj-1) + zalf1 * psxy(ji,jj)               &
-               &                  + 3.0 * (- zalf1 * zfx(ji,jj-1) + zalf * psx(ji,jj) )  )   &
-               &                                                + zbt1 * psxy(ji,jj)
-            psx (ji,jj) = zbt * ( psx (ji,jj) + zfx (ji,jj-1) ) + zbt1 * psx (ji,jj)
-            psxx(ji,jj) = zbt * ( psxx(ji,jj) + zfxx(ji,jj-1) ) + zbt1 * psxx(ji,jj)
-         END DO
-      END DO
-
-      DO jj = 2, jpjm1                   !  Flux from j+1 to j IF v LT 0.
-         DO ji = 1, jpi
-            zbt  =         zbet(ji,jj)
-            zbt1 = ( 1.0 - zbet(ji,jj) )
-            psm(ji,jj)  = zbt * psm(ji,jj) + zbt1 * ( psm(ji,jj) + zfm(ji,jj) )
-            zalf        = zbt1 * zfm(ji,jj) / psm(ji,jj)
-            zalf1       = 1.0 - zalf
-            ztemp       = - zalf * ps0 (ji,jj) + zalf1 * zf0(ji,jj)
-            ps0 (ji,jj) =   zbt  * ps0 (ji,jj) + zbt1  * ( ps0(ji,jj) + zf0(ji,jj) )
-            psy (ji,jj) =   zbt  * psy (ji,jj) + zbt1  * ( zalf * zfy(ji,jj) + zalf1 * psy(ji,jj) + 3.0 * ztemp )
-            psyy(ji,jj) =   zbt  * psyy(ji,jj) + zbt1 * (  zalf * zalf * zfyy(ji,jj) + zalf1 * zalf1 * psyy(ji,jj)   &
-               &                                         + 5.0 *( zalf *zalf1 *( -psy(ji,jj) + zfy(ji,jj) )          &
-               &                                         + ( zalf1 - zalf ) * ztemp )                                )
-            psxy(ji,jj) =   zbt  * psxy(ji,jj) + zbt1 * (  zalf * zfxy(ji,jj) + zalf1 * psxy(ji,jj)       &
-               &                                         + 3.0 * ( zalf1 * zfx(ji,jj) - zalf * psx(ji,jj) )  )
-            psx (ji,jj) =   zbt  * psx (ji,jj) + zbt1 * ( psx (ji,jj) + zfx (ji,jj) )
-            psxx(ji,jj) =   zbt  * psxx(ji,jj) + zbt1 * ( psxx(ji,jj) + zfxx(ji,jj) )
-         END DO
-      END DO
-
-      !-- Lateral boundary conditions
-      CALL lbc_lnk_multi( 'icedyn_adv_pra', psm , 'T',  1.,  ps0 , 'T',  1.   &
-         &              , psx , 'T', -1.,  psy , 'T', -1.   &   ! caution gradient ==> the sign changes
-         &              , psxx, 'T',  1.,  psyy, 'T',  1.   &
-         &              , psxy, 'T',  1. )
-
-      IF(ln_ctl) THEN
-         CALL prt_ctl(tab2d_1=psm  , clinfo1=' adv_y: psm  :', tab2d_2=ps0 , clinfo2=' ps0  : ')
-         CALL prt_ctl(tab2d_1=psx  , clinfo1=' adv_y: psx  :', tab2d_2=psxx, clinfo2=' psxx : ')
-         CALL prt_ctl(tab2d_1=psy  , clinfo1=' adv_y: psy  :', tab2d_2=psyy, clinfo2=' psyy : ')
-         CALL prt_ctl(tab2d_1=psxy , clinfo1=' adv_y: psxy :')
-      ENDIF
-      !
-   END SUBROUTINE adv_y
+      !-- correct pond concentration to avoid a_ip > a_i -- !
+      WHERE( pa_ip(:,:,:) > pa_i(:,:,:) )   pa_ip(:,:,:) = pa_i(:,:,:)
+      !
+   END SUBROUTINE Hsnow
 
 
@@ -624,6 +654,5 @@
       !
       !                             !* allocate prather fields
-      ALLOCATE( sxopw(jpi,jpj)     , syopw(jpi,jpj)     , sxxopw(jpi,jpj)     , syyopw(jpi,jpj)     , sxyopw(jpi,jpj)     ,   &
-         &      sxice(jpi,jpj,jpl) , syice(jpi,jpj,jpl) , sxxice(jpi,jpj,jpl) , syyice(jpi,jpj,jpl) , sxyice(jpi,jpj,jpl) ,   &
+      ALLOCATE( sxice(jpi,jpj,jpl) , syice(jpi,jpj,jpl) , sxxice(jpi,jpj,jpl) , syyice(jpi,jpj,jpl) , sxyice(jpi,jpj,jpl) ,   &
          &      sxsn (jpi,jpj,jpl) , sysn (jpi,jpj,jpl) , sxxsn (jpi,jpj,jpl) , syysn (jpi,jpj,jpl) , sxysn (jpi,jpj,jpl) ,   &
          &      sxa  (jpi,jpj,jpl) , sya  (jpi,jpj,jpl) , sxxa  (jpi,jpj,jpl) , syya  (jpi,jpj,jpl) , sxya  (jpi,jpj,jpl) ,   &
@@ -652,5 +681,5 @@
       !!                   ***  ROUTINE adv_pra_rst  ***
       !!                     
-      !! ** Purpose :   Read or write RHG file in restart file
+      !! ** Purpose :   Read or write file in restart file
       !!
       !! ** Method  :   use of IOM library
@@ -671,5 +700,5 @@
          !                                   !==========================!
          !
-         IF( ln_rstart ) THEN   ;   id1 = iom_varid( numrir, 'sxopw' , ldstop = .FALSE. )    ! file exist: id1>0
+         IF( ln_rstart ) THEN   ;   id1 = iom_varid( numrir, 'sxice' , ldstop = .FALSE. )    ! file exist: id1>0
          ELSE                   ;   id1 = 0                                                  ! no restart: id1=0
          ENDIF
@@ -689,5 +718,5 @@
             CALL iom_get( numrir, jpdom_autoglo, 'syysn' , syysn  )
             CALL iom_get( numrir, jpdom_autoglo, 'sxysn' , sxysn  )
-            !                                                        ! lead fraction
+            !                                                        ! ice concentration
             CALL iom_get( numrir, jpdom_autoglo, 'sxa'   , sxa    )
             CALL iom_get( numrir, jpdom_autoglo, 'sya'   , sya    )
@@ -707,10 +736,4 @@
             CALL iom_get( numrir, jpdom_autoglo, 'syyage', syyage )
             CALL iom_get( numrir, jpdom_autoglo, 'sxyage', sxyage )
-            !                                                        ! open water in sea ice
-            CALL iom_get( numrir, jpdom_autoglo, 'sxopw' , sxopw  )
-            CALL iom_get( numrir, jpdom_autoglo, 'syopw' , syopw  )
-            CALL iom_get( numrir, jpdom_autoglo, 'sxxopw', sxxopw )
-            CALL iom_get( numrir, jpdom_autoglo, 'syyopw', syyopw )
-            CALL iom_get( numrir, jpdom_autoglo, 'sxyopw', sxyopw )
             !                                                        ! snow layers heat content
             DO jk = 1, nlay_s
@@ -752,8 +775,7 @@
             sxice = 0._wp   ;   syice = 0._wp   ;   sxxice = 0._wp   ;   syyice = 0._wp   ;   sxyice = 0._wp      ! ice thickness
             sxsn  = 0._wp   ;   sysn  = 0._wp   ;   sxxsn  = 0._wp   ;   syysn  = 0._wp   ;   sxysn  = 0._wp      ! snow thickness
-            sxa   = 0._wp   ;   sya   = 0._wp   ;   sxxa   = 0._wp   ;   syya   = 0._wp   ;   sxya   = 0._wp      ! lead fraction
+            sxa   = 0._wp   ;   sya   = 0._wp   ;   sxxa   = 0._wp   ;   syya   = 0._wp   ;   sxya   = 0._wp      ! ice concentration
             sxsal = 0._wp   ;   sysal = 0._wp   ;   sxxsal = 0._wp   ;   syysal = 0._wp   ;   sxysal = 0._wp      ! ice salinity
             sxage = 0._wp   ;   syage = 0._wp   ;   sxxage = 0._wp   ;   syyage = 0._wp   ;   sxyage = 0._wp      ! ice age
-            sxopw = 0._wp   ;   syopw = 0._wp   ;   sxxopw = 0._wp   ;   syyopw = 0._wp   ;   sxyopw = 0._wp      ! open water in sea ice
             sxc0  = 0._wp   ;   syc0  = 0._wp   ;   sxxc0  = 0._wp   ;   syyc0  = 0._wp   ;   sxyc0  = 0._wp      ! snow layers heat content
             sxe   = 0._wp   ;   sye   = 0._wp   ;   sxxe   = 0._wp   ;   syye   = 0._wp   ;   sxye   = 0._wp      ! ice layers heat content
@@ -786,5 +808,5 @@
          CALL iom_rstput( iter, nitrst, numriw, 'syysn' , syysn  )
          CALL iom_rstput( iter, nitrst, numriw, 'sxysn' , sxysn  )
-         !                                                           ! lead fraction
+         !                                                           ! ice concentration
          CALL iom_rstput( iter, nitrst, numriw, 'sxa'   , sxa    )
          CALL iom_rstput( iter, nitrst, numriw, 'sya'   , sya    )
@@ -804,10 +826,4 @@
          CALL iom_rstput( iter, nitrst, numriw, 'syyage', syyage )
          CALL iom_rstput( iter, nitrst, numriw, 'sxyage', sxyage )
-         !                                                           ! open water in sea ice
-         CALL iom_rstput( iter, nitrst, numriw, 'sxopw' , sxopw  )
-         CALL iom_rstput( iter, nitrst, numriw, 'syopw' , syopw  )
-         CALL iom_rstput( iter, nitrst, numriw, 'sxxopw', sxxopw )
-         CALL iom_rstput( iter, nitrst, numriw, 'syyopw', syyopw )
-         CALL iom_rstput( iter, nitrst, numriw, 'sxyopw', sxyopw )
          !                                                           ! snow layers heat content
          DO jk = 1, nlay_s
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_adv_umx.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_adv_umx.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_adv_umx.F90	(revision 12143)
@@ -83,5 +83,5 @@
       REAL(wp), DIMENSION(:,:,:)  , INTENT(inout) ::   poa_i      ! age content
       REAL(wp), DIMENSION(:,:,:)  , INTENT(inout) ::   pa_i       ! ice concentration
-      REAL(wp), DIMENSION(:,:,:)  , INTENT(inout) ::   pa_ip      ! melt pond fraction
+      REAL(wp), DIMENSION(:,:,:)  , INTENT(inout) ::   pa_ip      ! melt pond concentration
       REAL(wp), DIMENSION(:,:,:)  , INTENT(inout) ::   pv_ip      ! melt pond volume
       REAL(wp), DIMENSION(:,:,:,:), INTENT(inout) ::   pe_s       ! snw heat content
@@ -319,13 +319,11 @@
          !
          !== Ice age ==!
-         IF( iom_use('iceage') .OR. iom_use('iceage_cat') ) THEN
-            zamsk = 1._wp
-            CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy , zvdx , zu_cat, zv_cat, zcu_box, zcv_box, &
-               &                                      poa_i, poa_i )
-         ENDIF
+         zamsk = 1._wp
+         CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy , zvdx , zu_cat, zv_cat, zcu_box, zcv_box, &
+            &                                      poa_i, poa_i )
          !
          !== melt ponds ==!
          IF ( ln_pnd_H12 ) THEN
-            ! fraction
+            ! concentration
             zamsk = 1._wp
             CALL adv_umx( zamsk, kn_umx, jt, kt, zdt, zudy , zvdx , zu_cat , zv_cat , zcu_box, zcv_box, &
@@ -1529,5 +1527,5 @@
       !!              3- check whether snow load deplets the snow-ice interface below sea level$
       !!                 and reduce it by sending the excess in the ocean
-      !!              4- correct pond fraction to avoid a_ip > a_i
+      !!              4- correct pond concentration to avoid a_ip > a_i
       !!
       !! ** input   : Max thickness of the surrounding 9-points
@@ -1599,5 +1597,5 @@
          END DO
       END DO 
-      !                                           !-- correct pond fraction to avoid a_ip > a_i
+      !                                           !-- correct pond concentration to avoid a_ip > a_i
       WHERE( pa_ip(:,:,:) > pa_i(:,:,:) )   pa_ip(:,:,:) = pa_i(:,:,:)
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_rdgrft.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_rdgrft.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_rdgrft.F90	(revision 12143)
@@ -86,7 +86,7 @@
       !!                ***  ROUTINE ice_dyn_rdgrft_alloc ***
       !!-------------------------------------------------------------------
-      ALLOCATE( closing_net(jpij), opning(jpij)   , closing_gross(jpij),   &
-         &      apartf(jpij,0:jpl), hrmin(jpij,jpl), hraft(jpij,jpl)    , aridge(jpij,jpl),   &
-         &      hrmax(jpij,jpl), hi_hrdg(jpij,jpl)  , araft (jpij,jpl),  &
+      ALLOCATE( closing_net(jpij)  , opning(jpij)      , closing_gross(jpij) ,               &
+         &      apartf(jpij,0:jpl) , hrmin  (jpij,jpl) , hraft(jpij,jpl) , aridge(jpij,jpl), &
+         &      hrmax (jpij,jpl)   , hi_hrdg(jpij,jpl) , araft(jpij,jpl) ,                   &
          &      ze_i_2d(jpij,nlay_i,jpl), ze_s_2d(jpij,nlay_s,jpl), STAT=ice_dyn_rdgrft_alloc )
 
@@ -137,5 +137,4 @@
       REAL(wp) ::   zfac                       ! local scalar
       INTEGER , DIMENSION(jpij) ::   iptidx        ! compute ridge/raft or not
-      REAL(wp), DIMENSION(jpij) ::   zdivu_adv     ! divu as implied by transport scheme  (1/s)
       REAL(wp), DIMENSION(jpij) ::   zdivu, zdelt  ! 1D divu_i & delta_i
       !
@@ -145,4 +144,5 @@
       IF( ln_timing    )   CALL timing_start('icedyn_rdgrft')                                                             ! timing
       IF( ln_icediachk )   CALL ice_cons_hsm(0, 'icedyn_rdgrft', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
+      IF( ln_icediachk )   CALL ice_cons2D  (0, 'icedyn_rdgrft',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
 
       IF( kt == nit000 ) THEN
@@ -174,7 +174,7 @@
         
          ! just needed here
-         CALL tab_2d_1d( npti, nptidx(1:npti), zdivu   (1:npti)      , divu_i  )
          CALL tab_2d_1d( npti, nptidx(1:npti), zdelt   (1:npti)      , delta_i )
          ! needed here and in the iteration loop
+         CALL tab_2d_1d( npti, nptidx(1:npti), zdivu   (1:npti)      , divu_i) ! zdivu is used as a work array here (no change in divu_i)
          CALL tab_3d_2d( npti, nptidx(1:npti), a_i_2d  (1:npti,1:jpl), a_i   )
          CALL tab_3d_2d( npti, nptidx(1:npti), v_i_2d  (1:npti,1:jpl), v_i   )
@@ -186,16 +186,8 @@
             closing_net(ji) = rn_csrdg * 0.5_wp * ( zdelt(ji) - ABS( zdivu(ji) ) ) - MIN( zdivu(ji), 0._wp )
             !
-            ! divergence given by the advection scheme
-            !   (which may not be equal to divu as computed from the velocity field)
-            IF    ( ln_adv_Pra ) THEN
-               zdivu_adv(ji) = ( 1._wp - ato_i_1d(ji) - SUM( a_i_2d(ji,:) ) ) * r1_rdtice
-            ELSEIF( ln_adv_UMx ) THEN
-               zdivu_adv(ji) = zdivu(ji)
-            ENDIF
-            !
-            IF( zdivu_adv(ji) < 0._wp )   closing_net(ji) = MAX( closing_net(ji), -zdivu_adv(ji) )   ! make sure the closing rate is large enough
-            !                                                                                        ! to give asum = 1.0 after ridging
+            IF( zdivu(ji) < 0._wp )   closing_net(ji) = MAX( closing_net(ji), -zdivu(ji) )   ! make sure the closing rate is large enough
+            !                                                                                ! to give asum = 1.0 after ridging
             ! Opening rate (non-negative) that will give asum = 1.0 after ridging.
-            opning(ji) = closing_net(ji) + zdivu_adv(ji)
+            opning(ji) = closing_net(ji) + zdivu(ji)
          END DO
          !
@@ -214,5 +206,5 @@
                ato_i_1d   (ipti)   = ato_i_1d   (ji)
                closing_net(ipti)   = closing_net(ji)
-               zdivu_adv  (ipti)   = zdivu_adv  (ji)
+               zdivu      (ipti)   = zdivu      (ji)
                opning     (ipti)   = opning     (ji)
             ENDIF
@@ -258,7 +250,7 @@
                ELSE
                   iterate_ridging  = 1
-                  zdivu_adv  (ji) = zfac * r1_rdtice
-                  closing_net(ji) = MAX( 0._wp, -zdivu_adv(ji) )
-                  opning     (ji) = MAX( 0._wp,  zdivu_adv(ji) )
+                  zdivu      (ji) = zfac * r1_rdtice
+                  closing_net(ji) = MAX( 0._wp, -zdivu(ji) )
+                  opning     (ji) = MAX( 0._wp,  zdivu(ji) )
                ENDIF
             END DO
@@ -276,6 +268,8 @@
 
       ! controls
+      IF( ln_ctl       )   CALL ice_prt3D   ('icedyn_rdgrft')                                                             ! prints
+      IF( ln_icectl    )   CALL ice_prt     (kt, iiceprt, jiceprt,-1, ' - ice dyn rdgrft - ')                             ! prints
       IF( ln_icediachk )   CALL ice_cons_hsm(1, 'icedyn_rdgrft', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
-      IF( ln_ctl       )   CALL ice_prt3D   ('icedyn_rdgrft')                                                             ! prints
+      IF( ln_icediachk )   CALL ice_cons2D  (1, 'icedyn_rdgrft',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
       IF( ln_timing    )   CALL timing_stop ('icedyn_rdgrft')                                                             ! timing
       !
@@ -306,5 +300,5 @@
 
       !                       ! Ice thickness needed for rafting
-      WHERE( pa_i(1:npti,:) > epsi20 )   ;   zhi(1:npti,:) = pv_i(1:npti,:) / pa_i(1:npti,:)
+      WHERE( pa_i(1:npti,:) > epsi10 )   ;   zhi(1:npti,:) = pv_i(1:npti,:) / pa_i(1:npti,:)
       ELSEWHERE                          ;   zhi(1:npti,:) = 0._wp
       END WHERE
@@ -325,5 +319,5 @@
       zasum(1:npti) = pato_i(1:npti) + SUM( pa_i(1:npti,:), dim=2 )
       !
-      WHERE( zasum(1:npti) > epsi20 )   ;   z1_asum(1:npti) = 1._wp / zasum(1:npti)
+      WHERE( zasum(1:npti) > epsi10 )   ;   z1_asum(1:npti) = 1._wp / zasum(1:npti)
       ELSEWHERE                         ;   z1_asum(1:npti) = 0._wp
       END WHERE
@@ -451,5 +445,5 @@
       ! Based on the ITD of ridging and ridged ice, convert the net closing rate to a gross closing rate.  
       ! NOTE: 0 < aksum <= 1
-      WHERE( zaksum(1:npti) > epsi20 )   ;   closing_gross(1:npti) = pclosing_net(1:npti) / zaksum(1:npti)
+      WHERE( zaksum(1:npti) > epsi10 )   ;   closing_gross(1:npti) = pclosing_net(1:npti) / zaksum(1:npti)
       ELSEWHERE                          ;   closing_gross(1:npti) = 0._wp
       END WHERE
@@ -534,5 +528,5 @@
             IF( apartf(ji,jl1) > 0._wp .AND. closing_gross(ji) > 0._wp ) THEN   ! only if ice is ridging
 
-               IF( a_i_2d(ji,jl1) > epsi20 ) THEN   ;   z1_ai(ji) = 1._wp / a_i_2d(ji,jl1)
+               IF( a_i_2d(ji,jl1) > epsi10 ) THEN   ;   z1_ai(ji) = 1._wp / a_i_2d(ji,jl1)
                ELSE                                 ;   z1_ai(ji) = 0._wp
                ENDIF
@@ -592,5 +586,5 @@
                ! virtual salt flux to keep salinity constant
                IF( nn_icesal /= 2 )  THEN
-                  sirdg2(ji)     = sirdg2(ji)     - vsw * ( sss_1d(ji) - s_i_1d(ji) )        ! ridge salinity = s_i
+                  sirdg2(ji)     = sirdg2(ji)     - vsw * ( sss_1d(ji) - s_i_1d(ji) )       ! ridge salinity = s_i
                   sfx_bri_1d(ji) = sfx_bri_1d(ji) + sss_1d(ji) * vsw * rhoi * r1_rdtice  &  ! put back sss_m into the ocean
                      &                            - s_i_1d(ji) * vsw * rhoi * r1_rdtice     ! and get  s_i  from the ocean 
@@ -916,8 +910,8 @@
       REWIND( numnam_ice_ref )              ! Namelist namicetdme in reference namelist : Ice mechanical ice redistribution
       READ  ( numnam_ice_ref, namdyn_rdgrft, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_rdgrft in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_rdgrft in reference namelist' )
       REWIND( numnam_ice_cfg )              ! Namelist namdyn_rdgrft in configuration namelist : Ice mechanical ice redistribution
       READ  ( numnam_ice_cfg, namdyn_rdgrft, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_rdgrft in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_rdgrft in configuration namelist' )
       IF(lwm) WRITE ( numoni, namdyn_rdgrft )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_rhg.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_rhg.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_rhg.F90	(revision 12143)
@@ -64,4 +64,5 @@
       IF( ln_timing    )   CALL timing_start('icedyn_rhg')                                                             ! timing
       IF( ln_icediachk )   CALL ice_cons_hsm(0, 'icedyn_rhg', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
+      IF( ln_icediachk )   CALL ice_cons2D  (0, 'icedyn_rhg',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
       !
       IF( kt == nit000 .AND. lwp ) THEN
@@ -69,11 +70,4 @@
          WRITE(numout,*)'ice_dyn_rhg: sea-ice rheology'
          WRITE(numout,*)'~~~~~~~~~~~'
-      ENDIF
-      !
-      IF( ln_landfast_home ) THEN      !-- Landfast ice parameterization
-         tau_icebfr(:,:) = 0._wp
-         DO jl = 1, jpl
-            WHERE( h_i(:,:,jl) > ht_n(:,:) * rn_depfra )   tau_icebfr(:,:) = tau_icebfr(:,:) + a_i(:,:,jl) * rn_icebfr
-         END DO
       ENDIF
       !
@@ -94,6 +88,7 @@
       !
       ! controls
+      IF( ln_ctl       )   CALL ice_prt3D   ('icedyn_rhg')                                                             ! prints
       IF( ln_icediachk )   CALL ice_cons_hsm(1, 'icedyn_rhg', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
-      IF( ln_ctl       )   CALL ice_prt3D   ('icedyn_rhg')                                                             ! prints
+      IF( ln_icediachk )   CALL ice_cons2D  (1, 'icedyn_rhg',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
       IF( ln_timing    )   CALL timing_stop ('icedyn_rhg')                                                             ! timing
       !
@@ -120,8 +115,8 @@
       REWIND( numnam_ice_ref )         ! Namelist namdyn_rhg in reference namelist : Ice dynamics
       READ  ( numnam_ice_ref, namdyn_rhg, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_rhg in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_rhg in reference namelist' )
       REWIND( numnam_ice_cfg )         ! Namelist namdyn_rhg in configuration namelist : Ice dynamics
       READ  ( numnam_ice_cfg, namdyn_rhg, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namdyn_rhg in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namdyn_rhg in configuration namelist' )
       IF(lwm) WRITE ( numoni, namdyn_rhg )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_rhg_evp.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_rhg_evp.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icedyn_rhg_evp.F90	(revision 12143)
@@ -112,6 +112,4 @@
       REAL(wp), DIMENSION(:,:), INTENT(  out) ::   pshear_i  , pdivu_i   , pdelta_i      !
       !!
-      LOGICAL, PARAMETER ::   ll_bdy_substep = .TRUE. ! temporary option to call bdy at each sub-time step (T)
-      !                                                                              or only at the main time step (F)
       INTEGER ::   ji, jj       ! dummy loop indices
       INTEGER ::   jter         ! local integers
@@ -123,5 +121,5 @@
       REAL(wp) ::   zm1, zm2, zm3, zmassU, zmassV, zvU, zvV             ! ice/snow mass and volume
       REAL(wp) ::   zdelta, zp_delf, zds2, zdt, zdt2, zdiv, zdiv2       ! temporary scalars
-      REAL(wp) ::   zTauO, zTauB, zTauE, zvel                           ! temporary scalars
+      REAL(wp) ::   zTauO, zTauB, zRHS, zvel                            ! temporary scalars
       REAL(wp) ::   zkt                                                 ! isotropic tensile strength for landfast ice
       REAL(wp) ::   zvCr                                                ! critical ice volume above which ice is landfast
@@ -132,17 +130,12 @@
       REAL(wp) ::   zshear, zdum1, zdum2
       !
-      REAL(wp), DIMENSION(jpi,jpj) ::   z1_e1t0, z1_e2t0                ! scale factors
       REAL(wp), DIMENSION(jpi,jpj) ::   zp_delt                         ! P/delta at T points
       REAL(wp), DIMENSION(jpi,jpj) ::   zbeta                           ! beta coef from Kimmritz 2017
       !
       REAL(wp), DIMENSION(jpi,jpj) ::   zdt_m                           ! (dt / ice-snow_mass) on T points
-      REAL(wp), DIMENSION(jpi,jpj) ::   zaU   , zaV                     ! ice fraction on U/V points
+      REAL(wp), DIMENSION(jpi,jpj) ::   zaU  , zaV                      ! ice fraction on U/V points
       REAL(wp), DIMENSION(jpi,jpj) ::   zmU_t, zmV_t                    ! (ice-snow_mass / dt) on U/V points
       REAL(wp), DIMENSION(jpi,jpj) ::   zmf                             ! coriolis parameter at T points
-      REAL(wp), DIMENSION(jpi,jpj) ::   zTauU_ia , ztauV_ia             ! ice-atm. stress at U-V points
-      REAL(wp), DIMENSION(jpi,jpj) ::   zTauU_ib , ztauV_ib             ! ice-bottom stress at U-V points (landfast param)
-      REAL(wp), DIMENSION(jpi,jpj) ::   zspgU , zspgV                   ! surface pressure gradient at U/V points
       REAL(wp), DIMENSION(jpi,jpj) ::   v_oceU, u_oceV, v_iceU, u_iceV  ! ocean/ice u/v component on V/U points                           
-      REAL(wp), DIMENSION(jpi,jpj) ::   zfU   , zfV                     ! internal stresses
       !
       REAL(wp), DIMENSION(jpi,jpj) ::   zds                             ! shear
@@ -152,9 +145,14 @@
       !                                                                 !    ocean surface (ssh_m) if ice is not embedded
       !                                                                 !    ice bottom surface if ice is embedded   
-      REAL(wp), DIMENSION(jpi,jpj) ::   zCorx, zCory                    ! Coriolis stress array
-      REAL(wp), DIMENSION(jpi,jpj) ::   ztaux_oi, ztauy_oi              ! Ocean-to-ice stress array
-      !
-      REAL(wp), DIMENSION(jpi,jpj) ::   zswitchU, zswitchV              ! dummy arrays
-      REAL(wp), DIMENSION(jpi,jpj) ::   zmaskU, zmaskV                  ! mask for ice presence
+      REAL(wp), DIMENSION(jpi,jpj) ::   zfU  , zfV                      ! internal stresses
+      REAL(wp), DIMENSION(jpi,jpj) ::   zspgU, zspgV                    ! surface pressure gradient at U/V points
+      REAL(wp), DIMENSION(jpi,jpj) ::   zCorU, zCorV                    ! Coriolis stress array
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztaux_ai, ztauy_ai              ! ice-atm. stress at U-V points
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztaux_oi, ztauy_oi              ! ice-ocean stress at U-V points
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztaux_bi, ztauy_bi              ! ice-OceanBottom stress at U-V points (landfast)
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztaux_base, ztauy_base          ! ice-bottom stress at U-V points (landfast)
+      !
+      REAL(wp), DIMENSION(jpi,jpj) ::   zmsk01x, zmsk01y                ! dummy arrays
+      REAL(wp), DIMENSION(jpi,jpj) ::   zmsk00x, zmsk00y                ! mask for ice presence
       REAL(wp), DIMENSION(jpi,jpj) ::   zfmask, zwf                     ! mask at F points for the ice
 
@@ -163,17 +161,7 @@
       REAL(wp), PARAMETER          ::   zamin  = 0.001_wp               ! ice concentration below which ice velocity becomes very small
       !! --- diags
-      REAL(wp), DIMENSION(jpi,jpj) ::   zswi
+      REAL(wp), DIMENSION(jpi,jpj) ::   zmsk00
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zsig1, zsig2, zsig3
       !! --- SIMIP diags
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_sig1      ! Average normal stress in sea ice   
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_sig2      ! Maximum shear stress in sea ice
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_dssh_dx   ! X-direction sea-surface tilt term (N/m2)
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_dssh_dy   ! X-direction sea-surface tilt term (N/m2)
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_corstrx   ! X-direction coriolis stress (N/m2)
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_corstry   ! Y-direction coriolis stress (N/m2)
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_intstrx   ! X-direction internal stress (N/m2)
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_intstry   ! Y-direction internal stress (N/m2)
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_utau_oi   ! X-direction ocean-ice stress
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_vtau_oi   ! Y-direction ocean-ice stress  
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_xmtrp_ice ! X-component of ice mass transport (kg/s)
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_ymtrp_ice ! Y-component of ice mass transport (kg/s)
@@ -255,15 +243,7 @@
       CALL ice_strength
 
-      ! scale factors
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1
-            z1_e1t0(ji,jj) = 1._wp / ( e1t(ji+1,jj  ) + e1t(ji,jj  ) )
-            z1_e2t0(ji,jj) = 1._wp / ( e2t(ji  ,jj+1) + e2t(ji,jj  ) )
-         END DO
-      END DO
-
       ! landfast param from Lemieux(2016): add isotropic tensile strength (following Konig Beatty and Holland, 2010)
-      IF( ln_landfast_L16 .OR. ln_landfast_home ) THEN   ;   zkt = rn_tensile
-      ELSE                                               ;   zkt = 0._wp
+      IF( ln_landfast_L16 ) THEN   ;   zkt = rn_tensile
+      ELSE                         ;   zkt = 0._wp
       ENDIF
       !
@@ -291,9 +271,6 @@
 
             ! Ocean currents at U-V points
-            v_oceU(ji,jj)   = 0.5_wp * ( ( v_oce(ji  ,jj) + v_oce(ji  ,jj-1) ) * e1t(ji+1,jj)    &
-               &                       + ( v_oce(ji+1,jj) + v_oce(ji+1,jj-1) ) * e1t(ji  ,jj) ) * z1_e1t0(ji,jj) * umask(ji,jj,1)
-            
-            u_oceV(ji,jj)   = 0.5_wp * ( ( u_oce(ji,jj  ) + u_oce(ji-1,jj  ) ) * e2t(ji,jj+1)    &
-               &                       + ( u_oce(ji,jj+1) + u_oce(ji-1,jj+1) ) * e2t(ji,jj  ) ) * z1_e2t0(ji,jj) * vmask(ji,jj,1)
+            v_oceU(ji,jj)   = 0.25_wp * ( v_oce(ji,jj) + v_oce(ji,jj-1) + v_oce(ji+1,jj) + v_oce(ji+1,jj-1) ) * umask(ji,jj,1)
+            u_oceV(ji,jj)   = 0.25_wp * ( u_oce(ji,jj) + u_oce(ji-1,jj) + u_oce(ji,jj+1) + u_oce(ji-1,jj+1) ) * vmask(ji,jj,1)
 
             ! Coriolis at T points (m*f)
@@ -308,6 +285,6 @@
             
             ! Drag ice-atm.
-            zTauU_ia(ji,jj) = zaU(ji,jj) * utau_ice(ji,jj)
-            zTauV_ia(ji,jj) = zaV(ji,jj) * vtau_ice(ji,jj)
+            ztaux_ai(ji,jj) = zaU(ji,jj) * utau_ice(ji,jj)
+            ztauy_ai(ji,jj) = zaV(ji,jj) * vtau_ice(ji,jj)
 
             ! Surface pressure gradient (- m*g*GRAD(ssh)) at U-V points
@@ -316,12 +293,12 @@
 
             ! masks
-            zmaskU(ji,jj) = 1._wp - MAX( 0._wp, SIGN( 1._wp, -zmassU ) )  ! 0 if no ice
-            zmaskV(ji,jj) = 1._wp - MAX( 0._wp, SIGN( 1._wp, -zmassV ) )  ! 0 if no ice
+            zmsk00x(ji,jj) = 1._wp - MAX( 0._wp, SIGN( 1._wp, -zmassU ) )  ! 0 if no ice
+            zmsk00y(ji,jj) = 1._wp - MAX( 0._wp, SIGN( 1._wp, -zmassV ) )  ! 0 if no ice
 
             ! switches
-            IF( zmassU <= zmmin .AND. zaU(ji,jj) <= zamin ) THEN   ;   zswitchU(ji,jj) = 0._wp
-            ELSE                                                   ;   zswitchU(ji,jj) = 1._wp   ;   ENDIF
-            IF( zmassV <= zmmin .AND. zaV(ji,jj) <= zamin ) THEN   ;   zswitchV(ji,jj) = 0._wp
-            ELSE                                                   ;   zswitchV(ji,jj) = 1._wp   ;   ENDIF
+            IF( zmassU <= zmmin .AND. zaU(ji,jj) <= zamin ) THEN   ;   zmsk01x(ji,jj) = 0._wp
+            ELSE                                                   ;   zmsk01x(ji,jj) = 1._wp   ;   ENDIF
+            IF( zmassV <= zmmin .AND. zaV(ji,jj) <= zamin ) THEN   ;   zmsk01y(ji,jj) = 0._wp
+            ELSE                                                   ;   zmsk01y(ji,jj) = 1._wp   ;   ENDIF
 
          END DO
@@ -339,32 +316,23 @@
                ! ice-bottom stress at U points
                zvCr = zaU(ji,jj) * rn_depfra * hu_n(ji,jj)
-               zTauU_ib(ji,jj)   = rn_icebfr * MAX( 0._wp, zvU - zvCr ) * EXP( -rn_crhg * ( 1._wp - zaU(ji,jj) ) )
+               ztaux_base(ji,jj) = - rn_icebfr * MAX( 0._wp, zvU - zvCr ) * EXP( -rn_crhg * ( 1._wp - zaU(ji,jj) ) )
                ! ice-bottom stress at V points
                zvCr = zaV(ji,jj) * rn_depfra * hv_n(ji,jj)
-               zTauV_ib(ji,jj)   = rn_icebfr * MAX( 0._wp, zvV - zvCr ) * EXP( -rn_crhg * ( 1._wp - zaV(ji,jj) ) )
+               ztauy_base(ji,jj) = - rn_icebfr * MAX( 0._wp, zvV - zvCr ) * EXP( -rn_crhg * ( 1._wp - zaV(ji,jj) ) )
                ! ice_bottom stress at T points
                zvCr = at_i(ji,jj) * rn_depfra * ht_n(ji,jj)
-               tau_icebfr(ji,jj) = rn_icebfr * MAX( 0._wp, vt_i(ji,jj) - zvCr ) * EXP( -rn_crhg * ( 1._wp - at_i(ji,jj) ) )
+               tau_icebfr(ji,jj) = - rn_icebfr * MAX( 0._wp, vt_i(ji,jj) - zvCr ) * EXP( -rn_crhg * ( 1._wp - at_i(ji,jj) ) )
             END DO
          END DO
          CALL lbc_lnk( 'icedyn_rhg_evp', tau_icebfr(:,:), 'T', 1. )
          !
-      ELSEIF( ln_landfast_home ) THEN          !-- Home made
+      ELSE                               !-- no landfast
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1
-               zTauU_ib(ji,jj) = tau_icebfr(ji,jj)
-               zTauV_ib(ji,jj) = tau_icebfr(ji,jj)
-            END DO
-         END DO
-         !
-      ELSE                                     !-- no landfast
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1
-               zTauU_ib(ji,jj) = 0._wp
-               zTauV_ib(ji,jj) = 0._wp
+               ztaux_base(ji,jj) = 0._wp
+               ztauy_base(ji,jj) = 0._wp
             END DO
          END DO
       ENDIF
-      IF( iom_use('tau_icebfr') )   CALL iom_put( 'tau_icebfr', tau_icebfr(:,:) )
 
       !------------------------------------------------------------------------------!
@@ -372,7 +340,7 @@
       !------------------------------------------------------------------------------!
       !
-      !                                               !----------------------!
+      !                                               ! ==================== !
       DO jter = 1 , nn_nevp                           !    loop over jter    !
-         !                                            !----------------------!        
+         !                                            ! ==================== !        
          l_full_nf_update = jter == nn_nevp   ! false: disable full North fold update (performances) for iter = 1 to nn_nevp-1
          !
@@ -479,11 +447,8 @@
                   &                  ) * r1_e1e2v(ji,jj)
                !
-               !                !--- u_ice at V point
-               u_iceV(ji,jj) = 0.5_wp * ( ( u_ice(ji,jj  ) + u_ice(ji-1,jj  ) ) * e2t(ji,jj+1)     &
-                  &                     + ( u_ice(ji,jj+1) + u_ice(ji-1,jj+1) ) * e2t(ji,jj  ) ) * z1_e2t0(ji,jj) * vmask(ji,jj,1)
+               !                !--- ice currents at U-V point
+               v_iceU(ji,jj) = 0.25_wp * ( v_ice(ji,jj) + v_ice(ji,jj-1) + v_ice(ji+1,jj) + v_ice(ji+1,jj-1) ) * umask(ji,jj,1)
+               u_iceV(ji,jj) = 0.25_wp * ( u_ice(ji,jj) + u_ice(ji-1,jj) + u_ice(ji,jj+1) + u_ice(ji-1,jj+1) ) * vmask(ji,jj,1)
                !
-               !                !--- v_ice at U point
-               v_iceU(ji,jj) = 0.5_wp * ( ( v_ice(ji  ,jj) + v_ice(ji  ,jj-1) ) * e1t(ji+1,jj)     &
-                  &                     + ( v_ice(ji+1,jj) + v_ice(ji+1,jj-1) ) * e1t(ji  ,jj) ) * z1_e1t0(ji,jj) * umask(ji,jj,1)
             END DO
          END DO
@@ -504,31 +469,34 @@
                   !                 !--- tau_bottom/v_ice
                   zvel  = 5.e-05_wp + SQRT( v_ice(ji,jj) * v_ice(ji,jj) + u_iceV(ji,jj) * u_iceV(ji,jj) )
-                  zTauB = - zTauV_ib(ji,jj) / zvel
+                  zTauB = ztauy_base(ji,jj) / zvel
+                  !                 !--- OceanBottom-to-Ice stress
+                  ztauy_bi(ji,jj) = zTauB * v_ice(ji,jj)
                   !
                   !                 !--- Coriolis at V-points (energy conserving formulation)
-                  zCory(ji,jj)  = - 0.25_wp * r1_e2v(ji,jj) *  &
+                  zCorV(ji,jj)  = - 0.25_wp * r1_e2v(ji,jj) *  &
                      &    ( zmf(ji,jj  ) * ( e2u(ji,jj  ) * u_ice(ji,jj  ) + e2u(ji-1,jj  ) * u_ice(ji-1,jj  ) )  &
                      &    + zmf(ji,jj+1) * ( e2u(ji,jj+1) * u_ice(ji,jj+1) + e2u(ji-1,jj+1) * u_ice(ji-1,jj+1) ) )
                   !
                   !                 !--- Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
-                  zTauE = zfV(ji,jj) + zTauV_ia(ji,jj) + zCory(ji,jj) + zspgV(ji,jj) + ztauy_oi(ji,jj)
-                  !
-                  !                 !--- landfast switch => 0 = static friction ; 1 = sliding friction
-                  rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, ztauE - zTauV_ib(ji,jj) ) - SIGN( 1._wp, zTauE ) ) )
+                  zRHS = zfV(ji,jj) + ztauy_ai(ji,jj) + zCorV(ji,jj) + zspgV(ji,jj) + ztauy_oi(ji,jj)
+                  !
+                  !                 !--- landfast switch => 0 = static  friction : TauB > RHS & sign(TauB) /= sign(RHS)
+                  !                                         1 = sliding friction : TauB < RHS
+                  rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, zRHS + ztauy_base(ji,jj) ) - SIGN( 1._wp, zRHS ) ) )
                   !
                   IF( ln_aEVP ) THEN !--- ice velocity using aEVP (Kimmritz et al 2016 & 2017)
-                  v_ice(ji,jj) = ( (          rswitch * ( zmV_t(ji,jj) * ( zbeta(ji,jj) * v_ice(ji,jj) + v_ice_b(ji,jj) )         & ! previous velocity
-                     &                                  + zTauE + zTauO * v_ice(ji,jj)                                            & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
-                     &                                  ) / MAX( zepsi, zmV_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
-                     &                 + ( 1._wp - rswitch ) * v_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )           & ! static friction => slow decrease to v=0
-                     &             ) * zswitchV(ji,jj) + v_oce(ji,jj) * 0.01_wp * ( 1._wp - zswitchV(ji,jj) )                     & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
-                     &           ) * zmaskV(ji,jj)
+                     v_ice(ji,jj) = ( (          rswitch * ( zmV_t(ji,jj) * ( zbeta(ji,jj) * v_ice(ji,jj) + v_ice_b(ji,jj) )       & ! previous velocity
+                        &                                  + zRHS + zTauO * v_ice(ji,jj) )                                         & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                        &                                  / MAX( zepsi, zmV_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
+                        &               + ( 1._wp - rswitch ) * v_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )           & ! static friction => slow decrease to v=0
+                        &             ) * zmsk01y(ji,jj) + v_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01y(ji,jj) )                     & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
+                        &           )   * zmsk00y(ji,jj)
                   ELSE               !--- ice velocity using EVP implicit formulation (cf Madec doc & Bouillon 2009)
-                  v_ice(ji,jj) = ( (           rswitch   * ( zmV_t(ji,jj)  * v_ice(ji,jj)                             &  ! previous velocity
-                     &                                     + zTauE + zTauO * v_ice(ji,jj)                             &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
-                     &                                     ) / MAX( zepsi, zmV_t(ji,jj) + zTauO - zTauB )             &  ! m/dt + tau_io(only ice part) + landfast
-                     &              + ( 1._wp - rswitch ) * v_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )  &  ! static friction => slow decrease to v=0
-                     &              ) * zswitchV(ji,jj) + v_oce(ji,jj) * 0.01_wp * ( 1._wp - zswitchV(ji,jj) )        &  ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
-                     &            ) * zmaskV(ji,jj)
+                     v_ice(ji,jj) = ( (           rswitch   * ( zmV_t(ji,jj)  * v_ice(ji,jj)                                       & ! previous velocity
+                        &                                     + zRHS + zTauO * v_ice(ji,jj) )                                      & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                        &                                     / MAX( zepsi, zmV_t(ji,jj) + zTauO - zTauB )                         & ! m/dt + tau_io(only ice part) + landfast
+                        &                + ( 1._wp - rswitch ) * v_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )          & ! static friction => slow decrease to v=0
+                        &              ) * zmsk01y(ji,jj) + v_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01y(ji,jj) )                    & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
+                        &            )   * zmsk00y(ji,jj)
                   ENDIF
                END DO
@@ -540,5 +508,5 @@
             CALL agrif_interp_ice( 'V' )
 #endif
-            IF( ln_bdy .AND. ll_bdy_substep ) CALL bdy_ice_dyn( 'V' )
+            IF( ln_bdy )   CALL bdy_ice_dyn( 'V' )
             !
             DO jj = 2, jpjm1
@@ -552,31 +520,34 @@
                   !                 !--- tau_bottom/u_ice
                   zvel  = 5.e-05_wp + SQRT( v_iceU(ji,jj) * v_iceU(ji,jj) + u_ice(ji,jj) * u_ice(ji,jj) )
-                  zTauB = - zTauU_ib(ji,jj) / zvel
+                  zTauB = ztaux_base(ji,jj) / zvel
+                  !                 !--- OceanBottom-to-Ice stress
+                  ztaux_bi(ji,jj) = zTauB * u_ice(ji,jj)
                   !
                   !                 !--- Coriolis at U-points (energy conserving formulation)
-                  zCorx(ji,jj)  =   0.25_wp * r1_e1u(ji,jj) *  &
+                  zCorU(ji,jj)  =   0.25_wp * r1_e1u(ji,jj) *  &
                      &    ( zmf(ji  ,jj) * ( e1v(ji  ,jj) * v_ice(ji  ,jj) + e1v(ji  ,jj-1) * v_ice(ji  ,jj-1) )  &
                      &    + zmf(ji+1,jj) * ( e1v(ji+1,jj) * v_ice(ji+1,jj) + e1v(ji+1,jj-1) * v_ice(ji+1,jj-1) ) )
                   !
                   !                 !--- Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
-                  zTauE = zfU(ji,jj) + zTauU_ia(ji,jj) + zCorx(ji,jj) + zspgU(ji,jj) + ztaux_oi(ji,jj)
-                  !
-                  !                 !--- landfast switch => 0 = static friction ; 1 = sliding friction
-                  rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, ztauE - zTauU_ib(ji,jj) ) - SIGN( 1._wp, zTauE ) ) )
+                  zRHS = zfU(ji,jj) + ztaux_ai(ji,jj) + zCorU(ji,jj) + zspgU(ji,jj) + ztaux_oi(ji,jj)
+                  !
+                  !                 !--- landfast switch => 0 = static  friction : TauB > RHS & sign(TauB) /= sign(RHS)
+                  !                                         1 = sliding friction : TauB < RHS
+                  rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, zRHS + ztaux_base(ji,jj) ) - SIGN( 1._wp, zRHS ) ) )
                   !
                   IF( ln_aEVP ) THEN !--- ice velocity using aEVP (Kimmritz et al 2016 & 2017)
-                  u_ice(ji,jj) = ( (          rswitch * ( zmU_t(ji,jj) * ( zbeta(ji,jj) * u_ice(ji,jj) + u_ice_b(ji,jj) )         & ! previous velocity
-                     &                                     + zTauE + zTauO * u_ice(ji,jj)                                         & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
-                     &                                  ) / MAX( zepsi, zmU_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
-                     &              + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )              & ! static friction => slow decrease to v=0
-                     &              ) * zswitchU(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zswitchU(ji,jj) )                    & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin 
-                     &            ) * zmaskU(ji,jj)
+                     u_ice(ji,jj) = ( (          rswitch * ( zmU_t(ji,jj) * ( zbeta(ji,jj) * u_ice(ji,jj) + u_ice_b(ji,jj) )       & ! previous velocity
+                        &                                  + zRHS + zTauO * u_ice(ji,jj) )                                         & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                        &                                  / MAX( zepsi, zmU_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
+                        &               + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )           & ! static friction => slow decrease to v=0
+                        &             ) * zmsk01x(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01x(ji,jj) )                     & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin 
+                        &           )   * zmsk00x(ji,jj)
                   ELSE               !--- ice velocity using EVP implicit formulation (cf Madec doc & Bouillon 2009)
-                  u_ice(ji,jj) = ( (           rswitch   * ( zmU_t(ji,jj)  * u_ice(ji,jj)                             &  ! previous velocity
-                     &                                     + zTauE + zTauO * u_ice(ji,jj)                             &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
-                     &                                     ) / MAX( zepsi, zmU_t(ji,jj) + zTauO - zTauB )             &  ! m/dt + tau_io(only ice part) + landfast
-                     &              + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )  &  ! static friction => slow decrease to v=0
-                     &              ) * zswitchU(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zswitchU(ji,jj) )        &  ! v_ice = v_oce/100 if mass < zmmin & conc < zamin 
-                     &            ) * zmaskU(ji,jj)
+                     u_ice(ji,jj) = ( (           rswitch   * ( zmU_t(ji,jj)  * u_ice(ji,jj)                                       & ! previous velocity
+                        &                                     + zRHS + zTauO * u_ice(ji,jj) )                                      & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                        &                                     / MAX( zepsi, zmU_t(ji,jj) + zTauO - zTauB )                         & ! m/dt + tau_io(only ice part) + landfast
+                        &                + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )          & ! static friction => slow decrease to v=0
+                        &              ) * zmsk01x(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01x(ji,jj) )                    & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin 
+                        &            )   * zmsk00x(ji,jj)
                   ENDIF
                END DO
@@ -588,5 +559,5 @@
             CALL agrif_interp_ice( 'U' )
 #endif
-            IF( ln_bdy .AND. ll_bdy_substep ) CALL bdy_ice_dyn( 'U' )
+            IF( ln_bdy )   CALL bdy_ice_dyn( 'U' )
             !
          ELSE ! odd iterations
@@ -602,31 +573,34 @@
                   !                 !--- tau_bottom/u_ice
                   zvel  = 5.e-05_wp + SQRT( v_iceU(ji,jj) * v_iceU(ji,jj) + u_ice(ji,jj) * u_ice(ji,jj) )
-                  zTauB = - zTauU_ib(ji,jj) / zvel
+                  zTauB = ztaux_base(ji,jj) / zvel
+                  !                 !--- OceanBottom-to-Ice stress
+                  ztaux_bi(ji,jj) = zTauB * u_ice(ji,jj)
                   !
                   !                 !--- Coriolis at U-points (energy conserving formulation)
-                  zCorx(ji,jj)  =   0.25_wp * r1_e1u(ji,jj) *  &
+                  zCorU(ji,jj)  =   0.25_wp * r1_e1u(ji,jj) *  &
                      &    ( zmf(ji  ,jj) * ( e1v(ji  ,jj) * v_ice(ji  ,jj) + e1v(ji  ,jj-1) * v_ice(ji  ,jj-1) )  &
                      &    + zmf(ji+1,jj) * ( e1v(ji+1,jj) * v_ice(ji+1,jj) + e1v(ji+1,jj-1) * v_ice(ji+1,jj-1) ) )
                   !
                   !                 !--- Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
-                  zTauE = zfU(ji,jj) + zTauU_ia(ji,jj) + zCorx(ji,jj) + zspgU(ji,jj) + ztaux_oi(ji,jj)
-                  !
-                  !                 !--- landfast switch => 0 = static friction ; 1 = sliding friction
-                  rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, ztauE - zTauU_ib(ji,jj) ) - SIGN( 1._wp, zTauE ) ) )
+                  zRHS = zfU(ji,jj) + ztaux_ai(ji,jj) + zCorU(ji,jj) + zspgU(ji,jj) + ztaux_oi(ji,jj)
+                  !
+                  !                 !--- landfast switch => 0 = static  friction : TauB > RHS & sign(TauB) /= sign(RHS)
+                  !                                         1 = sliding friction : TauB < RHS
+                  rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, zRHS + ztaux_base(ji,jj) ) - SIGN( 1._wp, zRHS ) ) )
                   !
                   IF( ln_aEVP ) THEN !--- ice velocity using aEVP (Kimmritz et al 2016 & 2017)
-                  u_ice(ji,jj) = ( (          rswitch * ( zmU_t(ji,jj) * ( zbeta(ji,jj) * u_ice(ji,jj) + u_ice_b(ji,jj) )         & ! previous velocity
-                     &                                     + zTauE + zTauO * u_ice(ji,jj)                                         & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
-                     &                                  ) / MAX( zepsi, zmU_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
-                     &              + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )              & ! static friction => slow decrease to v=0
-                     &              ) * zswitchU(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zswitchU(ji,jj) )                    & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin 
-                     &            ) * zmaskU(ji,jj)
+                     u_ice(ji,jj) = ( (          rswitch * ( zmU_t(ji,jj) * ( zbeta(ji,jj) * u_ice(ji,jj) + u_ice_b(ji,jj) )       & ! previous velocity
+                        &                                  + zRHS + zTauO * u_ice(ji,jj) )                                         & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                        &                                  / MAX( zepsi, zmU_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
+                        &               + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )           & ! static friction => slow decrease to v=0
+                        &             ) * zmsk01x(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01x(ji,jj) )                     & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin 
+                        &           )   * zmsk00x(ji,jj)
                   ELSE               !--- ice velocity using EVP implicit formulation (cf Madec doc & Bouillon 2009)
-                  u_ice(ji,jj) = ( (           rswitch   * ( zmU_t(ji,jj)  * u_ice(ji,jj)                             &  ! previous velocity
-                     &                                     + zTauE + zTauO * u_ice(ji,jj)                             &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
-                     &                                     ) / MAX( zepsi, zmU_t(ji,jj) + zTauO - zTauB )             &  ! m/dt + tau_io(only ice part) + landfast
-                     &              + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )  &  ! static friction => slow decrease to v=0
-                     &              ) * zswitchU(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zswitchU(ji,jj) )        &  ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
-                     &            ) * zmaskU(ji,jj)
+                     u_ice(ji,jj) = ( (           rswitch   * ( zmU_t(ji,jj)  * u_ice(ji,jj)                                       & ! previous velocity
+                        &                                     + zRHS + zTauO * u_ice(ji,jj) )                                      & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                        &                                     / MAX( zepsi, zmU_t(ji,jj) + zTauO - zTauB )                         & ! m/dt + tau_io(only ice part) + landfast
+                        &                + ( 1._wp - rswitch ) * u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )          & ! static friction => slow decrease to v=0
+                        &              ) * zmsk01x(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01x(ji,jj) )                    & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
+                        &            )   * zmsk00x(ji,jj)
                   ENDIF
                END DO
@@ -638,5 +612,5 @@
             CALL agrif_interp_ice( 'U' )
 #endif
-            IF( ln_bdy .AND. ll_bdy_substep ) CALL bdy_ice_dyn( 'U' )
+            IF( ln_bdy )   CALL bdy_ice_dyn( 'U' )
             !
             DO jj = 2, jpjm1
@@ -650,31 +624,34 @@
                   !                 !--- tau_bottom/v_ice
                   zvel  = 5.e-05_wp + SQRT( v_ice(ji,jj) * v_ice(ji,jj) + u_iceV(ji,jj) * u_iceV(ji,jj) )
-                  zTauB = - zTauV_ib(ji,jj) / zvel
+                  zTauB = ztauy_base(ji,jj) / zvel
+                  !                 !--- OceanBottom-to-Ice stress
+                  ztauy_bi(ji,jj) = zTauB * v_ice(ji,jj)
                   !
                   !                 !--- Coriolis at v-points (energy conserving formulation)
-                  zCory(ji,jj)  = - 0.25_wp * r1_e2v(ji,jj) *  &
+                  zCorV(ji,jj)  = - 0.25_wp * r1_e2v(ji,jj) *  &
                      &    ( zmf(ji,jj  ) * ( e2u(ji,jj  ) * u_ice(ji,jj  ) + e2u(ji-1,jj  ) * u_ice(ji-1,jj  ) )  &
                      &    + zmf(ji,jj+1) * ( e2u(ji,jj+1) * u_ice(ji,jj+1) + e2u(ji-1,jj+1) * u_ice(ji-1,jj+1) ) )
                   !
                   !                 !--- Sum of external forces (explicit solution) = F + tau_ia + Coriolis + spg + tau_io
-                  zTauE = zfV(ji,jj) + zTauV_ia(ji,jj) + zCory(ji,jj) + zspgV(ji,jj) + ztauy_oi(ji,jj)
-                  !
-                  !                 !--- landfast switch => 0 = static friction ; 1 = sliding friction
-                  rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, zTauE - zTauV_ib(ji,jj) ) - SIGN( 1._wp, zTauE ) ) )
+                  zRHS = zfV(ji,jj) + ztauy_ai(ji,jj) + zCorV(ji,jj) + zspgV(ji,jj) + ztauy_oi(ji,jj)
+                  !
+                  !                 !--- landfast switch => 0 = static  friction : TauB > RHS & sign(TauB) /= sign(RHS)
+                  !                                         1 = sliding friction : TauB < RHS
+                  rswitch = 1._wp - MIN( 1._wp, ABS( SIGN( 1._wp, zRHS + ztauy_base(ji,jj) ) - SIGN( 1._wp, zRHS ) ) )
                   !
                   IF( ln_aEVP ) THEN !--- ice velocity using aEVP (Kimmritz et al 2016 & 2017)
-                  v_ice(ji,jj) = ( (          rswitch * ( zmV_t(ji,jj) * ( zbeta(ji,jj) * v_ice(ji,jj) + v_ice_b(ji,jj) )         & ! previous velocity
-                     &                                  + zTauE + zTauO * v_ice(ji,jj)                                            & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
-                     &                                  ) / MAX( zepsi, zmV_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
-                     &                 + ( 1._wp - rswitch ) * v_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )           & ! static friction => slow decrease to v=0
-                     &             ) * zswitchV(ji,jj) + v_oce(ji,jj) * 0.01_wp * ( 1._wp - zswitchV(ji,jj) )                     & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
-                     &           ) * zmaskV(ji,jj)
+                     v_ice(ji,jj) = ( (          rswitch * ( zmV_t(ji,jj) * ( zbeta(ji,jj) * v_ice(ji,jj) + v_ice_b(ji,jj) )       & ! previous velocity
+                        &                                  + zRHS + zTauO * v_ice(ji,jj) )                                         & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                        &                                  / MAX( zepsi, zmV_t(ji,jj) * ( zbeta(ji,jj) + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
+                        &               + ( 1._wp - rswitch ) * v_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )           & ! static friction => slow decrease to v=0
+                        &             ) * zmsk01y(ji,jj) + v_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01y(ji,jj) )                     & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
+                        &           )   * zmsk00y(ji,jj)
                   ELSE               !--- ice velocity using EVP implicit formulation (cf Madec doc & Bouillon 2009)
-                  v_ice(ji,jj) = ( (           rswitch   * ( zmV_t(ji,jj)  * v_ice(ji,jj)                             &  ! previous velocity
-                     &                                     + zTauE + zTauO * v_ice(ji,jj)                             &  ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
-                     &                                     ) / MAX( zepsi, zmV_t(ji,jj) + zTauO - zTauB )             &  ! m/dt + tau_io(only ice part) + landfast
-                     &              + ( 1._wp - rswitch ) * v_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )  &  ! static friction => slow decrease to v=0
-                     &              ) * zswitchV(ji,jj) + v_oce(ji,jj) * 0.01_wp * ( 1._wp - zswitchV(ji,jj) )        &  ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
-                     &            ) * zmaskV(ji,jj)
+                     v_ice(ji,jj) = ( (           rswitch   * ( zmV_t(ji,jj)  * v_ice(ji,jj)                                       & ! previous velocity
+                        &                                     + zRHS + zTauO * v_ice(ji,jj) )                                      & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
+                        &                                     / MAX( zepsi, zmV_t(ji,jj) + zTauO - zTauB )                         & ! m/dt + tau_io(only ice part) + landfast
+                        &                + ( 1._wp - rswitch ) * v_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lfrelax )          & ! static friction => slow decrease to v=0
+                        &              ) * zmsk01y(ji,jj) + v_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01y(ji,jj) )                    & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
+                        &            )   * zmsk00y(ji,jj)
                   ENDIF
                END DO
@@ -686,5 +663,5 @@
             CALL agrif_interp_ice( 'V' )
 #endif
-            IF( ln_bdy .AND. ll_bdy_substep ) CALL bdy_ice_dyn( 'V' )
+            IF( ln_bdy )   CALL bdy_ice_dyn( 'V' )
             !
          ENDIF
@@ -701,9 +678,4 @@
       END DO                                              !  end loop over jter  !
       !                                                   ! ==================== !
-      !
-      IF( ln_bdy .AND. .NOT.ll_bdy_substep ) THEN
-         CALL bdy_ice_dyn( 'U' )
-         CALL bdy_ice_dyn( 'V' )
-      ENDIF
       !
       !------------------------------------------------------------------------------!
@@ -764,15 +736,30 @@
       DO jj = 1, jpj
          DO ji = 1, jpi
-            zswi(ji,jj) = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi06 ) ) ! 1 if ice, 0 if no ice
+            zmsk00(ji,jj) = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi06 ) ) ! 1 if ice, 0 if no ice
          END DO
       END DO
 
+      ! --- ice-ocean, ice-atm. & ice-oceanbottom(landfast) stresses --- !
+      IF(  iom_use('utau_oi') .OR. iom_use('vtau_oi') .OR. iom_use('utau_ai') .OR. iom_use('vtau_ai') .OR. &
+         & iom_use('utau_bi') .OR. iom_use('vtau_bi') ) THEN
+         !
+         CALL lbc_lnk_multi( 'icedyn_rhg_evp', ztaux_oi, 'U', -1., ztauy_oi, 'V', -1., ztaux_ai, 'U', -1., ztauy_ai, 'V', -1., &
+            &                                  ztaux_bi, 'U', -1., ztauy_bi, 'V', -1. )
+         !
+         CALL iom_put( 'utau_oi' , ztaux_oi * zmsk00 )
+         CALL iom_put( 'vtau_oi' , ztauy_oi * zmsk00 )
+         CALL iom_put( 'utau_ai' , ztaux_ai * zmsk00 )
+         CALL iom_put( 'vtau_ai' , ztauy_ai * zmsk00 )
+         CALL iom_put( 'utau_bi' , ztaux_bi * zmsk00 )
+         CALL iom_put( 'vtau_bi' , ztauy_bi * zmsk00 )
+      ENDIF
+       
       ! --- divergence, shear and strength --- !
-      IF( iom_use('icediv') )   CALL iom_put( "icediv" , pdivu_i (:,:) * zswi(:,:) )   ! divergence
-      IF( iom_use('iceshe') )   CALL iom_put( "iceshe" , pshear_i(:,:) * zswi(:,:) )   ! shear
-      IF( iom_use('icestr') )   CALL iom_put( "icestr" , strength(:,:) * zswi(:,:) )   ! Ice strength
-
-      ! --- charge ellipse --- !
-      IF( iom_use('isig1') .OR. iom_use('isig2') .OR. iom_use('isig3') ) THEN
+      IF( iom_use('icediv') )   CALL iom_put( 'icediv' , pdivu_i  * zmsk00 )   ! divergence
+      IF( iom_use('iceshe') )   CALL iom_put( 'iceshe' , pshear_i * zmsk00 )   ! shear
+      IF( iom_use('icestr') )   CALL iom_put( 'icestr' , strength * zmsk00 )   ! strength
+
+      ! --- stress tensor --- !
+      IF( iom_use('isig1') .OR. iom_use('isig2') .OR. iom_use('isig3') .OR. iom_use('normstr') .OR. iom_use('sheastr') ) THEN
          !
          ALLOCATE( zsig1(jpi,jpj) , zsig2(jpi,jpj) , zsig3(jpi,jpj) )
@@ -780,11 +767,11 @@
          DO jj = 2, jpjm1
             DO ji = 2, jpim1
-               zdum1 = ( zswi(ji-1,jj) * pstress12_i(ji-1,jj) + zswi(ji  ,jj-1) * pstress12_i(ji  ,jj-1) +  &  ! stress12_i at T-point
-                  &      zswi(ji  ,jj) * pstress12_i(ji  ,jj) + zswi(ji-1,jj-1) * pstress12_i(ji-1,jj-1) )  &
-                  &    / MAX( 1._wp, zswi(ji-1,jj) + zswi(ji,jj-1) + zswi(ji,jj) + zswi(ji-1,jj-1) )
+               zdum1 = ( zmsk00(ji-1,jj) * pstress12_i(ji-1,jj) + zmsk00(ji  ,jj-1) * pstress12_i(ji  ,jj-1) +  &  ! stress12_i at T-point
+                  &      zmsk00(ji  ,jj) * pstress12_i(ji  ,jj) + zmsk00(ji-1,jj-1) * pstress12_i(ji-1,jj-1) )  &
+                  &    / MAX( 1._wp, zmsk00(ji-1,jj) + zmsk00(ji,jj-1) + zmsk00(ji,jj) + zmsk00(ji-1,jj-1) )
 
                zshear = SQRT( pstress2_i(ji,jj) * pstress2_i(ji,jj) + 4._wp * zdum1 * zdum1 ) ! shear stress  
 
-               zdum2 = zswi(ji,jj) / MAX( 1._wp, strength(ji,jj) )
+               zdum2 = zmsk00(ji,jj) / MAX( 1._wp, strength(ji,jj) )
 
 !!               zsig1(ji,jj) = 0.5_wp * zdum2 * ( pstress1_i(ji,jj) + zshear ) ! principal stress (y-direction, see Hunke & Dukowicz 2002)
@@ -799,90 +786,67 @@
          CALL lbc_lnk_multi( 'icedyn_rhg_evp', zsig1, 'T', 1., zsig2, 'T', 1., zsig3, 'T', 1. )
          !
-         IF( iom_use('isig1') )   CALL iom_put( "isig1" , zsig1 )
-         IF( iom_use('isig2') )   CALL iom_put( "isig2" , zsig2 )
-         IF( iom_use('isig3') )   CALL iom_put( "isig3" , zsig3 )
-         !
+         CALL iom_put( 'isig1' , zsig1 )
+         CALL iom_put( 'isig2' , zsig2 )
+         CALL iom_put( 'isig3' , zsig3 )
+         !
+         ! Stress tensor invariants (normal and shear stress N/m)
+         IF( iom_use('normstr') )   CALL iom_put( 'normstr' ,       ( zs1(:,:) + zs2(:,:) )                       * zmsk00(:,:) ) ! Normal stress
+         IF( iom_use('sheastr') )   CALL iom_put( 'sheastr' , SQRT( ( zs1(:,:) - zs2(:,:) )**2 + 4*zs12(:,:)**2 ) * zmsk00(:,:) ) ! Shear stress
+
          DEALLOCATE( zsig1 , zsig2 , zsig3 )
       ENDIF
       
       ! --- SIMIP --- !
-      IF ( iom_use( 'normstr'  ) .OR. iom_use( 'sheastr'  ) .OR. iom_use( 'dssh_dx'  ) .OR. iom_use( 'dssh_dy'  ) .OR. &
-         & iom_use( 'corstrx'  ) .OR. iom_use( 'corstry'  ) .OR. iom_use( 'intstrx'  ) .OR. iom_use( 'intstry'  ) .OR. &
-         & iom_use( 'utau_oi'  ) .OR. iom_use( 'vtau_oi'  ) .OR. iom_use( 'xmtrpice' ) .OR. iom_use( 'ymtrpice' ) .OR. &
-         & iom_use( 'xmtrpsnw' ) .OR. iom_use( 'ymtrpsnw' ) .OR. iom_use( 'xatrp'    ) .OR. iom_use( 'yatrp'    ) ) THEN
-
-         ALLOCATE( zdiag_sig1     (jpi,jpj) , zdiag_sig2     (jpi,jpj) , zdiag_dssh_dx  (jpi,jpj) , zdiag_dssh_dy  (jpi,jpj) ,  &
-            &      zdiag_corstrx  (jpi,jpj) , zdiag_corstry  (jpi,jpj) , zdiag_intstrx  (jpi,jpj) , zdiag_intstry  (jpi,jpj) ,  &
-            &      zdiag_utau_oi  (jpi,jpj) , zdiag_vtau_oi  (jpi,jpj) , zdiag_xmtrp_ice(jpi,jpj) , zdiag_ymtrp_ice(jpi,jpj) ,  &
-            &      zdiag_xmtrp_snw(jpi,jpj) , zdiag_ymtrp_snw(jpi,jpj) , zdiag_xatrp    (jpi,jpj) , zdiag_yatrp    (jpi,jpj) )
-         
+      IF(  iom_use('dssh_dx') .OR. iom_use('dssh_dy') .OR. &
+         & iom_use('corstrx') .OR. iom_use('corstry') .OR. iom_use('intstrx') .OR. iom_use('intstry') ) THEN
+         !
+         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zspgU, 'U', -1., zspgV, 'V', -1., &
+            &                                  zCorU, 'U', -1., zCorV, 'V', -1., zfU, 'U', -1., zfV, 'V', -1. )
+
+         CALL iom_put( 'dssh_dx' , zspgU * zmsk00 )   ! Sea-surface tilt term in force balance (x)
+         CALL iom_put( 'dssh_dy' , zspgV * zmsk00 )   ! Sea-surface tilt term in force balance (y)
+         CALL iom_put( 'corstrx' , zCorU * zmsk00 )   ! Coriolis force term in force balance (x)
+         CALL iom_put( 'corstry' , zCorV * zmsk00 )   ! Coriolis force term in force balance (y)
+         CALL iom_put( 'intstrx' , zfU   * zmsk00 )   ! Internal force term in force balance (x)
+         CALL iom_put( 'intstry' , zfV   * zmsk00 )   ! Internal force term in force balance (y)
+      ENDIF
+
+      IF(  iom_use('xmtrpice') .OR. iom_use('ymtrpice') .OR. &
+         & iom_use('xmtrpsnw') .OR. iom_use('ymtrpsnw') .OR. iom_use('xatrp') .OR. iom_use('yatrp') ) THEN
+         !
+         ALLOCATE( zdiag_xmtrp_ice(jpi,jpj) , zdiag_ymtrp_ice(jpi,jpj) , &
+            &      zdiag_xmtrp_snw(jpi,jpj) , zdiag_ymtrp_snw(jpi,jpj) , zdiag_xatrp(jpi,jpj) , zdiag_yatrp(jpi,jpj) )
+         !
          DO jj = 2, jpjm1
             DO ji = 2, jpim1
-               rswitch  = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi06 ) ) ! 1 if ice, 0 if no ice
-               
-               ! Stress tensor invariants (normal and shear stress N/m)
-               zdiag_sig1(ji,jj) = ( zs1(ji,jj) + zs2(ji,jj) ) * rswitch                                 ! normal stress
-               zdiag_sig2(ji,jj) = SQRT( ( zs1(ji,jj) - zs2(ji,jj) )**2 + 4*zs12(ji,jj)**2 ) * rswitch   ! shear stress
-               
-               ! Stress terms of the momentum equation (N/m2)
-               zdiag_dssh_dx(ji,jj) = zspgU(ji,jj) * rswitch     ! sea surface slope stress term
-               zdiag_dssh_dy(ji,jj) = zspgV(ji,jj) * rswitch
-               
-               zdiag_corstrx(ji,jj) = zCorx(ji,jj) * rswitch     ! Coriolis stress term
-               zdiag_corstry(ji,jj) = zCory(ji,jj) * rswitch
-               
-               zdiag_intstrx(ji,jj) = zfU(ji,jj)   * rswitch     ! internal stress term
-               zdiag_intstry(ji,jj) = zfV(ji,jj)   * rswitch
-               
-               zdiag_utau_oi(ji,jj) = ztaux_oi(ji,jj) * rswitch  ! oceanic stress
-               zdiag_vtau_oi(ji,jj) = ztauy_oi(ji,jj) * rswitch
-               
                ! 2D ice mass, snow mass, area transport arrays (X, Y)
-               zfac_x = 0.5 * u_ice(ji,jj) * e2u(ji,jj) * rswitch
-               zfac_y = 0.5 * v_ice(ji,jj) * e1v(ji,jj) * rswitch
-               
+               zfac_x = 0.5 * u_ice(ji,jj) * e2u(ji,jj) * zmsk00(ji,jj)
+               zfac_y = 0.5 * v_ice(ji,jj) * e1v(ji,jj) * zmsk00(ji,jj)
+
                zdiag_xmtrp_ice(ji,jj) = rhoi * zfac_x * ( vt_i(ji+1,jj) + vt_i(ji,jj) ) ! ice mass transport, X-component
                zdiag_ymtrp_ice(ji,jj) = rhoi * zfac_y * ( vt_i(ji,jj+1) + vt_i(ji,jj) ) !        ''           Y-   ''
-               
+
                zdiag_xmtrp_snw(ji,jj) = rhos * zfac_x * ( vt_s(ji+1,jj) + vt_s(ji,jj) ) ! snow mass transport, X-component
                zdiag_ymtrp_snw(ji,jj) = rhos * zfac_y * ( vt_s(ji,jj+1) + vt_s(ji,jj) ) !          ''          Y-   ''
-               
+
                zdiag_xatrp(ji,jj)     = zfac_x * ( at_i(ji+1,jj) + at_i(ji,jj) )        ! area transport,      X-component
                zdiag_yatrp(ji,jj)     = zfac_y * ( at_i(ji,jj+1) + at_i(ji,jj) )        !        ''            Y-   ''
-               
-            END DO
-         END DO
-         
-         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zdiag_sig1   , 'T',  1., zdiag_sig2   , 'T',  1.,   &
-            &                zdiag_dssh_dx, 'U', -1., zdiag_dssh_dy, 'V', -1.,   &
-            &                zdiag_corstrx, 'U', -1., zdiag_corstry, 'V', -1.,   & 
-            &                zdiag_intstrx, 'U', -1., zdiag_intstry, 'V', -1.    )
-                  
-         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zdiag_utau_oi  , 'U', -1., zdiag_vtau_oi  , 'V', -1.,   &
-            &                zdiag_xmtrp_ice, 'U', -1., zdiag_xmtrp_snw, 'U', -1.,   &
-            &                zdiag_xatrp    , 'U', -1., zdiag_ymtrp_ice, 'V', -1.,   &
-            &                zdiag_ymtrp_snw, 'V', -1., zdiag_yatrp    , 'V', -1.    )
-         
-         IF( iom_use('normstr' ) )   CALL iom_put( 'normstr'  ,  zdiag_sig1(:,:)      )   ! Normal stress
-         IF( iom_use('sheastr' ) )   CALL iom_put( 'sheastr'  ,  zdiag_sig2(:,:)      )   ! Shear stress
-         IF( iom_use('dssh_dx' ) )   CALL iom_put( 'dssh_dx'  ,  zdiag_dssh_dx(:,:)   )   ! Sea-surface tilt term in force balance (x)
-         IF( iom_use('dssh_dy' ) )   CALL iom_put( 'dssh_dy'  ,  zdiag_dssh_dy(:,:)   )   ! Sea-surface tilt term in force balance (y)
-         IF( iom_use('corstrx' ) )   CALL iom_put( 'corstrx'  ,  zdiag_corstrx(:,:)   )   ! Coriolis force term in force balance (x)
-         IF( iom_use('corstry' ) )   CALL iom_put( 'corstry'  ,  zdiag_corstry(:,:)   )   ! Coriolis force term in force balance (y)
-         IF( iom_use('intstrx' ) )   CALL iom_put( 'intstrx'  ,  zdiag_intstrx(:,:)   )   ! Internal force term in force balance (x)
-         IF( iom_use('intstry' ) )   CALL iom_put( 'intstry'  ,  zdiag_intstry(:,:)   )   ! Internal force term in force balance (y)
-         IF( iom_use('utau_oi' ) )   CALL iom_put( 'utau_oi'  ,  zdiag_utau_oi(:,:)   )   ! Ocean stress term in force balance (x)
-         IF( iom_use('vtau_oi' ) )   CALL iom_put( 'vtau_oi'  ,  zdiag_vtau_oi(:,:)   )   ! Ocean stress term in force balance (y)
-         IF( iom_use('xmtrpice') )   CALL iom_put( 'xmtrpice' ,  zdiag_xmtrp_ice(:,:) )   ! X-component of sea-ice mass transport (kg/s)
-         IF( iom_use('ymtrpice') )   CALL iom_put( 'ymtrpice' ,  zdiag_ymtrp_ice(:,:) )   ! Y-component of sea-ice mass transport 
-         IF( iom_use('xmtrpsnw') )   CALL iom_put( 'xmtrpsnw' ,  zdiag_xmtrp_snw(:,:) )   ! X-component of snow mass transport (kg/s)
-         IF( iom_use('ymtrpsnw') )   CALL iom_put( 'ymtrpsnw' ,  zdiag_ymtrp_snw(:,:) )   ! Y-component of snow mass transport
-         IF( iom_use('xatrp'   ) )   CALL iom_put( 'xatrp'    ,  zdiag_xatrp(:,:)     )   ! X-component of ice area transport
-         IF( iom_use('yatrp'   ) )   CALL iom_put( 'yatrp'    ,  zdiag_yatrp(:,:)     )   ! Y-component of ice area transport
-
-         DEALLOCATE( zdiag_sig1      , zdiag_sig2      , zdiag_dssh_dx   , zdiag_dssh_dy   ,  &
-            &        zdiag_corstrx   , zdiag_corstry   , zdiag_intstrx   , zdiag_intstry   ,  &
-            &        zdiag_utau_oi   , zdiag_vtau_oi   , zdiag_xmtrp_ice , zdiag_ymtrp_ice ,  &
-            &        zdiag_xmtrp_snw , zdiag_ymtrp_snw , zdiag_xatrp     , zdiag_yatrp     )
+
+            END DO
+         END DO
+
+         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zdiag_xmtrp_ice, 'U', -1., zdiag_ymtrp_ice, 'V', -1., &
+            &                                  zdiag_xmtrp_snw, 'U', -1., zdiag_ymtrp_snw, 'V', -1., &
+            &                                  zdiag_xatrp    , 'U', -1., zdiag_yatrp    , 'V', -1. )
+
+         CALL iom_put( 'xmtrpice' , zdiag_xmtrp_ice )   ! X-component of sea-ice mass transport (kg/s)
+         CALL iom_put( 'ymtrpice' , zdiag_ymtrp_ice )   ! Y-component of sea-ice mass transport 
+         CALL iom_put( 'xmtrpsnw' , zdiag_xmtrp_snw )   ! X-component of snow mass transport (kg/s)
+         CALL iom_put( 'ymtrpsnw' , zdiag_ymtrp_snw )   ! Y-component of snow mass transport
+         CALL iom_put( 'xatrp'    , zdiag_xatrp     )   ! X-component of ice area transport
+         CALL iom_put( 'yatrp'    , zdiag_yatrp     )   ! Y-component of ice area transport
+
+         DEALLOCATE( zdiag_xmtrp_ice , zdiag_ymtrp_ice , &
+            &        zdiag_xmtrp_snw , zdiag_ymtrp_snw , zdiag_xatrp , zdiag_yatrp )
 
       ENDIF
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/iceistate.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/iceistate.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/iceistate.F90	(revision 12143)
@@ -22,6 +22,8 @@
    USE eosbn2         ! equation of state
    USE domvvl         ! Variable volume
-   USE ice            ! sea-ice variables
-   USE icevar         ! ice_var_salprof
+   USE ice            ! sea-ice: variables
+   USE ice1D          ! sea-ice: thermodynamics variables
+   USE icetab         ! sea-ice: 1D <==> 2D transformation
+   USE icevar         ! sea-ice: operations
    !
    USE in_out_manager ! I/O manager
@@ -36,29 +38,27 @@
    PUBLIC   ice_istate        ! called by icestp.F90
    PUBLIC   ice_istate_init   ! called by icestp.F90
-
-   INTEGER , PARAMETER ::   jpfldi = 6           ! maximum number of files to read
-   INTEGER , PARAMETER ::   jp_hti = 1           ! index of ice thickness (m)    at T-point
-   INTEGER , PARAMETER ::   jp_hts = 2           ! index of snow thicknes (m)    at T-point
-   INTEGER , PARAMETER ::   jp_ati = 3           ! index of ice fraction (%) at T-point
-   INTEGER , PARAMETER ::   jp_tsu = 4           ! index of ice surface temp (K)    at T-point
-   INTEGER , PARAMETER ::   jp_tmi = 5           ! index of ice temp at T-point
-   INTEGER , PARAMETER ::   jp_smi = 6           ! index of ice sali at T-point
-   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   si  ! structure of input fields (file informations, fields read)
    !
    !                             !! ** namelist (namini) **
-   LOGICAL  ::   ln_iceini        ! initialization or not
-   LOGICAL  ::   ln_iceini_file   ! Ice initialization state from 2D netcdf file
-   REAL(wp) ::   rn_thres_sst     ! threshold water temperature for initial sea ice
-   REAL(wp) ::   rn_hts_ini_n     ! initial snow thickness in the north
-   REAL(wp) ::   rn_hts_ini_s     ! initial snow thickness in the south
-   REAL(wp) ::   rn_hti_ini_n     ! initial ice thickness in the north
-   REAL(wp) ::   rn_hti_ini_s     ! initial ice thickness in the south
-   REAL(wp) ::   rn_ati_ini_n     ! initial leads area in the north
-   REAL(wp) ::   rn_ati_ini_s     ! initial leads area in the south
-   REAL(wp) ::   rn_smi_ini_n     ! initial salinity 
-   REAL(wp) ::   rn_smi_ini_s     ! initial salinity
-   REAL(wp) ::   rn_tmi_ini_n     ! initial temperature
-   REAL(wp) ::   rn_tmi_ini_s     ! initial temperature
-   
+   LOGICAL, PUBLIC  ::   ln_iceini        !: Ice initialization or not
+   LOGICAL, PUBLIC  ::   ln_iceini_file   !: Ice initialization from 2D netcdf file
+   REAL(wp) ::   rn_thres_sst
+   REAL(wp) ::   rn_hti_ini_n, rn_hts_ini_n, rn_ati_ini_n, rn_smi_ini_n, rn_tmi_ini_n, rn_tsu_ini_n, rn_tms_ini_n
+   REAL(wp) ::   rn_hti_ini_s, rn_hts_ini_s, rn_ati_ini_s, rn_smi_ini_s, rn_tmi_ini_s, rn_tsu_ini_s, rn_tms_ini_s
+   REAL(wp) ::   rn_apd_ini_n, rn_hpd_ini_n
+   REAL(wp) ::   rn_apd_ini_s, rn_hpd_ini_s
+   !
+   !                              ! if ln_iceini_file = T
+   INTEGER , PARAMETER ::   jpfldi = 9           ! maximum number of files to read
+   INTEGER , PARAMETER ::   jp_hti = 1           ! index of ice thickness    (m)
+   INTEGER , PARAMETER ::   jp_hts = 2           ! index of snw thickness    (m)
+   INTEGER , PARAMETER ::   jp_ati = 3           ! index of ice fraction     (-)
+   INTEGER , PARAMETER ::   jp_smi = 4           ! index of ice salinity     (g/kg)
+   INTEGER , PARAMETER ::   jp_tmi = 5           ! index of ice temperature  (K)
+   INTEGER , PARAMETER ::   jp_tsu = 6           ! index of ice surface temp (K)
+   INTEGER , PARAMETER ::   jp_tms = 7           ! index of snw temperature  (K)
+   INTEGER , PARAMETER ::   jp_apd = 8           ! index of pnd fraction     (-)
+   INTEGER , PARAMETER ::   jp_hpd = 9           ! index of pnd depth        (m)
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   si  ! structure of input fields (file informations, fields read)
+   !   
    !!----------------------------------------------------------------------
    !! NEMO/ICE 4.0 , NEMO Consortium (2018)
@@ -68,5 +68,5 @@
 CONTAINS
 
-   SUBROUTINE ice_istate
+   SUBROUTINE ice_istate( kt )
       !!-------------------------------------------------------------------
       !!                    ***  ROUTINE ice_istate  ***
@@ -87,16 +87,19 @@
       !!
       !! ** Notes   : o_i, t_su, t_s, t_i, sz_i must be filled everywhere, even
-      !!              where there is no ice (clem: I do not know why, is it mandatory?) 
+      !!              where there is no ice
       !!--------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! time step 
+      !!
       INTEGER  ::   ji, jj, jk, jl         ! dummy loop indices
-      INTEGER  ::   i_hemis, i_fill, jl0   ! local integers
-      REAL(wp) ::   ztmelts, zdh
-      REAL(wp) ::   zarg, zV, zconv, zdv, zfac
+      REAL(wp) ::   ztmelts
       INTEGER , DIMENSION(4)           ::   itest
       REAL(wp), DIMENSION(jpi,jpj)     ::   z2d
       REAL(wp), DIMENSION(jpi,jpj)     ::   zswitch    ! ice indicator
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zht_i_ini, zat_i_ini, zvt_i_ini            !data from namelist or nc file
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zts_u_ini, zht_s_ini, zsm_i_ini, ztm_i_ini !data from namelist or nc file
-      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zh_i_ini , za_i_ini                        !data by cattegories to fill
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zht_i_ini, zat_i_ini, ztm_s_ini            !data from namelist or nc file
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zt_su_ini, zht_s_ini, zsm_i_ini, ztm_i_ini !data from namelist or nc file
+      REAL(wp), DIMENSION(jpi,jpj)     ::   zapnd_ini, zhpnd_ini                       !data from namelist or nc file
+      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zti_3d , zts_3d                            !temporary arrays
+      !!
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   zhi_2d, zhs_2d, zai_2d, zti_2d, zts_2d, ztsu_2d, zsi_2d, zaip_2d, zhip_2d
       !--------------------------------------------------------------------
 
@@ -105,9 +108,13 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
 
-      !--------------------------------------------------------------------
-      ! 1) Set surface and bottom temperatures to initial values
-      !--------------------------------------------------------------------
-      !
-      ! init surface temperature
+      !---------------------------
+      ! 1) 1st init. of the fields
+      !---------------------------
+      !
+      ! basal temperature (considered at freezing point)   [Kelvin]
+      CALL eos_fzp( sss_m(:,:), t_bo(:,:) )
+      t_bo(:,:) = ( t_bo(:,:) + rt0 ) * tmask(:,:,1) 
+      !
+      ! surface temperature and conductivity
       DO jl = 1, jpl
          t_su   (:,:,jl) = rt0 * tmask(:,:,1)  ! temp at the surface
@@ -115,33 +122,110 @@
       END DO
       !
-      ! init basal temperature (considered at freezing point)   [Kelvin]
-      CALL eos_fzp( sss_m(:,:), t_bo(:,:) )
-      t_bo(:,:) = ( t_bo(:,:) + rt0 ) * tmask(:,:,1) 
-
+      ! ice and snw temperatures
+      DO jl = 1, jpl
+         DO jk = 1, nlay_i
+            t_i(:,:,jk,jl) = rt0 * tmask(:,:,1)
+         END DO
+         DO jk = 1, nlay_s
+            t_s(:,:,jk,jl) = rt0 * tmask(:,:,1)
+         END DO
+      END DO
+      !
+      ! specific temperatures for coupled runs
+      tn_ice (:,:,:) = t_i (:,:,1,:)
+      t1_ice (:,:,:) = t_i (:,:,1,:)
+
+      ! heat contents
+      e_i (:,:,:,:) = 0._wp
+      e_s (:,:,:,:) = 0._wp
+      
+      ! general fields
+      a_i (:,:,:) = 0._wp
+      v_i (:,:,:) = 0._wp
+      v_s (:,:,:) = 0._wp
+      sv_i(:,:,:) = 0._wp
+      oa_i(:,:,:) = 0._wp
+      !
+      h_i (:,:,:) = 0._wp
+      h_s (:,:,:) = 0._wp
+      s_i (:,:,:) = 0._wp
+      o_i (:,:,:) = 0._wp
+      !
+      ! melt ponds
+      a_ip     (:,:,:) = 0._wp
+      v_ip     (:,:,:) = 0._wp
+      a_ip_frac(:,:,:) = 0._wp
+      h_ip     (:,:,:) = 0._wp
+      !
+      ! ice velocities
+      u_ice (:,:) = 0._wp
+      v_ice (:,:) = 0._wp
+      !
+      !------------------------------------------------------------------------
+      ! 2) overwrite some of the fields with namelist parameters or netcdf file
+      !------------------------------------------------------------------------
       IF( ln_iceini ) THEN
-         !-----------------------------------------------------------
-         ! 2) Compute or read sea ice variables ===> single category
-         !-----------------------------------------------------------
-         !
          !                             !---------------!
          IF( ln_iceini_file )THEN      ! Read a file   !
             !                          !---------------!
-            !
-            zht_i_ini(:,:)  = si(jp_hti)%fnow(:,:,1)
-            zht_s_ini(:,:)  = si(jp_hts)%fnow(:,:,1)
-            zat_i_ini(:,:)  = si(jp_ati)%fnow(:,:,1)
-            zts_u_ini(:,:)  = si(jp_tsu)%fnow(:,:,1)
-            ztm_i_ini(:,:)  = si(jp_tmi)%fnow(:,:,1)
-            zsm_i_ini(:,:)  = si(jp_smi)%fnow(:,:,1)
-            !
-            WHERE( zat_i_ini(:,:) > 0._wp ) ; zswitch(:,:) = tmask(:,:,1) 
-            ELSEWHERE                       ; zswitch(:,:) = 0._wp
+            WHERE( ff_t(:,:) >= 0._wp )   ;   zswitch(:,:) = 1._wp
+            ELSEWHERE                     ;   zswitch(:,:) = 0._wp
             END WHERE
-            zvt_i_ini(:,:) = zht_i_ini(:,:) * zat_i_ini(:,:)
-            !
+            !
+            CALL fld_read( kt, 1, si ) ! input fields provided at the current time-step
+            !
+            ! -- mandatory fields -- !
+            zht_i_ini(:,:) = si(jp_hti)%fnow(:,:,1)
+            zht_s_ini(:,:) = si(jp_hts)%fnow(:,:,1)
+            zat_i_ini(:,:) = si(jp_ati)%fnow(:,:,1)
+
+            ! -- optional fields -- !
+            !    if fields do not exist then set them to the values present in the namelist (except for snow and surface temperature)
+            !
+            ! ice salinity
+            IF( TRIM(si(jp_smi)%clrootname) == 'NOT USED' ) &
+               &     si(jp_smi)%fnow(:,:,1) = ( rn_smi_ini_n * zswitch + rn_smi_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+            zsm_i_ini(:,:) = si(jp_smi)%fnow(:,:,1)
+            !
+            ! ice temperature
+            IF( TRIM(si(jp_tmi)%clrootname) == 'NOT USED' ) &
+               &     si(jp_tmi)%fnow(:,:,1) = ( rn_tmi_ini_n * zswitch + rn_tmi_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+            ztm_i_ini(:,:) = si(jp_tmi)%fnow(:,:,1)
+            !
+            ! surface temperature => set to ice temperature if it exists
+            IF    ( TRIM(si(jp_tsu)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tmi)%clrootname) == 'NOT USED' ) THEN
+                     si(jp_tsu)%fnow(:,:,1) = ( rn_tsu_ini_n * zswitch + rn_tsu_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+            ELSEIF( TRIM(si(jp_tsu)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tmi)%clrootname) /= 'NOT USED' ) THEN
+                     si(jp_tsu)%fnow(:,:,1) = si(jp_tmi)%fnow(:,:,1)
+            ENDIF
+            zt_su_ini(:,:) = si(jp_tsu)%fnow(:,:,1)
+            !
+            ! snow temperature => set to ice temperature if it exists
+            IF    ( TRIM(si(jp_tms)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tmi)%clrootname) == 'NOT USED' ) THEN
+                     si(jp_tms)%fnow(:,:,1) = ( rn_tms_ini_n * zswitch + rn_tms_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+            ELSEIF( TRIM(si(jp_tms)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tmi)%clrootname) /= 'NOT USED' ) THEN
+                     si(jp_tms)%fnow(:,:,1) = si(jp_tmi)%fnow(:,:,1)
+            ENDIF
+            ztm_s_ini(:,:) = si(jp_tms)%fnow(:,:,1)
+            !
+            ! pond concentration
+            IF( TRIM(si(jp_apd)%clrootname) == 'NOT USED' ) &
+               &     si(jp_apd)%fnow(:,:,1) = ( rn_apd_ini_n * zswitch + rn_apd_ini_s * (1._wp - zswitch) ) * tmask(:,:,1) & ! rn_apd = pond fraction => rn_apnd * a_i = pond conc.
+               &                              * si(jp_ati)%fnow(:,:,1) 
+            zapnd_ini(:,:) = si(jp_apd)%fnow(:,:,1)
+            !
+            ! pond depth
+            IF( TRIM(si(jp_hpd)%clrootname) == 'NOT USED' ) &
+               &     si(jp_hpd)%fnow(:,:,1) = ( rn_hpd_ini_n * zswitch + rn_hpd_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+            zhpnd_ini(:,:) = si(jp_hpd)%fnow(:,:,1)
+            !
+            ! change the switch for the following
+            WHERE( zat_i_ini(:,:) > 0._wp )   ;   zswitch(:,:) = tmask(:,:,1) 
+            ELSEWHERE                         ;   zswitch(:,:) = 0._wp
+            END WHERE
             !                          !---------------!
          ELSE                          ! Read namelist !
             !                          !---------------!
-            ! no ice if sst <= t-freez + ttest
+            ! no ice if (sst - Tfreez) >= thresold
             WHERE( ( sst_m(:,:) - (t_bo(:,:) - rt0) ) * tmask(:,:,1) >= rn_thres_sst )   ;   zswitch(:,:) = 0._wp 
             ELSEWHERE                                                                    ;   zswitch(:,:) = tmask(:,:,1)
@@ -153,184 +237,103 @@
                zht_s_ini(:,:) = rn_hts_ini_n * zswitch(:,:)
                zat_i_ini(:,:) = rn_ati_ini_n * zswitch(:,:)
-               zts_u_ini(:,:) = rn_tmi_ini_n * zswitch(:,:)
                zsm_i_ini(:,:) = rn_smi_ini_n * zswitch(:,:)
                ztm_i_ini(:,:) = rn_tmi_ini_n * zswitch(:,:)
+               zt_su_ini(:,:) = rn_tsu_ini_n * zswitch(:,:)
+               ztm_s_ini(:,:) = rn_tms_ini_n * zswitch(:,:)
+               zapnd_ini(:,:) = rn_apd_ini_n * zswitch(:,:) * zat_i_ini(:,:) ! rn_apd = pond fraction => rn_apd * a_i = pond conc. 
+               zhpnd_ini(:,:) = rn_hpd_ini_n * zswitch(:,:)
             ELSEWHERE
                zht_i_ini(:,:) = rn_hti_ini_s * zswitch(:,:)
                zht_s_ini(:,:) = rn_hts_ini_s * zswitch(:,:)
                zat_i_ini(:,:) = rn_ati_ini_s * zswitch(:,:)
-               zts_u_ini(:,:) = rn_tmi_ini_s * zswitch(:,:)
                zsm_i_ini(:,:) = rn_smi_ini_s * zswitch(:,:)
                ztm_i_ini(:,:) = rn_tmi_ini_s * zswitch(:,:)
+               zt_su_ini(:,:) = rn_tsu_ini_s * zswitch(:,:)
+               ztm_s_ini(:,:) = rn_tms_ini_s * zswitch(:,:)
+               zapnd_ini(:,:) = rn_apd_ini_s * zswitch(:,:) * zat_i_ini(:,:) ! rn_apd = pond fraction => rn_apd * a_i = pond conc.
+               zhpnd_ini(:,:) = rn_hpd_ini_s * zswitch(:,:)
             END WHERE
-            zvt_i_ini(:,:) = zht_i_ini(:,:) * zat_i_ini(:,:)
-            !
+            !
+         ENDIF
+
+         ! make sure ponds = 0 if no ponds scheme
+         IF ( .NOT.ln_pnd ) THEN
+            zapnd_ini(:,:) = 0._wp
+            zhpnd_ini(:,:) = 0._wp
          ENDIF
          
-         !------------------------------------------------------------------
-         ! 3) Distribute ice concentration and thickness into the categories
-         !------------------------------------------------------------------
-         ! a gaussian distribution for ice concentration is used
-         ! then we check whether the distribution fullfills
-         ! volume and area conservation, positivity and ice categories bounds
-
-         IF( jpl == 1 ) THEN
-            !
-            zh_i_ini(:,:,1) = zht_i_ini(:,:)
-            za_i_ini(:,:,1) = zat_i_ini(:,:)            
-            !
-         ELSE
-            zh_i_ini(:,:,:) = 0._wp 
-            za_i_ini(:,:,:) = 0._wp
-            !
+         !-------------!
+         ! fill fields !
+         !-------------!
+         ! select ice covered grid points
+         npti = 0 ; nptidx(:) = 0
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF ( zht_i_ini(ji,jj) > 0._wp ) THEN
+                  npti         = npti  + 1
+                  nptidx(npti) = (jj - 1) * jpi + ji
+               ENDIF
+            END DO
+         END DO
+
+         ! move to 1D arrays: (jpi,jpj) -> (jpi*jpj)
+         CALL tab_2d_1d( npti, nptidx(1:npti), h_i_1d (1:npti)  , zht_i_ini )
+         CALL tab_2d_1d( npti, nptidx(1:npti), h_s_1d (1:npti)  , zht_s_ini )
+         CALL tab_2d_1d( npti, nptidx(1:npti), at_i_1d(1:npti)  , zat_i_ini )
+         CALL tab_2d_1d( npti, nptidx(1:npti), t_i_1d (1:npti,1), ztm_i_ini )
+         CALL tab_2d_1d( npti, nptidx(1:npti), t_s_1d (1:npti,1), ztm_s_ini )
+         CALL tab_2d_1d( npti, nptidx(1:npti), t_su_1d(1:npti)  , zt_su_ini )
+         CALL tab_2d_1d( npti, nptidx(1:npti), s_i_1d (1:npti)  , zsm_i_ini )
+         CALL tab_2d_1d( npti, nptidx(1:npti), a_ip_1d(1:npti)  , zapnd_ini )
+         CALL tab_2d_1d( npti, nptidx(1:npti), h_ip_1d(1:npti)  , zhpnd_ini )
+
+         ! allocate temporary arrays
+         ALLOCATE( zhi_2d(npti,jpl), zhs_2d(npti,jpl), zai_2d (npti,jpl), &
+            &      zti_2d(npti,jpl), zts_2d(npti,jpl), ztsu_2d(npti,jpl), zsi_2d(npti,jpl), zaip_2d(npti,jpl), zhip_2d(npti,jpl) )
+         
+         ! distribute 1-cat into jpl-cat: (jpi*jpj) -> (jpi*jpj,jpl)
+         CALL ice_var_itd( h_i_1d(1:npti)  , h_s_1d(1:npti)  , at_i_1d(1:npti),                                                   &
+            &              zhi_2d          , zhs_2d          , zai_2d         ,                                                   &
+            &              t_i_1d(1:npti,1), t_s_1d(1:npti,1), t_su_1d(1:npti), s_i_1d(1:npti), a_ip_1d(1:npti), h_ip_1d(1:npti), &
+            &              zti_2d          , zts_2d          , ztsu_2d        , zsi_2d        , zaip_2d        , zhip_2d )
+
+         ! move to 3D arrays: (jpi*jpj,jpl) -> (jpi,jpj,jpl)
+         DO jl = 1, jpl
+            zti_3d(:,:,jl) = rt0 * tmask(:,:,1)
+            zts_3d(:,:,jl) = rt0 * tmask(:,:,1)
+         END DO
+         CALL tab_2d_3d( npti, nptidx(1:npti), zhi_2d   , h_i    )
+         CALL tab_2d_3d( npti, nptidx(1:npti), zhs_2d   , h_s    )
+         CALL tab_2d_3d( npti, nptidx(1:npti), zai_2d   , a_i    )
+         CALL tab_2d_3d( npti, nptidx(1:npti), zti_2d   , zti_3d )
+         CALL tab_2d_3d( npti, nptidx(1:npti), zts_2d   , zts_3d )
+         CALL tab_2d_3d( npti, nptidx(1:npti), ztsu_2d  , t_su   )
+         CALL tab_2d_3d( npti, nptidx(1:npti), zsi_2d   , s_i    )
+         CALL tab_2d_3d( npti, nptidx(1:npti), zaip_2d  , a_ip   )
+         CALL tab_2d_3d( npti, nptidx(1:npti), zhip_2d  , h_ip   )
+
+         ! deallocate temporary arrays
+         DEALLOCATE( zhi_2d, zhs_2d, zai_2d , &
+            &        zti_2d, zts_2d, ztsu_2d, zsi_2d, zaip_2d, zhip_2d )
+
+         ! calculate extensive and intensive variables
+         CALL ice_var_salprof ! for sz_i
+         DO jl = 1, jpl
             DO jj = 1, jpj
                DO ji = 1, jpi
-                  !
-                  IF( zat_i_ini(ji,jj) > 0._wp .AND. zht_i_ini(ji,jj) > 0._wp )THEN
-
-                     ! find which category (jl0) the input ice thickness falls into
-                     jl0 = jpl
-                     DO jl = 1, jpl
-                        IF ( ( zht_i_ini(ji,jj) >  hi_max(jl-1) ) .AND. ( zht_i_ini(ji,jj) <= hi_max(jl) ) ) THEN
-                           jl0 = jl
-                           CYCLE
-                        ENDIF
-                     END DO
-                     !
-                     itest(:) = 0
-                     i_fill   = jpl + 1                                            !------------------------------------
-                     DO WHILE ( ( SUM( itest(:) ) /= 4 ) .AND. ( i_fill >= 2 ) )   ! iterative loop on i_fill categories
-                        !                                                          !------------------------------------
-                        i_fill = i_fill - 1
-                        !
-                        zh_i_ini(ji,jj,:) = 0._wp 
-                        za_i_ini(ji,jj,:) = 0._wp
-                        itest(:) = 0
-                        !
-                        IF ( i_fill == 1 ) THEN      !-- case very thin ice: fill only category 1
-                           zh_i_ini(ji,jj,1) = zht_i_ini(ji,jj)
-                           za_i_ini(ji,jj,1) = zat_i_ini(ji,jj)
-                        ELSE                         !-- case ice is thicker: fill categories >1
-                           ! thickness
-                           DO jl = 1, i_fill-1
-                              zh_i_ini(ji,jj,jl) = hi_mean(jl)
-                           END DO
-                           !
-                           ! concentration
-                           za_i_ini(ji,jj,jl0) = zat_i_ini(ji,jj) / SQRT(REAL(jpl))
-                           DO jl = 1, i_fill - 1
-                              IF( jl /= jl0 )THEN
-                                 zarg               = ( zh_i_ini(ji,jj,jl) - zht_i_ini(ji,jj) ) / ( 0.5_wp * zht_i_ini(ji,jj) )
-                                 za_i_ini(ji,jj,jl) = za_i_ini(ji,jj,jl0) * EXP(-zarg**2)
-                              ENDIF
-                           END DO
-
-                           ! last category
-                           za_i_ini(ji,jj,i_fill) = zat_i_ini(ji,jj) - SUM( za_i_ini(ji,jj,1:i_fill-1) )
-                           zV = SUM( za_i_ini(ji,jj,1:i_fill-1) * zh_i_ini(ji,jj,1:i_fill-1) )
-                           zh_i_ini(ji,jj,i_fill) = ( zvt_i_ini(ji,jj) - zV ) / MAX( za_i_ini(ji,jj,i_fill), epsi10 ) 
-
-                           ! correction if concentration of upper cat is greater than lower cat
-                           !   (it should be a gaussian around jl0 but sometimes it is not)
-                           IF ( jl0 /= jpl ) THEN
-                              DO jl = jpl, jl0+1, -1
-                                 IF ( za_i_ini(ji,jj,jl) > za_i_ini(ji,jj,jl-1) ) THEN
-                                    zdv = zh_i_ini(ji,jj,jl) * za_i_ini(ji,jj,jl)
-                                    zh_i_ini(ji,jj,jl    ) = 0._wp
-                                    za_i_ini(ji,jj,jl    ) = 0._wp
-                                    za_i_ini(ji,jj,1:jl-1) = za_i_ini(ji,jj,1:jl-1)  &
-                                       &                     + zdv / MAX( REAL(jl-1) * zht_i_ini(ji,jj), epsi10 )
-                                 END IF
-                              ENDDO
-                           ENDIF
-                           !
-                        ENDIF
-                        !
-                        ! Compatibility tests
-                        zconv = ABS( zat_i_ini(ji,jj) - SUM( za_i_ini(ji,jj,1:jpl) ) )           ! Test 1: area conservation
-                        IF ( zconv < epsi06 ) itest(1) = 1
-                        !
-                        zconv = ABS(       zat_i_ini(ji,jj)       * zht_i_ini(ji,jj)   &         ! Test 2: volume conservation
-                           &        - SUM( za_i_ini (ji,jj,1:jpl) * zh_i_ini (ji,jj,1:jpl) ) )
-                        IF ( zconv < epsi06 ) itest(2) = 1
-                        !
-                        IF ( zh_i_ini(ji,jj,i_fill) >= hi_max(i_fill-1) ) itest(3) = 1           ! Test 3: thickness of the last category is in-bounds ?
-                        !
-                        itest(4) = 1
-                        DO jl = 1, i_fill
-                           IF ( za_i_ini(ji,jj,jl) < 0._wp ) itest(4) = 0                        ! Test 4: positivity of ice concentrations
-                        END DO
-                        !                                                          !----------------------------
-                     END DO                                                        ! end iteration on categories
-                     !                                                             !----------------------------
-                     IF( lwp .AND. SUM(itest) /= 4 ) THEN 
-                        WRITE(numout,*)
-                        WRITE(numout,*) ' !!!! ALERT itest is not equal to 4      !!! '
-                        WRITE(numout,*) ' !!!! Something is wrong in the SI3 initialization procedure '
-                        WRITE(numout,*)
-                        WRITE(numout,*) ' *** itest_i (i=1,4) = ', itest(:)
-                        WRITE(numout,*) ' zat_i_ini : ', zat_i_ini(ji,jj)
-                        WRITE(numout,*) ' zht_i_ini : ', zht_i_ini(ji,jj)
-                     ENDIF
-                     !
-                  ENDIF
-                  !
+                  v_i (ji,jj,jl) = h_i(ji,jj,jl) * a_i(ji,jj,jl)
+                  v_s (ji,jj,jl) = h_s(ji,jj,jl) * a_i(ji,jj,jl)
+                  sv_i(ji,jj,jl) = MIN( MAX( rn_simin , s_i(ji,jj,jl) ) , rn_simax ) * v_i(ji,jj,jl)
                END DO
             END DO
-         ENDIF
-         
-         !---------------------------------------------------------------------
-         ! 4) Fill in sea ice arrays
-         !---------------------------------------------------------------------
-         !
-         ! Ice concentration, thickness and volume, ice salinity, ice age, surface temperature
-         DO jl = 1, jpl ! loop over categories
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  a_i(ji,jj,jl)  = zswitch(ji,jj) * za_i_ini(ji,jj,jl)                       ! concentration
-                  h_i(ji,jj,jl)  = zswitch(ji,jj) * zh_i_ini(ji,jj,jl)                       ! ice thickness
-                  s_i(ji,jj,jl)  = zswitch(ji,jj) * zsm_i_ini(ji,jj)                         ! salinity
-                  o_i(ji,jj,jl)  = 0._wp                                                     ! age (0 day)
-                  t_su(ji,jj,jl) = zswitch(ji,jj) * zts_u_ini(ji,jj) + ( 1._wp - zswitch(ji,jj) ) * rt0 ! surf temp
-                  !
-                  IF( zht_i_ini(ji,jj) > 0._wp )THEN
-                    h_s(ji,jj,jl)= h_i(ji,jj,jl) * ( zht_s_ini(ji,jj) / zht_i_ini(ji,jj) )  ! snow depth
-                  ELSE
-                    h_s(ji,jj,jl)= 0._wp
-                  ENDIF
-                  !
-                  ! This case below should not be used if (h_s/h_i) is ok in namelist
-                  ! In case snow load is in excess that would lead to transformation from snow to ice
-                  ! Then, transfer the snow excess into the ice (different from icethd_dh)
-                  zdh = MAX( 0._wp, ( rhos * h_s(ji,jj,jl) + ( rhoi - rau0 ) * h_i(ji,jj,jl) ) * r1_rau0 ) 
-                  ! recompute h_i, h_s avoiding out of bounds values
-                  h_i(ji,jj,jl) = MIN( hi_max(jl), h_i(ji,jj,jl) + zdh )
-                  h_s(ji,jj,jl) = MAX( 0._wp, h_s(ji,jj,jl) - zdh * rhoi * r1_rhos )
-                  !
-                  ! ice volume, salt content, age content
-                  v_i (ji,jj,jl) = h_i(ji,jj,jl) * a_i(ji,jj,jl)              ! ice volume
-                  v_s (ji,jj,jl) = h_s(ji,jj,jl) * a_i(ji,jj,jl)              ! snow volume
-                  sv_i(ji,jj,jl) = MIN( s_i(ji,jj,jl) , sss_m(ji,jj) ) * v_i(ji,jj,jl) ! salt content
-                  oa_i(ji,jj,jl) = o_i(ji,jj,jl) * a_i(ji,jj,jl)               ! age content
-               END DO
-            END DO
-         END DO
-         !
-         IF( nn_icesal /= 2 )  THEN         ! for constant salinity in time
-            CALL ice_var_salprof
-            sv_i = s_i * v_i
-         ENDIF
-         !  
-         ! Snow temperature and heat content
-         DO jk = 1, nlay_s
-            DO jl = 1, jpl ! loop over categories
+         END DO
+         !
+         DO jl = 1, jpl
+            DO jk = 1, nlay_s
                DO jj = 1, jpj
                   DO ji = 1, jpi
-                     t_s(ji,jj,jk,jl) = zswitch(ji,jj) * ztm_i_ini(ji,jj) + ( 1._wp - zswitch(ji,jj) ) * rt0
-                     ! Snow energy of melting
-                     e_s(ji,jj,jk,jl) = zswitch(ji,jj) * rhos * ( rcpi * ( rt0 - t_s(ji,jj,jk,jl) ) + rLfus )
-                     !
-                     ! Mutliply by volume, and divide by number of layers to get heat content in J/m2
-                     e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) * v_s(ji,jj,jl) * r1_nlay_s
+                     t_s(ji,jj,jk,jl) = zts_3d(ji,jj,jl)
+                     e_s(ji,jj,jk,jl) = zswitch(ji,jj) * v_s(ji,jj,jl) * r1_nlay_s * &
+                        &               rhos * ( rcpi * ( rt0 - t_s(ji,jj,jk,jl) ) + rLfus )
                   END DO
                END DO
@@ -338,85 +341,37 @@
          END DO
          !
-         ! Ice salinity, temperature and heat content
-         DO jk = 1, nlay_i
-            DO jl = 1, jpl ! loop over categories
+         DO jl = 1, jpl
+            DO jk = 1, nlay_i
                DO jj = 1, jpj
                   DO ji = 1, jpi
-                     t_i (ji,jj,jk,jl) = zswitch(ji,jj) * ztm_i_ini(ji,jj) + ( 1._wp - zswitch(ji,jj) ) * rt0 
-                     sz_i(ji,jj,jk,jl) = zswitch(ji,jj) * zsm_i_ini(ji,jj) + ( 1._wp - zswitch(ji,jj) ) * rn_simin
-                     ztmelts          = - rTmlt * sz_i(ji,jj,jk,jl) + rt0 !Melting temperature in K
-                     !
-                     ! heat content per unit volume
-                     e_i(ji,jj,jk,jl) = zswitch(ji,jj) * rhoi * (   rcpi    * ( ztmelts - t_i(ji,jj,jk,jl) )           &
-                        &             + rLfus * ( 1._wp - (ztmelts-rt0) / MIN( (t_i(ji,jj,jk,jl)-rt0) , -epsi20 )  )   &
-                        &             - rcp  * ( ztmelts - rt0 ) )
-                     !
-                     ! Mutliply by ice volume, and divide by number of layers to get heat content in J/m2
-                     e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * v_i(ji,jj,jl) * r1_nlay_i
+                     t_i (ji,jj,jk,jl) = zti_3d(ji,jj,jl) 
+                     ztmelts          = - rTmlt * sz_i(ji,jj,jk,jl) + rt0 ! melting temperature in K
+                     e_i(ji,jj,jk,jl) = zswitch(ji,jj) * v_i(ji,jj,jl) * r1_nlay_i * &
+                        &               rhoi * (  rcpi  * ( ztmelts - t_i(ji,jj,jk,jl) ) + &
+                        &                         rLfus * ( 1._wp - (ztmelts-rt0) / MIN( (t_i(ji,jj,jk,jl)-rt0), -epsi20 ) ) &
+                        &                       - rcp   * ( ztmelts - rt0 ) )
                   END DO
                END DO
             END DO
          END DO
-         !
-         tn_ice (:,:,:) = t_su (:,:,:)
-         t1_ice (:,:,:) = t_i (:,:,1,:)   ! initialisation of 1st layer temp for coupled simu
-
-         ! Melt pond volume and fraction
-         IF ( ln_pnd_CST .OR. ln_pnd_H12 ) THEN   ;   zfac = 1._wp
-         ELSE                                     ;   zfac = 0._wp
-         ENDIF 
-         DO jl = 1, jpl
-            a_ip_frac(:,:,jl) = rn_apnd * zswitch(:,:) * zfac
-            h_ip     (:,:,jl) = rn_hpnd * zswitch(:,:) * zfac
-         END DO
-         a_ip(:,:,:) = a_ip_frac(:,:,:) * a_i (:,:,:) 
-         v_ip(:,:,:) = h_ip     (:,:,:) * a_ip(:,:,:)
-         !
-      ELSE ! if ln_iceini=false
-         a_i  (:,:,:) = 0._wp
-         v_i  (:,:,:) = 0._wp
-         v_s  (:,:,:) = 0._wp
-         sv_i (:,:,:) = 0._wp
-         oa_i (:,:,:) = 0._wp
-         h_i  (:,:,:) = 0._wp
-         h_s  (:,:,:) = 0._wp
-         s_i  (:,:,:) = 0._wp
-         o_i  (:,:,:) = 0._wp
-         !
-         e_i(:,:,:,:) = 0._wp
-         e_s(:,:,:,:) = 0._wp
-         !
-         DO jl = 1, jpl
-            DO jk = 1, nlay_i
-               t_i(:,:,jk,jl) = rt0 * tmask(:,:,1)
-            END DO
-            DO jk = 1, nlay_s
-               t_s(:,:,jk,jl) = rt0 * tmask(:,:,1)
-            END DO
-         END DO
-
-         tn_ice (:,:,:) = t_i (:,:,1,:)
-         t1_ice (:,:,:) = t_i (:,:,1,:)   ! initialisation of 1st layer temp for coupled simu
-         
-         a_ip(:,:,:)      = 0._wp
-         v_ip(:,:,:)      = 0._wp
-         a_ip_frac(:,:,:) = 0._wp
-         h_ip     (:,:,:) = 0._wp
+
+         ! Melt ponds
+         WHERE( a_i > epsi10 )
+            a_ip_frac(:,:,:) = a_ip(:,:,:) / a_i(:,:,:)
+         ELSEWHERE
+            a_ip_frac(:,:,:) = 0._wp
+         END WHERE
+         v_ip(:,:,:) = h_ip(:,:,:) * a_ip(:,:,:)
+          
+         ! specific temperatures for coupled runs
+         tn_ice(:,:,:) = t_su(:,:,:)
+         t1_ice(:,:,:) = t_i (:,:,1,:)
          !
       ENDIF ! ln_iceini
       !
-      at_i (:,:) = 0.0_wp
-      DO jl = 1, jpl
-         at_i (:,:) = at_i (:,:) + a_i (:,:,jl)
-      END DO
-      !
-      ! --- set ice velocities --- !
-      u_ice (:,:) = 0._wp
-      v_ice (:,:) = 0._wp
-      ! fields needed for ice_dyn_adv_umx
-      l_split_advumx(1) = .FALSE.
+      at_i(:,:) = SUM( a_i, dim=3 )
       !
       !----------------------------------------------
-      ! 5) Snow-ice mass (case ice is fully embedded)
+      ! 3) Snow-ice mass (case ice is fully embedded)
       !----------------------------------------------
       snwice_mass  (:,:) = tmask(:,:,1) * SUM( rhos * v_s(:,:,:) + rhoi * v_i(:,:,:), dim=3  )   ! snow+ice mass
@@ -470,5 +425,5 @@
       
       !------------------------------------
-      ! 6) store fields at before time-step
+      ! 4) store fields at before time-step
       !------------------------------------
       ! it is only necessary for the 1st interpolation by Agrif
@@ -508,24 +463,27 @@
       !
       CHARACTER(len=256) ::  cn_dir          ! Root directory for location of ice files
-      TYPE(FLD_N)                    ::   sn_hti, sn_hts, sn_ati, sn_tsu, sn_tmi, sn_smi
+      TYPE(FLD_N)                    ::   sn_hti, sn_hts, sn_ati, sn_smi, sn_tmi, sn_tsu, sn_tms, sn_apd, sn_hpd
       TYPE(FLD_N), DIMENSION(jpfldi) ::   slf_i                 ! array of namelist informations on the fields to read
       !
-      NAMELIST/namini/ ln_iceini, ln_iceini_file, rn_thres_sst, rn_hts_ini_n, rn_hts_ini_s,  &
-         &             rn_hti_ini_n, rn_hti_ini_s, rn_ati_ini_n, rn_ati_ini_s, rn_smi_ini_n, &
-         &             rn_smi_ini_s, rn_tmi_ini_n, rn_tmi_ini_s,                             &
-         &             sn_hti, sn_hts, sn_ati, sn_tsu, sn_tmi, sn_smi, cn_dir
+      NAMELIST/namini/ ln_iceini, ln_iceini_file, rn_thres_sst, &
+         &             rn_hti_ini_n, rn_hti_ini_s, rn_hts_ini_n, rn_hts_ini_s, &
+         &             rn_ati_ini_n, rn_ati_ini_s, rn_smi_ini_n, rn_smi_ini_s, &
+         &             rn_tmi_ini_n, rn_tmi_ini_s, rn_tsu_ini_n, rn_tsu_ini_s, rn_tms_ini_n, rn_tms_ini_s, &
+         &             rn_apd_ini_n, rn_apd_ini_s, rn_hpd_ini_n, rn_hpd_ini_s, &
+         &             sn_hti, sn_hts, sn_ati, sn_tsu, sn_tmi, sn_smi, sn_tms, sn_apd, sn_hpd, cn_dir
       !!-----------------------------------------------------------------------------
       !
       REWIND( numnam_ice_ref )              ! Namelist namini in reference namelist : Ice initial state
       READ  ( numnam_ice_ref, namini, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namini in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namini in reference namelist' )
       REWIND( numnam_ice_cfg )              ! Namelist namini in configuration namelist : Ice initial state
       READ  ( numnam_ice_cfg, namini, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namini in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namini in configuration namelist' )
       IF(lwm) WRITE ( numoni, namini )
       !
       slf_i(jp_hti) = sn_hti  ;  slf_i(jp_hts) = sn_hts
-      slf_i(jp_ati) = sn_ati  ;  slf_i(jp_tsu) = sn_tsu
-      slf_i(jp_tmi) = sn_tmi  ;  slf_i(jp_smi) = sn_smi
+      slf_i(jp_ati) = sn_ati  ;  slf_i(jp_smi) = sn_smi
+      slf_i(jp_tmi) = sn_tmi  ;  slf_i(jp_tsu) = sn_tsu   ;   slf_i(jp_tms) = sn_tms
+      slf_i(jp_apd) = sn_apd  ;  slf_i(jp_hpd) = sn_hpd
       !
       IF(lwp) THEN                          ! control print
@@ -534,17 +492,18 @@
          WRITE(numout,*) '~~~~~~~~~~~~~~~'
          WRITE(numout,*) '   Namelist namini:'
-         WRITE(numout,*) '      initialization with ice (T) or not (F)                 ln_iceini       = ', ln_iceini
-         WRITE(numout,*) '      ice initialization from a netcdf file                  ln_iceini_file  = ', ln_iceini_file
-         WRITE(numout,*) '      max delta ocean temp. above Tfreeze with initial ice   rn_thres_sst    = ', rn_thres_sst
-         WRITE(numout,*) '      initial snow thickness in the north                    rn_hts_ini_n    = ', rn_hts_ini_n
-         WRITE(numout,*) '      initial snow thickness in the south                    rn_hts_ini_s    = ', rn_hts_ini_s 
-         WRITE(numout,*) '      initial ice thickness  in the north                    rn_hti_ini_n    = ', rn_hti_ini_n
-         WRITE(numout,*) '      initial ice thickness  in the south                    rn_hti_ini_s    = ', rn_hti_ini_s
-         WRITE(numout,*) '      initial ice concentr.  in the north                    rn_ati_ini_n    = ', rn_ati_ini_n
-         WRITE(numout,*) '      initial ice concentr.  in the north                    rn_ati_ini_s    = ', rn_ati_ini_s
-         WRITE(numout,*) '      initial  ice salinity  in the north                    rn_smi_ini_n    = ', rn_smi_ini_n
-         WRITE(numout,*) '      initial  ice salinity  in the south                    rn_smi_ini_s    = ', rn_smi_ini_s
-         WRITE(numout,*) '      initial  ice/snw temp  in the north                    rn_tmi_ini_n    = ', rn_tmi_ini_n
-         WRITE(numout,*) '      initial  ice/snw temp  in the south                    rn_tmi_ini_s    = ', rn_tmi_ini_s
+         WRITE(numout,*) '      ice initialization (T) or not (F)                ln_iceini      = ', ln_iceini
+         WRITE(numout,*) '      ice initialization from a netcdf file            ln_iceini_file = ', ln_iceini_file
+         WRITE(numout,*) '      max ocean temp. above Tfreeze with initial ice   rn_thres_sst   = ', rn_thres_sst
+         IF( ln_iceini .AND. .NOT.ln_iceini_file ) THEN
+            WRITE(numout,*) '      initial snw thickness in the north-south         rn_hts_ini     = ', rn_hts_ini_n,rn_hts_ini_s 
+            WRITE(numout,*) '      initial ice thickness in the north-south         rn_hti_ini     = ', rn_hti_ini_n,rn_hti_ini_s
+            WRITE(numout,*) '      initial ice concentr  in the north-south         rn_ati_ini     = ', rn_ati_ini_n,rn_ati_ini_s
+            WRITE(numout,*) '      initial ice salinity  in the north-south         rn_smi_ini     = ', rn_smi_ini_n,rn_smi_ini_s
+            WRITE(numout,*) '      initial surf temperat in the north-south         rn_tsu_ini     = ', rn_tsu_ini_n,rn_tsu_ini_s
+            WRITE(numout,*) '      initial ice temperat  in the north-south         rn_tmi_ini     = ', rn_tmi_ini_n,rn_tmi_ini_s
+            WRITE(numout,*) '      initial snw temperat  in the north-south         rn_tms_ini     = ', rn_tms_ini_n,rn_tms_ini_s
+            WRITE(numout,*) '      initial pnd fraction  in the north-south         rn_apd_ini     = ', rn_apd_ini_n,rn_apd_ini_s
+            WRITE(numout,*) '      initial pnd depth     in the north-south         rn_hpd_ini     = ', rn_hpd_ini_n,rn_hpd_ini_s
+         ENDIF
       ENDIF
       !
@@ -554,17 +513,21 @@
          ALLOCATE( si(jpfldi), STAT=ierror )
          IF( ierror > 0 ) THEN
-            CALL ctl_stop( 'Ice_ini in iceistate: unable to allocate si structure' )   ;   RETURN
+            CALL ctl_stop( 'ice_istate_ini in iceistate: unable to allocate si structure' )   ;   RETURN
          ENDIF
          !
          DO ifpr = 1, jpfldi
             ALLOCATE( si(ifpr)%fnow(jpi,jpj,1) )
-            ALLOCATE( si(ifpr)%fdta(jpi,jpj,1,2) )
+            IF( slf_i(ifpr)%ln_tint )  ALLOCATE( si(ifpr)%fdta(jpi,jpj,1,2) )
          END DO
          !
          ! fill si with slf_i and control print
-         CALL fld_fill( si, slf_i, cn_dir, 'ice_istate', 'ice istate ini', 'numnam_ice' )
-         !
-         CALL fld_read( nit000, 1, si )                ! input fields provided at the current time-step
-         !
+         CALL fld_fill( si, slf_i, cn_dir, 'ice_istate_ini', 'initialization of sea ice fields', 'numnam_ice' )
+         !
+      ENDIF
+      !
+      IF( .NOT.ln_pnd ) THEN
+         rn_apd_ini_n = 0. ; rn_apd_ini_s = 0.
+         rn_hpd_ini_n = 0. ; rn_hpd_ini_s = 0.
+         CALL ctl_warn( 'rn_apd_ini & rn_hpd_ini = 0 when no ponds' )
       ENDIF
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/iceitd.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/iceitd.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/iceitd.F90	(revision 12143)
@@ -88,4 +88,5 @@
 
       IF( ln_icediachk )   CALL ice_cons_hsm(0, 'iceitd_rem', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft)
+      IF( ln_icediachk )   CALL ice_cons2D  (0, 'iceitd_rem',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft)
 
       !-----------------------------------------------------------------------------------------------
@@ -210,5 +211,5 @@
                CALL itd_glinear( zhb0(1:npti)  , zhb1(1:npti)  , h_ib_1d(1:npti)  , a_i_1d(1:npti)  ,  &   ! in
                   &              g0  (1:npti,1), g1  (1:npti,1), hL     (1:npti,1), hR    (1:npti,1)   )   ! out
-                  !
+               !
                ! Area lost due to melting of thin ice
                DO ji = 1, npti
@@ -217,5 +218,5 @@
                      !
                      zdh0 =  h_i_1d(ji) - h_ib_1d(ji)                
-                     IF( zdh0 < 0.0 ) THEN      !remove area from category 1
+                     IF( zdh0 < 0.0 ) THEN      ! remove area from category 1
                         zdh0 = MIN( -zdh0, hi_max(1) )
                         !Integrate g(1) from 0 to dh0 to estimate area melted
@@ -225,8 +226,7 @@
                            zx1    = zetamax
                            zx2    = 0.5 * zetamax * zetamax 
-                           zda0   = g1(ji,1) * zx2 + g0(ji,1) * zx1                        ! ice area removed
+                           zda0   = g1(ji,1) * zx2 + g0(ji,1) * zx1                ! ice area removed
                            zdamax = a_i_1d(ji) * (1.0 - h_i_1d(ji) / h_ib_1d(ji) ) ! Constrain new thickness <= h_i                
-                           zda0   = MIN( zda0, zdamax )                                                  ! ice area lost due to melting 
-                           !     of thin ice (zdamax > 0)
+                           zda0   = MIN( zda0, zdamax )                            ! ice area lost due to melting of thin ice (zdamax > 0)
                            ! Remove area, conserving volume
                            h_i_1d(ji) = h_i_1d(ji) * a_i_1d(ji) / ( a_i_1d(ji) - zda0 )
@@ -316,4 +316,5 @@
       !
       IF( ln_icediachk )   CALL ice_cons_hsm(1, 'iceitd_rem', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft)
+      IF( ln_icediachk )   CALL ice_cons2D  (1, 'iceitd_rem',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft)
       !
    END SUBROUTINE ice_itd_rem
@@ -347,5 +348,5 @@
       DO ji = 1, npti
          !
-         IF( paice(ji) > epsi10  .AND. phice(ji) > 0._wp )  THEN
+         IF( paice(ji) > epsi10  .AND. phice(ji) > epsi10 )  THEN
             !
             ! Initialize hL and hR
@@ -586,4 +587,5 @@
       !
       IF( ln_icediachk )   CALL ice_cons_hsm(0, 'iceitd_reb', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft)
+      IF( ln_icediachk )   CALL ice_cons2D  (0, 'iceitd_reb',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft)
       !
       jdonor(:,:) = 0
@@ -664,4 +666,5 @@
       !
       IF( ln_icediachk )   CALL ice_cons_hsm(1, 'iceitd_reb', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft)
+      IF( ln_icediachk )   CALL ice_cons2D  (1, 'iceitd_reb',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft)
       !
    END SUBROUTINE ice_itd_reb
@@ -685,8 +688,8 @@
       REWIND( numnam_ice_ref )      ! Namelist namitd in reference namelist : Parameters for ice
       READ  ( numnam_ice_ref, namitd, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namitd in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namitd in reference namelist' )
       REWIND( numnam_ice_cfg )      ! Namelist namitd in configuration namelist : Parameters for ice
       READ  ( numnam_ice_cfg, namitd, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namitd in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namitd in configuration namelist' )
       IF(lwm) WRITE( numoni, namitd )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icerst.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icerst.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icerst.F90	(revision 12143)
@@ -14,8 +14,10 @@
    !!   ice_rst_read  : read  restart file 
    !!----------------------------------------------------------------------
-   USE ice            ! sea-ice variables
+   USE ice            ! sea-ice: variables
    USE dom_oce        ! ocean domain
+   USE phycst  , ONLY : rt0
    USE sbc_oce , ONLY : nn_fsbc, ln_cpl
-   USE icectl
+   USE iceistate      ! sea-ice: initial state
+   USE icectl         ! sea-ice: control
    !
    USE in_out_manager ! I/O manager
@@ -53,8 +55,9 @@
       IF( kt == nit000 )   lrst_ice = .FALSE.   ! default definition
 
+      IF( ln_rst_list .OR. nn_stock /= -1 ) THEN
       ! in order to get better performances with NetCDF format, we open and define the ice restart file 
       ! one ice time step before writing the data (-> at nitrst - 2*nn_fsbc + 1), except if we write ice 
       ! restart files every ice time step or if an ice restart file was writen at nitend - 2*nn_fsbc + 1
-      IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nstock == nn_fsbc    &
+      IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nn_stock == nn_fsbc    &
          &                             .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_ice ) ) THEN
          IF( nitrst <= nitend .AND. nitrst > 0 ) THEN
@@ -81,4 +84,5 @@
          ENDIF
       ENDIF
+      ENDIF
       !
       IF( ln_icectl )   CALL ice_prt( kt, iiceprt, jiceprt, 1, ' - Beginning the time step - ' )   ! control print
@@ -118,13 +122,14 @@
 
       ! Prognostic variables
-      CALL iom_rstput( iter, nitrst, numriw, 'v_i' , v_i  )
-      CALL iom_rstput( iter, nitrst, numriw, 'v_s' , v_s  )
-      CALL iom_rstput( iter, nitrst, numriw, 'sv_i', sv_i )
-      CALL iom_rstput( iter, nitrst, numriw, 'oa_i', oa_i )
-      CALL iom_rstput( iter, nitrst, numriw, 'a_i' , a_i  )
-      CALL iom_rstput( iter, nitrst, numriw, 't_su', t_su )
-      ! Melt ponds
-      CALL iom_rstput( iter, nitrst, numriw, 'a_ip', a_ip )
-      CALL iom_rstput( iter, nitrst, numriw, 'v_ip', v_ip )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_i'  , v_i   )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_s'  , v_s   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sv_i' , sv_i  )
+      CALL iom_rstput( iter, nitrst, numriw, 'a_i'  , a_i   )
+      CALL iom_rstput( iter, nitrst, numriw, 't_su' , t_su  )
+      CALL iom_rstput( iter, nitrst, numriw, 'u_ice', u_ice )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_ice', v_ice )
+      CALL iom_rstput( iter, nitrst, numriw, 'oa_i' , oa_i  )
+      CALL iom_rstput( iter, nitrst, numriw, 'a_ip' , a_ip  )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_ip' , v_ip  )
       ! Snow enthalpy
       DO jk = 1, nlay_s 
@@ -141,7 +146,4 @@
          CALL iom_rstput( iter, nitrst, numriw, znam , z3d )
       END DO
-      ! ice velocity
-      CALL iom_rstput( iter, nitrst, numriw, 'u_ice', u_ice ) ! u_ice
-      CALL iom_rstput( iter, nitrst, numriw, 'v_ice', v_ice ) ! v_ice
       ! fields needed for Met Office (Jules) coupling
       IF( ln_cpl ) THEN
@@ -169,5 +171,5 @@
       INTEGER           ::   jk
       LOGICAL           ::   llok
-      INTEGER           ::   id1            ! local integer
+      INTEGER           ::   id0, id1, id2, id3, id4   ! local integer
       CHARACTER(len=25) ::   znam
       CHARACTER(len=2)  ::   zchar, zchar1
@@ -184,60 +186,95 @@
       CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir, kdlev = jpl )
 
-      CALL iom_get( numrir, 'nn_fsbc', zfice )
-      CALL iom_get( numrir, 'kt_ice' , ziter )    
-      IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', ziter
-      IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
-
-      ! Control of date
-      IF( ( nit000 - NINT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
-         &     CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nit000 in ice restart',  &
-         &                   '   verify the file or rerun with the value 0 for the',        &
-         &                   '   control of time parameter  nrstdt' )
-      IF( NINT(zfice) /= nn_fsbc          .AND. ABS( nrstdt ) == 1 )   &
-         &     CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nn_fsbc in ice restart',  &
-         &                   '   verify the file or rerun with the value 0 for the',         &
-         &                   '   control of time parameter  nrstdt' )
-
-      ! Prognostic variables 
-      CALL iom_get( numrir, jpdom_autoglo, 'v_i' , v_i  )
-      CALL iom_get( numrir, jpdom_autoglo, 'v_s' , v_s  )
-      CALL iom_get( numrir, jpdom_autoglo, 'sv_i', sv_i )
-      CALL iom_get( numrir, jpdom_autoglo, 'oa_i', oa_i )
-      CALL iom_get( numrir, jpdom_autoglo, 'a_i' , a_i  )
-      CALL iom_get( numrir, jpdom_autoglo, 't_su', t_su )
-      ! Melt ponds
-      id1 = iom_varid( numrir, 'a_ip' , ldstop = .FALSE. )
-      IF( id1 > 0 ) THEN                       ! fields exist (melt ponds)
-         CALL iom_get( numrir, jpdom_autoglo, 'a_ip' , a_ip )
-         CALL iom_get( numrir, jpdom_autoglo, 'v_ip' , v_ip )
-      ELSE                                     ! start from rest
-         IF(lwp) WRITE(numout,*) '   ==>>   previous run without melt ponds output then set it to zero'
-         a_ip(:,:,:) = 0._wp
-         v_ip(:,:,:) = 0._wp
-      ENDIF
-      ! Snow enthalpy
-      DO jk = 1, nlay_s
-         WRITE(zchar1,'(I2.2)') jk
-         znam = 'e_s'//'_l'//zchar1
-         CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
-         e_s(:,:,jk,:) = z3d(:,:,:)
-      END DO
-      ! Ice enthalpy
-      DO jk = 1, nlay_i
-         WRITE(zchar1,'(I2.2)') jk
-         znam = 'e_i'//'_l'//zchar1
-         CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
-         e_i(:,:,jk,:) = z3d(:,:,:)
-      END DO
-      ! ice velocity
-      CALL iom_get( numrir, jpdom_autoglo, 'u_ice', u_ice )
-      CALL iom_get( numrir, jpdom_autoglo, 'v_ice', v_ice )
-
-      CALL iom_delay_rst( 'READ', 'ICE', numrir )   ! read only ice delayed global communication variables
-
-      ! fields needed for Met Office (Jules) coupling
-      IF( ln_cpl ) THEN
-         CALL iom_get( numrir, jpdom_autoglo, 'cnd_ice', cnd_ice )
-         CALL iom_get( numrir, jpdom_autoglo, 't1_ice' , t1_ice  )
+      ! test if v_i exists 
+      id0 = iom_varid( numrir, 'v_i' , ldstop = .FALSE. )
+
+      !                    ! ------------------------------ !
+      IF( id0 > 0 ) THEN   ! == case of a normal restart == !
+         !                 ! ------------------------------ !
+         
+         ! Time info
+         CALL iom_get( numrir, 'nn_fsbc', zfice )
+         CALL iom_get( numrir, 'kt_ice' , ziter )    
+         IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', ziter
+         IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
+
+         ! Control of date
+         IF( ( nit000 - NINT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 )   &
+            &     CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nit000 in ice restart',  &
+            &                   '   verify the file or rerun with the value 0 for the',        &
+            &                   '   control of time parameter  nrstdt' )
+         IF( NINT(zfice) /= nn_fsbc          .AND. ABS( nrstdt ) == 1 )   &
+            &     CALL ctl_stop( 'ice_rst_read ===>>>> : problem with nn_fsbc in ice restart',  &
+            &                   '   verify the file or rerun with the value 0 for the',         &
+            &                   '   control of time parameter  nrstdt' )
+
+         ! --- mandatory fields --- ! 
+         CALL iom_get( numrir, jpdom_autoglo, 'v_i'  , v_i   )
+         CALL iom_get( numrir, jpdom_autoglo, 'v_s'  , v_s   )
+         CALL iom_get( numrir, jpdom_autoglo, 'sv_i' , sv_i  )
+         CALL iom_get( numrir, jpdom_autoglo, 'a_i'  , a_i   )
+         CALL iom_get( numrir, jpdom_autoglo, 't_su' , t_su  )
+         CALL iom_get( numrir, jpdom_autoglo, 'u_ice', u_ice )
+         CALL iom_get( numrir, jpdom_autoglo, 'v_ice', v_ice )
+         ! Snow enthalpy
+         DO jk = 1, nlay_s
+            WRITE(zchar1,'(I2.2)') jk
+            znam = 'e_s'//'_l'//zchar1
+            CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
+            e_s(:,:,jk,:) = z3d(:,:,:)
+         END DO
+         ! Ice enthalpy
+         DO jk = 1, nlay_i
+            WRITE(zchar1,'(I2.2)') jk
+            znam = 'e_i'//'_l'//zchar1
+            CALL iom_get( numrir, jpdom_autoglo, znam , z3d )
+            e_i(:,:,jk,:) = z3d(:,:,:)
+         END DO
+         ! -- optional fields -- !
+         ! ice age
+         id1 = iom_varid( numrir, 'oa_i' , ldstop = .FALSE. )
+         IF( id1 > 0 ) THEN                       ! fields exist
+            CALL iom_get( numrir, jpdom_autoglo, 'oa_i', oa_i )
+         ELSE                                     ! start from rest
+            IF(lwp) WRITE(numout,*) '   ==>>   previous run without ice age output then set it to zero'
+            oa_i(:,:,:) = 0._wp
+         ENDIF
+         ! melt ponds
+         id2 = iom_varid( numrir, 'a_ip' , ldstop = .FALSE. )
+         IF( id2 > 0 ) THEN                       ! fields exist
+            CALL iom_get( numrir, jpdom_autoglo, 'a_ip' , a_ip )
+            CALL iom_get( numrir, jpdom_autoglo, 'v_ip' , v_ip )
+         ELSE                                     ! start from rest
+            IF(lwp) WRITE(numout,*) '   ==>>   previous run without melt ponds output then set it to zero'
+            a_ip(:,:,:) = 0._wp
+            v_ip(:,:,:) = 0._wp
+         ENDIF
+         ! fields needed for Met Office (Jules) coupling
+         IF( ln_cpl ) THEN
+            id3 = iom_varid( numrir, 'cnd_ice' , ldstop = .FALSE. )
+            id4 = iom_varid( numrir, 't1_ice'  , ldstop = .FALSE. )
+            IF( id3 > 0 .AND. id4 > 0 ) THEN         ! fields exist
+               CALL iom_get( numrir, jpdom_autoglo, 'cnd_ice', cnd_ice )
+               CALL iom_get( numrir, jpdom_autoglo, 't1_ice' , t1_ice  )
+            ELSE                                     ! start from rest
+               IF(lwp) WRITE(numout,*) '   ==>>   previous run without conductivity output then set it to zero'
+               cnd_ice(:,:,:) = 0._wp
+               t1_ice (:,:,:) = rt0
+            ENDIF
+         ENDIF
+
+         CALL iom_delay_rst( 'READ', 'ICE', numrir )   ! read only ice delayed global communication variables
+
+         !                 ! ---------------------------------- !
+      ELSE                 ! == case of a simplified restart == !
+         !                 ! ---------------------------------- !
+         CALL ctl_warn('ice_rst_read: you are using a simplified ice restart')
+         !
+         CALL ice_istate_init
+         CALL ice_istate( nit000 )
+         !
+         IF( .NOT.ln_iceini .OR. .NOT.ln_iceini_file ) &
+            &   CALL ctl_stop('STOP', 'ice_rst_read: you need ln_ice_ini=T and ln_iceini_file=T')
+         !
       ENDIF
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icesbc.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icesbc.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icesbc.F90	(revision 12143)
@@ -114,7 +114,8 @@
       INTEGER, INTENT(in) ::   ksbc   ! flux formulation (user defined, bulk or Pure Coupled)
       !
-      INTEGER  ::   ji, jj, jl                                ! dummy loop index
-      REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zalb_os, zalb_cs  ! ice albedo under overcast/clear sky
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zalb              ! 2D workspace
+      INTEGER  ::   ji, jj, jl      ! dummy loop index
+      REAL(wp) ::   zmiss_val       ! missing value retrieved from xios 
+      REAL(wp), DIMENSION(jpi,jpj,jpl)              ::   zalb_os, zalb_cs  ! ice albedo under overcast/clear sky
+      REAL(wp), DIMENSION(:,:)        , ALLOCATABLE ::   zalb, zmsk00      ! 2D workspace
       !!--------------------------------------------------------------------
       !
@@ -126,4 +127,7 @@
          WRITE(numout,*)'~~~~~~~~~~~~~~~'
       ENDIF
+
+      ! get missing value from xml
+      CALL iom_miss_val( "icetemp", zmiss_val )
 
       ! --- cloud-sky and overcast-sky ice albedos --- !
@@ -152,13 +156,23 @@
 
       !--- output ice albedo and surface albedo ---!
-      IF( iom_use('icealb') ) THEN
-         WHERE( at_i_b <= epsi06 )   ;   zalb(:,:) = rn_alb_oce
-         ELSEWHERE                   ;   zalb(:,:) = SUM( alb_ice * a_i_b, dim=3 ) / at_i_b
+      IF( iom_use('icealb') .OR. iom_use('albedo') ) THEN
+
+         ALLOCATE( zalb(jpi,jpj), zmsk00(jpi,jpj) )
+
+         WHERE( at_i_b < 1.e-03 )
+            zmsk00(:,:) = 0._wp
+            zalb  (:,:) = rn_alb_oce
+         ELSEWHERE
+            zmsk00(:,:) = 1._wp            
+            zalb  (:,:) = SUM( alb_ice * a_i_b, dim=3 ) / at_i_b
          END WHERE
-         CALL iom_put( "icealb" , zalb(:,:) )
-      ENDIF
-      IF( iom_use('albedo') ) THEN
+         ! ice albedo
+         CALL iom_put( 'icealb' , zalb * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) )
+         ! ice+ocean albedo
          zalb(:,:) = SUM( alb_ice * a_i_b, dim=3 ) + rn_alb_oce * ( 1._wp - at_i_b )
-         CALL iom_put( "albedo" , zalb(:,:) )
+         CALL iom_put( 'albedo' , zalb )
+
+         DEALLOCATE( zalb, zmsk00 )
+
       ENDIF
       !
@@ -272,8 +286,8 @@
       REWIND( numnam_ice_ref )         ! Namelist namsbc in reference namelist : Ice dynamics
       READ  ( numnam_ice_ref, namsbc, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc in reference namelist' )
       REWIND( numnam_ice_cfg )         ! Namelist namsbc in configuration namelist : Ice dynamics
       READ  ( numnam_ice_cfg, namsbc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc in configuration namelist' )
       IF(lwm) WRITE( numoni, namsbc )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icestp.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icestp.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icestp.F90	(revision 12143)
@@ -254,5 +254,5 @@
       IF( .NOT. ln_rstart ) THEN              ! start from rest: sea-ice deduced from sst
          CALL ice_istate_init
-         CALL ice_istate
+         CALL ice_istate( nit000 )
       ELSE                                    ! start from a restart file
          CALL ice_rst_read
@@ -303,8 +303,8 @@
       REWIND( numnam_ice_ref )      ! Namelist nampar in reference namelist : Parameters for ice
       READ  ( numnam_ice_ref, nampar, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampar in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampar in reference namelist' )
       REWIND( numnam_ice_cfg )      ! Namelist nampar in configuration namelist : Parameters for ice
       READ  ( numnam_ice_cfg, nampar, IOSTAT = ios, ERR = 902 )
-902   IF( ios > 0 )   CALL ctl_nam ( ios , 'nampar in configuration namelist', lwp )
+902   IF( ios > 0 )   CALL ctl_nam ( ios , 'nampar in configuration namelist' )
       IF(lwm) WRITE( numoni, nampar )
       !
@@ -425,6 +425,4 @@
       wfx_err_sub(:,:) = 0._wp
       !
-      afx_tot(:,:) = 0._wp   ;
-      !
       diag_heat(:,:) = 0._wp ;   diag_sice(:,:) = 0._wp
       diag_vice(:,:) = 0._wp ;   diag_vsnw(:,:) = 0._wp
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd.F90	(revision 12143)
@@ -95,4 +95,5 @@
       IF( ln_timing    )   CALL timing_start('icethd')                                                             ! timing
       IF( ln_icediachk )   CALL ice_cons_hsm(0, 'icethd', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
+      IF( ln_icediachk )   CALL ice_cons2D  (0, 'icethd',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
 
       IF( kt == nit000 .AND. lwp ) THEN
@@ -243,4 +244,5 @@
       !
       IF( ln_icediachk )   CALL ice_cons_hsm(1, 'icethd', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft)
+      IF( ln_icediachk )   CALL ice_cons2D  (1, 'icethd',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft)
       !                   
       IF( jpl > 1  )          CALL ice_itd_rem( kt )                ! --- Transport ice between thickness categories --- !
@@ -539,8 +541,8 @@
       REWIND( numnam_ice_ref )              ! Namelist namthd in reference namelist : Ice thermodynamics
       READ  ( numnam_ice_ref, namthd, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd in reference namelist' )
       REWIND( numnam_ice_cfg )              ! Namelist namthd in configuration namelist : Ice thermodynamics
       READ  ( numnam_ice_cfg, namthd, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd in configuration namelist' )
       IF(lwm) WRITE( numoni, namthd )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_da.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_da.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_da.F90	(revision 12143)
@@ -179,8 +179,8 @@
       REWIND( numnam_ice_ref )              ! Namelist namthd_da in reference namelist : Ice thermodynamics
       READ  ( numnam_ice_ref, namthd_da, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd_da in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd_da in reference namelist' )
       REWIND( numnam_ice_cfg )              ! Namelist namthd_da in configuration namelist : Ice thermodynamics
       READ  ( numnam_ice_cfg, namthd_da, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd_da in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd_da in configuration namelist' )
       IF(lwm) WRITE( numoni, namthd_da )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_do.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_do.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_do.F90	(revision 12143)
@@ -113,4 +113,5 @@
 
       IF( ln_icediachk )   CALL ice_cons_hsm( 0, 'icethd_do', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft )
+      IF( ln_icediachk )   CALL ice_cons2D  ( 0, 'icethd_do',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft )
 
       at_i(:,:) = SUM( a_i, dim=3 )
@@ -420,4 +421,5 @@
       !
       IF( ln_icediachk )   CALL ice_cons_hsm(1, 'icethd_do', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft)
+      IF( ln_icediachk )   CALL ice_cons2D  (1, 'icethd_do',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft)
       !
    END SUBROUTINE ice_thd_do
@@ -443,8 +445,8 @@
       REWIND( numnam_ice_ref )              ! Namelist namthd_do in reference namelist : Ice thermodynamics
       READ  ( numnam_ice_ref, namthd_do, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd_do in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd_do in reference namelist' )
       REWIND( numnam_ice_cfg )              ! Namelist namthd_do in configuration namelist : Ice thermodynamics
       READ  ( numnam_ice_cfg, namthd_do, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd_do in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd_do in configuration namelist' )
       IF(lwm) WRITE( numoni, namthd_do )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_pnd.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_pnd.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_pnd.F90	(revision 12143)
@@ -205,13 +205,13 @@
       INTEGER  ::   ios, ioptio   ! Local integer
       !!
-      NAMELIST/namthd_pnd/  ln_pnd_H12, ln_pnd_CST, rn_apnd, rn_hpnd, ln_pnd_alb
+      NAMELIST/namthd_pnd/  ln_pnd, ln_pnd_H12, ln_pnd_CST, rn_apnd, rn_hpnd, ln_pnd_alb
       !!-------------------------------------------------------------------
       !
       REWIND( numnam_ice_ref )              ! Namelist namthd_pnd  in reference namelist : Melt Ponds  
       READ  ( numnam_ice_ref, namthd_pnd, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd_pnd  in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd_pnd  in reference namelist' )
       REWIND( numnam_ice_cfg )              ! Namelist namthd_pnd  in configuration namelist : Melt Ponds
       READ  ( numnam_ice_cfg, namthd_pnd, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd_pnd in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd_pnd in configuration namelist' )
       IF(lwm) WRITE ( numoni, namthd_pnd )
       !
@@ -221,17 +221,19 @@
          WRITE(numout,*) '~~~~~~~~~~~~~~~~'
          WRITE(numout,*) '   Namelist namicethd_pnd:'
-         WRITE(numout,*) '      Evolutive  melt pond fraction and depth (Holland et al 2012) ln_pnd_H12 = ', ln_pnd_H12
-         WRITE(numout,*) '      Prescribed melt pond fraction and depth                      ln_pnd_CST = ', ln_pnd_CST
-         WRITE(numout,*) '         Prescribed pond fraction                                  rn_apnd    = ', rn_apnd
-         WRITE(numout,*) '         Prescribed pond depth                                     rn_hpnd    = ', rn_hpnd
-         WRITE(numout,*) '      Melt ponds affect albedo or not                              ln_pnd_alb = ', ln_pnd_alb
+         WRITE(numout,*) '      Melt ponds activated or not                                     ln_pnd     = ', ln_pnd
+         WRITE(numout,*) '         Evolutive  melt pond fraction and depth (Holland et al 2012) ln_pnd_H12 = ', ln_pnd_H12
+         WRITE(numout,*) '         Prescribed melt pond fraction and depth                      ln_pnd_CST = ', ln_pnd_CST
+         WRITE(numout,*) '            Prescribed pond fraction                                  rn_apnd    = ', rn_apnd
+         WRITE(numout,*) '            Prescribed pond depth                                     rn_hpnd    = ', rn_hpnd
+         WRITE(numout,*) '         Melt ponds affect albedo or not                              ln_pnd_alb = ', ln_pnd_alb
       ENDIF
       !
       !                             !== set the choice of ice pond scheme ==!
       ioptio = 0
-                                                            nice_pnd = np_pndNO
-      IF( ln_pnd_CST ) THEN   ;   ioptio = ioptio + 1   ;   nice_pnd = np_pndCST    ;   ENDIF
-      IF( ln_pnd_H12 ) THEN   ;   ioptio = ioptio + 1   ;   nice_pnd = np_pndH12    ;   ENDIF
-      IF( ioptio > 1 )   CALL ctl_stop( 'ice_thd_pnd_init: choose one and only one pond scheme (ln_pnd_H12 or ln_pnd_CST)' )
+      IF( .NOT.ln_pnd ) THEN   ;   ioptio = ioptio + 1   ;   nice_pnd = np_pndNO     ;   ENDIF
+      IF( ln_pnd_CST  ) THEN   ;   ioptio = ioptio + 1   ;   nice_pnd = np_pndCST    ;   ENDIF
+      IF( ln_pnd_H12  ) THEN   ;   ioptio = ioptio + 1   ;   nice_pnd = np_pndH12    ;   ENDIF
+      IF( ioptio /= 1 )   &
+         & CALL ctl_stop( 'ice_thd_pnd_init: choose either none (ln_pnd=F) or only one pond scheme (ln_pnd_H12 or ln_pnd_CST)' )
       !
       SELECT CASE( nice_pnd )
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_sal.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_sal.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_sal.F90	(revision 12143)
@@ -134,8 +134,8 @@
       REWIND( numnam_ice_ref )              ! Namelist namthd_sal in reference namelist : Ice salinity
       READ  ( numnam_ice_ref, namthd_sal, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd_sal in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd_sal in reference namelist' )
       REWIND( numnam_ice_cfg )              ! Namelist namthd_sal in configuration namelist : Ice salinity
       READ  ( numnam_ice_cfg, namthd_sal, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd_sal in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd_sal in configuration namelist' )
       IF(lwm) WRITE ( numoni, namthd_sal )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_zdf.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_zdf.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icethd_zdf.F90	(revision 12143)
@@ -90,8 +90,8 @@
       REWIND( numnam_ice_ref )              ! Namelist namthd_zdf in reference namelist : Ice thermodynamics
       READ  ( numnam_ice_ref, namthd_zdf, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd_zdf in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namthd_zdf in reference namelist' )
       REWIND( numnam_ice_cfg )              ! Namelist namthd_zdf in configuration namelist : Ice thermodynamics
       READ  ( numnam_ice_cfg, namthd_zdf, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd_zdf in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namthd_zdf in configuration namelist' )
       IF(lwm) WRITE( numoni, namthd_zdf )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/iceupdate.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/iceupdate.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/iceupdate.F90	(revision 12143)
@@ -198,89 +198,86 @@
       ! --- salt fluxes [kg/m2/s] --- !
       !                           ! sfxice =  sfxbog + sfxbom + sfxsum + sfxsni + sfxopw + sfxres + sfxdyn + sfxbri + sfxsub + sfxlam
-      IF( iom_use('sfxice'  ) )   CALL iom_put( "sfxice", sfx     * 1.e-03 )   ! salt flux from total ice growth/melt
-      IF( iom_use('sfxbog'  ) )   CALL iom_put( "sfxbog", sfx_bog * 1.e-03 )   ! salt flux from bottom growth
-      IF( iom_use('sfxbom'  ) )   CALL iom_put( "sfxbom", sfx_bom * 1.e-03 )   ! salt flux from bottom melting
-      IF( iom_use('sfxsum'  ) )   CALL iom_put( "sfxsum", sfx_sum * 1.e-03 )   ! salt flux from surface melting
-      IF( iom_use('sfxlam'  ) )   CALL iom_put( "sfxlam", sfx_lam * 1.e-03 )   ! salt flux from lateral melting
-      IF( iom_use('sfxsni'  ) )   CALL iom_put( "sfxsni", sfx_sni * 1.e-03 )   ! salt flux from snow ice formation
-      IF( iom_use('sfxopw'  ) )   CALL iom_put( "sfxopw", sfx_opw * 1.e-03 )   ! salt flux from open water formation
-      IF( iom_use('sfxdyn'  ) )   CALL iom_put( "sfxdyn", sfx_dyn * 1.e-03 )   ! salt flux from ridging rafting
-      IF( iom_use('sfxbri'  ) )   CALL iom_put( "sfxbri", sfx_bri * 1.e-03 )   ! salt flux from brines
-      IF( iom_use('sfxres'  ) )   CALL iom_put( "sfxres", sfx_res * 1.e-03 )   ! salt flux from undiagnosed processes
-      IF( iom_use('sfxsub'  ) )   CALL iom_put( "sfxsub", sfx_sub * 1.e-03 )   ! salt flux from sublimation
+      IF( iom_use('sfxice'  ) )   CALL iom_put( 'sfxice', sfx     * 1.e-03 )   ! salt flux from total ice growth/melt
+      IF( iom_use('sfxbog'  ) )   CALL iom_put( 'sfxbog', sfx_bog * 1.e-03 )   ! salt flux from bottom growth
+      IF( iom_use('sfxbom'  ) )   CALL iom_put( 'sfxbom', sfx_bom * 1.e-03 )   ! salt flux from bottom melting
+      IF( iom_use('sfxsum'  ) )   CALL iom_put( 'sfxsum', sfx_sum * 1.e-03 )   ! salt flux from surface melting
+      IF( iom_use('sfxlam'  ) )   CALL iom_put( 'sfxlam', sfx_lam * 1.e-03 )   ! salt flux from lateral melting
+      IF( iom_use('sfxsni'  ) )   CALL iom_put( 'sfxsni', sfx_sni * 1.e-03 )   ! salt flux from snow ice formation
+      IF( iom_use('sfxopw'  ) )   CALL iom_put( 'sfxopw', sfx_opw * 1.e-03 )   ! salt flux from open water formation
+      IF( iom_use('sfxdyn'  ) )   CALL iom_put( 'sfxdyn', sfx_dyn * 1.e-03 )   ! salt flux from ridging rafting
+      IF( iom_use('sfxbri'  ) )   CALL iom_put( 'sfxbri', sfx_bri * 1.e-03 )   ! salt flux from brines
+      IF( iom_use('sfxres'  ) )   CALL iom_put( 'sfxres', sfx_res * 1.e-03 )   ! salt flux from undiagnosed processes
+      IF( iom_use('sfxsub'  ) )   CALL iom_put( 'sfxsub', sfx_sub * 1.e-03 )   ! salt flux from sublimation
 
       ! --- mass fluxes [kg/m2/s] --- !
-      IF( iom_use('emp_oce' ) )   CALL iom_put( "emp_oce", emp_oce )   ! emp over ocean (taking into account the snow blown away from the ice)
-      IF( iom_use('emp_ice' ) )   CALL iom_put( "emp_ice", emp_ice )   ! emp over ice   (taking into account the snow blown away from the ice)
+      CALL iom_put( 'emp_oce', emp_oce )   ! emp over ocean (taking into account the snow blown away from the ice)
+      CALL iom_put( 'emp_ice', emp_ice )   ! emp over ice   (taking into account the snow blown away from the ice)
 
       !                           ! vfxice = vfxbog + vfxbom + vfxsum + vfxsni + vfxopw + vfxdyn + vfxres + vfxlam + vfxpnd
-      IF( iom_use('vfxice'  ) )   CALL iom_put( "vfxice" , wfx_ice )   ! mass flux from total ice growth/melt
-      IF( iom_use('vfxbog'  ) )   CALL iom_put( "vfxbog" , wfx_bog )   ! mass flux from bottom growth
-      IF( iom_use('vfxbom'  ) )   CALL iom_put( "vfxbom" , wfx_bom )   ! mass flux from bottom melt 
-      IF( iom_use('vfxsum'  ) )   CALL iom_put( "vfxsum" , wfx_sum )   ! mass flux from surface melt 
-      IF( iom_use('vfxlam'  ) )   CALL iom_put( "vfxlam" , wfx_lam )   ! mass flux from lateral melt 
-      IF( iom_use('vfxsni'  ) )   CALL iom_put( "vfxsni" , wfx_sni )   ! mass flux from snow-ice formation
-      IF( iom_use('vfxopw'  ) )   CALL iom_put( "vfxopw" , wfx_opw )   ! mass flux from growth in open water
-      IF( iom_use('vfxdyn'  ) )   CALL iom_put( "vfxdyn" , wfx_dyn )   ! mass flux from dynamics (ridging)
-      IF( iom_use('vfxres'  ) )   CALL iom_put( "vfxres" , wfx_res )   ! mass flux from undiagnosed processes 
-      IF( iom_use('vfxpnd'  ) )   CALL iom_put( "vfxpnd" , wfx_pnd )   ! mass flux from melt ponds
-      IF( iom_use('vfxsub'  ) )   CALL iom_put( "vfxsub" , wfx_ice_sub )   ! mass flux from ice sublimation (ice-atm.)
-      IF( iom_use('vfxsub_err') ) CALL iom_put( "vfxsub_err", wfx_err_sub )   ! "excess" of sublimation sent to ocean      
-
-      IF ( iom_use( "vfxthin" ) ) THEN   ! mass flux from ice growth in open water + thin ice (<20cm) => comparable to observations  
+      CALL iom_put( 'vfxice'    , wfx_ice     )   ! mass flux from total ice growth/melt
+      CALL iom_put( 'vfxbog'    , wfx_bog     )   ! mass flux from bottom growth
+      CALL iom_put( 'vfxbom'    , wfx_bom     )   ! mass flux from bottom melt 
+      CALL iom_put( 'vfxsum'    , wfx_sum     )   ! mass flux from surface melt 
+      CALL iom_put( 'vfxlam'    , wfx_lam     )   ! mass flux from lateral melt 
+      CALL iom_put( 'vfxsni'    , wfx_sni     )   ! mass flux from snow-ice formation
+      CALL iom_put( 'vfxopw'    , wfx_opw     )   ! mass flux from growth in open water
+      CALL iom_put( 'vfxdyn'    , wfx_dyn     )   ! mass flux from dynamics (ridging)
+      CALL iom_put( 'vfxres'    , wfx_res     )   ! mass flux from undiagnosed processes 
+      CALL iom_put( 'vfxpnd'    , wfx_pnd     )   ! mass flux from melt ponds
+      CALL iom_put( 'vfxsub'    , wfx_ice_sub )   ! mass flux from ice sublimation (ice-atm.)
+      CALL iom_put( 'vfxsub_err', wfx_err_sub )   ! "excess" of sublimation sent to ocean      
+
+      IF ( iom_use( 'vfxthin' ) ) THEN   ! mass flux from ice growth in open water + thin ice (<20cm) => comparable to observations  
          WHERE( hm_i(:,:) < 0.2 .AND. hm_i(:,:) > 0. ) ; z2d = wfx_bog
          ELSEWHERE                                     ; z2d = 0._wp
          END WHERE
-         CALL iom_put( "vfxthin", wfx_opw + z2d )
-      ENDIF
-
-      !                              ! vfxsnw = vfxsnw_sni + vfxsnw_dyn + vfxsnw_sum
-      IF( iom_use('vfxsnw'     ) )   CALL iom_put( "vfxsnw"     , wfx_snw     )   ! mass flux from total snow growth/melt
-      IF( iom_use('vfxsnw_sum' ) )   CALL iom_put( "vfxsnw_sum" , wfx_snw_sum )   ! mass flux from snow melt at the surface
-      IF( iom_use('vfxsnw_sni' ) )   CALL iom_put( "vfxsnw_sni" , wfx_snw_sni )   ! mass flux from snow melt during snow-ice formation 
-      IF( iom_use('vfxsnw_dyn' ) )   CALL iom_put( "vfxsnw_dyn" , wfx_snw_dyn )   ! mass flux from dynamics (ridging) 
-      IF( iom_use('vfxsnw_sub' ) )   CALL iom_put( "vfxsnw_sub" , wfx_snw_sub )   ! mass flux from snow sublimation (ice-atm.) 
-      IF( iom_use('vfxsnw_pre' ) )   CALL iom_put( "vfxsnw_pre" , wfx_spr     )   ! snow precip
+         CALL iom_put( 'vfxthin', wfx_opw + z2d )
+      ENDIF
+
+      !                            ! vfxsnw = vfxsnw_sni + vfxsnw_dyn + vfxsnw_sum
+      CALL iom_put( 'vfxsnw'     , wfx_snw     )   ! mass flux from total snow growth/melt
+      CALL iom_put( 'vfxsnw_sum' , wfx_snw_sum )   ! mass flux from snow melt at the surface
+      CALL iom_put( 'vfxsnw_sni' , wfx_snw_sni )   ! mass flux from snow melt during snow-ice formation 
+      CALL iom_put( 'vfxsnw_dyn' , wfx_snw_dyn )   ! mass flux from dynamics (ridging) 
+      CALL iom_put( 'vfxsnw_sub' , wfx_snw_sub )   ! mass flux from snow sublimation (ice-atm.) 
+      CALL iom_put( 'vfxsnw_pre' , wfx_spr     )   ! snow precip
 
       ! --- heat fluxes [W/m2] --- !
       !                              ! qt_atm_oi - qt_oce_ai = hfxdhc - ( dihctrp + dshctrp )
-      IF( iom_use('qsr_oce'    ) )   CALL iom_put( "qsr_oce"    , qsr_oce * ( 1._wp - at_i_b )                               )   !     solar flux at ocean surface
-      IF( iom_use('qns_oce'    ) )   CALL iom_put( "qns_oce"    , qns_oce * ( 1._wp - at_i_b ) + qemp_oce                    )   ! non-solar flux at ocean surface
-      IF( iom_use('qsr_ice'    ) )   CALL iom_put( "qsr_ice"    , SUM( qsr_ice * a_i_b, dim=3 )                              )   !     solar flux at ice surface
-      IF( iom_use('qns_ice'    ) )   CALL iom_put( "qns_ice"    , SUM( qns_ice * a_i_b, dim=3 ) + qemp_ice                   )   ! non-solar flux at ice surface
-      IF( iom_use('qtr_ice_bot') )   CALL iom_put( "qtr_ice_bot", SUM( qtr_ice_bot * a_i_b, dim=3 )                          )   !     solar flux transmitted thru ice
-      IF( iom_use('qtr_ice_top') )   CALL iom_put( "qtr_ice_top", SUM( qtr_ice_top * a_i_b, dim=3 )                          )   !     solar flux transmitted thru ice surface
-      IF( iom_use('qt_oce'     ) )   CALL iom_put( "qt_oce"     ,      ( qsr_oce + qns_oce ) * ( 1._wp - at_i_b ) + qemp_oce )
-      IF( iom_use('qt_ice'     ) )   CALL iom_put( "qt_ice"     , SUM( ( qns_ice + qsr_ice ) * a_i_b, dim=3 )     + qemp_ice )
-      IF( iom_use('qt_oce_ai'  ) )   CALL iom_put( "qt_oce_ai"  , qt_oce_ai * tmask(:,:,1)                                   )   ! total heat flux at the ocean   surface: interface oce-(ice+atm) 
-      IF( iom_use('qt_atm_oi'  ) )   CALL iom_put( "qt_atm_oi"  , qt_atm_oi * tmask(:,:,1)                                   )   ! total heat flux at the oce-ice surface: interface atm-(ice+oce) 
-      IF( iom_use('qemp_oce'   ) )   CALL iom_put( "qemp_oce"   , qemp_oce                                                   )   ! Downward Heat Flux from E-P over ocean
-      IF( iom_use('qemp_ice'   ) )   CALL iom_put( "qemp_ice"   , qemp_ice                                                   )   ! Downward Heat Flux from E-P over ice
+      IF( iom_use('qsr_oce'    ) )   CALL iom_put( 'qsr_oce'    , qsr_oce * ( 1._wp - at_i_b )                               )   !     solar flux at ocean surface
+      IF( iom_use('qns_oce'    ) )   CALL iom_put( 'qns_oce'    , qns_oce * ( 1._wp - at_i_b ) + qemp_oce                    )   ! non-solar flux at ocean surface
+      IF( iom_use('qsr_ice'    ) )   CALL iom_put( 'qsr_ice'    , SUM( qsr_ice * a_i_b, dim=3 )                              )   !     solar flux at ice surface
+      IF( iom_use('qns_ice'    ) )   CALL iom_put( 'qns_ice'    , SUM( qns_ice * a_i_b, dim=3 ) + qemp_ice                   )   ! non-solar flux at ice surface
+      IF( iom_use('qtr_ice_bot') )   CALL iom_put( 'qtr_ice_bot', SUM( qtr_ice_bot * a_i_b, dim=3 )                          )   !     solar flux transmitted thru ice
+      IF( iom_use('qtr_ice_top') )   CALL iom_put( 'qtr_ice_top', SUM( qtr_ice_top * a_i_b, dim=3 )                          )   !     solar flux transmitted thru ice surface
+      IF( iom_use('qt_oce'     ) )   CALL iom_put( 'qt_oce'     ,      ( qsr_oce + qns_oce ) * ( 1._wp - at_i_b ) + qemp_oce )
+      IF( iom_use('qt_ice'     ) )   CALL iom_put( 'qt_ice'     , SUM( ( qns_ice + qsr_ice ) * a_i_b, dim=3 )     + qemp_ice )
+      IF( iom_use('qt_oce_ai'  ) )   CALL iom_put( 'qt_oce_ai'  , qt_oce_ai * tmask(:,:,1)                                   )   ! total heat flux at the ocean   surface: interface oce-(ice+atm) 
+      IF( iom_use('qt_atm_oi'  ) )   CALL iom_put( 'qt_atm_oi'  , qt_atm_oi * tmask(:,:,1)                                   )   ! total heat flux at the oce-ice surface: interface atm-(ice+oce) 
+      IF( iom_use('qemp_oce'   ) )   CALL iom_put( 'qemp_oce'   , qemp_oce                                                   )   ! Downward Heat Flux from E-P over ocean
+      IF( iom_use('qemp_ice'   ) )   CALL iom_put( 'qemp_ice'   , qemp_ice                                                   )   ! Downward Heat Flux from E-P over ice
 
       ! heat fluxes from ice transformations
-      !                              ! hfxdhc = hfxbog + hfxbom + hfxsum + hfxopw + hfxdif + hfxsnw - ( hfxthd + hfxdyn + hfxres + hfxsub + hfxspr )
-      IF( iom_use('hfxbog'     ) )   CALL iom_put ("hfxbog"     , hfx_bog             )   ! heat flux used for ice bottom growth 
-      IF( iom_use('hfxbom'     ) )   CALL iom_put ("hfxbom"     , hfx_bom             )   ! heat flux used for ice bottom melt
-      IF( iom_use('hfxsum'     ) )   CALL iom_put ("hfxsum"     , hfx_sum             )   ! heat flux used for ice surface melt
-      IF( iom_use('hfxopw'     ) )   CALL iom_put ("hfxopw"     , hfx_opw             )   ! heat flux used for ice formation in open water
-      IF( iom_use('hfxdif'     ) )   CALL iom_put ("hfxdif"     , hfx_dif             )   ! heat flux used for ice temperature change
-      IF( iom_use('hfxsnw'     ) )   CALL iom_put ("hfxsnw"     , hfx_snw             )   ! heat flux used for snow melt 
-      IF( iom_use('hfxerr'     ) )   CALL iom_put ("hfxerr"     , hfx_err_dif         )   ! heat flux error after heat diffusion (included in qt_oce_ai)
+      !                            ! hfxdhc = hfxbog + hfxbom + hfxsum + hfxopw + hfxdif + hfxsnw - ( hfxthd + hfxdyn + hfxres + hfxsub + hfxspr )
+      CALL iom_put ('hfxbog'     , hfx_bog     )   ! heat flux used for ice bottom growth 
+      CALL iom_put ('hfxbom'     , hfx_bom     )   ! heat flux used for ice bottom melt
+      CALL iom_put ('hfxsum'     , hfx_sum     )   ! heat flux used for ice surface melt
+      CALL iom_put ('hfxopw'     , hfx_opw     )   ! heat flux used for ice formation in open water
+      CALL iom_put ('hfxdif'     , hfx_dif     )   ! heat flux used for ice temperature change
+      CALL iom_put ('hfxsnw'     , hfx_snw     )   ! heat flux used for snow melt 
+      CALL iom_put ('hfxerr'     , hfx_err_dif )   ! heat flux error after heat diffusion (included in qt_oce_ai)
 
       ! heat fluxes associated with mass exchange (freeze/melt/precip...)
-      IF( iom_use('hfxthd'     ) )   CALL iom_put ("hfxthd"     , hfx_thd             )   !  
-      IF( iom_use('hfxdyn'     ) )   CALL iom_put ("hfxdyn"     , hfx_dyn             )   !  
-      IF( iom_use('hfxres'     ) )   CALL iom_put ("hfxres"     , hfx_res             )   !  
-      IF( iom_use('hfxsub'     ) )   CALL iom_put ("hfxsub"     , hfx_sub             )   !  
-      IF( iom_use('hfxspr'     ) )   CALL iom_put ("hfxspr"     , hfx_spr             )   ! Heat flux from snow precip heat content 
+      CALL iom_put ('hfxthd'     , hfx_thd     )   !  
+      CALL iom_put ('hfxdyn'     , hfx_dyn     )   !  
+      CALL iom_put ('hfxres'     , hfx_res     )   !  
+      CALL iom_put ('hfxsub'     , hfx_sub     )   !  
+      CALL iom_put ('hfxspr'     , hfx_spr     )   ! Heat flux from snow precip heat content 
 
       ! other heat fluxes
-      IF( iom_use('hfxsensib'  ) )   CALL iom_put( "hfxsensib"  ,     -qsb_ice_bot * at_i_b         )   ! Sensible oceanic heat flux
-      IF( iom_use('hfxcndbot'  ) )   CALL iom_put( "hfxcndbot"  , SUM( qcn_ice_bot * a_i_b, dim=3 ) )   ! Bottom conduction flux
-      IF( iom_use('hfxcndtop'  ) )   CALL iom_put( "hfxcndtop"  , SUM( qcn_ice_top * a_i_b, dim=3 ) )   ! Surface conduction flux
-
-      ! diags
-      IF( iom_use('hfxdhc'     ) )   CALL iom_put ("hfxdhc"     , diag_heat           )   ! Heat content variation in snow and ice 
-      !
+      IF( iom_use('hfxsensib'  ) )   CALL iom_put( 'hfxsensib'  ,     -qsb_ice_bot * at_i_b         )   ! Sensible oceanic heat flux
+      IF( iom_use('hfxcndbot'  ) )   CALL iom_put( 'hfxcndbot'  , SUM( qcn_ice_bot * a_i_b, dim=3 ) )   ! Bottom conduction flux
+      IF( iom_use('hfxcndtop'  ) )   CALL iom_put( 'hfxcndtop'  , SUM( qcn_ice_top * a_i_b, dim=3 ) )   ! Surface conduction flux
+
       ! controls
       !---------
@@ -413,5 +410,5 @@
       !! ** Method  :   use of IOM library
       !!----------------------------------------------------------------------
-      CHARACTER(len=*) , INTENT(in) ::   cdrw   ! "READ"/"WRITE" flag
+      CHARACTER(len=*) , INTENT(in) ::   cdrw   ! 'READ'/'WRITE' flag
       INTEGER, OPTIONAL, INTENT(in) ::   kt     ! ice time-step
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icevar.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icevar.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icevar.F90	(revision 12143)
@@ -32,4 +32,5 @@
    !!                        - vt_s(jpi,jpj)
    !!                        - at_i(jpi,jpj)
+   !!                        - st_i(jpi,jpj)
    !!                        - et_s(jpi,jpj)  total snow heat content
    !!                        - et_i(jpi,jpj)  total ice thermal content 
@@ -46,9 +47,8 @@
    !!   ice_var_zapneg    : remove negative ice fields
    !!   ice_var_roundoff  : remove negative values arising from roundoff erros
-   !!   ice_var_itd       : convert 1-cat to jpl-cat
-   !!   ice_var_itd2      : convert N-cat to jpl-cat
    !!   ice_var_bv        : brine volume
    !!   ice_var_enthalpy  : compute ice and snow enthalpies from temperature
    !!   ice_var_sshdyn    : compute equivalent ssh in lead
+   !!   ice_var_itd       : convert N-cat to M-cat
    !!----------------------------------------------------------------------
    USE dom_oce        ! ocean space and time domain
@@ -104,9 +104,10 @@
       !
       !                                      ! integrated values
-      vt_i(:,:) =       SUM( v_i(:,:,:)           , dim=3 )
-      vt_s(:,:) =       SUM( v_s(:,:,:)           , dim=3 )
-      at_i(:,:) =       SUM( a_i(:,:,:)           , dim=3 )
-      et_s(:,:)  = SUM( SUM( e_s(:,:,:,:), dim=4 ), dim=3 )
-      et_i(:,:)  = SUM( SUM( e_i(:,:,:,:), dim=4 ), dim=3 )
+      vt_i(:,:) =       SUM( v_i (:,:,:)           , dim=3 )
+      vt_s(:,:) =       SUM( v_s (:,:,:)           , dim=3 )
+      st_i(:,:) =       SUM( sv_i(:,:,:)           , dim=3 )
+      at_i(:,:) =       SUM( a_i (:,:,:)           , dim=3 )
+      et_s(:,:)  = SUM( SUM( e_s (:,:,:,:), dim=4 ), dim=3 )
+      et_i(:,:)  = SUM( SUM( e_i (:,:,:,:), dim=4 ), dim=3 )
       !
       at_ip(:,:) = SUM( a_ip(:,:,:), dim=3 ) ! melt ponds
@@ -138,5 +139,5 @@
          tm_si(:,:) = SUM( t_si(:,:,:) * a_i(:,:,:) , dim=3 ) * z1_at_i(:,:)
          om_i (:,:) = SUM( oa_i(:,:,:)              , dim=3 ) * z1_at_i(:,:)
-         sm_i (:,:) = SUM( sv_i(:,:,:)              , dim=3 ) * z1_vt_i(:,:)
+         sm_i (:,:) =      st_i(:,:)                          * z1_vt_i(:,:)
          !
          tm_i(:,:) = 0._wp
@@ -158,6 +159,12 @@
             tm_s (:,:) = rt0
          END WHERE
-
+         !
+         !                           ! mean melt pond depth
+         WHERE( at_ip(:,:) > epsi20 )   ;   hm_ip(:,:) = vt_ip(:,:) / at_ip(:,:)
+         ELSEWHERE                      ;   hm_ip(:,:) = 0._wp
+         END WHERE         
+         !
          DEALLOCATE( z1_at_i , z1_vt_i , z1_vt_s )
+         !
       ENDIF
       !
@@ -263,7 +270,7 @@
       !
       ! integrated values 
-      vt_i (:,:) = SUM( v_i, dim=3 )
-      vt_s (:,:) = SUM( v_s, dim=3 )
-      at_i (:,:) = SUM( a_i, dim=3 )
+      vt_i (:,:) = SUM( v_i , dim=3 )
+      vt_s (:,:) = SUM( v_s , dim=3 )
+      at_i (:,:) = SUM( a_i , dim=3 )
       !
    END SUBROUTINE ice_var_glo2eqv
@@ -533,6 +540,12 @@
 
       ! to be sure that at_i is the sum of a_i(jl)
-      at_i (:,:) = SUM( a_i(:,:,:), dim=3 )
-      vt_i (:,:) = SUM( v_i(:,:,:), dim=3 )
+      at_i (:,:) = SUM( a_i (:,:,:), dim=3 )
+      vt_i (:,:) = SUM( v_i (:,:,:), dim=3 )
+!!clem add?
+!      vt_s (:,:) = SUM( v_s (:,:,:), dim=3 )
+!      st_i (:,:) = SUM( sv_i(:,:,:), dim=3 )
+!      et_s(:,:)  = SUM( SUM( e_s (:,:,:,:), dim=4 ), dim=3 )
+!      et_i(:,:)  = SUM( SUM( e_i (:,:,:,:), dim=4 ), dim=3 )
+!!clem
 
       ! open water = 1 if at_i=0
@@ -609,5 +622,5 @@
                   pv_s   (ji,jj,jl) = 0._wp
                ENDIF
-               IF( psv_i(ji,jj,jl) < 0._wp .OR. pa_i(ji,jj,jl) <= 0._wp ) THEN
+               IF( psv_i(ji,jj,jl) < 0._wp .OR. pa_i(ji,jj,jl) <= 0._wp .OR. pv_i(ji,jj,jl) <= 0._wp ) THEN
                   sfx_res(ji,jj)    = sfx_res(ji,jj) + psv_i(ji,jj,jl) * rhoi * z1_dt
                   psv_i  (ji,jj,jl) = 0._wp
@@ -652,5 +665,5 @@
       WHERE( pe_i (1:npti,:,:) < 0._wp .AND. pe_i (1:npti,:,:) > -epsi06 )   pe_i (1:npti,:,:) = 0._wp   !  e_i must be >= 0
       WHERE( pe_s (1:npti,:,:) < 0._wp .AND. pe_s (1:npti,:,:) > -epsi06 )   pe_s (1:npti,:,:) = 0._wp   !  e_s must be >= 0
-      IF ( ln_pnd_H12 ) THEN
+      IF( ln_pnd_H12 ) THEN
          WHERE( pa_ip(1:npti,:) < 0._wp .AND. pa_ip(1:npti,:) > -epsi10 )    pa_ip(1:npti,:)   = 0._wp   ! a_ip must be >= 0
          WHERE( pv_ip(1:npti,:) < 0._wp .AND. pv_ip(1:npti,:) > -epsi10 )    pv_ip(1:npti,:)   = 0._wp   ! v_ip must be >= 0
@@ -773,182 +786,221 @@
    !! ** Purpose :  converting N-cat ice to jpl ice categories
    !!-------------------------------------------------------------------
-   SUBROUTINE ice_var_itd_1c1c( zhti, zhts, zati, zh_i, zh_s, za_i )
+   SUBROUTINE ice_var_itd_1c1c( phti, phts, pati ,                       ph_i, ph_s, pa_i, &
+      &                         ptmi, ptms, ptmsu, psmi, patip, phtip,   pt_i, pt_s, pt_su, ps_i, pa_ip, ph_ip )
       !!-------------------------------------------------------------------
       !! ** Purpose :  converting 1-cat ice to 1 ice category
       !!-------------------------------------------------------------------
-      REAL(wp), DIMENSION(:), INTENT(in)    ::   zhti, zhts, zati    ! input ice/snow variables
-      REAL(wp), DIMENSION(:), INTENT(inout) ::   zh_i, zh_s, za_i    ! output ice/snow variables
-      !!-------------------------------------------------------------------
-      zh_i(:) = zhti(:)
-      zh_s(:) = zhts(:)
-      za_i(:) = zati(:)
+      REAL(wp), DIMENSION(:), INTENT(in)    ::   phti, phts, pati    ! input  ice/snow variables
+      REAL(wp), DIMENSION(:), INTENT(inout) ::   ph_i, ph_s, pa_i    ! output ice/snow variables
+      REAL(wp), DIMENSION(:), INTENT(in)    ::   ptmi, ptms, ptmsu, psmi, patip, phtip    ! input  ice/snow temp & sal & ponds
+      REAL(wp), DIMENSION(:), INTENT(inout) ::   pt_i, pt_s, pt_su, ps_i, pa_ip, ph_ip    ! output ice/snow temp & sal & ponds
+      !!-------------------------------------------------------------------
+      ! == thickness and concentration == !
+      ph_i(:) = phti(:)
+      ph_s(:) = phts(:)
+      pa_i(:) = pati(:)
+      !
+      ! == temperature and salinity and ponds == !
+      pt_i (:) = ptmi (:)
+      pt_s (:) = ptms (:)
+      pt_su(:) = ptmsu(:)
+      ps_i (:) = psmi (:)
+      pa_ip(:) = patip(:)
+      ph_ip(:) = phtip(:)
+      
    END SUBROUTINE ice_var_itd_1c1c
 
-   SUBROUTINE ice_var_itd_Nc1c( zhti, zhts, zati, zh_i, zh_s, za_i )
+   SUBROUTINE ice_var_itd_Nc1c( phti, phts, pati ,                       ph_i, ph_s, pa_i, &
+      &                         ptmi, ptms, ptmsu, psmi, patip, phtip,   pt_i, pt_s, pt_su, ps_i, pa_ip, ph_ip )
       !!-------------------------------------------------------------------
       !! ** Purpose :  converting N-cat ice to 1 ice category
       !!-------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:), INTENT(in)    ::   zhti, zhts, zati    ! input ice/snow variables
-      REAL(wp), DIMENSION(:)  , INTENT(inout) ::   zh_i, zh_s, za_i    ! output ice/snow variables
-      !!-------------------------------------------------------------------
-      !
-      za_i(:) = SUM( zati(:,:), dim=2 )
-      !
-      WHERE( za_i(:) /= 0._wp )
-         zh_i(:) = SUM( zhti(:,:) * zati(:,:), dim=2 ) / za_i(:)
-         zh_s(:) = SUM( zhts(:,:) * zati(:,:), dim=2 ) / za_i(:)
-      ELSEWHERE
-         zh_i(:) = 0._wp
-         zh_s(:) = 0._wp
+      REAL(wp), DIMENSION(:,:), INTENT(in)    ::   phti, phts, pati    ! input  ice/snow variables
+      REAL(wp), DIMENSION(:)  , INTENT(inout) ::   ph_i, ph_s, pa_i    ! output ice/snow variables
+      REAL(wp), DIMENSION(:,:), INTENT(in)    ::   ptmi, ptms, ptmsu, psmi, patip, phtip    ! input  ice/snow temp & sal & ponds
+      REAL(wp), DIMENSION(:)  , INTENT(inout) ::   pt_i, pt_s, pt_su, ps_i, pa_ip, ph_ip    ! output ice/snow temp & sal & ponds
+      !
+      REAL(wp), ALLOCATABLE, DIMENSION(:) ::   z1_ai, z1_vi, z1_vs
+      !
+      INTEGER ::   idim  
+      !!-------------------------------------------------------------------
+      !
+      idim = SIZE( phti, 1 )
+      !
+      ! == thickness and concentration == !
+      ALLOCATE( z1_ai(idim), z1_vi(idim), z1_vs(idim) )
+      !
+      pa_i(:) = SUM( pati(:,:), dim=2 )
+
+      WHERE( ( pa_i(:) ) /= 0._wp )   ;   z1_ai(:) = 1._wp / pa_i(:)
+      ELSEWHERE                       ;   z1_ai(:) = 0._wp
       END WHERE
+
+      ph_i(:) = SUM( phti(:,:) * pati(:,:), dim=2 ) * z1_ai(:)
+      ph_s(:) = SUM( phts(:,:) * pati(:,:), dim=2 ) * z1_ai(:)
+      !
+      ! == temperature and salinity == !
+      WHERE( ( pa_i(:) * ph_i(:) ) /= 0._wp )   ;   z1_vi(:) = 1._wp / ( pa_i(:) * ph_i(:) )
+      ELSEWHERE                                 ;   z1_vi(:) = 0._wp
+      END WHERE
+      WHERE( ( pa_i(:) * ph_s(:) ) /= 0._wp )   ;   z1_vs(:) = 1._wp / ( pa_i(:) * ph_s(:) )
+      ELSEWHERE                                 ;   z1_vs(:) = 0._wp
+      END WHERE
+      pt_i (:) = SUM( ptmi (:,:) * pati(:,:) * phti(:,:), dim=2 ) * z1_vi(:)
+      pt_s (:) = SUM( ptms (:,:) * pati(:,:) * phts(:,:), dim=2 ) * z1_vs(:)
+      pt_su(:) = SUM( ptmsu(:,:) * pati(:,:)            , dim=2 ) * z1_ai(:)
+      ps_i (:) = SUM( psmi (:,:) * pati(:,:) * phti(:,:), dim=2 ) * z1_vi(:)
+
+      ! == ponds == !
+      pa_ip(:) = SUM( patip(:,:), dim=2 )
+      WHERE( pa_ip(:) /= 0._wp )   ;   ph_ip(:) = SUM( phtip(:,:) * patip(:,:), dim=2 ) / pa_ip(:)
+      ELSEWHERE                    ;   ph_ip(:) = 0._wp
+      END WHERE
+      !
+      DEALLOCATE( z1_ai, z1_vi, z1_vs )
       !
    END SUBROUTINE ice_var_itd_Nc1c
    
-   SUBROUTINE ice_var_itd_1cMc( zhti, zhts, zati, zh_i, zh_s, za_i )
+   SUBROUTINE ice_var_itd_1cMc( phti, phts, pati ,                       ph_i, ph_s, pa_i, &
+      &                         ptmi, ptms, ptmsu, psmi, patip, phtip,   pt_i, pt_s, pt_su, ps_i, pa_ip, ph_ip )
       !!-------------------------------------------------------------------
       !!
       !! ** Purpose :  converting 1-cat ice to jpl ice categories
       !!
-      !!                  ice thickness distribution follows a gaussian law
-      !!               around the concentration of the most likely ice thickness
-      !!                           (similar as iceistate.F90)
-      !!
-      !! ** Method:   Iterative procedure
-      !!                
-      !!               1) Try to fill the jpl ice categories (bounds hi_max(0:jpl)) with a gaussian
-      !!
-      !!               2) Check whether the distribution conserves area and volume, positivity and
-      !!                  category boundaries
+      !!
+      !! ** Method:   ice thickness distribution follows a gamma function from Abraham et al. (2015)
+      !!              it has the property of conserving total concentration and volume
       !!              
-      !!               3) If not (input ice is too thin), the last category is empty and
-      !!                  the number of categories is reduced (jpl-1)
-      !!
-      !!               4) Iterate until ok (SUM(itest(:) = 4)
-      !!
-      !! ** Arguments : zhti: 1-cat ice thickness
-      !!                zhts: 1-cat snow depth
-      !!                zati: 1-cat ice concentration
+      !!
+      !! ** Arguments : phti: 1-cat ice thickness
+      !!                phts: 1-cat snow depth
+      !!                pati: 1-cat ice concentration
       !!
       !! ** Output    : jpl-cat 
       !!
-      !!  (Example of application: BDY forcings when input are cell averaged)  
-      !!-------------------------------------------------------------------
-      INTEGER  :: ji, jk, jl             ! dummy loop indices
-      INTEGER  :: idim, i_fill, jl0  
-      REAL(wp) :: zarg, zV, zconv, zdh, zdv
-      REAL(wp), DIMENSION(:),   INTENT(in)    ::   zhti, zhts, zati    ! input  ice/snow variables
-      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   zh_i, zh_s, za_i    ! output ice/snow variables
-      INTEGER , DIMENSION(4)                  ::   itest
-      !!-------------------------------------------------------------------
-      !
-      ! ----------------------------------------
-      ! distribution over the jpl ice categories
-      ! ----------------------------------------
-      ! a gaussian distribution for ice concentration is used
-      ! then we check whether the distribution fullfills
-      ! volume and area conservation, positivity and ice categories bounds
-      idim = SIZE( zhti , 1 )
-      zh_i(1:idim,1:jpl) = 0._wp
-      zh_s(1:idim,1:jpl) = 0._wp
-      za_i(1:idim,1:jpl) = 0._wp
-      !
+      !!  Abraham, C., Steiner, N., Monahan, A. and Michel, C., 2015.
+      !!               Effects of subgrid‐scale snow thickness variability on radiative transfer in sea ice.
+      !!               Journal of Geophysical Research: Oceans, 120(8), pp.5597-5614 
+      !!-------------------------------------------------------------------
+      REAL(wp), DIMENSION(:),   INTENT(in)    ::   phti, phts, pati    ! input  ice/snow variables
+      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   ph_i, ph_s, pa_i    ! output ice/snow variables
+      REAL(wp), DIMENSION(:)  , INTENT(in)    ::   ptmi, ptms, ptmsu, psmi, patip, phtip    ! input  ice/snow temp & sal & ponds
+      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pt_i, pt_s, pt_su, ps_i, pa_ip, ph_ip    ! output ice/snow temp & sal & ponds
+      !
+      REAL(wp), ALLOCATABLE, DIMENSION(:) ::   zfra, z1_hti
+      INTEGER  ::   ji, jk, jl
+      INTEGER  ::   idim
+      REAL(wp) ::   zv, zdh
+      !!-------------------------------------------------------------------
+      !
+      idim = SIZE( phti , 1 )
+      !
+      ph_i(1:idim,1:jpl) = 0._wp
+      ph_s(1:idim,1:jpl) = 0._wp
+      pa_i(1:idim,1:jpl) = 0._wp
+      !
+      ALLOCATE( z1_hti(idim) )
+      WHERE( phti(:) /= 0._wp )   ;   z1_hti(:) = 1._wp / phti(:)
+      ELSEWHERE                   ;   z1_hti(:) = 0._wp
+      END WHERE
+      !
+      ! == thickness and concentration == !
+      ! for categories 1:jpl-1, integrate the gamma function from hi_max(jl-1) to hi_max(jl)
+      DO jl = 1, jpl-1
+         DO ji = 1, idim
+            !
+            IF( phti(ji) > 0._wp ) THEN
+               ! concentration : integrate ((4A/H^2)xexp(-2x/H))dx from x=hi_max(jl-1) to hi_max(jl)
+               pa_i(ji,jl) = pati(ji) * z1_hti(ji) * (  ( phti(ji) + 2.*hi_max(jl-1) ) * EXP( -2.*hi_max(jl-1)*z1_hti(ji) ) &
+                  &                                   - ( phti(ji) + 2.*hi_max(jl  ) ) * EXP( -2.*hi_max(jl  )*z1_hti(ji) ) )
+               !
+               ! volume : integrate ((4A/H^2)x^2exp(-2x/H))dx from x=hi_max(jl-1) to hi_max(jl)
+               zv = pati(ji) * z1_hti(ji) * (  ( phti(ji)*phti(ji) + 2.*phti(ji)*hi_max(jl-1) + 2.*hi_max(jl-1)*hi_max(jl-1) ) &
+                  &                            * EXP( -2.*hi_max(jl-1)*z1_hti(ji) ) &
+                  &                          - ( phti(ji)*phti(ji) + 2.*phti(ji)*hi_max(jl) + 2.*hi_max(jl)*hi_max(jl) ) &
+                  &                            * EXP(-2.*hi_max(jl)*z1_hti(ji)) )
+               ! thickness
+               IF( pa_i(ji,jl) > epsi06 ) THEN
+                  ph_i(ji,jl) = zv / pa_i(ji,jl)
+               ELSE
+                  ph_i(ji,jl) = 0.
+                  pa_i(ji,jl) = 0.
+               ENDIF
+            ENDIF
+            !
+         ENDDO
+      ENDDO
+      !
+      ! for the last category (jpl), integrate the gamma function from hi_max(jpl-1) to infinity
       DO ji = 1, idim
          !
-         IF( zhti(ji) > 0._wp ) THEN
-            !
-            ! find which category (jl0) the input ice thickness falls into
-            jl0 = jpl
-            DO jl = 1, jpl
-               IF ( ( zhti(ji) >= hi_max(jl-1) ) .AND. ( zhti(ji) < hi_max(jl) ) ) THEN
-                  jl0 = jl
-                  CYCLE
-               ENDIF
-            END DO
-            !
-            itest(:) = 0
-            i_fill   = jpl + 1                                            !------------------------------------
-            DO WHILE ( ( SUM( itest(:) ) /= 4 ) .AND. ( i_fill >= 2 ) )   ! iterative loop on i_fill categories
-               !                                                          !------------------------------------
-               i_fill = i_fill - 1
-               !
-               zh_i(ji,1:jpl) = 0._wp
-               za_i(ji,1:jpl) = 0._wp
-               itest(:)       = 0      
-               !
-               IF ( i_fill == 1 ) THEN      !-- case very thin ice: fill only category 1
-                  zh_i(ji,1) = zhti(ji)
-                  za_i (ji,1) = zati (ji)
-               ELSE                         !-- case ice is thicker: fill categories >1
-                  ! thickness
-                  DO jl = 1, i_fill - 1
-                     zh_i(ji,jl) = hi_mean(jl)
-                  END DO
-                  !
-                  ! concentration
-                  za_i(ji,jl0) = zati(ji) / SQRT(REAL(jpl))
-                  DO jl = 1, i_fill - 1
-                     IF ( jl /= jl0 ) THEN
-                        zarg        = ( zh_i(ji,jl) - zhti(ji) ) / ( zhti(ji) * 0.5_wp )
-                        za_i(ji,jl) =   za_i (ji,jl0) * EXP(-zarg**2)
-                     ENDIF
-                  END DO
-                  !
-                  ! last category
-                  za_i(ji,i_fill) = zati(ji) - SUM( za_i(ji,1:i_fill-1) )
-                  zV = SUM( za_i(ji,1:i_fill-1) * zh_i(ji,1:i_fill-1) )
-                  zh_i(ji,i_fill) = ( zhti(ji) * zati(ji) - zV ) / MAX( za_i(ji,i_fill), epsi10 ) 
-                  !
-                  ! correction if concentration of upper cat is greater than lower cat
-                  !    (it should be a gaussian around jl0 but sometimes it is not)
-                  IF ( jl0 /= jpl ) THEN
-                     DO jl = jpl, jl0+1, -1
-                        IF ( za_i(ji,jl) > za_i(ji,jl-1) ) THEN
-                           zdv = zh_i(ji,jl) * za_i(ji,jl)
-                           zh_i(ji,jl    ) = 0._wp
-                           za_i (ji,jl    ) = 0._wp
-                           za_i (ji,1:jl-1) = za_i(ji,1:jl-1) + zdv / MAX( REAL(jl-1) * zhti(ji), epsi10 )
-                        END IF
-                     END DO
-                  ENDIF
-                  !
-               ENDIF
-               !
-               ! Compatibility tests
-               zconv = ABS( zati(ji) - SUM( za_i(ji,1:jpl) ) ) 
-               IF ( zconv < epsi06 )   itest(1) = 1                                        ! Test 1: area conservation
-               !
-               zconv = ABS( zhti(ji)*zati(ji) - SUM( za_i(ji,1:jpl)*zh_i(ji,1:jpl) ) )
-               IF ( zconv < epsi06 )   itest(2) = 1                                        ! Test 2: volume conservation
-               !
-               IF ( zh_i(ji,i_fill) >= hi_max(i_fill-1) )   itest(3) = 1                  ! Test 3: thickness of the last category is in-bounds ?
-               !
-               itest(4) = 1
-               DO jl = 1, i_fill
-                  IF ( za_i(ji,jl) < 0._wp ) itest(4) = 0                                ! Test 4: positivity of ice concentrations
-               END DO
-               !                                         !----------------------------
-            END DO                                       ! end iteration on categories
-            !                                            !----------------------------
+         IF( phti(ji) > 0._wp ) THEN
+            ! concentration : integrate ((4A/H^2)xexp(-2x/H))dx from x=hi_max(jpl-1) to infinity
+            pa_i(ji,jpl) = pati(ji) * z1_hti(ji) * ( phti(ji) + 2.*hi_max(jpl-1) ) * EXP( -2.*hi_max(jpl-1)*z1_hti(ji) )
+
+            ! volume : integrate ((4A/H^2)x^2exp(-2x/H))dx from x=hi_max(jpl-1) to infinity
+            zv = pati(ji) * z1_hti(ji) * ( phti(ji)*phti(ji) + 2.*phti(ji)*hi_max(jpl-1) + 2.*hi_max(jpl-1)*hi_max(jpl-1) ) &
+               &                         * EXP( -2.*hi_max(jpl-1)*z1_hti(ji) )
+            ! thickness
+            IF( pa_i(ji,jpl) > epsi06 ) THEN
+               ph_i(ji,jpl) = zv / pa_i(ji,jpl)
+            else
+               ph_i(ji,jpl) = 0.
+               pa_i(ji,jpl) = 0.
+            ENDIF
          ENDIF
-      END DO
-
-      ! Add Snow in each category where za_i is not 0
+         !
+      ENDDO
+      !
+      ! Add Snow in each category where pa_i is not 0
       DO jl = 1, jpl
          DO ji = 1, idim
-            IF( za_i(ji,jl) > 0._wp ) THEN
-               zh_s(ji,jl) = zh_i(ji,jl) * ( zhts(ji) / zhti(ji) )
+            IF( pa_i(ji,jl) > 0._wp ) THEN
+               ph_s(ji,jl) = ph_i(ji,jl) * phts(ji) * z1_hti(ji)
                ! In case snow load is in excess that would lead to transformation from snow to ice
                ! Then, transfer the snow excess into the ice (different from icethd_dh)
-               zdh = MAX( 0._wp, ( rhos * zh_s(ji,jl) + ( rhoi - rau0 ) * zh_i(ji,jl) ) * r1_rau0 ) 
+               zdh = MAX( 0._wp, ( rhos * ph_s(ji,jl) + ( rhoi - rau0 ) * ph_i(ji,jl) ) * r1_rau0 ) 
                ! recompute h_i, h_s avoiding out of bounds values
-               zh_i(ji,jl) = MIN( hi_max(jl), zh_i(ji,jl) + zdh )
-               zh_s(ji,jl) = MAX( 0._wp, zh_s(ji,jl) - zdh * rhoi * r1_rhos )
+               ph_i(ji,jl) = MIN( hi_max(jl), ph_i(ji,jl) + zdh )
+               ph_s(ji,jl) = MAX( 0._wp, ph_s(ji,jl) - zdh * rhoi * r1_rhos )
             ENDIF
          END DO
       END DO
       !
+      DEALLOCATE( z1_hti )
+      !
+      ! == temperature and salinity == !
+      DO jl = 1, jpl
+         pt_i (:,jl) = ptmi (:)
+         pt_s (:,jl) = ptms (:)
+         pt_su(:,jl) = ptmsu(:)
+         ps_i (:,jl) = psmi (:)
+         ps_i (:,jl) = psmi (:)         
+      END DO
+      !
+      ! == ponds == !
+      ALLOCATE( zfra(idim) )
+      ! keep the same pond fraction atip/ati for each category
+      WHERE( pati(:) /= 0._wp )   ;   zfra(:) = patip(:) / pati(:)
+      ELSEWHERE                   ;   zfra(:) = 0._wp
+      END WHERE
+      DO jl = 1, jpl
+         pa_ip(:,jl) = zfra(:) * pa_i(:,jl)
+      END DO
+      ! keep the same v_ip/v_i ratio for each category
+      WHERE( ( phti(:) * pati(:) ) /= 0._wp )   ;   zfra(:) = ( phtip(:) * patip(:) ) / ( phti(:) * pati(:) )
+      ELSEWHERE                                 ;   zfra(:) = 0._wp
+      END WHERE
+      DO jl = 1, jpl
+         WHERE( pa_ip(:,jl) /= 0._wp )   ;   ph_ip(:,jl) = zfra(:) * ( ph_i(:,jl) * pa_i(:,jl) ) / pa_ip(:,jl)
+         ELSEWHERE                       ;   ph_ip(:,jl) = 0._wp
+         END WHERE
+      END DO
+      DEALLOCATE( zfra )
+      !
    END SUBROUTINE ice_var_itd_1cMc
 
-   SUBROUTINE ice_var_itd_NcMc( zhti, zhts, zati, zh_i, zh_s, za_i )
+   SUBROUTINE ice_var_itd_NcMc( phti, phts, pati ,                       ph_i, ph_s, pa_i, &
+      &                         ptmi, ptms, ptmsu, psmi, patip, phtip,   pt_i, pt_s, pt_su, ps_i, pa_ip, ph_ip )
       !!-------------------------------------------------------------------
       !!
@@ -971,7 +1023,7 @@
       !!                      b) removing 25% ice area from the higher cat (descendant loop jlmax=>jlmin)
       !!
-      !! ** Arguments : zhti: N-cat ice thickness
-      !!                zhts: N-cat snow depth
-      !!                zati: N-cat ice concentration
+      !! ** Arguments : phti: N-cat ice thickness
+      !!                phts: N-cat snow depth
+      !!                pati: N-cat ice concentration
       !!
       !! ** Output    : jpl-cat 
@@ -979,29 +1031,50 @@
       !!  (Example of application: BDY forcings when inputs have N-cat /= jpl)  
       !!-------------------------------------------------------------------
-      INTEGER  ::   ji, jl, jl1, jl2             ! dummy loop indices
+      REAL(wp), DIMENSION(:,:), INTENT(in)    ::   phti, phts, pati    ! input  ice/snow variables
+      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   ph_i, ph_s, pa_i    ! output ice/snow variables
+      REAL(wp), DIMENSION(:,:), INTENT(in)    ::   ptmi, ptms, ptmsu, psmi, patip, phtip    ! input  ice/snow temp & sal & ponds
+      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pt_i, pt_s, pt_su, ps_i, pa_ip, ph_ip    ! output ice/snow temp & sal & ponds
+      !
+      INTEGER , ALLOCATABLE, DIMENSION(:,:) ::   jlfil, jlfil2
+      INTEGER , ALLOCATABLE, DIMENSION(:)   ::   jlmax, jlmin
+      REAL(wp), ALLOCATABLE, DIMENSION(:)   ::   z1_ai, z1_vi, z1_vs, ztmp, zfra
+      !
+      REAL(wp), PARAMETER ::   ztrans = 0.25_wp
+      INTEGER  ::   ji, jl, jl1, jl2
       INTEGER  ::   idim, icat  
-      REAL(wp), PARAMETER ::   ztrans = 0.25_wp
-      REAL(wp), DIMENSION(:,:), INTENT(in)    ::   zhti, zhts, zati    ! input ice/snow variables
-      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   zh_i, zh_s, za_i    ! output ice/snow variables
-      INTEGER , DIMENSION(:,:), ALLOCATABLE   ::   jlfil, jlfil2
-      INTEGER , DIMENSION(:)  , ALLOCATABLE   ::   jlmax, jlmin
-      !!-------------------------------------------------------------------
-      !
-      idim = SIZE( zhti, 1 )
-      icat = SIZE( zhti, 2 )
+      !!-------------------------------------------------------------------
+      !
+      idim = SIZE( phti, 1 )
+      icat = SIZE( phti, 2 )
+      !
+      ! == thickness and concentration == !
       !                                 ! ---------------------- !
       IF( icat == jpl ) THEN            ! input cat = output cat !
          !                              ! ---------------------- !
-         zh_i(:,:) = zhti(:,:)
-         zh_s(:,:) = zhts(:,:)
-         za_i(:,:) = zati(:,:)
+         ph_i(:,:) = phti(:,:)
+         ph_s(:,:) = phts(:,:)
+         pa_i(:,:) = pati(:,:)
+         !
+         ! == temperature and salinity and ponds == !
+         pt_i (:,:) = ptmi (:,:)
+         pt_s (:,:) = ptms (:,:)
+         pt_su(:,:) = ptmsu(:,:)
+         ps_i (:,:) = psmi (:,:)
+         pa_ip(:,:) = patip(:,:)
+         ph_ip(:,:) = phtip(:,:)
          !                              ! ---------------------- !
       ELSEIF( icat == 1 ) THEN          ! input cat = 1          !
          !                              ! ---------------------- !
-         CALL  ice_var_itd_1cMc( zhti(:,1), zhts(:,1), zati(:,1), zh_i(:,:), zh_s(:,:), za_i(:,:) )
+         CALL  ice_var_itd_1cMc( phti(:,1), phts(:,1), pati (:,1), &
+            &                    ph_i(:,:), ph_s(:,:), pa_i (:,:), &
+            &                    ptmi(:,1), ptms(:,1), ptmsu(:,1), psmi(:,1), patip(:,1), phtip(:,1), &
+            &                    pt_i(:,:), pt_s(:,:), pt_su(:,:), ps_i(:,:), pa_ip(:,:), ph_ip(:,:)  )
          !                              ! ---------------------- !
       ELSEIF( jpl == 1 ) THEN           ! output cat = 1         !
          !                              ! ---------------------- !
-         CALL  ice_var_itd_Nc1c( zhti(:,:), zhts(:,:), zati(:,:), zh_i(:,1), zh_s(:,1), za_i(:,1) )         
+         CALL  ice_var_itd_Nc1c( phti(:,:), phts(:,:), pati (:,:), &
+            &                    ph_i(:,1), ph_s(:,1), pa_i (:,1), &
+            &                    ptmi(:,:), ptms(:,:), ptmsu(:,:), psmi(:,:), patip(:,:), phtip(:,:), &
+            &                    pt_i(:,1), pt_s(:,1), pt_su(:,1), ps_i(:,1), pa_ip(:,1), ph_ip(:,1)  )
          !                              ! ----------------------- !
       ELSE                              ! input cat /= output cat !
@@ -1012,7 +1085,7 @@
 
          ! --- initialize output fields to 0 --- !
-         zh_i(1:idim,1:jpl) = 0._wp
-         zh_s(1:idim,1:jpl) = 0._wp
-         za_i(1:idim,1:jpl) = 0._wp
+         ph_i(1:idim,1:jpl) = 0._wp
+         ph_s(1:idim,1:jpl) = 0._wp
+         pa_i(1:idim,1:jpl) = 0._wp
          !
          ! --- fill the categories --- !
@@ -1024,9 +1097,9 @@
             DO jl2 = 1, icat
                DO ji = 1, idim
-                  IF( hi_max(jl1-1) <= zhti(ji,jl2) .AND. hi_max(jl1) > zhti(ji,jl2) ) THEN
+                  IF( hi_max(jl1-1) <= phti(ji,jl2) .AND. hi_max(jl1) > phti(ji,jl2) ) THEN
                      ! fill the right category
-                     zh_i(ji,jl1) = zhti(ji,jl2)
-                     zh_s(ji,jl1) = zhts(ji,jl2)
-                     za_i(ji,jl1) = zati(ji,jl2)
+                     ph_i(ji,jl1) = phti(ji,jl2)
+                     ph_s(ji,jl1) = phts(ji,jl2)
+                     pa_i(ji,jl1) = pati(ji,jl2)
                      ! record categories that are filled
                      jlmax(ji) = MAX( jlmax(ji), jl1 )
@@ -1045,15 +1118,15 @@
             IF( jl1 > 1 ) THEN
                ! fill the lower cat (jl1-1)
-               za_i(ji,jl1-1) = ztrans * za_i(ji,jl1)
-               zh_i(ji,jl1-1) = hi_mean(jl1-1)
+               pa_i(ji,jl1-1) = ztrans * pa_i(ji,jl1)
+               ph_i(ji,jl1-1) = hi_mean(jl1-1)
                ! remove from cat jl1
-               za_i(ji,jl1  ) = ( 1._wp - ztrans ) * za_i(ji,jl1)
+               pa_i(ji,jl1  ) = ( 1._wp - ztrans ) * pa_i(ji,jl1)
             ENDIF
             IF( jl2 < jpl ) THEN
                ! fill the upper cat (jl2+1)
-               za_i(ji,jl2+1) = ztrans * za_i(ji,jl2)
-               zh_i(ji,jl2+1) = hi_mean(jl2+1)
+               pa_i(ji,jl2+1) = ztrans * pa_i(ji,jl2)
+               ph_i(ji,jl2+1) = hi_mean(jl2+1)
                ! remove from cat jl2
-               za_i(ji,jl2  ) = ( 1._wp - ztrans ) * za_i(ji,jl2)
+               pa_i(ji,jl2  ) = ( 1._wp - ztrans ) * pa_i(ji,jl2)
             ENDIF
          END DO
@@ -1065,9 +1138,9 @@
                IF( jlfil(ji,jl-1) /= 0 .AND. jlfil(ji,jl) == 0 ) THEN
                   ! fill high
-                  za_i(ji,jl) = ztrans * za_i(ji,jl-1)
-                  zh_i(ji,jl) = hi_mean(jl)
+                  pa_i(ji,jl) = ztrans * pa_i(ji,jl-1)
+                  ph_i(ji,jl) = hi_mean(jl)
                   jlfil(ji,jl) = jl
                   ! remove low
-                  za_i(ji,jl-1) = ( 1._wp - ztrans ) * za_i(ji,jl-1)
+                  pa_i(ji,jl-1) = ( 1._wp - ztrans ) * pa_i(ji,jl-1)
                ENDIF
             END DO
@@ -1079,9 +1152,9 @@
                IF( jlfil2(ji,jl+1) /= 0 .AND. jlfil2(ji,jl) == 0 ) THEN
                   ! fill low
-                  za_i(ji,jl) = za_i(ji,jl) + ztrans * za_i(ji,jl+1)
-                  zh_i(ji,jl) = hi_mean(jl) 
+                  pa_i(ji,jl) = pa_i(ji,jl) + ztrans * pa_i(ji,jl+1)
+                  ph_i(ji,jl) = hi_mean(jl) 
                   jlfil2(ji,jl) = jl
                   ! remove high
-                  za_i(ji,jl+1) = ( 1._wp - ztrans ) * za_i(ji,jl+1)
+                  pa_i(ji,jl+1) = ( 1._wp - ztrans ) * pa_i(ji,jl+1)
                ENDIF
             END DO
@@ -1090,4 +1163,60 @@
          DEALLOCATE( jlfil, jlfil2 )      ! deallocate arrays
          DEALLOCATE( jlmin, jlmax )
+         !
+         ! == temperature and salinity == !
+         !
+         ALLOCATE( z1_ai(idim), z1_vi(idim), z1_vs(idim), ztmp(idim) )
+         !
+         WHERE( SUM( pa_i(:,:), dim=2 ) /= 0._wp )               ;   z1_ai(:) = 1._wp / SUM( pa_i(:,:), dim=2 )
+         ELSEWHERE                                               ;   z1_ai(:) = 0._wp
+         END WHERE
+         WHERE( SUM( pa_i(:,:) * ph_i(:,:), dim=2 ) /= 0._wp )   ;   z1_vi(:) = 1._wp / SUM( pa_i(:,:) * ph_i(:,:), dim=2 )
+         ELSEWHERE                                               ;   z1_vi(:) = 0._wp
+         END WHERE
+         WHERE( SUM( pa_i(:,:) * ph_s(:,:), dim=2 ) /= 0._wp )   ;   z1_vs(:) = 1._wp / SUM( pa_i(:,:) * ph_s(:,:), dim=2 )
+         ELSEWHERE                                               ;   z1_vs(:) = 0._wp
+         END WHERE
+         !
+         ! fill all the categories with the same value
+         ztmp(:) = SUM( ptmi (:,:) * pati(:,:) * phti(:,:), dim=2 ) * z1_vi(:)
+         DO jl = 1, jpl
+            pt_i (:,jl) = ztmp(:)
+         END DO
+         ztmp(:) = SUM( ptms (:,:) * pati(:,:) * phts(:,:), dim=2 ) * z1_vs(:)
+         DO jl = 1, jpl
+            pt_s (:,jl) = ztmp(:)
+         END DO
+         ztmp(:) = SUM( ptmsu(:,:) * pati(:,:)            , dim=2 ) * z1_ai(:)
+         DO jl = 1, jpl
+            pt_su(:,jl) = ztmp(:)
+         END DO
+         ztmp(:) = SUM( psmi (:,:) * pati(:,:) * phti(:,:), dim=2 ) * z1_vi(:)
+         DO jl = 1, jpl
+            ps_i (:,jl) = ztmp(:)
+         END DO
+         !
+         DEALLOCATE( z1_ai, z1_vi, z1_vs, ztmp )
+         !
+         ! == ponds == !
+         ALLOCATE( zfra(idim) )
+         ! keep the same pond fraction atip/ati for each category
+         WHERE( SUM( pati(:,:), dim=2 ) /= 0._wp )   ;   zfra(:) = SUM( patip(:,:), dim=2 ) / SUM( pati(:,:), dim=2 )
+         ELSEWHERE                                   ;   zfra(:) = 0._wp
+         END WHERE
+         DO jl = 1, jpl
+            pa_ip(:,jl) = zfra(:) * pa_i(:,jl)
+         END DO
+         ! keep the same v_ip/v_i ratio for each category
+         WHERE( SUM( phti(:,:) * pati(:,:), dim=2 ) /= 0._wp )
+            zfra(:) = SUM( phtip(:,:) * patip(:,:), dim=2 ) / SUM( phti(:,:) * pati(:,:), dim=2 )
+         ELSEWHERE
+            zfra(:) = 0._wp
+         END WHERE
+         DO jl = 1, jpl
+            WHERE( pa_ip(:,jl) /= 0._wp )   ;   ph_ip(:,jl) = zfra(:) * ( ph_i(:,jl) * pa_i(:,jl) ) / pa_ip(:,jl)
+            ELSEWHERE                       ;   ph_ip(:,jl) = 0._wp
+            END WHERE
+         END DO
+         DEALLOCATE( zfra )
          !
       ENDIF
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icewri.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icewri.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/ICE/icewri.F90	(revision 12143)
@@ -50,5 +50,6 @@
       INTEGER  ::   ji, jj, jk, jl  ! dummy loop indices
       REAL(wp) ::   z2da, z2db, zrho1, zrho2
-      REAL(wp), DIMENSION(jpi,jpj)     ::   z2d, zfast !  2D workspace
+      REAL(wp) ::   zmiss_val       ! missing value retrieved from xios 
+      REAL(wp), DIMENSION(jpi,jpj)     ::   z2d, zfast                     ! 2D workspace
       REAL(wp), DIMENSION(jpi,jpj)     ::   zmsk00, zmsk05, zmsk15, zmsksn ! O%, 5% and 15% concentration mask and snow mask
       REAL(wp), DIMENSION(jpi,jpj,jpl) ::   zmsk00l, zmsksnl               ! cat masks
@@ -58,6 +59,9 @@
       REAL(wp) ::   zdiag_area_sh, zdiag_extt_sh, zdiag_volu_sh 
       !!-------------------------------------------------------------------
-
+      !
       IF( ln_timing )   CALL timing_start('icewri')
+
+      ! get missing value from xml
+      CALL iom_miss_val( 'icetemp', zmiss_val )
 
       ! brine volume
@@ -85,84 +89,80 @@
       ! Standard outputs
       !-----------------
-      zrho1 = ( rau0 - rhoi ) * r1_rau0; zrho2 = rhos * r1_rau0
+      zrho1 = ( rau0 - rhoi ) * r1_rau0 ; zrho2 = rhos * r1_rau0
       ! masks
-      IF( iom_use('icemask'  ) )   CALL iom_put( "icemask"  , zmsk00              )   ! ice mask 0%
-      IF( iom_use('icemask05') )   CALL iom_put( "icemask05", zmsk05              )   ! ice mask 5%
-      IF( iom_use('icemask15') )   CALL iom_put( "icemask15", zmsk15              )   ! ice mask 15%
+      CALL iom_put( 'icemask'  , zmsk00 )   ! ice mask 0%
+      CALL iom_put( 'icemask05', zmsk05 )   ! ice mask 5%
+      CALL iom_put( 'icemask15', zmsk15 )   ! ice mask 15%
+      CALL iom_put( 'icepres'  , zmsk00 )   ! Ice presence (1 or 0) 
       !
       ! general fields
-      IF( iom_use('icemass'  ) )   CALL iom_put( "icemass", rhoi * vt_i * zmsk00  )   ! Ice mass per cell area 
-      IF( iom_use('snwmass'  ) )   CALL iom_put( "snwmass", rhos * vt_s * zmsksn  )   ! Snow mass per cell area
-      IF( iom_use('icepres'  ) )   CALL iom_put( "icepres", zmsk00                )   ! Ice presence (1 or 0) 
-      IF( iom_use('iceconc'  ) )   CALL iom_put( "iceconc", at_i  * zmsk00        )   ! ice concentration
-      IF( iom_use('icevolu'  ) )   CALL iom_put( "icevolu", vt_i  * zmsk00        )   ! ice volume = mean ice thickness over the cell
-      IF( iom_use('icethic'  ) )   CALL iom_put( "icethic", hm_i  * zmsk00        )   ! ice thickness
-      IF( iom_use('snwthic'  ) )   CALL iom_put( "snwthic", hm_s  * zmsk00        )   ! snw thickness
-      IF( iom_use('icebrv'   ) )   CALL iom_put( "icebrv" , bvm_i * zmsk00 * 100. )   ! brine volume
-      IF( iom_use('iceage'   ) )   CALL iom_put( "iceage" , om_i  * zmsk15 / rday )   ! ice age
-      IF( iom_use('icehnew'  ) )   CALL iom_put( "icehnew", ht_i_new              )   ! new ice thickness formed in the leads
-      IF( iom_use('snwvolu'  ) )   CALL iom_put( "snwvolu", vt_s  * zmsksn        )   ! snow volume
-      IF( iom_use('icefrb') ) THEN
+      IF( iom_use('icemass' ) )   CALL iom_put( 'icemass', vt_i * rhoi * zmsk00 )                                           ! Ice mass per cell area 
+      IF( iom_use('snwmass' ) )   CALL iom_put( 'snwmass', vt_s * rhos * zmsksn )                                           ! Snow mass per cell area
+      IF( iom_use('iceconc' ) )   CALL iom_put( 'iceconc', at_i        * zmsk00 )                                           ! ice concentration
+      IF( iom_use('icevolu' ) )   CALL iom_put( 'icevolu', vt_i        * zmsk00 )                                           ! ice volume = mean ice thickness over the cell
+      IF( iom_use('icethic' ) )   CALL iom_put( 'icethic', hm_i        * zmsk00 )                                           ! ice thickness
+      IF( iom_use('snwthic' ) )   CALL iom_put( 'snwthic', hm_s        * zmsk00 )                                           ! snw thickness
+      IF( iom_use('icebrv'  ) )   CALL iom_put( 'icebrv' , bvm_i* 100. * zmsk00 )                                           ! brine volume
+      IF( iom_use('iceage'  ) )   CALL iom_put( 'iceage' , om_i / rday * zmsk15 + zmiss_val * ( 1._wp - zmsk15 ) )          ! ice age
+      IF( iom_use('icehnew' ) )   CALL iom_put( 'icehnew', ht_i_new             )                                           ! new ice thickness formed in the leads
+      IF( iom_use('snwvolu' ) )   CALL iom_put( 'snwvolu', vt_s        * zmsksn )                                           ! snow volume
+      IF( iom_use('icefrb'  ) ) THEN                                                                                        ! Ice freeboard
          z2d(:,:) = ( zrho1 * hm_i(:,:) - zrho2 * hm_s(:,:) )                                         
          WHERE( z2d < 0._wp )   z2d = 0._wp
-                                   CALL iom_put( "icefrb" , z2d * zmsk00          )   ! Ice freeboard
+                                  CALL iom_put( 'icefrb' , z2d * zmsk00         )
       ENDIF
-      !
       ! melt ponds
-      IF( iom_use('iceapnd'  ) )   CALL iom_put( "iceapnd", at_ip  * zmsk00       )   ! melt pond total fraction
-      IF( iom_use('icevpnd'  ) )   CALL iom_put( "icevpnd", vt_ip  * zmsk00       )   ! melt pond total volume per unit area
-      !
+      IF( iom_use('iceapnd' ) )   CALL iom_put( 'iceapnd', at_ip  * zmsk00      )                                           ! melt pond total fraction
+      IF( iom_use('icehpnd' ) )   CALL iom_put( 'icehpnd', hm_ip  * zmsk00      )                                           ! melt pond depth
+      IF( iom_use('icevpnd' ) )   CALL iom_put( 'icevpnd', vt_ip  * zmsk00      )                                           ! melt pond total volume per unit area
       ! salt
-      IF( iom_use('icesalt'  ) )   CALL iom_put( "icesalt", sm_i  * zmsk00        )   ! mean ice salinity
-      IF( iom_use('icesalm'  ) )   CALL iom_put( "icesalm", SUM( sv_i, DIM = 3 ) * rhoi * 1.0e-3 * zmsk00 )   ! Mass of salt in sea ice per cell area
-
+      IF( iom_use('icesalt' ) )   CALL iom_put( 'icesalt', sm_i                 * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) ) ! mean ice salinity
+      IF( iom_use('icesalm' ) )   CALL iom_put( 'icesalm', st_i * rhoi * 1.0e-3 * zmsk00 )                                  ! Mass of salt in sea ice per cell area
       ! heat
-      IF( iom_use('icetemp'  ) )   CALL iom_put( "icetemp", ( tm_i  - rt0 ) * zmsk00 )   ! ice mean temperature
-      IF( iom_use('snwtemp'  ) )   CALL iom_put( "snwtemp", ( tm_s  - rt0 ) * zmsksn )   ! snw mean temperature
-      IF( iom_use('icettop'  ) )   CALL iom_put( "icettop", ( tm_su - rt0 ) * zmsk00 )   ! temperature at the ice surface
-      IF( iom_use('icetbot'  ) )   CALL iom_put( "icetbot", ( t_bo  - rt0 ) * zmsk00 )   ! temperature at the ice bottom
-      IF( iom_use('icetsni'  ) )   CALL iom_put( "icetsni", ( tm_si - rt0 ) * zmsk00 )   ! temperature at the snow-ice interface
-      IF( iom_use('icehc'    ) )   CALL iom_put( "icehc"  ,  -et_i          * zmsk00 )   ! ice heat content
-      IF( iom_use('snwhc'    ) )   CALL iom_put( "snwhc"  ,  -et_s          * zmsksn )   ! snow heat content
-
+      IF( iom_use('icetemp' ) )   CALL iom_put( 'icetemp', ( tm_i  - rt0 ) * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) )      ! ice mean temperature
+      IF( iom_use('snwtemp' ) )   CALL iom_put( 'snwtemp', ( tm_s  - rt0 ) * zmsksn + zmiss_val * ( 1._wp - zmsksn ) )      ! snw mean temperature
+      IF( iom_use('icettop' ) )   CALL iom_put( 'icettop', ( tm_su - rt0 ) * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) )      ! temperature at the ice surface
+      IF( iom_use('icetbot' ) )   CALL iom_put( 'icetbot', ( t_bo  - rt0 ) * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) )      ! temperature at the ice bottom
+      IF( iom_use('icetsni' ) )   CALL iom_put( 'icetsni', ( tm_si - rt0 ) * zmsk00 + zmiss_val * ( 1._wp - zmsk00 ) )      ! temperature at the snow-ice interface
+      IF( iom_use('icehc'   ) )   CALL iom_put( 'icehc'  ,  -et_i          * zmsk00 )                                       ! ice heat content
+      IF( iom_use('snwhc'   ) )   CALL iom_put( 'snwhc'  ,  -et_s          * zmsksn )                                       ! snow heat content
       ! momentum
-      IF( iom_use('uice'     ) )   CALL iom_put( "uice"   , u_ice                 )   ! ice velocity u component
-      IF( iom_use('vice'     ) )   CALL iom_put( "vice"   , v_ice                 )   ! ice velocity v component
-      IF( iom_use('utau_ai'  ) )   CALL iom_put( "utau_ai", utau_ice * zmsk00     )   ! Wind stress term in force balance (x)
-      IF( iom_use('vtau_ai'  ) )   CALL iom_put( "vtau_ai", vtau_ice * zmsk00     )   ! Wind stress term in force balance (y)
-
-      IF( iom_use('icevel') .OR. iom_use('fasticepres') ) THEN 
-        ! module of ice velocity
+      IF( iom_use('uice'    ) )   CALL iom_put( 'uice'   , u_ice    )                                                       ! ice velocity u
+      IF( iom_use('vice'    ) )   CALL iom_put( 'vice'   , v_ice    )                                                       ! ice velocity v
+      !
+      IF( iom_use('icevel') .OR. iom_use('fasticepres') ) THEN                                                              ! module of ice velocity
          DO jj = 2 , jpjm1
             DO ji = 2 , jpim1
-               z2da  = ( u_ice(ji,jj) + u_ice(ji-1,jj) )
-               z2db  = ( v_ice(ji,jj) + v_ice(ji,jj-1) )
+               z2da  = u_ice(ji,jj) + u_ice(ji-1,jj)
+               z2db  = v_ice(ji,jj) + v_ice(ji,jj-1)
                z2d(ji,jj) = 0.5_wp * SQRT( z2da * z2da + z2db * z2db )
            END DO
          END DO
          CALL lbc_lnk( 'icewri', z2d, 'T', 1. )
-         IF( iom_use('icevel') )   CALL iom_put( "icevel" , z2d )
-
-        ! record presence of fast ice
-         WHERE( z2d(:,:) < 5.e-04_wp .AND. zmsk15(:,:) == 1._wp ) ; zfast(:,:) = 1._wp
+         CALL iom_put( 'icevel', z2d )
+
+         WHERE( z2d(:,:) < 5.e-04_wp .AND. zmsk15(:,:) == 1._wp ) ; zfast(:,:) = 1._wp                                      ! record presence of fast ice
          ELSEWHERE                                                ; zfast(:,:) = 0._wp
          END WHERE
-         IF( iom_use('fasticepres') )   CALL iom_put( "fasticepres" , zfast )
+         CALL iom_put( 'fasticepres', zfast )
       ENDIF
 
       ! --- category-dependent fields --- !
-      IF( iom_use('icemask_cat' ) )   CALL iom_put( "icemask_cat" , zmsk00l                                                    )   ! ice mask 0%
-      IF( iom_use('iceconc_cat' ) )   CALL iom_put( "iceconc_cat" , a_i * zmsk00l                                              )   ! area for categories
-      IF( iom_use('icethic_cat' ) )   CALL iom_put( "icethic_cat" , h_i * zmsk00l                                              )   ! thickness for categories
-      IF( iom_use('snwthic_cat' ) )   CALL iom_put( "snwthic_cat" , h_s * zmsksnl                                              )   ! snow depth for categories
-      IF( iom_use('icesalt_cat' ) )   CALL iom_put( "icesalt_cat" , s_i * zmsk00l                                              )   ! salinity for categories
-      IF( iom_use('iceage_cat'  ) )   CALL iom_put( "iceage_cat"  , o_i * zmsk00l / rday                                       )   ! ice age
-      IF( iom_use('icetemp_cat' ) )   CALL iom_put( "icetemp_cat" , ( SUM( t_i(:,:,:,:), dim=3 ) * r1_nlay_i - rt0 ) * zmsk00l )   ! ice temperature
-      IF( iom_use('snwtemp_cat' ) )   CALL iom_put( "snwtemp_cat" , ( SUM( t_s(:,:,:,:), dim=3 ) * r1_nlay_s - rt0 ) * zmsksnl )   ! snow temperature
-      IF( iom_use('icettop_cat' ) )   CALL iom_put( "icettop_cat" , ( t_su - rt0 ) * zmsk00l                                   )   ! surface temperature
-      IF( iom_use('icebrv_cat'  ) )   CALL iom_put( "icebrv_cat"  ,   bv_i * 100.  * zmsk00l                                   )   ! brine volume
-      IF( iom_use('iceapnd_cat' ) )   CALL iom_put( "iceapnd_cat" ,   a_ip         * zmsk00l                                   )   ! melt pond frac for categories
-      IF( iom_use('icehpnd_cat' ) )   CALL iom_put( "icehpnd_cat" ,   h_ip         * zmsk00l                                   )   ! melt pond frac for categories
-      IF( iom_use('iceafpnd_cat') )   CALL iom_put( "iceafpnd_cat",   a_ip_frac    * zmsk00l                                   )   ! melt pond frac for categories
+      IF( iom_use('icemask_cat' ) )   CALL iom_put( 'icemask_cat' ,                  zmsk00l                                   ) ! ice mask 0%
+      IF( iom_use('iceconc_cat' ) )   CALL iom_put( 'iceconc_cat' , a_i            * zmsk00l                                   ) ! area for categories
+      IF( iom_use('icethic_cat' ) )   CALL iom_put( 'icethic_cat' , h_i            * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! thickness for categories
+      IF( iom_use('snwthic_cat' ) )   CALL iom_put( 'snwthic_cat' , h_s            * zmsksnl + zmiss_val * ( 1._wp - zmsksnl ) ) ! snow depth for categories
+      IF( iom_use('icesalt_cat' ) )   CALL iom_put( 'icesalt_cat' , s_i            * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! salinity for categories
+      IF( iom_use('iceage_cat'  ) )   CALL iom_put( 'iceage_cat'  , o_i / rday     * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! ice age
+      IF( iom_use('icetemp_cat' ) )   CALL iom_put( 'icetemp_cat' , ( SUM( t_i, dim=3 ) * r1_nlay_i - rt0 ) &
+         &                                                                         * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! ice temperature
+      IF( iom_use('snwtemp_cat' ) )   CALL iom_put( 'snwtemp_cat' , ( SUM( t_s, dim=3 ) * r1_nlay_s - rt0 ) &
+         &                                                                         * zmsksnl + zmiss_val * ( 1._wp - zmsksnl ) ) ! snow temperature
+      IF( iom_use('icettop_cat' ) )   CALL iom_put( 'icettop_cat' , ( t_su - rt0 ) * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! surface temperature
+      IF( iom_use('icebrv_cat'  ) )   CALL iom_put( 'icebrv_cat'  ,   bv_i * 100.  * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! brine volume
+      IF( iom_use('iceapnd_cat' ) )   CALL iom_put( 'iceapnd_cat' ,   a_ip         * zmsk00l                                   ) ! melt pond frac for categories
+      IF( iom_use('icehpnd_cat' ) )   CALL iom_put( 'icehpnd_cat' ,   h_ip         * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! melt pond frac for categories
+      IF( iom_use('iceafpnd_cat') )   CALL iom_put( 'iceafpnd_cat',   a_ip_frac    * zmsk00l                                   ) ! melt pond frac for categories
+      IF( iom_use('icealb_cat'  ) )   CALL iom_put( 'icealb_cat'  ,   alb_ice      * zmsk00l + zmiss_val * ( 1._wp - zmsk00l ) ) ! ice albedo for categories
 
       !------------------
@@ -170,62 +170,48 @@
       !------------------
       ! trends
-      IF( iom_use('dmithd') )   CALL iom_put( "dmithd", - wfx_bog - wfx_bom - wfx_sum - wfx_sni - wfx_opw - wfx_lam - wfx_res ) ! Sea-ice mass change from thermodynamics
-      IF( iom_use('dmidyn') )   CALL iom_put( "dmidyn", - wfx_dyn + rhoi * diag_trp_vi      )   ! Sea-ice mass change from dynamics(kg/m2/s)
-      IF( iom_use('dmiopw') )   CALL iom_put( "dmiopw", - wfx_opw                           )   ! Sea-ice mass change through growth in open water
-      IF( iom_use('dmibog') )   CALL iom_put( "dmibog", - wfx_bog                           )   ! Sea-ice mass change through basal growth
-      IF( iom_use('dmisni') )   CALL iom_put( "dmisni", - wfx_sni                           )   ! Sea-ice mass change through snow-to-ice conversion
-      IF( iom_use('dmisum') )   CALL iom_put( "dmisum", - wfx_sum                           )   ! Sea-ice mass change through surface melting
-      IF( iom_use('dmibom') )   CALL iom_put( "dmibom", - wfx_bom                           )   ! Sea-ice mass change through bottom melting
-      IF( iom_use('dmtsub') )   CALL iom_put( "dmtsub", - wfx_sub                           )   ! Sea-ice mass change through evaporation and sublimation
-      IF( iom_use('dmssub') )   CALL iom_put( "dmssub", - wfx_snw_sub                       )   ! Snow mass change through sublimation
-      IF( iom_use('dmisub') )   CALL iom_put( "dmisub", - wfx_ice_sub                       )   ! Sea-ice mass change through sublimation
-      IF( iom_use('dmsspr') )   CALL iom_put( "dmsspr", - wfx_spr                           )   ! Snow mass change through snow fall
-      IF( iom_use('dmsssi') )   CALL iom_put( "dmsssi",   wfx_sni*rhos*r1_rhoi              )   ! Snow mass change through snow-to-ice conversion
-      IF( iom_use('dmsmel') )   CALL iom_put( "dmsmel", - wfx_snw_sum                       )   ! Snow mass change through melt
-      IF( iom_use('dmsdyn') )   CALL iom_put( "dmsdyn", - wfx_snw_dyn + rhos * diag_trp_vs  )   ! Snow mass change through dynamics(kg/m2/s)
-
+      IF( iom_use('dmithd') )   CALL iom_put( 'dmithd', - wfx_bog - wfx_bom - wfx_sum - wfx_sni - wfx_opw - wfx_lam - wfx_res ) ! Sea-ice mass change from thermodynamics
+      IF( iom_use('dmidyn') )   CALL iom_put( 'dmidyn', - wfx_dyn + rhoi * diag_trp_vi                                        ) ! Sea-ice mass change from dynamics(kg/m2/s)
+      IF( iom_use('dmiopw') )   CALL iom_put( 'dmiopw', - wfx_opw                                                             ) ! Sea-ice mass change through growth in open water
+      IF( iom_use('dmibog') )   CALL iom_put( 'dmibog', - wfx_bog                                                             ) ! Sea-ice mass change through basal growth
+      IF( iom_use('dmisni') )   CALL iom_put( 'dmisni', - wfx_sni                                                             ) ! Sea-ice mass change through snow-to-ice conversion
+      IF( iom_use('dmisum') )   CALL iom_put( 'dmisum', - wfx_sum                                                             ) ! Sea-ice mass change through surface melting
+      IF( iom_use('dmibom') )   CALL iom_put( 'dmibom', - wfx_bom                                                             ) ! Sea-ice mass change through bottom melting
+      IF( iom_use('dmtsub') )   CALL iom_put( 'dmtsub', - wfx_sub                                                             ) ! Sea-ice mass change through evaporation and sublimation
+      IF( iom_use('dmssub') )   CALL iom_put( 'dmssub', - wfx_snw_sub                                                         ) ! Snow mass change through sublimation
+      IF( iom_use('dmisub') )   CALL iom_put( 'dmisub', - wfx_ice_sub                                                         ) ! Sea-ice mass change through sublimation
+      IF( iom_use('dmsspr') )   CALL iom_put( 'dmsspr', - wfx_spr                                                             ) ! Snow mass change through snow fall
+      IF( iom_use('dmsssi') )   CALL iom_put( 'dmsssi',   wfx_sni*rhos*r1_rhoi                                                ) ! Snow mass change through snow-to-ice conversion
+      IF( iom_use('dmsmel') )   CALL iom_put( 'dmsmel', - wfx_snw_sum                                                         ) ! Snow mass change through melt
+      IF( iom_use('dmsdyn') )   CALL iom_put( 'dmsdyn', - wfx_snw_dyn + rhos * diag_trp_vs                                    ) ! Snow mass change through dynamics(kg/m2/s)
+      
       ! Global ice diagnostics
-      IF( iom_use('NH_icearea') .OR. iom_use('NH_icevolu') .OR. iom_use('NH_iceextt') )   THEN   ! NH diagnostics
-         !
-         WHERE( ff_t > 0._wp )   ;   zmsk00(:,:) = 1.0e-12
-         ELSEWHERE               ;   zmsk00(:,:) = 0.
-         END WHERE 
-         zdiag_area_nh = glob_sum( 'icewri', at_i(:,:) * zmsk00(:,:) * e1e2t(:,:) )
-         zdiag_volu_nh = glob_sum( 'icewri', vt_i(:,:) * zmsk00(:,:) * e1e2t(:,:) )
-         !
-         WHERE( ff_t > 0._wp .AND. at_i > 0.15 )   ; zmsk00(:,:) = 1.0e-12
-         ELSEWHERE                                 ; zmsk00(:,:) = 0.
-         END WHERE 
-         zdiag_extt_nh = glob_sum( 'icewri', zmsk00(:,:) * e1e2t(:,:) )
-         !
-         IF( iom_use('NH_icearea') )   CALL iom_put( "NH_icearea" ,  zdiag_area_nh )
-         IF( iom_use('NH_icevolu') )   CALL iom_put( "NH_icevolu" ,  zdiag_volu_nh )
-         IF( iom_use('NH_iceextt') )   CALL iom_put( "NH_iceextt" ,  zdiag_extt_nh )
+      IF(  iom_use('NH_icearea') .OR. iom_use('NH_icevolu') .OR. iom_use('NH_iceextt') .OR. &
+         & iom_use('SH_icearea') .OR. iom_use('SH_icevolu') .OR. iom_use('SH_iceextt') ) THEN
+         !
+         WHERE( ff_t(:,:) > 0._wp )   ;   z2d(:,:) = 1._wp
+         ELSEWHERE                    ;   z2d(:,:) = 0.
+         END WHERE
+         !
+         IF( iom_use('NH_icearea') )   zdiag_area_nh = glob_sum( 'icewri', at_i *           z2d   * e1e2t * 1.e-12 )
+         IF( iom_use('NH_icevolu') )   zdiag_volu_nh = glob_sum( 'icewri', vt_i *           z2d   * e1e2t * 1.e-12 )
+         IF( iom_use('NH_iceextt') )   zdiag_extt_nh = glob_sum( 'icewri',                  z2d   * e1e2t * 1.e-12 * zmsk15 )
+         !
+         IF( iom_use('SH_icearea') )   zdiag_area_sh = glob_sum( 'icewri', at_i * ( 1._wp - z2d ) * e1e2t * 1.e-12 )
+         IF( iom_use('SH_icevolu') )   zdiag_volu_sh = glob_sum( 'icewri', vt_i * ( 1._wp - z2d ) * e1e2t * 1.e-12 )
+         IF( iom_use('SH_iceextt') )   zdiag_extt_sh = glob_sum( 'icewri',        ( 1._wp - z2d ) * e1e2t * 1.e-12 * zmsk15 )
+         !
+         CALL iom_put( 'NH_icearea' , zdiag_area_nh )
+         CALL iom_put( 'NH_icevolu' , zdiag_volu_nh )
+         CALL iom_put( 'NH_iceextt' , zdiag_extt_nh )
+         CALL iom_put( 'SH_icearea' , zdiag_area_sh )
+         CALL iom_put( 'SH_icevolu' , zdiag_volu_sh )
+         CALL iom_put( 'SH_iceextt' , zdiag_extt_sh )
          !
       ENDIF
-      !
-      IF( iom_use('SH_icearea') .OR. iom_use('SH_icevolu') .OR. iom_use('SH_iceextt') )   THEN   ! SH diagnostics
-         !
-         WHERE( ff_t < 0._wp ); zmsk00(:,:) = 1.0e-12; 
-         ELSEWHERE            ; zmsk00(:,:) = 0.
-         END WHERE 
-         zdiag_area_sh = glob_sum( 'icewri', at_i(:,:) * zmsk00(:,:) * e1e2t(:,:) ) 
-         zdiag_volu_sh = glob_sum( 'icewri', vt_i(:,:) * zmsk00(:,:) * e1e2t(:,:) )
-         !
-         WHERE( ff_t < 0._wp .AND. at_i > 0.15 ); zmsk00(:,:) = 1.0e-12
-         ELSEWHERE                              ; zmsk00(:,:) = 0.
-         END WHERE 
-         zdiag_extt_sh = glob_sum( 'icewri', zmsk00(:,:) * e1e2t(:,:) )
-         !
-         IF( iom_use('SH_icearea') ) CALL iom_put( "SH_icearea", zdiag_area_sh )
-         IF( iom_use('SH_icevolu') ) CALL iom_put( "SH_icevolu", zdiag_volu_sh )
-         IF( iom_use('SH_iceextt') ) CALL iom_put( "SH_iceextt", zdiag_extt_sh )
-         !
-      ENDIF 
       !
 !!CR      !     !  Create an output files (output.lim.abort.nc) if S < 0 or u > 20 m/s
 !!CR      !     IF( kindic < 0 )   CALL ice_wri_state( 'output.abort' )
 !!CR      !     not yet implemented
-!!gm  idem for the ocean...  Ask Seb how to get read of ioipsl....
+!!gm  idem for the ocean...  Ask Seb how to get rid of ioipsl....
       !
       IF( ln_timing )  CALL timing_stop('icewri')
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/NST/agrif_user.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/NST/agrif_user.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/NST/agrif_user.F90	(revision 12143)
@@ -714,8 +714,8 @@
    REWIND( numnam_ref )              ! Namelist namagrif in reference namelist : AGRIF zoom
    READ  ( numnam_ref, namagrif, IOSTAT = ios, ERR = 901)
-901 IF( ios /= 0 )   CALL ctl_nam ( ios , 'namagrif in reference namelist', lwp )
+901 IF( ios /= 0 )   CALL ctl_nam ( ios , 'namagrif in reference namelist' )
    REWIND( numnam_cfg )              ! Namelist namagrif in configuration namelist : AGRIF zoom
    READ  ( numnam_cfg, namagrif, IOSTAT = ios, ERR = 902 )
-902 IF( ios >  0 )   CALL ctl_nam ( ios , 'namagrif in configuration namelist', lwp )
+902 IF( ios >  0 )   CALL ctl_nam ( ios , 'namagrif in configuration namelist' )
    IF(lwm) WRITE ( numond, namagrif )
    !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ASM/asminc.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ASM/asminc.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ASM/asminc.F90	(revision 12143)
@@ -147,8 +147,8 @@
       REWIND( numnam_ref )              ! Namelist nam_asminc in reference namelist : Assimilation increment
       READ  ( numnam_ref, nam_asminc, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_asminc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_asminc in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist nam_asminc in configuration namelist : Assimilation increment
       READ  ( numnam_cfg, nam_asminc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_asminc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_asminc in configuration namelist' )
       IF(lwm) WRITE ( numond, nam_asminc )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdy_oce.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdy_oce.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdy_oce.F90	(revision 12143)
@@ -22,8 +22,10 @@
       INTEGER ,          DIMENSION(jpbgrd) ::  nblen
       INTEGER ,          DIMENSION(jpbgrd) ::  nblenrim
+      INTEGER ,          DIMENSION(jpbgrd) ::  nblenrim0
       INTEGER , POINTER, DIMENSION(:,:)    ::  nbi
       INTEGER , POINTER, DIMENSION(:,:)    ::  nbj
       INTEGER , POINTER, DIMENSION(:,:)    ::  nbr
       INTEGER , POINTER, DIMENSION(:,:)    ::  nbmap
+      INTEGER , POINTER, DIMENSION(:,:)    ::  ntreat
       REAL(wp), POINTER, DIMENSION(:,:)    ::  nbw
       REAL(wp), POINTER, DIMENSION(:,:)    ::  nbd
@@ -40,12 +42,9 @@
    TYPE, PUBLIC ::   OBC_DATA     !: Storage for external data
       INTEGER          , DIMENSION(2)   ::  nread
-      LOGICAL                           ::  ll_ssh
-      LOGICAL                           ::  ll_u2d
-      LOGICAL                           ::  ll_v2d
-      LOGICAL                           ::  ll_u3d
-      LOGICAL                           ::  ll_v3d
-      LOGICAL                           ::  ll_tem
-      LOGICAL                           ::  ll_sal
-      LOGICAL                           ::  ll_fvl
+      LOGICAL                           ::  lneed_ssh
+      LOGICAL                           ::  lneed_dyn2d
+      LOGICAL                           ::  lneed_dyn3d
+      LOGICAL                           ::  lneed_tra
+      LOGICAL                           ::  lneed_ice
       REAL(wp), POINTER, DIMENSION(:)   ::  ssh
       REAL(wp), POINTER, DIMENSION(:)   ::  u2d
@@ -55,12 +54,13 @@
       REAL(wp), POINTER, DIMENSION(:,:) ::  tem
       REAL(wp), POINTER, DIMENSION(:,:) ::  sal
-#if defined key_si3
-      LOGICAL                           ::   ll_a_i
-      LOGICAL                           ::   ll_h_i
-      LOGICAL                           ::   ll_h_s
-      REAL(wp), POINTER, DIMENSION(:,:) ::   a_i    !: now ice leads fraction climatology
-      REAL(wp), POINTER, DIMENSION(:,:) ::   h_i    !: Now ice  thickness climatology
-      REAL(wp), POINTER, DIMENSION(:,:) ::   h_s    !: now snow thickness
-#endif
+      REAL(wp), POINTER, DIMENSION(:,:) ::  a_i    !: now ice leads fraction climatology
+      REAL(wp), POINTER, DIMENSION(:,:) ::  h_i    !: Now ice  thickness climatology
+      REAL(wp), POINTER, DIMENSION(:,:) ::  h_s    !: now snow thickness
+      REAL(wp), POINTER, DIMENSION(:,:) ::  t_i    !: now ice  temperature
+      REAL(wp), POINTER, DIMENSION(:,:) ::  t_s    !: now snow temperature
+      REAL(wp), POINTER, DIMENSION(:,:) ::  tsu    !: now surf temperature
+      REAL(wp), POINTER, DIMENSION(:,:) ::  s_i    !: now ice  salinity
+      REAL(wp), POINTER, DIMENSION(:,:) ::  aip    !: now ice  pond concentration
+      REAL(wp), POINTER, DIMENSION(:,:) ::  hip    !: now ice  pond depth
 #if defined key_top
       CHARACTER(LEN=20)                   :: cn_obc  !: type of boundary condition to apply
@@ -74,4 +74,5 @@
    !! Namelist variables
    !!----------------------------------------------------------------------
+   !                                                   !!** nambdy **
    LOGICAL, PUBLIC            ::   ln_bdy                   !: Unstructured Ocean Boundary Condition
 
@@ -85,5 +86,4 @@
    !
    INTEGER                    ::   nb_bdy                   !: number of open boundary sets
-   INTEGER, DIMENSION(jp_bdy) ::   nb_jpk_bdy               !: number of levels in the bdy data (set < 0 if consistent with planned run)
    INTEGER, DIMENSION(jp_bdy) ::   nn_rimwidth              !: boundary rim width for Flow Relaxation Scheme
    INTEGER                    ::   nn_volctl                !: = 0 the total volume will have the variability of the surface Flux E-P 
@@ -108,9 +108,12 @@
    INTEGER , DIMENSION(jp_bdy)          ::   nn_ice_dta     !: = 0 use the initial state as bdy dta ; 
                                                             !: = 1 read it in a NetCDF file
-   REAL(wp), DIMENSION(jp_bdy) ::   rn_ice_tem              !: choice of the temperature of incoming sea ice
-   REAL(wp), DIMENSION(jp_bdy) ::   rn_ice_sal              !: choice of the salinity    of incoming sea ice
-   REAL(wp), DIMENSION(jp_bdy) ::   rn_ice_age              !: choice of the age         of incoming sea ice
+   ! 
+   !                                                   !!** nambdy_dta **
+   REAL(wp), DIMENSION(jp_bdy) ::   rice_tem                !: temperature of incoming sea ice
+   REAL(wp), DIMENSION(jp_bdy) ::   rice_sal                !: salinity    of incoming sea ice
+   REAL(wp), DIMENSION(jp_bdy) ::   rice_age                !: age         of incoming sea ice
+   REAL(wp), DIMENSION(jp_bdy) ::   rice_apnd               !: pond conc.  of incoming sea ice
+   REAL(wp), DIMENSION(jp_bdy) ::   rice_hpnd               !: pond thick. of incoming sea ice
    !
-   
    !!----------------------------------------------------------------------
    !! Global variables
@@ -128,14 +131,14 @@
    INTEGER,  DIMENSION(jp_bdy)                     ::   nn_dta            !: =0 => *all* data is set to initial conditions
                                                                           !: =1 => some data to be read in from data files
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:), TARGET ::   dta_global        !: workspace for reading in global data arrays (unstr.  bdy)
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:), TARGET ::   dta_global_z      !: workspace for reading in global depth arrays (unstr.  bdy)
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:), TARGET ::   dta_global_dz     !: workspace for reading in global depth arrays (unstr.  bdy)
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:), TARGET ::   dta_global2       !: workspace for reading in global data arrays (struct. bdy)
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:), TARGET ::   dta_global2_z     !: workspace for reading in global depth arrays (struct. bdy)
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:), TARGET ::   dta_global2_dz    !: workspace for reading in global depth arrays (struct. bdy)
 !$AGRIF_DO_NOT_TREAT
    TYPE(OBC_INDEX), DIMENSION(jp_bdy), TARGET      ::   idx_bdy           !: bdy indices (local process)
    TYPE(OBC_DATA) , DIMENSION(jp_bdy), TARGET      ::   dta_bdy           !: bdy external data (local process)
 !$AGRIF_END_DO_NOT_TREAT
+   LOGICAL, ALLOCATABLE, DIMENSION(:,:,:,:) ::   lsend_bdy      !: mark needed communication for given boundary, grid and neighbour
+   LOGICAL, ALLOCATABLE, DIMENSION(:,:,:,:) ::   lrecv_bdy      !:  when searching in any direction
+   LOGICAL, ALLOCATABLE, DIMENSION(:,:,:,:) ::   lsend_bdyint   !: mark needed communication for given boundary, grid and neighbour
+   LOGICAL, ALLOCATABLE, DIMENSION(:,:,:,:) ::   lrecv_bdyint   !:  when searching towards the interior of the computational domain
+   LOGICAL, ALLOCATABLE, DIMENSION(:,:,:,:) ::   lsend_bdyext   !: mark needed communication for given boundary, grid and neighbour
+   LOGICAL, ALLOCATABLE, DIMENSION(:,:,:,:) ::   lrecv_bdyext   !:  when searching towards the exterior of the computational domain
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdydta.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdydta.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdydta.F90	(revision 12143)
@@ -43,18 +43,28 @@
    PUBLIC   bdy_dta_init     ! routine called by nemogcm.F90
 
-   INTEGER, ALLOCATABLE, DIMENSION(:)   ::   nb_bdy_fld        ! Number of fields to update for each boundary set.
-   INTEGER                              ::   nb_bdy_fld_sum    ! Total number of fields to update for all boundary sets.
-   LOGICAL,           DIMENSION(jp_bdy) ::   ln_full_vel_array ! =T => full velocities in 3D boundary conditions
-                                                               ! =F => baroclinic velocities in 3D boundary conditions
+   INTEGER , PARAMETER ::   jpbdyfld  = 16    ! maximum number of files to read 
+   INTEGER , PARAMETER ::   jp_bdyssh = 1     ! 
+   INTEGER , PARAMETER ::   jp_bdyu2d = 2     ! 
+   INTEGER , PARAMETER ::   jp_bdyv2d = 3     !
+   INTEGER , PARAMETER ::   jp_bdyu3d = 4     !
+   INTEGER , PARAMETER ::   jp_bdyv3d = 5     !
+   INTEGER , PARAMETER ::   jp_bdytem = 6     ! 
+   INTEGER , PARAMETER ::   jp_bdysal = 7     ! 
+   INTEGER , PARAMETER ::   jp_bdya_i = 8     ! 
+   INTEGER , PARAMETER ::   jp_bdyh_i = 9     ! 
+   INTEGER , PARAMETER ::   jp_bdyh_s = 10    ! 
+   INTEGER , PARAMETER ::   jp_bdyt_i = 11    ! 
+   INTEGER , PARAMETER ::   jp_bdyt_s = 12    ! 
+   INTEGER , PARAMETER ::   jp_bdytsu = 13    ! 
+   INTEGER , PARAMETER ::   jp_bdys_i = 14    ! 
+   INTEGER , PARAMETER ::   jp_bdyaip = 15    ! 
+   INTEGER , PARAMETER ::   jp_bdyhip = 16    ! 
+#if ! defined key_si3
+   INTEGER , PARAMETER ::   jpl = 1
+#endif
+
 !$AGRIF_DO_NOT_TREAT
-   TYPE(FLD), PUBLIC, ALLOCATABLE, DIMENSION(:), TARGET ::   bf        ! structure of input fields (file informations, fields read)
+   TYPE(FLD), PUBLIC, ALLOCATABLE, DIMENSION(:,:), TARGET ::   bf   ! structure of input fields (file informations, fields read)
 !$AGRIF_END_DO_NOT_TREAT
-   TYPE(MAP_POINTER), ALLOCATABLE, DIMENSION(:) :: nbmap_ptr   ! array of pointers to nbmap
-
-#if defined key_si3
-   INTEGER ::   nice_cat                      ! number of categories in the input file
-   INTEGER ::   jfld_hti, jfld_hts, jfld_ai   ! indices of ice thickness, snow thickness and concentration in bf structure
-   INTEGER, DIMENSION(jp_bdy) :: jfld_htit, jfld_htst, jfld_ait
-#endif
 
    !!----------------------------------------------------------------------
@@ -65,5 +75,5 @@
 CONTAINS
 
-      SUBROUTINE bdy_dta( kt, jit, time_offset )
+   SUBROUTINE bdy_dta( kt, kit, kt_offset )
       !!----------------------------------------------------------------------
       !!                   ***  SUBROUTINE bdy_dta  ***
@@ -75,17 +85,18 @@
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in)           ::   kt           ! ocean time-step index 
-      INTEGER, INTENT(in), OPTIONAL ::   jit          ! subcycle time-step index (for timesplitting option)
-      INTEGER, INTENT(in), OPTIONAL ::   time_offset  ! time offset in units of timesteps. NB. if jit
+      INTEGER, INTENT(in), OPTIONAL ::   kit          ! subcycle time-step index (for timesplitting option)
+      INTEGER, INTENT(in), OPTIONAL ::   kt_offset    ! time offset in units of timesteps. NB. if kit
       !                                               ! is present then units = subcycle timesteps.
-      !                                               ! time_offset = 0 => get data at "now" time level
-      !                                               ! time_offset = -1 => get data at "before" time level
-      !                                               ! time_offset = +1 => get data at "after" time level
+      !                                               ! kt_offset = 0 => get data at "now" time level
+      !                                               ! kt_offset = -1 => get data at "before" time level
+      !                                               ! kt_offset = +1 => get data at "after" time level
       !                                               ! etc.
       !
-      INTEGER ::  jbdy, jfld, jstart, jend, ib, jl  ! dummy loop indices
-      INTEGER ::  ii, ij, ik, igrd                  ! local integers
-      INTEGER,          DIMENSION(jpbgrd) ::   ilen1 
-      INTEGER, POINTER, DIMENSION(:)      ::   nblen, nblenrim  ! short cuts
-      TYPE(OBC_DATA), POINTER             ::   dta              ! short cut
+      INTEGER ::  jbdy, jfld, jstart, jend, ib, jl    ! dummy loop indices
+      INTEGER ::  ii, ij, ik, igrd, ipl               ! local integers
+      INTEGER,   DIMENSION(jpbgrd)     ::   ilen1 
+      INTEGER,   DIMENSION(:), POINTER ::   nblen, nblenrim  ! short cuts
+      TYPE(OBC_DATA)         , POINTER ::   dta_alias        ! short cut
+      TYPE(FLD), DIMENSION(:), POINTER ::   bf_alias
       !!---------------------------------------------------------------------------
       !
@@ -94,18 +105,17 @@
       ! Initialise data arrays once for all from initial conditions where required
       !---------------------------------------------------------------------------
-      IF( kt == nit000 .AND. .NOT.PRESENT(jit) ) THEN
+      IF( kt == nit000 .AND. .NOT.PRESENT(kit) ) THEN
 
          ! Calculate depth-mean currents
          !-----------------------------
-         
+
          DO jbdy = 1, nb_bdy
             !
             nblen    => idx_bdy(jbdy)%nblen
             nblenrim => idx_bdy(jbdy)%nblenrim
-            dta      => dta_bdy(jbdy)
             !
             IF( nn_dyn2d_dta(jbdy) == 0 ) THEN 
                ilen1(:) = nblen(:)
-               IF( dta%ll_ssh ) THEN 
+               IF( dta_bdy(jbdy)%lneed_ssh ) THEN 
                   igrd = 1
                   DO ib = 1, ilen1(igrd)
@@ -113,7 +123,7 @@
                      ij = idx_bdy(jbdy)%nbj(ib,igrd)
                      dta_bdy(jbdy)%ssh(ib) = sshn(ii,ij) * tmask(ii,ij,1)         
-                  END DO 
-               ENDIF
-               IF( dta%ll_u2d ) THEN 
+                  END DO
+               ENDIF
+               IF( dta_bdy(jbdy)%lneed_dyn2d) THEN 
                   igrd = 2
                   DO ib = 1, ilen1(igrd)
@@ -121,7 +131,5 @@
                      ij = idx_bdy(jbdy)%nbj(ib,igrd)
                      dta_bdy(jbdy)%u2d(ib) = un_b(ii,ij) * umask(ii,ij,1)         
-                  END DO 
-               ENDIF
-               IF( dta%ll_v2d ) THEN 
+                  END DO
                   igrd = 3
                   DO ib = 1, ilen1(igrd)
@@ -129,5 +137,5 @@
                      ij = idx_bdy(jbdy)%nbj(ib,igrd)
                      dta_bdy(jbdy)%v2d(ib) = vn_b(ii,ij) * vmask(ii,ij,1)         
-                  END DO 
+                  END DO
                ENDIF
             ENDIF
@@ -135,5 +143,5 @@
             IF( nn_dyn3d_dta(jbdy) == 0 ) THEN 
                ilen1(:) = nblen(:)
-               IF( dta%ll_u3d ) THEN 
+               IF( dta_bdy(jbdy)%lneed_dyn3d ) THEN 
                   igrd = 2 
                   DO ib = 1, ilen1(igrd)
@@ -143,7 +151,5 @@
                         dta_bdy(jbdy)%u3d(ib,ik) =  ( un(ii,ij,ik) - un_b(ii,ij) ) * umask(ii,ij,ik)         
                      END DO
-                  END DO 
-               ENDIF
-               IF( dta%ll_v3d ) THEN 
+                  END DO
                   igrd = 3 
                   DO ib = 1, ilen1(igrd)
@@ -152,6 +158,6 @@
                         ij = idx_bdy(jbdy)%nbj(ib,igrd)
                         dta_bdy(jbdy)%v3d(ib,ik) =  ( vn(ii,ij,ik) - vn_b(ii,ij) ) * vmask(ii,ij,ik)         
-                        END DO
-                  END DO 
+                     END DO
+                  END DO
                ENDIF
             ENDIF
@@ -159,5 +165,5 @@
             IF( nn_tra_dta(jbdy) == 0 ) THEN 
                ilen1(:) = nblen(:)
-               IF( dta%ll_tem ) THEN
+               IF( dta_bdy(jbdy)%lneed_tra ) THEN
                   igrd = 1 
                   DO ib = 1, ilen1(igrd)
@@ -166,16 +172,7 @@
                         ij = idx_bdy(jbdy)%nbj(ib,igrd)
                         dta_bdy(jbdy)%tem(ib,ik) = tsn(ii,ij,ik,jp_tem) * tmask(ii,ij,ik)         
-                     END DO
-                  END DO 
-               ENDIF
-               IF( dta%ll_sal ) THEN
-                  igrd = 1 
-                  DO ib = 1, ilen1(igrd)
-                     DO ik = 1, jpkm1
-                        ii = idx_bdy(jbdy)%nbi(ib,igrd)
-                        ij = idx_bdy(jbdy)%nbj(ib,igrd)
                         dta_bdy(jbdy)%sal(ib,ik) = tsn(ii,ij,ik,jp_sal) * tmask(ii,ij,ik)         
                      END DO
-                  END DO 
+                  END DO
                ENDIF
             ENDIF
@@ -184,5 +181,5 @@
             IF( nn_ice_dta(jbdy) == 0 ) THEN    ! set ice to initial values
                ilen1(:) = nblen(:)
-               IF( dta%ll_a_i ) THEN
+               IF( dta_bdy(jbdy)%lneed_ice ) THEN
                   igrd = 1   
                   DO jl = 1, jpl
@@ -190,25 +187,14 @@
                         ii = idx_bdy(jbdy)%nbi(ib,igrd)
                         ij = idx_bdy(jbdy)%nbj(ib,igrd)
-                        dta_bdy(jbdy)%a_i (ib,jl) =  a_i(ii,ij,jl) * tmask(ii,ij,1) 
-                     END DO
-                  END DO
-               ENDIF
-               IF( dta%ll_h_i ) THEN
-                  igrd = 1   
-                  DO jl = 1, jpl
-                     DO ib = 1, ilen1(igrd)
-                        ii = idx_bdy(jbdy)%nbi(ib,igrd)
-                        ij = idx_bdy(jbdy)%nbj(ib,igrd)
-                        dta_bdy(jbdy)%h_i (ib,jl) =  h_i(ii,ij,jl) * tmask(ii,ij,1) 
-                     END DO
-                  END DO
-               ENDIF
-               IF( dta%ll_h_s ) THEN
-                  igrd = 1   
-                  DO jl = 1, jpl
-                     DO ib = 1, ilen1(igrd)
-                        ii = idx_bdy(jbdy)%nbi(ib,igrd)
-                        ij = idx_bdy(jbdy)%nbj(ib,igrd)
-                        dta_bdy(jbdy)%h_s (ib,jl) =  h_s(ii,ij,jl) * tmask(ii,ij,1) 
+                        dta_bdy(jbdy)%a_i(ib,jl) =  a_i (ii,ij,jl) * tmask(ii,ij,1) 
+                        dta_bdy(jbdy)%h_i(ib,jl) =  h_i (ii,ij,jl) * tmask(ii,ij,1) 
+                        dta_bdy(jbdy)%h_s(ib,jl) =  h_s (ii,ij,jl) * tmask(ii,ij,1) 
+                        dta_bdy(jbdy)%t_i(ib,jl) =  SUM(t_i (ii,ij,:,jl)) * r1_nlay_i * tmask(ii,ij,1) 
+                        dta_bdy(jbdy)%t_s(ib,jl) =  SUM(t_s (ii,ij,:,jl)) * r1_nlay_s * tmask(ii,ij,1)
+                        dta_bdy(jbdy)%tsu(ib,jl) =  t_su(ii,ij,jl) * tmask(ii,ij,1) 
+                        dta_bdy(jbdy)%s_i(ib,jl) =  s_i (ii,ij,jl) * tmask(ii,ij,1)
+                        ! melt ponds
+                        dta_bdy(jbdy)%aip(ib,jl) =  a_ip(ii,ij,jl) * tmask(ii,ij,1) 
+                        dta_bdy(jbdy)%hip(ib,jl) =  h_ip(ii,ij,jl) * tmask(ii,ij,1) 
                      END DO
                   END DO
@@ -222,183 +208,154 @@
       ! update external data from files
       !--------------------------------
-     
-      jstart = 1
-      DO jbdy = 1, nb_bdy   
-         dta => dta_bdy(jbdy)
-         IF( nn_dta(jbdy) == 1 ) THEN ! skip this bit if no external data required
-      
-            IF( PRESENT(jit) ) THEN
-               ! Update barotropic boundary conditions only
-               ! jit is optional argument for fld_read and bdytide_update
-               IF( cn_dyn2d(jbdy) /= 'none' ) THEN
-                  IF( nn_dyn2d_dta(jbdy) == 2 ) THEN ! tidal harmonic forcing ONLY: initialise arrays
-                     IF( dta%ll_ssh ) dta%ssh(:) = 0._wp
-                     IF( dta%ll_u2d ) dta%u2d(:) = 0._wp
-                     IF( dta%ll_u3d ) dta%v2d(:) = 0._wp
-                  ENDIF
-                  IF (cn_tra(jbdy) /= 'runoff') THEN
-                     IF( nn_dyn2d_dta(jbdy) == 1 .OR. nn_dyn2d_dta(jbdy) == 3 ) THEN
-
-                        jend = jstart + dta%nread(2) - 1
-                        IF( ln_full_vel_array(jbdy) ) THEN
-                           CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), map=nbmap_ptr(jstart:jend),  &
-                                     & kit=jit, kt_offset=time_offset , jpk_bdy=nb_jpk_bdy(jbdy),   &
-                                     & fvl=ln_full_vel_array(jbdy)  )
-                        ELSE
-                           CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), map=nbmap_ptr(jstart:jend),  &
-                                     & kit=jit, kt_offset=time_offset  )
-                        ENDIF
-
-                        ! If full velocities in boundary data then extract barotropic velocities from 3D fields
-                        IF( ln_full_vel_array(jbdy) .AND.                                             &
-                          &    ( nn_dyn2d_dta(jbdy) == 1 .OR. nn_dyn2d_dta(jbdy) == 3 .OR.  &
-                          &      nn_dyn3d_dta(jbdy) == 1 ) )THEN
-
-                           igrd = 2                      ! zonal velocity
-                           dta%u2d(:) = 0._wp
-                           DO ib = 1, idx_bdy(jbdy)%nblen(igrd)
-                              ii   = idx_bdy(jbdy)%nbi(ib,igrd)
-                              ij   = idx_bdy(jbdy)%nbj(ib,igrd)
-                              DO ik = 1, jpkm1
-                                 dta%u2d(ib) = dta%u2d(ib) &
-                       &                          + e3u_n(ii,ij,ik) * umask(ii,ij,ik) * dta%u3d(ib,ik)
-                              END DO
-                              dta%u2d(ib) =  dta%u2d(ib) * r1_hu_n(ii,ij)
-                           END DO
-                           igrd = 3                      ! meridional velocity
-                           dta%v2d(:) = 0._wp
-                           DO ib = 1, idx_bdy(jbdy)%nblen(igrd)
-                              ii   = idx_bdy(jbdy)%nbi(ib,igrd)
-                              ij   = idx_bdy(jbdy)%nbj(ib,igrd)
-                              DO ik = 1, jpkm1
-                                 dta%v2d(ib) = dta%v2d(ib) &
-                       &                       + e3v_n(ii,ij,ik) * vmask(ii,ij,ik) * dta%v3d(ib,ik)
-                              END DO
-                              dta%v2d(ib) =  dta%v2d(ib) * r1_hv_n(ii,ij)
-                           END DO
-                        ENDIF                    
-                     ENDIF
-                     IF( nn_dyn2d_dta(jbdy) .ge. 2 ) THEN ! update tidal harmonic forcing
-                        CALL bdytide_update( kt=kt, idx=idx_bdy(jbdy), dta=dta, td=tides(jbdy),   & 
-                          &                 jit=jit, time_offset=time_offset )
-                     ENDIF
-                  ENDIF
-               ENDIF
-            ELSE
-               IF (cn_tra(jbdy) == 'runoff') then      ! runoff condition
-                  jend = nb_bdy_fld(jbdy)
-                  CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend),  &
-                               & map=nbmap_ptr(jstart:jend), kt_offset=time_offset )
-                  !
-                  igrd = 2                      ! zonal velocity
-                  DO ib = 1, idx_bdy(jbdy)%nblen(igrd)
-                     ii   = idx_bdy(jbdy)%nbi(ib,igrd)
-                     ij   = idx_bdy(jbdy)%nbj(ib,igrd)
-                     dta%u2d(ib) = dta%u2d(ib) / ( e2u(ii,ij) * hu_0(ii,ij) )
-                  END DO
-                  !
-                  igrd = 3                      ! meridional velocity
-                  DO ib = 1, idx_bdy(jbdy)%nblen(igrd)
-                     ii   = idx_bdy(jbdy)%nbi(ib,igrd)
-                     ij   = idx_bdy(jbdy)%nbj(ib,igrd)
-                     dta%v2d(ib) = dta%v2d(ib) / ( e1v(ii,ij) * hv_0(ii,ij) )
-                  END DO
-               ELSE
-                  IF( nn_dyn2d_dta(jbdy) == 2 ) THEN ! tidal harmonic forcing ONLY: initialise arrays
-                     IF( dta%ll_ssh ) dta%ssh(:) = 0._wp
-                     IF( dta%ll_u2d ) dta%u2d(:) = 0._wp
-                     IF( dta%ll_v2d ) dta%v2d(:) = 0._wp
-                  ENDIF
-                  IF( dta%nread(1) .gt. 0 ) THEN ! update external data
-                     jend = jstart + dta%nread(1) - 1
-                     CALL fld_read( kt=kt, kn_fsbc=1, sd=bf(jstart:jend), &
-                                  & map=nbmap_ptr(jstart:jend), kt_offset=time_offset, jpk_bdy=nb_jpk_bdy(jbdy),   &
-                                  & fvl=ln_full_vel_array(jbdy) )
-                  ENDIF
-                  ! If full velocities in boundary data then split into barotropic and baroclinic data
-                  IF( ln_full_vel_array(jbdy) .and.                                             &
-                    & ( nn_dyn2d_dta(jbdy) == 1 .OR. nn_dyn2d_dta(jbdy) == 3 .OR. &
-                    &   nn_dyn3d_dta(jbdy) == 1 ) ) THEN
-                     igrd = 2                      ! zonal velocity
-                     dta%u2d(:) = 0._wp
-                     DO ib = 1, idx_bdy(jbdy)%nblen(igrd)
-                        ii   = idx_bdy(jbdy)%nbi(ib,igrd)
-                        ij   = idx_bdy(jbdy)%nbj(ib,igrd)
-                        DO ik = 1, jpkm1
-                           dta%u2d(ib) = dta%u2d(ib) &
-                 &                       + e3u_n(ii,ij,ik) * umask(ii,ij,ik) * dta%u3d(ib,ik)
-                        END DO
-                        dta%u2d(ib) =  dta%u2d(ib) * r1_hu_n(ii,ij)
-                        DO ik = 1, jpkm1
-                           dta%u3d(ib,ik) = dta%u3d(ib,ik) - dta%u2d(ib)
-                        END DO
-                     END DO
-                     igrd = 3                      ! meridional velocity
-                     dta%v2d(:) = 0._wp
-                     DO ib = 1, idx_bdy(jbdy)%nblen(igrd)
-                        ii   = idx_bdy(jbdy)%nbi(ib,igrd)
-                        ij   = idx_bdy(jbdy)%nbj(ib,igrd)
-                        DO ik = 1, jpkm1
-                           dta%v2d(ib) = dta%v2d(ib) &
-                 &                       + e3v_n(ii,ij,ik) * vmask(ii,ij,ik) * dta%v3d(ib,ik)
-                        END DO
-                        dta%v2d(ib) =  dta%v2d(ib) * r1_hv_n(ii,ij)
-                        DO ik = 1, jpkm1
-                           dta%v3d(ib,ik) = dta%v3d(ib,ik) - dta%v2d(ib)
-                        END DO
-                     END DO
-                  ENDIF
-
-               ENDIF
+
+      DO jbdy = 1, nb_bdy
+
+         dta_alias => dta_bdy(jbdy)
+         bf_alias  => bf(:,jbdy)
+
+         ! read/update all bdy data
+         ! ------------------------
+         CALL fld_read( kt, 1, bf_alias, kit = kit, kt_offset = kt_offset )
+
+         ! apply some corrections in some specific cases...
+         ! --------------------------------------------------
+         !
+         ! if runoff condition: change river flow we read (in m3/s) into barotropic velocity (m/s)
+         IF( cn_tra(jbdy) == 'runoff' .AND. TRIM(bf_alias(jp_bdyu2d)%clrootname) /= 'NOT USED' ) THEN   ! runoff and we read u/v2d
+            !
+            igrd = 2                      ! zonal flow (m3/s) to barotropic zonal velocity (m/s)
+            DO ib = 1, idx_bdy(jbdy)%nblen(igrd)
+               ii   = idx_bdy(jbdy)%nbi(ib,igrd)
+               ij   = idx_bdy(jbdy)%nbj(ib,igrd)
+               dta_alias%u2d(ib) = dta_alias%u2d(ib) / ( e2u(ii,ij) * hu_0(ii,ij) )
+            END DO
+            igrd = 3                      ! meridional flow (m3/s) to barotropic meridional velocity (m/s)
+            DO ib = 1, idx_bdy(jbdy)%nblen(igrd)
+               ii   = idx_bdy(jbdy)%nbi(ib,igrd)
+               ij   = idx_bdy(jbdy)%nbj(ib,igrd)
+               dta_alias%v2d(ib) = dta_alias%v2d(ib) / ( e1v(ii,ij) * hv_0(ii,ij) )
+            END DO
+         ENDIF
+
+         ! tidal harmonic forcing ONLY: initialise arrays
+         IF( nn_dyn2d_dta(jbdy) == 2 ) THEN   ! we did not read ssh, u/v2d 
+            IF( dta_alias%lneed_ssh   ) dta_alias%ssh(:) = 0._wp
+            IF( dta_alias%lneed_dyn2d ) dta_alias%u2d(:) = 0._wp
+            IF( dta_alias%lneed_dyn2d ) dta_alias%v2d(:) = 0._wp
+         ENDIF
+
+         ! If full velocities in boundary data, then split it into barotropic and baroclinic component
+         IF( bf_alias(jp_bdyu3d)%ltotvel ) THEN     ! if we read 3D total velocity (can be true only if u3d was read)
+            !
+            igrd = 2                       ! zonal velocity
+            dta_alias%u2d(:) = 0._wp       ! compute barotrope zonal velocity and put it in u2d
+            DO ib = 1, idx_bdy(jbdy)%nblen(igrd)
+               ii   = idx_bdy(jbdy)%nbi(ib,igrd)
+               ij   = idx_bdy(jbdy)%nbj(ib,igrd)
+               DO ik = 1, jpkm1
+                  dta_alias%u2d(ib) = dta_alias%u2d(ib) + e3u_n(ii,ij,ik) * umask(ii,ij,ik) * dta_alias%u3d(ib,ik)
+               END DO
+               dta_alias%u2d(ib) =  dta_alias%u2d(ib) * r1_hu_n(ii,ij)
+               DO ik = 1, jpkm1            ! compute barocline zonal velocity and put it in u3d
+                  dta_alias%u3d(ib,ik) = dta_alias%u3d(ib,ik) - dta_alias%u2d(ib)
+               END DO
+            END DO
+            igrd = 3                       ! meridional velocity
+            dta_alias%v2d(:) = 0._wp       ! compute barotrope meridional velocity and put it in v2d
+            DO ib = 1, idx_bdy(jbdy)%nblen(igrd)
+               ii   = idx_bdy(jbdy)%nbi(ib,igrd)
+               ij   = idx_bdy(jbdy)%nbj(ib,igrd)
+               DO ik = 1, jpkm1
+                  dta_alias%v2d(ib) = dta_alias%v2d(ib) + e3v_n(ii,ij,ik) * vmask(ii,ij,ik) * dta_alias%v3d(ib,ik)
+               END DO
+               dta_alias%v2d(ib) =  dta_alias%v2d(ib) * r1_hv_n(ii,ij)
+               DO ik = 1, jpkm1            ! compute barocline meridional velocity and put it in v3d
+                  dta_alias%v3d(ib,ik) = dta_alias%v3d(ib,ik) - dta_alias%v2d(ib)
+               END DO
+            END DO
+         ENDIF   ! ltotvel
+
+         ! update tidal harmonic forcing
+         IF( PRESENT(kit) .AND. nn_dyn2d_dta(jbdy) .GE. 2 ) THEN
+            CALL bdytide_update( kt = kt, idx = idx_bdy(jbdy), dta = dta_alias, td = tides(jbdy),   & 
+               &                 kit = kit, kt_offset = kt_offset )
+         ENDIF
+
+         !  atm surface pressure : add inverted barometer effect to ssh if it was read
+         IF ( ln_apr_obc .AND. TRIM(bf_alias(jp_bdyssh)%clrootname) /= 'NOT USED' ) THEN
+            igrd = 1
+            DO ib = 1, idx_bdy(jbdy)%nblenrim(igrd)   ! ssh is used only on the rim
+               ii   = idx_bdy(jbdy)%nbi(ib,igrd)
+               ij   = idx_bdy(jbdy)%nbj(ib,igrd)
+               dta_alias%ssh(ib) = dta_alias%ssh(ib) + ssh_ib(ii,ij)
+            END DO
+         ENDIF
+
 #if defined key_si3
-               ! convert N-cat fields (input) into jpl-cat (output)
-               IF( cn_ice(jbdy) /= 'none' .AND. nn_ice_dta(jbdy) == 1 ) THEN
-                  jfld_hti = jfld_htit(jbdy)
-                  jfld_hts = jfld_htst(jbdy)
-                  jfld_ai  = jfld_ait(jbdy)
-                  CALL ice_var_itd( bf(jfld_hti)%fnow(:,1,:), bf(jfld_hts)%fnow(:,1,:), bf(jfld_ai)%fnow(:,1,:), &
-                     &              dta_bdy(jbdy)%h_i       , dta_bdy(jbdy)%h_s       , dta_bdy(jbdy)%a_i      )
-               ENDIF
+         IF( dta_alias%lneed_ice ) THEN
+            ! fill temperature and salinity arrays
+            IF( TRIM(bf_alias(jp_bdyt_i)%clrootname) == 'NOT USED' )   bf_alias(jp_bdyt_i)%fnow(:,1,:) = rice_tem (jbdy)
+            IF( TRIM(bf_alias(jp_bdyt_s)%clrootname) == 'NOT USED' )   bf_alias(jp_bdyt_s)%fnow(:,1,:) = rice_tem (jbdy)
+            IF( TRIM(bf_alias(jp_bdytsu)%clrootname) == 'NOT USED' )   bf_alias(jp_bdytsu)%fnow(:,1,:) = rice_tem (jbdy)
+            IF( TRIM(bf_alias(jp_bdys_i)%clrootname) == 'NOT USED' )   bf_alias(jp_bdys_i)%fnow(:,1,:) = rice_sal (jbdy)
+            IF( TRIM(bf_alias(jp_bdyaip)%clrootname) == 'NOT USED' )   bf_alias(jp_bdyaip)%fnow(:,1,:) = rice_apnd(jbdy) * & ! rice_apnd is the pond fraction
+               &                                                                         bf_alias(jp_bdya_i)%fnow(:,1,:)     !   ( a_ip = rice_apnd * a_i )
+            IF( TRIM(bf_alias(jp_bdyhip)%clrootname) == 'NOT USED' )   bf_alias(jp_bdyhip)%fnow(:,1,:) = rice_hpnd(jbdy)
+            ! if T_su is read and not T_i, set T_i = (T_su + T_freeze)/2
+            IF( TRIM(bf_alias(jp_bdytsu)%clrootname) /= 'NOT USED' .AND. TRIM(bf_alias(jp_bdyt_i)%clrootname) == 'NOT USED' ) &
+               &   bf_alias(jp_bdyt_i)%fnow(:,1,:) = 0.5_wp * ( bf_alias(jp_bdytsu)%fnow(:,1,:) + 271.15 )
+            ! if T_su is read and not T_s, set T_s = T_su
+            IF( TRIM(bf_alias(jp_bdytsu)%clrootname) /= 'NOT USED' .AND. TRIM(bf_alias(jp_bdyt_s)%clrootname) == 'NOT USED' ) &
+               &   bf_alias(jp_bdyt_s)%fnow(:,1,:) = bf_alias(jp_bdytsu)%fnow(:,1,:)
+            ! if T_s is read and not T_su, set T_su = T_s
+            IF( TRIM(bf_alias(jp_bdyt_s)%clrootname) /= 'NOT USED' .AND. TRIM(bf_alias(jp_bdytsu)%clrootname) == 'NOT USED' ) &
+               &   bf_alias(jp_bdytsu)%fnow(:,1,:) = bf_alias(jp_bdyt_s)%fnow(:,1,:)
+            ! if T_s is read and not T_i, set T_i = (T_s + T_freeze)/2
+            IF( TRIM(bf_alias(jp_bdyt_s)%clrootname) /= 'NOT USED' .AND. TRIM(bf_alias(jp_bdyt_i)%clrootname) == 'NOT USED' ) &
+               &   bf_alias(jp_bdyt_i)%fnow(:,1,:) = 0.5_wp * ( bf_alias(jp_bdyt_s)%fnow(:,1,:) + 271.15 )
+
+            ! make sure ponds = 0 if no ponds scheme
+            IF ( .NOT.ln_pnd ) THEN
+               bf_alias(jp_bdyaip)%fnow(:,1,:) = 0._wp
+               bf_alias(jp_bdyhip)%fnow(:,1,:) = 0._wp
+            ENDIF
+            
+            ! convert N-cat fields (input) into jpl-cat (output)
+            ipl = SIZE(bf_alias(jp_bdya_i)%fnow, 3)            
+            IF( ipl /= jpl ) THEN      ! ice: convert N-cat fields (input) into jpl-cat (output)
+               CALL ice_var_itd( bf_alias(jp_bdyh_i)%fnow(:,1,:), bf_alias(jp_bdyh_s)%fnow(:,1,:), bf_alias(jp_bdya_i)%fnow(:,1,:), &
+                  &              dta_alias%h_i                  , dta_alias%h_s                  , dta_alias%a_i                  , &
+                  &              bf_alias(jp_bdyt_i)%fnow(:,1,:), bf_alias(jp_bdyt_s)%fnow(:,1,:), &
+                  &              bf_alias(jp_bdytsu)%fnow(:,1,:), bf_alias(jp_bdys_i)%fnow(:,1,:), &
+                  &              bf_alias(jp_bdyaip)%fnow(:,1,:), bf_alias(jp_bdyhip)%fnow(:,1,:), &
+                  &              dta_alias%t_i                  , dta_alias%t_s                  , &
+                  &              dta_alias%tsu                  , dta_alias%s_i                  , &
+                  &              dta_alias%aip                  , dta_alias%hip )
+            ENDIF
+         ENDIF
 #endif
-            ENDIF
-            jstart = jstart + dta%nread(1)
-         ENDIF    ! nn_dta(jbdy) = 1
       END DO  ! jbdy
-
-      IF ( ln_apr_obc ) THEN
-         DO jbdy = 1, nb_bdy
-            IF (cn_tra(jbdy) /= 'runoff')THEN
-               igrd = 1                      ! meridional velocity
-               DO ib = 1, idx_bdy(jbdy)%nblenrim(igrd)
-                  ii   = idx_bdy(jbdy)%nbi(ib,igrd)
-                  ij   = idx_bdy(jbdy)%nbj(ib,igrd)
-                  dta_bdy(jbdy)%ssh(ib) = dta_bdy(jbdy)%ssh(ib) + ssh_ib(ii,ij)
-               END DO
-            ENDIF
-         END DO
-      ENDIF
 
       IF ( ln_tide ) THEN
          IF (ln_dynspg_ts) THEN      ! Fill temporary arrays with slow-varying bdy data                           
-            DO jbdy = 1, nb_bdy    ! Tidal component added in ts loop
-               IF ( nn_dyn2d_dta(jbdy) .ge. 2 ) THEN
+            DO jbdy = 1, nb_bdy      ! Tidal component added in ts loop
+               IF ( nn_dyn2d_dta(jbdy) .GE. 2 ) THEN
                   nblen => idx_bdy(jbdy)%nblen
                   nblenrim => idx_bdy(jbdy)%nblenrim
-                  IF( cn_dyn2d(jbdy) == 'frs' ) THEN; ilen1(:)=nblen(:) ; ELSE ; ilen1(:)=nblenrim(:) ; ENDIF 
-                  IF ( dta_bdy(jbdy)%ll_ssh ) dta_bdy_s(jbdy)%ssh(1:ilen1(1)) = dta_bdy(jbdy)%ssh(1:ilen1(1))
-                  IF ( dta_bdy(jbdy)%ll_u2d ) dta_bdy_s(jbdy)%u2d(1:ilen1(2)) = dta_bdy(jbdy)%u2d(1:ilen1(2))
-                  IF ( dta_bdy(jbdy)%ll_v2d ) dta_bdy_s(jbdy)%v2d(1:ilen1(3)) = dta_bdy(jbdy)%v2d(1:ilen1(3))
-               ENDIF
-            END DO
-         ELSE ! Add tides if not split-explicit free surface else this is done in ts loop
-            !
-            CALL bdy_dta_tides( kt=kt, time_offset=time_offset )
-         ENDIF
-      ENDIF
-
-      !
-      IF( ln_timing )   CALL timing_stop('bdy_dta')
-      !
-   END SUBROUTINE bdy_dta
+                  IF( cn_dyn2d(jbdy) == 'frs' ) THEN ; ilen1(:)=nblen(:) ; ELSE ; ilen1(:)=nblenrim(:) ; ENDIF 
+                     IF ( dta_bdy(jbdy)%lneed_ssh   ) dta_bdy_s(jbdy)%ssh(1:ilen1(1)) = dta_bdy(jbdy)%ssh(1:ilen1(1))
+                     IF ( dta_bdy(jbdy)%lneed_dyn2d ) dta_bdy_s(jbdy)%u2d(1:ilen1(2)) = dta_bdy(jbdy)%u2d(1:ilen1(2))
+                     IF ( dta_bdy(jbdy)%lneed_dyn2d ) dta_bdy_s(jbdy)%v2d(1:ilen1(3)) = dta_bdy(jbdy)%v2d(1:ilen1(3))
+                  ENDIF
+               END DO
+            ELSE ! Add tides if not split-explicit free surface else this is done in ts loop
+               !
+               CALL bdy_dta_tides( kt=kt, kt_offset=kt_offset )
+            ENDIF
+         ENDIF
+         !
+         IF( ln_timing )   CALL timing_stop('bdy_dta')
+         !
+      END SUBROUTINE bdy_dta
 
 
@@ -413,33 +370,32 @@
       !!                
       !!----------------------------------------------------------------------
-      INTEGER ::   jbdy, jfld, jstart, jend, ierror, ios     ! Local integers
+      INTEGER ::   jbdy, jfld    ! Local integers
+      INTEGER ::   ierror, ios     ! 
       !
+      CHARACTER(len=3)                       ::   cl3           ! 
       CHARACTER(len=100)                     ::   cn_dir        ! Root directory for location of data files
-      CHARACTER(len=100), DIMENSION(nb_bdy)  ::   cn_dir_array  ! Root directory for location of data files
-      CHARACTER(len = 256)::   clname                           ! temporary file name
       LOGICAL                                ::   ln_full_vel   ! =T => full velocities in 3D boundary data
       !                                                         ! =F => baroclinic velocities in 3D boundary data
-      INTEGER                                ::   ilen_global   ! Max length required for global bdy dta arrays
-      INTEGER, ALLOCATABLE, DIMENSION(:)     ::   ilen1, ilen3  ! size of 1st and 3rd dimensions of local arrays
-      INTEGER, ALLOCATABLE, DIMENSION(:)     ::   ibdy           ! bdy set for a particular jfld
-      INTEGER, ALLOCATABLE, DIMENSION(:)     ::   igrid         ! index for grid type (1,2,3 = T,U,V)
-      INTEGER, POINTER, DIMENSION(:)         ::   nblen, nblenrim  ! short cuts
-      TYPE(OBC_DATA), POINTER                ::   dta           ! short cut
-#if defined key_si3
-      INTEGER               ::   kndims   ! number of dimensions in an array (i.e. 3 = wo ice cat; 4 = w ice cat)
-      INTEGER, DIMENSION(4) ::   kdimsz   ! size   of dimensions
-      INTEGER               ::   inum,id1 ! local integer
-#endif
-      TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) ::   blf_i         !  array of namelist information structures
-      TYPE(FLD_N) ::   bn_tem, bn_sal, bn_u3d, bn_v3d   ! 
-      TYPE(FLD_N) ::   bn_ssh, bn_u2d, bn_v2d           ! informations about the fields to be read
-#if defined key_si3
-      TYPE(FLD_N) ::   bn_a_i, bn_h_i, bn_h_s      
-#endif
+      LOGICAL                                ::   ln_zinterp    ! =T => requires a vertical interpolation of the bdydta
+      REAL(wp)                               ::   rn_ice_tem, rn_ice_sal, rn_ice_age, rn_ice_apnd, rn_ice_hpnd 
+      INTEGER                                ::   ipk,ipl       !
+      INTEGER                                ::   idvar         ! variable ID
+      INTEGER                                ::   indims        ! number of dimensions of the variable
+      INTEGER                                ::   iszdim        ! number of dimensions of the variable
+      INTEGER, DIMENSION(4)                  ::   i4dimsz       ! size of variable dimensions 
+      INTEGER                                ::   igrd          ! index for grid type (1,2,3 = T,U,V)
+      LOGICAL                                ::   lluld         ! is the variable using the unlimited dimension
+      LOGICAL                                ::   llneed        !
+      LOGICAL                                ::   llread        !
+      TYPE(FLD_N), DIMENSION(1), TARGET  ::   bn_tem, bn_sal, bn_u3d, bn_v3d   ! must be an array to be used with fld_fill
+      TYPE(FLD_N), DIMENSION(1), TARGET  ::   bn_ssh, bn_u2d, bn_v2d           ! informations about the fields to be read
+      TYPE(FLD_N), DIMENSION(1), TARGET  ::   bn_a_i, bn_h_i, bn_h_s, bn_t_i, bn_t_s, bn_tsu, bn_s_i, bn_aip, bn_hip       
+      TYPE(FLD_N), DIMENSION(:), POINTER ::   bn_alias                        ! must be an array to be used with fld_fill
+      TYPE(FLD  ), DIMENSION(:), POINTER ::   bf_alias
+      !
       NAMELIST/nambdy_dta/ cn_dir, bn_tem, bn_sal, bn_u3d, bn_v3d, bn_ssh, bn_u2d, bn_v2d 
-#if defined key_si3
-      NAMELIST/nambdy_dta/ bn_a_i, bn_h_i, bn_h_s
-#endif
-      NAMELIST/nambdy_dta/ ln_full_vel
+      NAMELIST/nambdy_dta/ bn_a_i, bn_h_i, bn_h_s, bn_t_i, bn_t_s, bn_tsu, bn_s_i, bn_aip, bn_hip
+      NAMELIST/nambdy_dta/ rn_ice_tem, rn_ice_sal, rn_ice_age, rn_ice_apnd, rn_ice_hpnd
+      NAMELIST/nambdy_dta/ ln_full_vel, ln_zinterp
       !!---------------------------------------------------------------------------
       !
@@ -449,389 +405,290 @@
       IF(lwp) WRITE(numout,*) ''
 
-      ! Set nn_dta
-      DO jbdy = 1, nb_bdy
-         nn_dta(jbdy) = MAX(   nn_dyn2d_dta  (jbdy)    &
-            &                , nn_dyn3d_dta  (jbdy)    &
-            &                , nn_tra_dta    (jbdy)    &
-#if defined key_si3
-            &                , nn_ice_dta    (jbdy)    &
-#endif
-                              )
-         IF(nn_dta(jbdy) > 1)   nn_dta(jbdy) = 1
-      END DO
-
-      ! Work out upper bound of how many fields there are to read in and allocate arrays
-      ! ---------------------------------------------------------------------------
-      ALLOCATE( nb_bdy_fld(nb_bdy) )
-      nb_bdy_fld(:) = 0
-      DO jbdy = 1, nb_bdy         
-         IF( cn_dyn2d(jbdy) /= 'none' .AND. ( nn_dyn2d_dta(jbdy) == 1 .or. nn_dyn2d_dta(jbdy) == 3 ) ) THEN
-            nb_bdy_fld(jbdy) = nb_bdy_fld(jbdy) + 3
-         ENDIF
-         IF( cn_dyn3d(jbdy) /= 'none' .AND. nn_dyn3d_dta(jbdy) == 1 ) THEN
-            nb_bdy_fld(jbdy) = nb_bdy_fld(jbdy) + 2
-         ENDIF
-         IF( cn_tra(jbdy) /= 'none' .AND. nn_tra_dta(jbdy) == 1  ) THEN
-            nb_bdy_fld(jbdy) = nb_bdy_fld(jbdy) + 2
-         ENDIF
-#if defined key_si3
-         IF( cn_ice(jbdy) /= 'none' .AND. nn_ice_dta(jbdy) == 1  ) THEN
-            nb_bdy_fld(jbdy) = nb_bdy_fld(jbdy) + 3
-         ENDIF
-#endif               
-         IF(lwp) WRITE(numout,*) 'Maximum number of files to open =', nb_bdy_fld(jbdy)
-      END DO            
-
-      nb_bdy_fld_sum = SUM( nb_bdy_fld )
-
-      ALLOCATE( bf(nb_bdy_fld_sum), STAT=ierror )
+      ALLOCATE( bf(jpbdyfld,nb_bdy), STAT=ierror )
       IF( ierror > 0 ) THEN   
          CALL ctl_stop( 'bdy_dta: unable to allocate bf structure' )   ;   RETURN  
       ENDIF
-      ALLOCATE( blf_i(nb_bdy_fld_sum), STAT=ierror )
-      IF( ierror > 0 ) THEN   
-         CALL ctl_stop( 'bdy_dta: unable to allocate blf_i structure' )   ;   RETURN  
-      ENDIF
-      ALLOCATE( nbmap_ptr(nb_bdy_fld_sum), STAT=ierror )
-      IF( ierror > 0 ) THEN   
-         CALL ctl_stop( 'bdy_dta: unable to allocate nbmap_ptr structure' )   ;   RETURN  
-      ENDIF
-      ALLOCATE( ilen1(nb_bdy_fld_sum), ilen3(nb_bdy_fld_sum) ) 
-      ALLOCATE( ibdy(nb_bdy_fld_sum) ) 
-      ALLOCATE( igrid(nb_bdy_fld_sum) ) 
-
+      bf(:,:)%clrootname = 'NOT USED'   ! default definition used as a flag in fld_read to do nothing.
+      bf(:,:)%lzint      = .FALSE.      ! default definition
+      bf(:,:)%ltotvel    = .FALSE.      ! default definition
+ 
       ! Read namelists
       ! --------------
       REWIND(numnam_cfg)
-      jfld = 0 
-      DO jbdy = 1, nb_bdy         
-         IF( nn_dta(jbdy) == 1 ) THEN
-            REWIND(numnam_ref)
-            READ  ( numnam_ref, nambdy_dta, IOSTAT = ios, ERR = 901)
-901         IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_dta in reference namelist', lwp )
+      DO jbdy = 1, nb_bdy
+
+         WRITE(ctmp1, '(a,i2)') 'BDY number ', jbdy
+         WRITE(ctmp2, '(a,i2)') 'block nambdy_dta number ', jbdy
+
+         ! There is only one nambdy_dta block in namelist_ref -> use it for each bdy so we do a rewind 
+         REWIND(numnam_ref)
+         READ  ( numnam_ref, nambdy_dta, IOSTAT = ios, ERR = 901)
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_dta in reference namelist' )
+
+         !   by-pass nambdy_dta reading if no input data used in this bdy   
+         IF(       ( dta_bdy(jbdy)%lneed_dyn2d .AND. MOD(nn_dyn2d_dta(jbdy),2) == 1 )   &
+            & .OR. ( dta_bdy(jbdy)%lneed_dyn3d .AND.     nn_dyn3d_dta(jbdy)    == 1 )   &
+            & .OR. ( dta_bdy(jbdy)%lneed_tra   .AND.       nn_tra_dta(jbdy)    == 1 )   &
+            & .OR. ( dta_bdy(jbdy)%lneed_ice   .AND.       nn_ice_dta(jbdy)    == 1 )   )   THEN
+            ! WARNING: we don't do a rewind here, each bdy reads its own nambdy_dta block one after another
             READ  ( numnam_cfg, nambdy_dta, IOSTAT = ios, ERR = 902 )
-902         IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy_dta in configuration namelist', lwp )
-            IF(lwm) WRITE( numond, nambdy_dta )
-
-            cn_dir_array(jbdy) = cn_dir
-            ln_full_vel_array(jbdy) = ln_full_vel
-
-            nblen => idx_bdy(jbdy)%nblen
-            nblenrim => idx_bdy(jbdy)%nblenrim
-            dta => dta_bdy(jbdy)
-            dta%nread(2) = 0
-
-            ! Only read in necessary fields for this set.
-            ! Important that barotropic variables come first.
-            IF( nn_dyn2d_dta(jbdy) == 1 .or. nn_dyn2d_dta(jbdy) == 3 ) THEN 
-
-               IF( dta%ll_ssh ) THEN 
-                  if(lwp) write(numout,*) '++++++ reading in ssh field'
-                  jfld = jfld + 1
-                  blf_i(jfld) = bn_ssh
-                  ibdy(jfld) = jbdy
-                  igrid(jfld) = 1
-                  ilen1(jfld) = nblen(igrid(jfld))
-                  ilen3(jfld) = 1
-                  dta%nread(2) = dta%nread(2) + 1
-               ENDIF
-
-               IF( dta%ll_u2d .and. .not. ln_full_vel_array(jbdy) ) THEN
-                  if(lwp) write(numout,*) '++++++ reading in u2d field'
-                  jfld = jfld + 1
-                  blf_i(jfld) = bn_u2d
-                  ibdy(jfld) = jbdy
-                  igrid(jfld) = 2
-                  ilen1(jfld) = nblen(igrid(jfld))
-                  ilen3(jfld) = 1
-                  dta%nread(2) = dta%nread(2) + 1
-               ENDIF
-
-               IF( dta%ll_v2d .and. .not. ln_full_vel_array(jbdy) ) THEN
-                  if(lwp) write(numout,*) '++++++ reading in v2d field'
-                  jfld = jfld + 1
-                  blf_i(jfld) = bn_v2d
-                  ibdy(jfld) = jbdy
-                  igrid(jfld) = 3
-                  ilen1(jfld) = nblen(igrid(jfld))
-                  ilen3(jfld) = 1
-                  dta%nread(2) = dta%nread(2) + 1
-               ENDIF
-
-            ENDIF
-
-            ! read 3D velocities if baroclinic velocities require OR if
-            ! barotropic velocities required and ln_full_vel set to .true.
-            IF( nn_dyn3d_dta(jbdy) == 1 .OR. &
-           &  ( ln_full_vel_array(jbdy) .AND. ( nn_dyn2d_dta(jbdy) == 1 .OR. nn_dyn2d_dta(jbdy) == 3 ) ) ) THEN
-
-               IF( dta%ll_u3d .OR. ( ln_full_vel_array(jbdy) .and. dta%ll_u2d ) ) THEN
-                  if(lwp) write(numout,*) '++++++ reading in u3d field'
-                  jfld = jfld + 1
-                  blf_i(jfld) = bn_u3d
-                  ibdy(jfld) = jbdy
-                  igrid(jfld) = 2
-                  ilen1(jfld) = nblen(igrid(jfld))
-                  ilen3(jfld) = jpk
-                  IF( ln_full_vel_array(jbdy) .and. dta%ll_u2d ) dta%nread(2) = dta%nread(2) + 1
-               ENDIF
-
-               IF( dta%ll_v3d .OR. ( ln_full_vel_array(jbdy) .and. dta%ll_v2d ) ) THEN
-                  if(lwp) write(numout,*) '++++++ reading in v3d field'
-                  jfld = jfld + 1
-                  blf_i(jfld) = bn_v3d
-                  ibdy(jfld) = jbdy
-                  igrid(jfld) = 3
-                  ilen1(jfld) = nblen(igrid(jfld))
-                  ilen3(jfld) = jpk
-                  IF( ln_full_vel_array(jbdy) .and. dta%ll_v2d ) dta%nread(2) = dta%nread(2) + 1
-               ENDIF
-
-            ENDIF
-
-            ! temperature and salinity
-            IF( nn_tra_dta(jbdy) == 1 ) THEN
-
-               IF( dta%ll_tem ) THEN
-                  if(lwp) write(numout,*) '++++++ reading in tem field'
-                  jfld = jfld + 1
-                  blf_i(jfld) = bn_tem
-                  ibdy(jfld) = jbdy
-                  igrid(jfld) = 1
-                  ilen1(jfld) = nblen(igrid(jfld))
-                  ilen3(jfld) = jpk
-               ENDIF
-
-               IF( dta%ll_sal ) THEN
-                  if(lwp) write(numout,*) '++++++ reading in sal field'
-                  jfld = jfld + 1
-                  blf_i(jfld) = bn_sal
-                  ibdy(jfld) = jbdy
-                  igrid(jfld) = 1
-                  ilen1(jfld) = nblen(igrid(jfld))
-                  ilen3(jfld) = jpk
-               ENDIF
-
-            ENDIF
+902         IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy_dta in configuration namelist' )
+            IF(lwm) WRITE( numond, nambdy_dta )           
+         ENDIF
+
+         ! get the number of ice categories in bdy data file (use a_i information to do this)
+         ipl = jpl   ! default definition
+         IF( dta_bdy(jbdy)%lneed_ice ) THEN    ! if we need ice bdy data
+            IF( nn_ice_dta(jbdy) == 1 ) THEN   ! if we get ice bdy data from netcdf file
+               CALL fld_fill(  bf(jp_bdya_i,jbdy:jbdy), bn_a_i, cn_dir, 'bdy_dta', 'a_i'//' '//ctmp1, ctmp2 )   ! use namelist info
+               CALL fld_clopn( bf(jp_bdya_i,jbdy), nyear, nmonth, nday )   ! not a problem when we call it again after
+               idvar = iom_varid( bf(jp_bdya_i,jbdy)%num, bf(jp_bdya_i,jbdy)%clvar, kndims=indims, kdimsz=i4dimsz, lduld=lluld )
+               IF( indims == 4 .OR. ( indims == 3 .AND. .NOT. lluld ) ) THEN   ;   ipl = i4dimsz(3)   ! xylt or xyl
+               ELSE                                                            ;   ipl = 1            ! xy or xyt
+               ENDIF
+               bf(jp_bdya_i,jbdy)%clrootname = 'NOT USED'   ! reset to default value as this subdomain may not need to read this bdy
+            ENDIF
+         ENDIF
 
 #if defined key_si3
-            ! sea ice
-            IF( nn_ice_dta(jbdy) == 1 ) THEN
-               ! Test for types of ice input (1cat or Xcat) 
-               ! Build file name to find dimensions 
-               clname=TRIM( cn_dir )//TRIM(bn_a_i%clname)
-               IF( .NOT. bn_a_i%ln_clim ) THEN   
-                                                  WRITE(clname, '(a,"_y",i4.4)' ) TRIM( clname ), nyear    ! add year
-                  IF( bn_a_i%cltype /= 'yearly' ) WRITE(clname, '(a,"m" ,i2.2)' ) TRIM( clname ), nmonth   ! add month
-               ELSE
-                  IF( bn_a_i%cltype /= 'yearly' ) WRITE(clname, '(a,"_m",i2.2)' ) TRIM( clname ), nmonth   ! add month
-               ENDIF
-               IF( bn_a_i%cltype == 'daily' .OR. bn_a_i%cltype(1:4) == 'week' ) &
-               &                                  WRITE(clname, '(a,"d" ,i2.2)' ) TRIM( clname ), nday     ! add day
+         IF( .NOT.ln_pnd ) THEN
+            rn_ice_apnd = 0. ; rn_ice_hpnd = 0.
+            CALL ctl_warn( 'rn_ice_apnd & rn_ice_hpnd = 0 when no ponds' )
+         ENDIF
+#endif
+
+         ! temp, salt, age and ponds of incoming ice
+         rice_tem (jbdy) = rn_ice_tem
+         rice_sal (jbdy) = rn_ice_sal
+         rice_age (jbdy) = rn_ice_age
+         rice_apnd(jbdy) = rn_ice_apnd
+         rice_hpnd(jbdy) = rn_ice_hpnd
+         
+         
+         DO jfld = 1, jpbdyfld
+
+            ! =====================
+            !          ssh 
+            ! =====================
+            IF( jfld == jp_bdyssh ) THEN
+               cl3 = 'ssh'
+               igrd = 1                                                    ! T point
+               ipk = 1                                                     ! surface data
+               llneed = dta_bdy(jbdy)%lneed_ssh                            ! dta_bdy(jbdy)%ssh will be needed
+               llread = MOD(nn_dyn2d_dta(jbdy),2) == 1                     ! get data from NetCDF file
+               bf_alias => bf(jp_bdyssh,jbdy:jbdy)                         ! alias for ssh structure of bdy number jbdy
+               bn_alias => bn_ssh                                          ! alias for ssh structure of nambdy_dta 
+               iszdim = idx_bdy(jbdy)%nblenrim(igrd)                       ! length of this bdy on this MPI processus : used only on the rim
+            ENDIF
+            ! =====================
+            !         dyn2d
+            ! =====================
+            IF( jfld == jp_bdyu2d ) THEN
+               cl3 = 'u2d'
+               igrd = 2                                                    ! U point
+               ipk = 1                                                     ! surface data
+               llneed = dta_bdy(jbdy)%lneed_dyn2d                          ! dta_bdy(jbdy)%ssh will be needed
+               llread = .NOT. ln_full_vel .AND. MOD(nn_dyn2d_dta(jbdy),2) == 1   ! don't get u2d from u3d and read NetCDF file
+               bf_alias => bf(jp_bdyu2d,jbdy:jbdy)                         ! alias for u2d structure of bdy number jbdy
+               bn_alias => bn_u2d                                          ! alias for u2d structure of nambdy_dta
+               IF( ln_full_vel ) THEN  ;   iszdim = idx_bdy(jbdy)%nblen(igrd)      ! will be computed from u3d -> need on the full bdy
+               ELSE                    ;   iszdim = idx_bdy(jbdy)%nblenrim(igrd)   ! used only on the rim
+               ENDIF
+            ENDIF
+            IF( jfld == jp_bdyv2d ) THEN
+               cl3 = 'v2d'
+               igrd = 3                                                    ! V point
+               ipk = 1                                                     ! surface data
+               llneed = dta_bdy(jbdy)%lneed_dyn2d                          ! dta_bdy(jbdy)%ssh will be needed
+               llread = .NOT. ln_full_vel .AND. MOD(nn_dyn2d_dta(jbdy),2) == 1   ! don't get v2d from v3d and read NetCDF file
+               bf_alias => bf(jp_bdyv2d,jbdy:jbdy)                         ! alias for v2d structure of bdy number jbdy
+               bn_alias => bn_v2d                                          ! alias for v2d structure of nambdy_dta 
+               IF( ln_full_vel ) THEN  ;   iszdim = idx_bdy(jbdy)%nblen(igrd)      ! will be computed from v3d -> need on the full bdy
+               ELSE                    ;   iszdim = idx_bdy(jbdy)%nblenrim(igrd)   ! used only on the rim
+               ENDIF
+            ENDIF
+            ! =====================
+            !         dyn3d
+            ! =====================
+            IF( jfld == jp_bdyu3d ) THEN
+               cl3 = 'u3d'
+               igrd = 2                                                    ! U point
+               ipk = jpk                                                   ! 3d data
+               llneed = dta_bdy(jbdy)%lneed_dyn3d .OR.               &     ! dta_bdy(jbdy)%u3d will be needed
+                  &   ( dta_bdy(jbdy)%lneed_dyn2d .AND. ln_full_vel )      !   u3d needed to compute u2d
+               llread = nn_dyn3d_dta(jbdy) == 1                            ! get data from NetCDF file
+               bf_alias => bf(jp_bdyu3d,jbdy:jbdy)                         ! alias for u3d structure of bdy number jbdy
+               bn_alias => bn_u3d                                          ! alias for u3d structure of nambdy_dta 
+               iszdim = idx_bdy(jbdy)%nblen(igrd)                          ! length of this bdy on this MPI processus
+           ENDIF
+            IF( jfld == jp_bdyv3d ) THEN
+               cl3 = 'v3d'
+               igrd = 3                                                    ! V point
+               ipk = jpk                                                   ! 3d data
+               llneed = dta_bdy(jbdy)%lneed_dyn3d .OR.               &     ! dta_bdy(jbdy)%v3d will be needed
+                  &   ( dta_bdy(jbdy)%lneed_dyn2d .AND. ln_full_vel )      !   v3d needed to compute v2d
+               llread = nn_dyn3d_dta(jbdy) == 1                            ! get data from NetCDF file
+               bf_alias => bf(jp_bdyv3d,jbdy:jbdy)                         ! alias for v3d structure of bdy number jbdy
+               bn_alias => bn_v3d                                          ! alias for v3d structure of nambdy_dta 
+               iszdim = idx_bdy(jbdy)%nblen(igrd)                          ! length of this bdy on this MPI processus
+           ENDIF
+
+            ! =====================
+            !          tra
+            ! =====================
+            IF( jfld == jp_bdytem ) THEN
+               cl3 = 'tem'
+               igrd = 1                                                    ! T point
+               ipk = jpk                                                   ! 3d data
+               llneed = dta_bdy(jbdy)%lneed_tra                            ! dta_bdy(jbdy)%tem will be needed
+               llread = nn_tra_dta(jbdy) == 1                              ! get data from NetCDF file
+               bf_alias => bf(jp_bdytem,jbdy:jbdy)                         ! alias for ssh structure of bdy number jbdy
+               bn_alias => bn_tem                                          ! alias for ssh structure of nambdy_dta 
+               iszdim = idx_bdy(jbdy)%nblen(igrd)                          ! length of this bdy on this MPI processus
+            ENDIF
+            IF( jfld == jp_bdysal ) THEN
+               cl3 = 'sal'
+               igrd = 1                                                    ! T point
+               ipk = jpk                                                   ! 3d data
+               llneed = dta_bdy(jbdy)%lneed_tra                            ! dta_bdy(jbdy)%sal will be needed
+               llread = nn_tra_dta(jbdy) == 1                              ! get data from NetCDF file
+               bf_alias => bf(jp_bdysal,jbdy:jbdy)                         ! alias for ssh structure of bdy number jbdy
+               bn_alias => bn_sal                                          ! alias for ssh structure of nambdy_dta 
+               iszdim = idx_bdy(jbdy)%nblen(igrd)                          ! length of this bdy on this MPI processus
+            ENDIF
+
+            ! =====================
+            !          ice
+            ! =====================
+            IF(  jfld == jp_bdya_i .OR. jfld == jp_bdyh_i .OR. jfld == jp_bdyh_s .OR. &
+               & jfld == jp_bdyt_i .OR. jfld == jp_bdyt_s .OR. jfld == jp_bdytsu .OR. &
+               & jfld == jp_bdys_i .OR. jfld == jp_bdyaip .OR. jfld == jp_bdyhip      ) THEN
+               igrd = 1                                                    ! T point
+               ipk = ipl                                                   ! jpl-cat data
+               llneed = dta_bdy(jbdy)%lneed_ice                            ! ice will be needed
+               llread = nn_ice_dta(jbdy) == 1                              ! get data from NetCDF file
+               iszdim = idx_bdy(jbdy)%nblen(igrd)                          ! length of this bdy on this MPI processus
+            ENDIF
+            IF( jfld == jp_bdya_i ) THEN
+               cl3 = 'a_i'
+               bf_alias => bf(jp_bdya_i,jbdy:jbdy)                         ! alias for a_i structure of bdy number jbdy
+               bn_alias => bn_a_i                                          ! alias for a_i structure of nambdy_dta 
+            ENDIF
+            IF( jfld == jp_bdyh_i ) THEN
+               cl3 = 'h_i'
+               bf_alias => bf(jp_bdyh_i,jbdy:jbdy)                         ! alias for h_i structure of bdy number jbdy
+               bn_alias => bn_h_i                                          ! alias for h_i structure of nambdy_dta 
+            ENDIF
+            IF( jfld == jp_bdyh_s ) THEN
+               cl3 = 'h_s'
+               bf_alias => bf(jp_bdyh_s,jbdy:jbdy)                         ! alias for h_s structure of bdy number jbdy
+               bn_alias => bn_h_s                                          ! alias for h_s structure of nambdy_dta 
+            ENDIF
+            IF( jfld == jp_bdyt_i ) THEN
+               cl3 = 't_i'
+               bf_alias => bf(jp_bdyt_i,jbdy:jbdy)                         ! alias for t_i structure of bdy number jbdy
+               bn_alias => bn_t_i                                          ! alias for t_i structure of nambdy_dta 
+            ENDIF
+            IF( jfld == jp_bdyt_s ) THEN
+               cl3 = 't_s'
+               bf_alias => bf(jp_bdyt_s,jbdy:jbdy)                         ! alias for t_s structure of bdy number jbdy
+               bn_alias => bn_t_s                                          ! alias for t_s structure of nambdy_dta 
+            ENDIF
+            IF( jfld == jp_bdytsu ) THEN
+               cl3 = 'tsu'
+               bf_alias => bf(jp_bdytsu,jbdy:jbdy)                         ! alias for tsu structure of bdy number jbdy
+               bn_alias => bn_tsu                                          ! alias for tsu structure of nambdy_dta 
+            ENDIF
+            IF( jfld == jp_bdys_i ) THEN
+               cl3 = 's_i'
+               bf_alias => bf(jp_bdys_i,jbdy:jbdy)                         ! alias for s_i structure of bdy number jbdy
+               bn_alias => bn_s_i                                          ! alias for s_i structure of nambdy_dta 
+            ENDIF
+            IF( jfld == jp_bdyaip ) THEN
+               cl3 = 'aip'
+               bf_alias => bf(jp_bdyaip,jbdy:jbdy)                         ! alias for aip structure of bdy number jbdy
+               bn_alias => bn_aip                                          ! alias for aip structure of nambdy_dta 
+            ENDIF
+            IF( jfld == jp_bdyhip ) THEN
+               cl3 = 'hip'
+               bf_alias => bf(jp_bdyhip,jbdy:jbdy)                         ! alias for hip structure of bdy number jbdy
+               bn_alias => bn_hip                                          ! alias for hip structure of nambdy_dta 
+            ENDIF
+
+            IF( llneed .AND. iszdim > 0 ) THEN                             ! dta_bdy(jbdy)%xxx will be needed
+               !                                                           !   -> must be associated with an allocated target
+               ALLOCATE( bf_alias(1)%fnow( iszdim, 1, ipk ) )              ! allocate the target
                !
-               CALL iom_open  ( clname, inum )
-               id1 = iom_varid( inum, bn_a_i%clvar, kdimsz=kdimsz, kndims=kndims, ldstop = .FALSE. )
-               CALL iom_close ( inum )
-
-      	       IF ( kndims == 4 ) THEN
-                 nice_cat = kdimsz(4)   ! Xcat input
-               ELSE
-                 nice_cat = 1           ! 1cat input      
-               ENDIF
-               ! End test
-
-               IF( dta%ll_a_i ) THEN
-                  jfld = jfld + 1
-                  blf_i(jfld) = bn_a_i
-                  ibdy(jfld)  = jbdy
-                  igrid(jfld) = 1
-                  ilen1(jfld) = nblen(igrid(jfld))
-                  ilen3(jfld) = nice_cat
-               ENDIF
-
-               IF( dta%ll_h_i ) THEN
-                  jfld = jfld + 1
-                  blf_i(jfld) = bn_h_i
-                  ibdy(jfld)  = jbdy
-                  igrid(jfld) = 1
-                  ilen1(jfld) = nblen(igrid(jfld))
-                  ilen3(jfld) = nice_cat
-               ENDIF
-
-               IF( dta%ll_h_s ) THEN
-                  jfld = jfld + 1
-                  blf_i(jfld) = bn_h_s
-                  ibdy(jfld)  = jbdy
-                  igrid(jfld) = 1
-                  ilen1(jfld) = nblen(igrid(jfld))
-                  ilen3(jfld) = nice_cat
-               ENDIF
-
-            ENDIF
-#endif
-            ! Recalculate field counts
-            !-------------------------
-            IF( jbdy == 1 ) THEN 
-               nb_bdy_fld_sum = 0
-               nb_bdy_fld(jbdy) = jfld
-               nb_bdy_fld_sum     = jfld              
-            ELSE
-               nb_bdy_fld(jbdy) = jfld - nb_bdy_fld_sum
-               nb_bdy_fld_sum = nb_bdy_fld_sum + nb_bdy_fld(jbdy)
-            ENDIF
-
-            dta%nread(1) = nb_bdy_fld(jbdy)
-
-         ENDIF ! nn_dta == 1
-      ENDDO ! jbdy
-
-      DO jfld = 1, nb_bdy_fld_sum
-         ALLOCATE( bf(jfld)%fnow(ilen1(jfld),1,ilen3(jfld)) )
-         IF( blf_i(jfld)%ln_tint ) ALLOCATE( bf(jfld)%fdta(ilen1(jfld),1,ilen3(jfld),2) )
-         nbmap_ptr(jfld)%ptr => idx_bdy(ibdy(jfld))%nbmap(:,igrid(jfld))
-         nbmap_ptr(jfld)%ll_unstruc = ln_coords_file(ibdy(jfld))
-      ENDDO
-
-      ! fill bf with blf_i and control print
-      !-------------------------------------
-      jstart = 1
-      DO jbdy = 1, nb_bdy
-         jend = jstart - 1 + nb_bdy_fld(jbdy) 
-         CALL fld_fill( bf(jstart:jend), blf_i(jstart:jend), cn_dir_array(jbdy), 'bdy_dta',   &
-         &              'open boundary conditions', 'nambdy_dta' )
-         jstart = jend + 1
-      ENDDO
-
-      DO jfld = 1, nb_bdy_fld_sum
-         bf(jfld)%igrd = igrid(jfld)
-         bf(jfld)%ibdy = ibdy(jfld)
-      ENDDO
-
-      ! Initialise local boundary data arrays
-      ! nn_xxx_dta=0 : allocate space - will be filled from initial conditions later
-      ! nn_xxx_dta=1 : point to "fnow" arrays
-      !-------------------------------------
-
-      jfld = 0
-      DO jbdy=1, nb_bdy
-
-         nblen => idx_bdy(jbdy)%nblen
-         dta => dta_bdy(jbdy)
-
-         if(lwp) then
-            write(numout,*) '++++++ dta%ll_ssh = ',dta%ll_ssh
-            write(numout,*) '++++++ dta%ll_u2d = ',dta%ll_u2d
-            write(numout,*) '++++++ dta%ll_v2d = ',dta%ll_v2d
-            write(numout,*) '++++++ dta%ll_u3d = ',dta%ll_u3d
-            write(numout,*) '++++++ dta%ll_v3d = ',dta%ll_v3d
-            write(numout,*) '++++++ dta%ll_tem = ',dta%ll_tem
-            write(numout,*) '++++++ dta%ll_sal = ',dta%ll_sal
-         endif
-
-         IF ( nn_dyn2d_dta(jbdy) == 0 .or. nn_dyn2d_dta(jbdy) == 2 ) THEN
-            if(lwp) write(numout,*) '++++++ dta%ssh/u2d/u3d allocated space'
-            IF( dta%ll_ssh ) ALLOCATE( dta%ssh(nblen(1)) )
-            IF( dta%ll_u2d ) ALLOCATE( dta%u2d(nblen(2)) )
-            IF( dta%ll_v2d ) ALLOCATE( dta%v2d(nblen(3)) )
-         ENDIF
-         IF ( nn_dyn2d_dta(jbdy) == 1 .or. nn_dyn2d_dta(jbdy) == 3 ) THEN
-            IF( dta%ll_ssh ) THEN
-               if(lwp) write(numout,*) '++++++ dta%ssh pointing to fnow'
-               jfld = jfld + 1
-               dta%ssh => bf(jfld)%fnow(:,1,1)
-            ENDIF
-            IF ( dta%ll_u2d ) THEN
-               IF ( ln_full_vel_array(jbdy) ) THEN
-                  if(lwp) write(numout,*) '++++++ dta%u2d allocated space'
-                  ALLOCATE( dta%u2d(nblen(2)) )
-               ELSE
-                  if(lwp) write(numout,*) '++++++ dta%u2d pointing to fnow'
-                  jfld = jfld + 1
-                  dta%u2d => bf(jfld)%fnow(:,1,1)
-               ENDIF
-            ENDIF
-            IF ( dta%ll_v2d ) THEN
-               IF ( ln_full_vel_array(jbdy) ) THEN
-                  if(lwp) write(numout,*) '++++++ dta%v2d allocated space'
-                  ALLOCATE( dta%v2d(nblen(3)) )
-               ELSE
-                  if(lwp) write(numout,*) '++++++ dta%v2d pointing to fnow'
-                  jfld = jfld + 1
-                  dta%v2d => bf(jfld)%fnow(:,1,1)
-               ENDIF
-            ENDIF
-         ENDIF
-
-         IF ( nn_dyn3d_dta(jbdy) == 0 ) THEN
-            if(lwp) write(numout,*) '++++++ dta%u3d/v3d allocated space'
-            IF( dta%ll_u3d ) ALLOCATE( dta_bdy(jbdy)%u3d(nblen(2),jpk) )
-            IF( dta%ll_v3d ) ALLOCATE( dta_bdy(jbdy)%v3d(nblen(3),jpk) )
-         ENDIF
-         IF ( nn_dyn3d_dta(jbdy) == 1 .or. &
-           &  ( ln_full_vel_array(jbdy) .and. ( nn_dyn2d_dta(jbdy) == 1 .or. nn_dyn2d_dta(jbdy) == 3 ) ) ) THEN
-            IF ( dta%ll_u3d .or. ( ln_full_vel_array(jbdy) .and. dta%ll_u2d ) ) THEN
-               if(lwp) write(numout,*) '++++++ dta%u3d pointing to fnow'
-               jfld = jfld + 1
-               dta_bdy(jbdy)%u3d => bf(jfld)%fnow(:,1,:)
-            ENDIF
-            IF ( dta%ll_v3d .or. ( ln_full_vel_array(jbdy) .and. dta%ll_v2d ) ) THEN
-               if(lwp) write(numout,*) '++++++ dta%v3d pointing to fnow'
-               jfld = jfld + 1
-               dta_bdy(jbdy)%v3d => bf(jfld)%fnow(:,1,:)
-            ENDIF
-         ENDIF
-
-         IF( nn_tra_dta(jbdy) == 0 ) THEN
-            if(lwp) write(numout,*) '++++++ dta%tem/sal allocated space'
-            IF( dta%ll_tem ) ALLOCATE( dta_bdy(jbdy)%tem(nblen(1),jpk) )
-            IF( dta%ll_sal ) ALLOCATE( dta_bdy(jbdy)%sal(nblen(1),jpk) )
-         ELSE
-            IF( dta%ll_tem ) THEN
-               if(lwp) write(numout,*) '++++++ dta%tem pointing to fnow'
-               jfld = jfld + 1
-               dta_bdy(jbdy)%tem => bf(jfld)%fnow(:,1,:)
-            ENDIF
-            IF( dta%ll_sal ) THEN 
-               if(lwp) write(numout,*) '++++++ dta%sal pointing to fnow'
-               jfld = jfld + 1
-               dta_bdy(jbdy)%sal => bf(jfld)%fnow(:,1,:)
-            ENDIF
-         ENDIF
-
-#if defined key_si3
-         IF (cn_ice(jbdy) /= 'none') THEN
-            IF( nn_ice_dta(jbdy) == 0 ) THEN
-               ALLOCATE( dta_bdy(jbdy)%a_i(nblen(1),jpl) )
-               ALLOCATE( dta_bdy(jbdy)%h_i(nblen(1),jpl) )
-               ALLOCATE( dta_bdy(jbdy)%h_s(nblen(1),jpl) )
-            ELSE
-               IF ( nice_cat == jpl ) THEN ! case input cat = jpl
-                  jfld = jfld + 1
-                  dta_bdy(jbdy)%a_i => bf(jfld)%fnow(:,1,:)
-                  jfld = jfld + 1
-                  dta_bdy(jbdy)%h_i => bf(jfld)%fnow(:,1,:)
-                  jfld = jfld + 1
-                  dta_bdy(jbdy)%h_s => bf(jfld)%fnow(:,1,:)
-               ELSE                        ! case input cat = 1 OR (/=1 and /=jpl)
-                  jfld_ait(jbdy)  = jfld + 1
-                  jfld_htit(jbdy) = jfld + 2
-                  jfld_htst(jbdy) = jfld + 3
-                  jfld     = jfld + 3
-                  ALLOCATE( dta_bdy(jbdy)%a_i(nblen(1),jpl) )
-                  ALLOCATE( dta_bdy(jbdy)%h_i(nblen(1),jpl) )
-                  ALLOCATE( dta_bdy(jbdy)%h_s(nblen(1),jpl) )
-                  dta_bdy(jbdy)%a_i(:,:) = 0._wp
-                  dta_bdy(jbdy)%h_i(:,:) = 0._wp
-                  dta_bdy(jbdy)%h_s(:,:) = 0._wp
-               ENDIF
-
-            ENDIF
-         ENDIF
-#endif
+               IF( llread ) THEN                                           ! get data from NetCDF file
+                  CALL fld_fill( bf_alias, bn_alias, cn_dir, 'bdy_dta', cl3//' '//ctmp1, ctmp2 )   ! use namelist info
+                  IF( bf_alias(1)%ln_tint ) ALLOCATE( bf_alias(1)%fdta( iszdim, 1, ipk, 2 ) )
+                  bf_alias(1)%imap    => idx_bdy(jbdy)%nbmap(1:iszdim,igrd)   ! associate the mapping used for this bdy
+                  bf_alias(1)%igrd    = igrd                                  ! used only for vertical integration of 3D arrays
+                  bf_alias(1)%ibdy    = jbdy                                  !  "    "    "     "          "      "  "    "    
+                  bf_alias(1)%ltotvel = ln_full_vel                           ! T if u3d is full velocity
+                  bf_alias(1)%lzint   = ln_zinterp                            ! T if it requires a vertical interpolation
+               ENDIF
+
+               ! associate the pointer and get rid of the dimensions with a size equal to 1
+               IF( jfld == jp_bdyssh )        dta_bdy(jbdy)%ssh => bf_alias(1)%fnow(:,1,1)
+               IF( jfld == jp_bdyu2d )        dta_bdy(jbdy)%u2d => bf_alias(1)%fnow(:,1,1)
+               IF( jfld == jp_bdyv2d )        dta_bdy(jbdy)%v2d => bf_alias(1)%fnow(:,1,1)
+               IF( jfld == jp_bdyu3d )        dta_bdy(jbdy)%u3d => bf_alias(1)%fnow(:,1,:)
+               IF( jfld == jp_bdyv3d )        dta_bdy(jbdy)%v3d => bf_alias(1)%fnow(:,1,:)
+               IF( jfld == jp_bdytem )        dta_bdy(jbdy)%tem => bf_alias(1)%fnow(:,1,:)
+               IF( jfld == jp_bdysal )        dta_bdy(jbdy)%sal => bf_alias(1)%fnow(:,1,:)
+               IF( jfld == jp_bdya_i ) THEN
+                  IF( ipk == jpl ) THEN   ;   dta_bdy(jbdy)%a_i => bf_alias(1)%fnow(:,1,:)
+                  ELSE                    ;   ALLOCATE( dta_bdy(jbdy)%a_i(iszdim,jpl) )
+                  ENDIF
+               ENDIF
+               IF( jfld == jp_bdyh_i ) THEN
+                  IF( ipk == jpl ) THEN   ;   dta_bdy(jbdy)%h_i => bf_alias(1)%fnow(:,1,:)
+                  ELSE                    ;   ALLOCATE( dta_bdy(jbdy)%h_i(iszdim,jpl) )
+                  ENDIF
+               ENDIF
+               IF( jfld == jp_bdyh_s ) THEN
+                  IF( ipk == jpl ) THEN   ;   dta_bdy(jbdy)%h_s => bf_alias(1)%fnow(:,1,:)
+                  ELSE                    ;   ALLOCATE( dta_bdy(jbdy)%h_s(iszdim,jpl) )
+                  ENDIF
+               ENDIF
+               IF( jfld == jp_bdyt_i ) THEN
+                  IF( ipk == jpl ) THEN   ;   dta_bdy(jbdy)%t_i => bf_alias(1)%fnow(:,1,:)
+                  ELSE                    ;   ALLOCATE( dta_bdy(jbdy)%t_i(iszdim,jpl) )
+                  ENDIF
+               ENDIF
+               IF( jfld == jp_bdyt_s ) THEN
+                  IF( ipk == jpl ) THEN   ;   dta_bdy(jbdy)%t_s => bf_alias(1)%fnow(:,1,:)
+                  ELSE                    ;   ALLOCATE( dta_bdy(jbdy)%t_s(iszdim,jpl) )
+                  ENDIF
+               ENDIF
+               IF( jfld == jp_bdytsu ) THEN
+                  IF( ipk == jpl ) THEN   ;   dta_bdy(jbdy)%tsu => bf_alias(1)%fnow(:,1,:)
+                  ELSE                    ;   ALLOCATE( dta_bdy(jbdy)%tsu(iszdim,jpl) )
+                  ENDIF
+               ENDIF
+               IF( jfld == jp_bdys_i ) THEN
+                  IF( ipk == jpl ) THEN   ;   dta_bdy(jbdy)%s_i => bf_alias(1)%fnow(:,1,:)
+                  ELSE                    ;   ALLOCATE( dta_bdy(jbdy)%s_i(iszdim,jpl) )
+                  ENDIF
+               ENDIF
+               IF( jfld == jp_bdyaip ) THEN
+                  IF( ipk == jpl ) THEN   ;   dta_bdy(jbdy)%aip => bf_alias(1)%fnow(:,1,:)
+                  ELSE                    ;   ALLOCATE( dta_bdy(jbdy)%aip(iszdim,jpl) )
+                  ENDIF
+               ENDIF
+               IF( jfld == jp_bdyhip ) THEN
+                  IF( ipk == jpl ) THEN   ;   dta_bdy(jbdy)%hip => bf_alias(1)%fnow(:,1,:)
+                  ELSE                    ;   ALLOCATE( dta_bdy(jbdy)%hip(iszdim,jpl) )
+                  ENDIF
+               ENDIF
+            ENDIF
+
+         END DO   ! jpbdyfld
          !
       END DO ! jbdy 
       !
    END SUBROUTINE bdy_dta_init
-
+   
    !!==============================================================================
 END MODULE bdydta
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdydyn2d.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdydyn2d.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdydyn2d.F90	(revision 12143)
@@ -14,5 +14,4 @@
    !!   bdy_ssh            : Duplicate sea level across open boundaries
    !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers 
    USE dom_oce         ! ocean space and time domain
    USE bdy_oce         ! ocean open boundary conditions
@@ -50,26 +49,65 @@
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: pssh
       !!
-      INTEGER                                  ::   ib_bdy ! Loop counter
-
-      DO ib_bdy=1, nb_bdy
-
-         SELECT CASE( cn_dyn2d(ib_bdy) )
-         CASE('none')
-            CYCLE
-         CASE('frs')
-            CALL bdy_dyn2d_frs( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, pua2d, pva2d )
-         CASE('flather')
-            CALL bdy_dyn2d_fla( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, pua2d, pva2d, pssh, phur, phvr )
-         CASE('orlanski')
-            CALL bdy_dyn2d_orlanski( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, &
-                                     & pua2d, pva2d, pub2d, pvb2d, ll_npo=.false.)
-         CASE('orlanski_npo')
-            CALL bdy_dyn2d_orlanski( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, &
-                                     & pua2d, pva2d, pub2d, pvb2d, ll_npo=.true. )
-         CASE DEFAULT
-            CALL ctl_stop( 'bdy_dyn2d : unrecognised option for open boundaries for barotropic variables' )
-         END SELECT
-      ENDDO
-
+      INTEGER  ::   ib_bdy, ir     ! BDY set index, rim index
+      LOGICAL  ::   llrim0         ! indicate if rim 0 is treated
+      LOGICAL, DIMENSION(4) :: llsend2, llrecv2, llsend3, llrecv3  ! indicate how communications are to be carried out
+      
+      llsend2(:) = .false.   ;   llrecv2(:) = .false.
+      llsend3(:) = .false.   ;   llrecv3(:) = .false.
+      DO ir = 1, 0, -1   ! treat rim 1 before rim 0
+         IF( ir == 0 ) THEN   ;   llrim0 = .TRUE.
+         ELSE                 ;   llrim0 = .FALSE.
+         END IF
+         DO ib_bdy=1, nb_bdy
+            SELECT CASE( cn_dyn2d(ib_bdy) )
+            CASE('none')
+               CYCLE
+            CASE('frs')   ! treat the whole boundary at once
+               IF( llrim0 )   CALL bdy_dyn2d_frs( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, pua2d, pva2d )
+            CASE('flather')
+               CALL bdy_dyn2d_fla( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, pua2d, pva2d, pssh, phur, phvr, llrim0 )
+            CASE('orlanski')
+               CALL bdy_dyn2d_orlanski( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, &
+                    & pua2d, pva2d, pub2d, pvb2d, llrim0, ll_npo=.false. )
+            CASE('orlanski_npo')
+               CALL bdy_dyn2d_orlanski( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, &
+                    & pua2d, pva2d, pub2d, pvb2d, llrim0, ll_npo=.true.  )
+            CASE DEFAULT
+               CALL ctl_stop( 'bdy_dyn2d : unrecognised option for open boundaries for barotropic variables' )
+            END SELECT
+         ENDDO
+         !
+         IF( nn_hls > 1 .AND. ir == 1 ) CYCLE   ! at least 2 halos will be corrected -> no need to correct rim 1 before rim 0
+         IF( nn_hls == 1 ) THEN
+            llsend2(:) = .false.   ;   llrecv2(:) = .false.
+            llsend3(:) = .false.   ;   llrecv3(:) = .false.
+         END IF
+         DO ib_bdy=1, nb_bdy
+            SELECT CASE( cn_dyn2d(ib_bdy) )
+            CASE('flather')
+               llsend2(1:2) = llsend2(1:2) .OR. lsend_bdyint(ib_bdy,2,1:2,ir)   ! west/east, U points
+               llsend2(1)   = llsend2(1)   .OR. lsend_bdyext(ib_bdy,2,1,ir)     ! neighbour might search point towards its east bdy
+               llrecv2(1:2) = llrecv2(1:2) .OR. lrecv_bdyint(ib_bdy,2,1:2,ir)   ! west/east, U points
+               llrecv2(2)   = llrecv2(2)   .OR. lrecv_bdyext(ib_bdy,2,2,ir)     ! might search point towards bdy on the east
+               llsend3(3:4) = llsend3(3:4) .OR. lsend_bdyint(ib_bdy,3,3:4,ir)   ! north/south, V points
+               llsend3(3)   = llsend3(3)   .OR. lsend_bdyext(ib_bdy,3,3,ir)     ! neighbour might search point towards its north bdy 
+               llrecv3(3:4) = llrecv3(3:4) .OR. lrecv_bdyint(ib_bdy,3,3:4,ir)   ! north/south, V points
+               llrecv3(4)   = llrecv3(4)   .OR. lrecv_bdyext(ib_bdy,3,4,ir)     ! might search point towards bdy on the north
+            CASE('orlanski', 'orlanski_npo')
+               llsend2(:) = llsend2(:) .OR. lsend_bdy(ib_bdy,2,:,ir)   ! possibly every direction, U points
+               llrecv2(:) = llrecv2(:) .OR. lrecv_bdy(ib_bdy,2,:,ir)   ! possibly every direction, U points
+               llsend3(:) = llsend3(:) .OR. lsend_bdy(ib_bdy,3,:,ir)   ! possibly every direction, V points
+               llrecv3(:) = llrecv3(:) .OR. lrecv_bdy(ib_bdy,3,:,ir)   ! possibly every direction, V points
+            END SELECT
+         END DO
+         IF( ANY(llsend2) .OR. ANY(llrecv2) ) THEN   ! if need to send/recv in at least one direction
+            CALL lbc_lnk( 'bdydyn2d', pua2d, 'U', -1., kfillmode=jpfillnothing ,lsend=llsend2, lrecv=llrecv2 )
+         END IF
+         IF( ANY(llsend3) .OR. ANY(llrecv3) ) THEN   ! if need to send/recv in at least one direction
+            CALL lbc_lnk( 'bdydyn2d', pva2d, 'V', -1., kfillmode=jpfillnothing ,lsend=llsend3, lrecv=llrecv3 )
+         END IF
+         !
+      END DO   ! ir
+      !
    END SUBROUTINE bdy_dyn2d
 
@@ -90,5 +128,5 @@
       REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pua2d, pva2d 
       !!
-      INTEGER  ::   jb, jk         ! dummy loop indices
+      INTEGER  ::   jb             ! dummy loop indices
       INTEGER  ::   ii, ij, igrd   ! local integers
       REAL(wp) ::   zwgt           ! boundary weight
@@ -110,11 +148,9 @@
          pva2d(ii,ij) = ( pva2d(ii,ij) + zwgt * ( dta%v2d(jb) - pva2d(ii,ij) ) ) * vmask(ii,ij,1)
       END DO 
-      CALL lbc_bdy_lnk( 'bdydyn2d', pua2d, 'U', -1., ib_bdy ) 
-      CALL lbc_bdy_lnk( 'bdydyn2d', pva2d, 'V', -1., ib_bdy)   ! Boundary points should be updated
       !
    END SUBROUTINE bdy_dyn2d_frs
 
 
-   SUBROUTINE bdy_dyn2d_fla( idx, dta, ib_bdy, pua2d, pva2d, pssh, phur, phvr )
+   SUBROUTINE bdy_dyn2d_fla( idx, dta, ib_bdy, pua2d, pva2d, pssh, phur, phvr, llrim0 )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_dyn2d_fla  ***
@@ -139,12 +175,15 @@
       INTEGER,                      INTENT(in) ::   ib_bdy  ! BDY set index
       REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pua2d, pva2d
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pssh, phur, phvr 
-
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pssh, phur, phvr
+      LOGICAL                     , INTENT(in) ::   llrim0   ! indicate if rim 0 is treated
+      INTEGER  ::   ibeg, iend                       ! length of rim to be treated (rim 0 or rim 1)
       INTEGER  ::   jb, igrd                         ! dummy loop indices
-      INTEGER  ::   ii, ij, iim1, iip1, ijm1, ijp1   ! 2D addresses
-      REAL(wp), POINTER :: flagu, flagv              ! short cuts
-      REAL(wp) ::   zcorr                            ! Flather correction
-      REAL(wp) ::   zforc                            ! temporary scalar
-      REAL(wp) ::   zflag, z1_2                      !    "        "
+      INTEGER  ::   ii, ij                           ! 2D addresses
+      INTEGER  ::   iiTrim, ijTrim                   ! T pts i/j-indice on the rim
+      INTEGER  ::   iiToce, ijToce, iiUoce, ijVoce   ! T, U and V pts i/j-indice of the ocean next to the rim
+      REAL(wp) ::   flagu, flagv                     ! short cuts
+      REAL(wp) ::   zfla                             ! Flather correction
+      REAL(wp) ::   z1_2                             ! 
+      REAL(wp), DIMENSION(jpi,jpj) ::   sshdta       ! 2D version of dta%ssh
       !!----------------------------------------------------------------------
 
@@ -153,66 +192,77 @@
       ! ---------------------------------!
       ! Flather boundary conditions     :!
-      ! ---------------------------------! 
-     
-!!! REPLACE spgu with nemo_wrk work space
-
-      ! Fill temporary array with ssh data (here spgu):
+      ! ---------------------------------!
+
+      ! Fill temporary array with ssh data (here we use spgu with the alias sshdta):
       igrd = 1
-      spgu(:,:) = 0.0
-      DO jb = 1, idx%nblenrim(igrd)
+      IF( llrim0 ) THEN   ;   ibeg = 1                       ;   iend = idx%nblenrim0(igrd)
+      ELSE                ;   ibeg = idx%nblenrim0(igrd)+1   ;   iend = idx%nblenrim(igrd)
+      END IF
+      !
+      DO jb = ibeg, iend
          ii = idx%nbi(jb,igrd)
          ij = idx%nbj(jb,igrd)
-         IF( ll_wd ) THEN
-            spgu(ii, ij) = dta%ssh(jb)  - ssh_ref 
-         ELSE
-            spgu(ii, ij) = dta%ssh(jb)
+         IF( ll_wd ) THEN   ;   sshdta(ii, ij) = dta%ssh(jb) - ssh_ref 
+         ELSE               ;   sshdta(ii, ij) = dta%ssh(jb)
          ENDIF
       END DO
-
-      CALL lbc_bdy_lnk( 'bdydyn2d', spgu(:,:), 'T', 1., ib_bdy )
-      !
-      igrd = 2      ! Flather bc on u-velocity; 
+      !
+      igrd = 2      ! Flather bc on u-velocity
       !             ! remember that flagu=-1 if normal velocity direction is outward
       !             ! I think we should rather use after ssh ?
-      DO jb = 1, idx%nblenrim(igrd)
-         ii  = idx%nbi(jb,igrd)
-         ij  = idx%nbj(jb,igrd) 
-         flagu => idx%flagu(jb,igrd)
-         iim1 = ii + MAX( 0, INT( flagu ) )   ! T pts i-indice inside the boundary
-         iip1 = ii - MIN( 0, INT( flagu ) )   ! T pts i-indice outside the boundary 
-         !
-         zcorr = - flagu * SQRT( grav * phur(ii, ij) ) * ( pssh(iim1, ij) - spgu(iip1,ij) )
-
-         ! jchanut tschanges: Set zflag to 0 below to revert to Flather scheme
-         ! Use characteristics method instead
-         zflag = ABS(flagu)
-         zforc = dta%u2d(jb) * (1._wp - z1_2*zflag) + z1_2 * zflag * pua2d(ii+NINT(flagu),ij)
-         pua2d(ii,ij) = zforc + (1._wp - z1_2*zflag) * zcorr * umask(ii,ij,1) 
+      IF( llrim0 ) THEN   ;   ibeg = 1                       ;   iend = idx%nblenrim0(igrd)
+      ELSE                ;   ibeg = idx%nblenrim0(igrd)+1   ;   iend = idx%nblenrim(igrd)
+      END IF
+      DO jb = ibeg, iend
+         ii    = idx%nbi(jb,igrd)
+         ij    = idx%nbj(jb,igrd)
+         flagu = idx%flagu(jb,igrd)
+         IF( flagu == 0. ) THEN
+            pua2d(ii,ij) = dta%u2d(jb)
+         ELSE      ! T pts j-indice       on the rim          on the ocean next to the rim on T and U points
+            IF( flagu ==  1. ) THEN   ;   iiTrim = ii     ;   iiToce = ii+1   ;   iiUoce = ii+1   ;   ENDIF
+            IF( flagu == -1. ) THEN   ;   iiTrim = ii+1   ;   iiToce = ii     ;   iiUoce = ii-1   ;   ENDIF
+            !
+            ! Rare case : rim is parallel to the mpi subdomain border and on the halo : point will be received
+            IF( iiTrim > jpi .OR. iiToce > jpi .OR. iiUoce > jpi .OR. iiUoce < 1 )   CYCLE   
+            !
+            zfla = dta%u2d(jb) - flagu * SQRT( grav * phur(ii, ij) ) * ( pssh(iiToce,ij) - sshdta(iiTrim,ij) )
+            !
+            ! jchanut tschanges, use characteristics method (Blayo et Debreu, 2005) :
+            ! mix Flather scheme with velocity of the ocean next to the rim
+            pua2d(ii,ij) =  z1_2 * ( pua2d(iiUoce,ij) + zfla )
+         END IF
       END DO
       !
       igrd = 3      ! Flather bc on v-velocity
       !             ! remember that flagv=-1 if normal velocity direction is outward
-      DO jb = 1, idx%nblenrim(igrd)
-         ii  = idx%nbi(jb,igrd)
-         ij  = idx%nbj(jb,igrd) 
-         flagv => idx%flagv(jb,igrd)
-         ijm1 = ij + MAX( 0, INT( flagv ) )   ! T pts j-indice inside the boundary
-         ijp1 = ij - MIN( 0, INT( flagv ) )   ! T pts j-indice outside the boundary 
-         !
-         zcorr = - flagv * SQRT( grav * phvr(ii, ij) ) * ( pssh(ii, ijm1) - spgu(ii,ijp1) )
-
-         ! jchanut tschanges: Set zflag to 0 below to revert to std Flather scheme
-         ! Use characteristics method instead
-         zflag = ABS(flagv)
-         zforc  = dta%v2d(jb) * (1._wp - z1_2*zflag) + z1_2 * zflag * pva2d(ii,ij+NINT(flagv))
-         pva2d(ii,ij) = zforc + (1._wp - z1_2*zflag) * zcorr * vmask(ii,ij,1)
-      END DO
-      CALL lbc_bdy_lnk( 'bdydyn2d', pua2d, 'U', -1., ib_bdy )   ! Boundary points should be updated
-      CALL lbc_bdy_lnk( 'bdydyn2d', pva2d, 'V', -1., ib_bdy )   !
+      IF( llrim0 ) THEN   ;   ibeg = 1                       ;   iend = idx%nblenrim0(igrd)
+      ELSE                ;   ibeg = idx%nblenrim0(igrd)+1   ;   iend = idx%nblenrim(igrd)
+      END IF
+      DO jb = ibeg, iend
+         ii    = idx%nbi(jb,igrd)
+         ij    = idx%nbj(jb,igrd)
+         flagv = idx%flagv(jb,igrd)
+         IF( flagv == 0. ) THEN
+            pva2d(ii,ij) = dta%v2d(jb)
+         ELSE      ! T pts j-indice       on the rim          on the ocean next to the rim on T and V points
+            IF( flagv ==  1. ) THEN   ;   ijTrim = ij     ;   ijToce = ij+1   ;   ijVoce = ij+1   ;   ENDIF
+            IF( flagv == -1. ) THEN   ;   ijTrim = ij+1   ;   ijToce = ij     ;   ijVoce = ij-1   ;   ENDIF
+            !
+            ! Rare case : rim is parallel to the mpi subdomain border and on the halo : point will be received
+            IF( ijTrim > jpj .OR. ijToce > jpj .OR. ijVoce > jpj .OR. ijVoce < 1 )   CYCLE
+            !
+            zfla = dta%v2d(jb) - flagv * SQRT( grav * phvr(ii, ij) ) * ( pssh(ii,ijToce) - sshdta(ii,ijTrim) )
+            !
+            ! jchanut tschanges, use characteristics method (Blayo et Debreu, 2005) :
+            ! mix Flather scheme with velocity of the ocean next to the rim
+            pva2d(ii,ij) =  z1_2 * ( pva2d(ii,ijVoce) + zfla )
+         END IF
+      END DO
       !
    END SUBROUTINE bdy_dyn2d_fla
 
 
-   SUBROUTINE bdy_dyn2d_orlanski( idx, dta, ib_bdy, pua2d, pva2d, pub2d, pvb2d, ll_npo )
+   SUBROUTINE bdy_dyn2d_orlanski( idx, dta, ib_bdy, pua2d, pva2d, pub2d, pvb2d, llrim0, ll_npo )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_dyn2d_orlanski  ***
@@ -231,5 +281,5 @@
       REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pub2d, pvb2d 
       LOGICAL,                      INTENT(in) ::   ll_npo  ! flag for NPO version
-
+      LOGICAL,                      INTENT(in) ::   llrim0   ! indicate if rim 0 is treated
       INTEGER  ::   ib, igrd                               ! dummy loop indices
       INTEGER  ::   ii, ij, iibm1, ijbm1                   ! indices
@@ -238,12 +288,9 @@
       igrd = 2      ! Orlanski bc on u-velocity; 
       !            
-      CALL bdy_orlanski_2d( idx, igrd, pub2d, pua2d, dta%u2d, ll_npo )
+      CALL bdy_orlanski_2d( idx, igrd, pub2d, pua2d, dta%u2d, llrim0, ll_npo )
 
       igrd = 3      ! Orlanski bc on v-velocity
       !  
-      CALL bdy_orlanski_2d( idx, igrd, pvb2d, pva2d, dta%v2d, ll_npo )
-      !
-      CALL lbc_bdy_lnk( 'bdydyn2d', pua2d, 'U', -1., ib_bdy )   ! Boundary points should be updated
-      CALL lbc_bdy_lnk( 'bdydyn2d', pva2d, 'V', -1., ib_bdy )   !
+      CALL bdy_orlanski_2d( idx, igrd, pvb2d, pva2d, dta%v2d, llrim0, ll_npo )
       !
    END SUBROUTINE bdy_dyn2d_orlanski
@@ -257,36 +304,28 @@
       !!
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   zssh ! Sea level
-      !!
-      INTEGER  ::   ib_bdy, ib, igrd                        ! local integers
-      INTEGER  ::   ii, ij, zcoef, zcoef1, zcoef2, ip, jp   !   "       "
-
-      igrd = 1                       ! Everything is at T-points here
-
-      DO ib_bdy = 1, nb_bdy
-         DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
-            ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
-            ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
-            ! Set gradient direction:
-            zcoef1 = bdytmask(ii-1,ij  ) +  bdytmask(ii+1,ij  )
-            zcoef2 = bdytmask(ii  ,ij-1) +  bdytmask(ii  ,ij+1)
-            IF ( zcoef1+zcoef2 == 0 ) THEN   ! corner
-               zcoef = bdytmask(ii-1,ij-1) + bdytmask(ii+1,ij+1) + bdytmask(ii+1,ij-1) + bdytmask(ii-1,ij+1)
-               zssh(ii,ij) = zssh( ii-1, ij-1 ) * bdytmask( ii-1, ij-1) + &
-                 &           zssh( ii+1, ij+1 ) * bdytmask( ii+1, ij+1) + &
-                 &           zssh( ii+1, ij-1 ) * bdytmask( ii+1, ij-1) + &
-                 &           zssh( ii-1, ij+1 ) * bdytmask( ii-1, ij+1)
-               zssh(ii,ij) = ( zssh(ii,ij) / MAX( 1, zcoef) ) * tmask(ii,ij,1)
-            ELSE
-               ip = bdytmask(ii+1,ij  ) - bdytmask(ii-1,ij  )
-               jp = bdytmask(ii  ,ij+1) - bdytmask(ii  ,ij-1)
-               zssh(ii,ij) = zssh(ii+ip,ij+jp) * tmask(ii+ip,ij+jp,1)
-            ENDIF
+      REAL(wp), DIMENSION(jpi,jpj,1), INTENT(inout) ::   zssh ! Sea level, need 3 dimensions to be used by bdy_nmn
+      !!
+      INTEGER ::   ib_bdy, ir      ! bdy index, rim index
+      INTEGER ::   ibeg, iend      ! length of rim to be treated (rim 0 or rim 1)
+      LOGICAL ::   llrim0          ! indicate if rim 0 is treated
+      LOGICAL, DIMENSION(4) :: llsend1, llrecv1  ! indicate how communications are to be carried out
+      !!----------------------------------------------------------------------
+      llsend1(:) = .false.   ;   llrecv1(:) = .false.
+      DO ir = 1, 0, -1   ! treat rim 1 before rim 0
+         IF( nn_hls == 1 ) THEN   ;   llsend1(:) = .false.   ;   llrecv1(:) = .false.   ;   END IF
+         IF( ir == 0 ) THEN   ;   llrim0 = .TRUE.
+         ELSE                 ;   llrim0 = .FALSE.
+         END IF
+         DO ib_bdy = 1, nb_bdy
+            CALL bdy_nmn( idx_bdy(ib_bdy), 1, zssh, llrim0 )   ! zssh is masked
+            llsend1(:) = llsend1(:) .OR. lsend_bdyint(ib_bdy,1,:,ir)   ! possibly every direction, T points
+            llrecv1(:) = llrecv1(:) .OR. lrecv_bdyint(ib_bdy,1,:,ir)   ! possibly every direction, T points
          END DO
-
-         ! Boundary points should be updated
-         CALL lbc_bdy_lnk( 'bdydyn2d', zssh(:,:), 'T', 1., ib_bdy )
-      END DO
-
+         IF( nn_hls > 1 .AND. ir == 1 ) CYCLE   ! at least 2 halos will be corrected -> no need to correct rim 1 before rim 0
+         IF( ANY(llsend1) .OR. ANY(llrecv1) ) THEN   ! if need to send/recv in at least one direction
+            CALL lbc_lnk( 'bdydyn2d', zssh(:,:,1), 'T',  1., kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
+         END IF
+      END DO
+      !
    END SUBROUTINE bdy_ssh
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdydyn3d.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdydyn3d.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdydyn3d.F90	(revision 12143)
@@ -42,21 +42,65 @@
       INTEGER, INTENT(in) ::   kt   ! Main time step counter
       !
-      INTEGER ::   ib_bdy   ! loop index
-      !!----------------------------------------------------------------------
-      !
-      DO ib_bdy=1, nb_bdy
+      INTEGER  ::   ib_bdy, ir     ! BDY set index, rim index
+      LOGICAL  ::   llrim0         ! indicate if rim 0 is treated
+      LOGICAL, DIMENSION(4) :: llsend2, llrecv2, llsend3, llrecv3  ! indicate how communications are to be carried out
+
+      !!----------------------------------------------------------------------
+      llsend2(:) = .false.   ;   llrecv2(:) = .false.
+      llsend3(:) = .false.   ;   llrecv3(:) = .false.
+      DO ir = 1, 0, -1   ! treat rim 1 before rim 0
+         IF( ir == 0 ) THEN   ;   llrim0 = .TRUE.
+         ELSE                 ;   llrim0 = .FALSE.
+         END IF
+         DO ib_bdy=1, nb_bdy
+            !
+            SELECT CASE( cn_dyn3d(ib_bdy) )
+            CASE('none')        ;   CYCLE
+            CASE('frs' )        ! treat the whole boundary at once
+               IF( ir == 0) CALL bdy_dyn3d_frs( idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy )
+            CASE('specified')   ! treat the whole rim      at once
+               IF( ir == 0) CALL bdy_dyn3d_spe( idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy )
+            CASE('zero')        ! treat the whole rim      at once
+               IF( ir == 0) CALL bdy_dyn3d_zro( idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy )
+            CASE('orlanski' )   ;   CALL bdy_dyn3d_orlanski( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, llrim0, ll_npo=.false. )
+            CASE('orlanski_npo');   CALL bdy_dyn3d_orlanski( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, llrim0, ll_npo=.true.  )
+            CASE('zerograd')    ;   CALL bdy_dyn3d_zgrad( idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy, llrim0 )
+            CASE('neumann')     ;   CALL bdy_dyn3d_nmn( idx_bdy(ib_bdy), ib_bdy, llrim0 )
+            CASE DEFAULT        ;   CALL ctl_stop( 'bdy_dyn3d : unrecognised option for open boundaries for baroclinic velocities' )
+            END SELECT
+         END DO
          !
-         SELECT CASE( cn_dyn3d(ib_bdy) )
-         CASE('none')        ;   CYCLE
-         CASE('frs' )        ;   CALL bdy_dyn3d_frs( idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy )
-         CASE('specified')   ;   CALL bdy_dyn3d_spe( idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy )
-         CASE('zero')        ;   CALL bdy_dyn3d_zro( idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy )
-         CASE('orlanski' )   ;   CALL bdy_dyn3d_orlanski( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, ll_npo=.false. )
-         CASE('orlanski_npo');   CALL bdy_dyn3d_orlanski( idx_bdy(ib_bdy), dta_bdy(ib_bdy), ib_bdy, ll_npo=.true. )
-         CASE('zerograd')    ;   CALL bdy_dyn3d_zgrad( idx_bdy(ib_bdy), dta_bdy(ib_bdy), kt, ib_bdy )
-         CASE('neumann')     ;   CALL bdy_dyn3d_nmn( idx_bdy(ib_bdy), ib_bdy )
-         CASE DEFAULT        ;   CALL ctl_stop( 'bdy_dyn3d : unrecognised option for open boundaries for baroclinic velocities' )
-         END SELECT
-      END DO
+         IF( nn_hls > 1 .AND. ir == 1 ) CYCLE   ! at least 2 halos will be corrected -> no need to correct rim 1 before rim 0
+         IF( nn_hls == 1 ) THEN
+            llsend2(:) = .false.   ;   llrecv2(:) = .false.
+            llsend3(:) = .false.   ;   llrecv3(:) = .false.
+         END IF
+         DO ib_bdy=1, nb_bdy
+            SELECT CASE( cn_dyn3d(ib_bdy) )
+            CASE('orlanski', 'orlanski_npo')
+               llsend2(:) = llsend2(:) .OR. lsend_bdy(ib_bdy,2,:,ir)   ! possibly every direction, U points
+               llrecv2(:) = llrecv2(:) .OR. lrecv_bdy(ib_bdy,2,:,ir)   ! possibly every direction, U points
+               llsend3(:) = llsend3(:) .OR. lsend_bdy(ib_bdy,3,:,ir)   ! possibly every direction, V points
+               llrecv3(:) = llrecv3(:) .OR. lrecv_bdy(ib_bdy,3,:,ir)   ! possibly every direction, V points
+            CASE('zerograd')
+               llsend2(3:4) = llsend2(3:4) .OR. lsend_bdyint(ib_bdy,2,3:4,ir)   ! north/south, U points
+               llrecv2(3:4) = llrecv2(3:4) .OR. lrecv_bdyint(ib_bdy,2,3:4,ir)   ! north/south, U points
+               llsend3(1:2) = llsend3(1:2) .OR. lsend_bdyint(ib_bdy,3,1:2,ir)   ! west/east, V points
+               llrecv3(1:2) = llrecv3(1:2) .OR. lrecv_bdyint(ib_bdy,3,1:2,ir)   ! west/east, V points
+            CASE('neumann')
+               llsend2(:) = llsend2(:) .OR. lsend_bdyint(ib_bdy,2,:,ir)   ! possibly every direction, U points
+               llrecv2(:) = llrecv2(:) .OR. lrecv_bdyint(ib_bdy,2,:,ir)   ! possibly every direction, U points
+               llsend3(:) = llsend3(:) .OR. lsend_bdyint(ib_bdy,3,:,ir)   ! possibly every direction, V points
+               llrecv3(:) = llrecv3(:) .OR. lrecv_bdyint(ib_bdy,3,:,ir)   ! possibly every direction, V points
+            END SELECT
+         END DO
+         !
+         IF( ANY(llsend2) .OR. ANY(llrecv2) ) THEN   ! if need to send/recv in at least one direction
+            CALL lbc_lnk( 'bdydyn2d', ua, 'U', -1., kfillmode=jpfillnothing ,lsend=llsend2, lrecv=llrecv2 )
+         END IF
+         IF( ANY(llsend3) .OR. ANY(llrecv3) ) THEN   ! if need to send/recv in at least one direction
+            CALL lbc_lnk( 'bdydyn2d', va, 'V', -1., kfillmode=jpfillnothing ,lsend=llsend3, lrecv=llrecv3 )
+         END IF
+      END DO   ! ir
       !
    END SUBROUTINE bdy_dyn3d
@@ -78,5 +122,4 @@
       INTEGER  ::   jb, jk         ! dummy loop indices
       INTEGER  ::   ii, ij, igrd   ! local integers
-      REAL(wp) ::   zwgt           ! boundary weight
       !!----------------------------------------------------------------------
       !
@@ -98,13 +141,9 @@
          END DO
       END DO
-      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )   ! Boundary points should be updated  
-      CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1., ib_bdy )   
-      !
-      IF( kt == nit000 )   CLOSE( unit = 102 )
       !
    END SUBROUTINE bdy_dyn3d_spe
 
 
-   SUBROUTINE bdy_dyn3d_zgrad( idx, dta, kt , ib_bdy )
+   SUBROUTINE bdy_dyn3d_zgrad( idx, dta, kt, ib_bdy, llrim0 )
       !!----------------------------------------------------------------------
       !!                  ***  SUBROUTINE bdy_dyn3d_zgrad  ***
@@ -114,39 +153,54 @@
       !!----------------------------------------------------------------------
       INTEGER                     ::   kt
-      TYPE(OBC_INDEX), INTENT(in) ::   idx  ! OBC indices
-      TYPE(OBC_DATA),  INTENT(in) ::   dta  ! OBC external data
-      INTEGER,         INTENT(in) ::   ib_bdy  ! BDY set index
+      TYPE(OBC_INDEX), INTENT(in) ::   idx      ! OBC indices
+      TYPE(OBC_DATA),  INTENT(in) ::   dta      ! OBC external data
+      INTEGER,         INTENT(in) ::   ib_bdy   ! BDY set index
+      LOGICAL,         INTENT(in) ::   llrim0   ! indicate if rim 0 is treated
       !!
       INTEGER  ::   jb, jk         ! dummy loop indices
       INTEGER  ::   ii, ij, igrd   ! local integers
-      REAL(wp) ::   zwgt           ! boundary weight
-      INTEGER  ::   fu, fv
+      INTEGER  ::   flagu, flagv           ! short cuts
+      INTEGER  ::   ibeg, iend     ! length of rim to be treated (rim 0 or rim 1 or both)
       !!----------------------------------------------------------------------
       !
       igrd = 2                      ! Copying tangential velocity into bdy points
-      DO jb = 1, idx%nblenrim(igrd)
-         DO jk = 1, jpkm1
-            ii   = idx%nbi(jb,igrd)
-            ij   = idx%nbj(jb,igrd)
-            fu   = ABS( ABS (NINT( idx%flagu(jb,igrd) ) ) - 1 )
-            ua(ii,ij,jk) = ua(ii,ij,jk) * REAL( 1 - fu) + ( ua(ii,ij+fu,jk) * umask(ii,ij+fu,jk) &
-                        &+ ua(ii,ij-fu,jk) * umask(ii,ij-fu,jk) ) * umask(ii,ij,jk) * REAL( fu )
-         END DO
+      IF( llrim0 ) THEN   ;   ibeg = 1                       ;   iend = idx%nblenrim0(igrd)
+      ELSE                ;   ibeg = idx%nblenrim0(igrd)+1   ;   iend = idx%nblenrim(igrd)
+      ENDIF
+      DO jb = ibeg, iend
+         ii    = idx%nbi(jb,igrd)
+         ij    = idx%nbj(jb,igrd)
+         flagu = NINT(idx%flagu(jb,igrd))
+         flagv = NINT(idx%flagv(jb,igrd))
+         !
+         IF( flagu == 0 )   THEN              ! north/south bdy
+            IF( ij+flagv > jpj .OR. ij+flagv < 1 )   CYCLE      
+            !
+            DO jk = 1, jpkm1
+               ua(ii,ij,jk) = ua(ii,ij+flagv,jk) * umask(ii,ij+flagv,jk)
+            END DO
+            !
+         END IF
       END DO
       !
       igrd = 3                      ! Copying tangential velocity into bdy points
-      DO jb = 1, idx%nblenrim(igrd)
-         DO jk = 1, jpkm1
-            ii   = idx%nbi(jb,igrd)
-            ij   = idx%nbj(jb,igrd)
-            fv   = ABS( ABS (NINT( idx%flagv(jb,igrd) ) ) - 1 )
-            va(ii,ij,jk) = va(ii,ij,jk) * REAL( 1 - fv ) + ( va(ii+fv,ij,jk) * vmask(ii+fv,ij,jk) &
-                        &+ va(ii-fv,ij,jk) * vmask(ii-fv,ij,jk) ) * vmask(ii,ij,jk) * REAL( fv )
-         END DO
-      END DO
-      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )   ! Boundary points should be updated  
-      CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1., ib_bdy )   
-      !
-      IF( kt == nit000 )   CLOSE( unit = 102 )
+      IF( llrim0 ) THEN   ;   ibeg = 1                       ;   iend = idx%nblenrim0(igrd)
+      ELSE                ;   ibeg = idx%nblenrim0(igrd)+1   ;   iend = idx%nblenrim(igrd)
+      ENDIF
+      DO jb = ibeg, iend
+         ii    = idx%nbi(jb,igrd)
+         ij    = idx%nbj(jb,igrd)
+         flagu = NINT(idx%flagu(jb,igrd))
+         flagv = NINT(idx%flagv(jb,igrd))
+         !
+         IF( flagv == 0 )   THEN              !  west/east  bdy
+            IF( ii+flagu > jpi .OR. ii+flagu < 1 )   CYCLE      
+            !
+            DO jk = 1, jpkm1
+               va(ii,ij,jk) = va(ii+flagu,ij,jk) * vmask(ii+flagu,ij,jk)
+            END DO
+            !
+         END IF
+      END DO
       !
    END SUBROUTINE bdy_dyn3d_zgrad
@@ -167,5 +221,4 @@
       INTEGER  ::   ib, ik         ! dummy loop indices
       INTEGER  ::   ii, ij, igrd   ! local integers
-      REAL(wp) ::   zwgt           ! boundary weight
       !!----------------------------------------------------------------------
       !
@@ -178,5 +231,5 @@
          END DO
       END DO
-
+      !
       igrd = 3                       ! Everything is at T-points here
       DO ib = 1, idx%nblenrim(igrd)
@@ -187,8 +240,4 @@
          END DO
       END DO
-      !
-      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )   ;   CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1.,ib_bdy )   ! Boundary points should be updated
-      !
-      IF( kt == nit000 )   CLOSE( unit = 102 )
       !
    END SUBROUTINE bdy_dyn3d_zro
@@ -234,14 +283,10 @@
             va(ii,ij,jk) = ( va(ii,ij,jk) + zwgt * ( dta%v3d(jb,jk) - va(ii,ij,jk) ) ) * vmask(ii,ij,jk)
          END DO
-      END DO 
-      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )    ! Boundary points should be updated
-      CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1., ib_bdy )   
-      !
-      IF( kt == nit000 )   CLOSE( unit = 102 )
+      END DO   
       !
    END SUBROUTINE bdy_dyn3d_frs
 
 
-   SUBROUTINE bdy_dyn3d_orlanski( idx, dta, ib_bdy, ll_npo )
+   SUBROUTINE bdy_dyn3d_orlanski( idx, dta, ib_bdy, llrim0, ll_npo )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_dyn3d_orlanski  ***
@@ -255,6 +300,7 @@
       TYPE(OBC_INDEX),              INTENT(in) ::   idx  ! OBC indices
       TYPE(OBC_DATA),               INTENT(in) ::   dta  ! OBC external data
-      INTEGER,                      INTENT(in) ::   ib_bdy  ! BDY set index
-      LOGICAL,                      INTENT(in) ::   ll_npo  ! switch for NPO version
+      INTEGER,                      INTENT(in) ::   ib_bdy   ! BDY set index
+      LOGICAL,                      INTENT(in) ::   llrim0   ! indicate if rim 0 is treated
+      LOGICAL,                      INTENT(in) ::   ll_npo   ! switch for NPO version
 
       INTEGER  ::   jb, igrd                               ! dummy loop indices
@@ -265,12 +311,9 @@
       igrd = 2      ! Orlanski bc on u-velocity; 
       !            
-      CALL bdy_orlanski_3d( idx, igrd, ub, ua, dta%u3d, ll_npo )
+      CALL bdy_orlanski_3d( idx, igrd, ub, ua, dta%u3d, ll_npo, llrim0 )
 
       igrd = 3      ! Orlanski bc on v-velocity
       !  
-      CALL bdy_orlanski_3d( idx, igrd, vb, va, dta%v3d, ll_npo )
-      !
-      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )    ! Boundary points should be updated
-      CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1., ib_bdy )   
+      CALL bdy_orlanski_3d( idx, igrd, vb, va, dta%v3d, ll_npo, llrim0 )
       !
    END SUBROUTINE bdy_dyn3d_orlanski
@@ -320,6 +363,4 @@
       END DO
       !
-      CALL lbc_lnk_multi( 'bdydyn3d', ua, 'U', -1.,  va, 'V', -1. )   ! Boundary points should be updated
-      !
       IF( ln_timing )   CALL timing_stop('bdy_dyn3d_dmp')
       !
@@ -327,5 +368,5 @@
 
 
-   SUBROUTINE bdy_dyn3d_nmn( idx, ib_bdy )
+   SUBROUTINE bdy_dyn3d_nmn( idx, ib_bdy, llrim0 )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_dyn3d_nmn  ***
@@ -336,8 +377,8 @@
       !!
       !!----------------------------------------------------------------------
-      TYPE(OBC_INDEX),              INTENT(in) ::   idx  ! OBC indices
-      INTEGER,                      INTENT(in) ::   ib_bdy  ! BDY set index
-
-      INTEGER  ::   jb, igrd                               ! dummy loop indices
+      TYPE(OBC_INDEX), INTENT(in) ::   idx      ! OBC indices
+      INTEGER,         INTENT(in) ::   ib_bdy   ! BDY set index
+      LOGICAL,         INTENT(in) ::   llrim0   ! indicate if rim 0 is treated
+      INTEGER  ::   igrd                        ! dummy indice
       !!----------------------------------------------------------------------
       !
@@ -346,12 +387,9 @@
       igrd = 2      ! Neumann bc on u-velocity; 
       !            
-      CALL bdy_nmn( idx, igrd, ua )
+      CALL bdy_nmn( idx, igrd, ua, llrim0 )   ! ua is masked
 
       igrd = 3      ! Neumann bc on v-velocity
       !  
-      CALL bdy_nmn( idx, igrd, va )
-      !
-      CALL lbc_bdy_lnk( 'bdydyn3d', ua, 'U', -1., ib_bdy )    ! Boundary points should be updated
-      CALL lbc_bdy_lnk( 'bdydyn3d', va, 'V', -1., ib_bdy )
+      CALL bdy_nmn( idx, igrd, va, llrim0 )   ! va is masked
       !
    END SUBROUTINE bdy_dyn3d_nmn
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyice.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyice.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyice.F90	(revision 12143)
@@ -55,22 +55,52 @@
       INTEGER, INTENT(in) ::   kt   ! Main time step counter
       !
-      INTEGER ::   jbdy   ! BDY set index
+      INTEGER ::   jbdy, ir                             ! BDY set index, rim index
+      INTEGER ::   ibeg, iend                           ! length of rim to be treated (rim 0 or rim 1)
+      LOGICAL ::   llrim0                               ! indicate if rim 0 is treated
+      LOGICAL, DIMENSION(4)  :: llsend1, llrecv1        ! indicate how communications are to be carried out
       !!----------------------------------------------------------------------
       ! controls
       IF( ln_timing    )   CALL timing_start('bdy_ice_thd')                                                            ! timing
       IF( ln_icediachk )   CALL ice_cons_hsm(0,'bdy_ice_thd', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
+      IF( ln_icediachk )   CALL ice_cons2D  (0,'bdy_ice_thd',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
       !
       CALL ice_var_glo2eqv
       !
-      DO jbdy = 1, nb_bdy
+      llsend1(:) = .false.   ;   llrecv1(:) = .false.
+      DO ir = 1, 0, -1   ! treat rim 1 before rim 0
+         IF( ir == 0 ) THEN   ;   llrim0 = .TRUE.
+         ELSE                 ;   llrim0 = .FALSE.
+         END IF
+         DO jbdy = 1, nb_bdy
+            !
+            SELECT CASE( cn_ice(jbdy) )
+            CASE('none')   ;   CYCLE
+            CASE('frs' )   ;   CALL bdy_ice_frs( idx_bdy(jbdy), dta_bdy(jbdy), kt, jbdy, llrim0 )
+            CASE DEFAULT
+               CALL ctl_stop( 'bdy_ice : unrecognised option for open boundaries for ice fields' )
+            END SELECT
+            !
+         END DO
          !
-         SELECT CASE( cn_ice(jbdy) )
-         CASE('none')   ;   CYCLE
-         CASE('frs' )   ;   CALL bdy_ice_frs( idx_bdy(jbdy), dta_bdy(jbdy), kt, jbdy )
-         CASE DEFAULT
-            CALL ctl_stop( 'bdy_ice : unrecognised option for open boundaries for ice fields' )
-         END SELECT
-         !
-      END DO
+         ! Update bdy points        
+         IF( nn_hls > 1 .AND. ir == 1 ) CYCLE   ! at least 2 halos will be corrected -> no need to correct rim 1 before rim 0
+         IF( nn_hls == 1 ) THEN   ;   llsend1(:) = .false.   ;   llrecv1(:) = .false.   ;   END IF
+         DO jbdy = 1, nb_bdy
+            IF( cn_ice(jbdy) == 'frs' ) THEN
+               llsend1(:) = llsend1(:) .OR. lsend_bdyint(jbdy,1,:,ir)   ! possibly every direction, T points
+               llrecv1(:) = llrecv1(:) .OR. lrecv_bdyint(jbdy,1,:,ir)   ! possibly every direction, T points
+            END IF
+         END DO   ! jbdy
+         IF( ANY(llsend1) .OR. ANY(llrecv1) ) THEN   ! if need to send/recv in at least one direction
+            ! exchange 3d arrays
+            CALL lbc_lnk_multi( 'bdyice', a_i , 'T', 1., h_i , 'T', 1., h_s , 'T', 1., oa_i, 'T', 1. &
+                 &                      , a_ip, 'T', 1., v_ip, 'T', 1., s_i , 'T', 1., t_su, 'T', 1. &
+                 &                      , v_i , 'T', 1., v_s , 'T', 1., sv_i, 'T', 1.                &
+                 &                      , kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1      )
+            ! exchange 4d arrays :   third dimension = 1   and then   third dimension = jpk
+            CALL lbc_lnk_multi( 'bdyice', t_s , 'T', 1., e_s , 'T', 1., kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
+            CALL lbc_lnk_multi( 'bdyice', t_i , 'T', 1., e_i , 'T', 1., kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
+         END IF
+      END DO   ! ir
       !
       CALL ice_cor( kt , 0 )      ! -- In case categories are out of bounds, do a remapping
@@ -80,6 +110,7 @@
       !
       ! controls
+      IF( ln_icectl    )   CALL ice_prt     ( kt, iiceprt, jiceprt, 1, ' - ice thermo bdy - ' )                        ! prints
       IF( ln_icediachk )   CALL ice_cons_hsm(1,'bdy_ice_thd', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
-      IF( ln_icectl    )   CALL ice_prt     ( kt, iiceprt, jiceprt, 1, ' - ice thermo bdy - ' )                        ! prints
+      IF( ln_icediachk )   CALL ice_cons2D  (1,'bdy_ice_thd',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
       IF( ln_timing    )   CALL timing_stop ('bdy_ice_thd')                                                            ! timing
       !
@@ -87,5 +118,5 @@
 
 
-   SUBROUTINE bdy_ice_frs( idx, dta, kt, jbdy )
+   SUBROUTINE bdy_ice_frs( idx, dta, kt, jbdy, llrim0 )
       !!------------------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_ice_frs  ***
@@ -96,29 +127,49 @@
       !!             dimensional baroclinic ocean model with realistic topography. Tellus, 365-382.
       !!------------------------------------------------------------------------------
-      TYPE(OBC_INDEX), INTENT(in) ::   idx     ! OBC indices
-      TYPE(OBC_DATA),  INTENT(in) ::   dta     ! OBC external data
-      INTEGER,         INTENT(in) ::   kt      ! main time-step counter
-      INTEGER,         INTENT(in) ::   jbdy    ! BDY set index
+      TYPE(OBC_INDEX), INTENT(in) ::   idx      ! OBC indices
+      TYPE(OBC_DATA),  INTENT(in) ::   dta      ! OBC external data
+      INTEGER,         INTENT(in) ::   kt       ! main time-step counter
+      INTEGER,         INTENT(in) ::   jbdy     ! BDY set index
+      LOGICAL,         INTENT(in) ::   llrim0   ! indicate if rim 0 is treated
       !
       INTEGER  ::   jpbound            ! 0 = incoming ice
       !                                ! 1 = outgoing ice
+      INTEGER  ::   ibeg, iend         ! length of rim to be treated (rim 0 or rim 1)
       INTEGER  ::   i_bdy, jgrd        ! dummy loop indices
       INTEGER  ::   ji, jj, jk, jl, ib, jb
       REAL(wp) ::   zwgt, zwgt1        ! local scalar
       REAL(wp) ::   ztmelts, zdh
+      REAL(wp), POINTER  :: flagu, flagv              ! short cuts
       !!------------------------------------------------------------------------------
       !
       jgrd = 1      ! Everything is at T-points here
+      IF( llrim0 ) THEN   ;   ibeg = 1                       ;   iend = idx%nblenrim0(jgrd)
+      ELSE                ;   ibeg = idx%nblenrim0(jgrd)+1   ;   iend = idx%nblenrim(jgrd)
+      END IF
       !
       DO jl = 1, jpl
-         DO i_bdy = 1, idx%nblenrim(jgrd)
+         DO i_bdy = ibeg, iend
             ji    = idx%nbi(i_bdy,jgrd)
             jj    = idx%nbj(i_bdy,jgrd)
             zwgt  = idx%nbw(i_bdy,jgrd)
             zwgt1 = 1.e0 - idx%nbw(i_bdy,jgrd)
-            a_i(ji,jj,jl) = ( a_i(ji,jj,jl) * zwgt1 + dta%a_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Leads fraction 
-            h_i(ji,jj,jl) = ( h_i(ji,jj,jl) * zwgt1 + dta%h_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice depth 
-            h_s(ji,jj,jl) = ( h_s(ji,jj,jl) * zwgt1 + dta%h_s(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Snow depth
-
+            a_i (ji,jj,  jl) = ( a_i (ji,jj,  jl) * zwgt1 + dta%a_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice  concentration 
+            h_i (ji,jj,  jl) = ( h_i (ji,jj,  jl) * zwgt1 + dta%h_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice  depth 
+            h_s (ji,jj,  jl) = ( h_s (ji,jj,  jl) * zwgt1 + dta%h_s(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Snow depth
+            t_i (ji,jj,:,jl) = ( t_i (ji,jj,:,jl) * zwgt1 + dta%t_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice  temperature
+            t_s (ji,jj,:,jl) = ( t_s (ji,jj,:,jl) * zwgt1 + dta%t_s(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Snow temperature
+            t_su(ji,jj,  jl) = ( t_su(ji,jj,  jl) * zwgt1 + dta%tsu(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Surf temperature
+            s_i (ji,jj,  jl) = ( s_i (ji,jj,  jl) * zwgt1 + dta%s_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice  salinity
+            a_ip(ji,jj,  jl) = ( a_ip(ji,jj,  jl) * zwgt1 + dta%aip(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice  pond concentration
+            h_ip(ji,jj,  jl) = ( h_ip(ji,jj,  jl) * zwgt1 + dta%hip(i_bdy,jl) * zwgt ) * tmask(ji,jj,1)  ! Ice  pond depth
+            !
+            sz_i(ji,jj,:,jl) = s_i(ji,jj,jl)
+            !
+            ! make sure ponds = 0 if no ponds scheme
+            IF( .NOT.ln_pnd ) THEN
+               a_ip(ji,jj,jl) = 0._wp
+               h_ip(ji,jj,jl) = 0._wp
+            ENDIF
+            !
             ! -----------------
             ! Pathological case
@@ -135,24 +186,34 @@
             h_i(ji,jj,jl) = MIN( hi_max(jl), h_i(ji,jj,jl) + zdh )
             h_s(ji,jj,jl) = MAX( 0._wp, h_s(ji,jj,jl) - zdh * rhoi / rhos ) 
-
+            !
          ENDDO
       ENDDO
-      CALL lbc_bdy_lnk( 'bdyice', a_i(:,:,:), 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', h_i(:,:,:), 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', h_s(:,:,:), 'T', 1., jbdy )
 
       DO jl = 1, jpl
-         DO i_bdy = 1, idx%nblenrim(jgrd)
+         DO i_bdy = ibeg, iend
             ji = idx%nbi(i_bdy,jgrd)
             jj = idx%nbj(i_bdy,jgrd)
-
+            flagu => idx%flagu(i_bdy,jgrd)
+            flagv => idx%flagv(i_bdy,jgrd)
             ! condition on ice thickness depends on the ice velocity
             ! if velocity is outward (strictly), then ice thickness, volume... must be equal to adjacent values
             jpbound = 0   ;   ib = ji   ;   jb = jj
             !
-            IF( u_ice(ji  ,jj  ) < 0. .AND. umask(ji-1,jj  ,1) == 0. )   jpbound = 1 ; ib = ji+1
-            IF( u_ice(ji-1,jj  ) > 0. .AND. umask(ji  ,jj  ,1) == 0. )   jpbound = 1 ; ib = ji-1
-            IF( v_ice(ji  ,jj  ) < 0. .AND. vmask(ji  ,jj-1,1) == 0. )   jpbound = 1 ; jb = jj+1
-            IF( v_ice(ji  ,jj-1) > 0. .AND. vmask(ji  ,jj  ,1) == 0. )   jpbound = 1 ; jb = jj-1
+            IF( flagu ==  1. )   THEN
+               IF( ji+1 > jpi )   CYCLE
+               IF( u_ice(ji  ,jj  ) < 0. )   jpbound = 1 ; ib = ji+1
+            END IF
+            IF( flagu == -1. )   THEN
+               IF( ji-1 < 1   )   CYCLE
+               IF( u_ice(ji-1,jj  ) < 0. )   jpbound = 1 ; ib = ji-1
+            END IF
+            IF( flagv ==  1. )   THEN
+               IF( jj+1 > jpj )   CYCLE
+               IF( v_ice(ji  ,jj  ) < 0. )   jpbound = 1 ; jb = jj+1
+            END IF
+            IF( flagv == -1. )   THEN
+               IF( jj-1 < 1   )   CYCLE
+               IF( v_ice(ji  ,jj-1) < 0. )   jpbound = 1 ; jb = jj-1
+            END IF
             !
             IF( nn_ice_dta(jbdy) == 0 )   jpbound = 0 ; ib = ji ; jb = jj   ! case ice boundaries = initial conditions
@@ -161,33 +222,22 @@
             IF( a_i(ib,jb,jl) > 0._wp ) THEN   ! there is ice at the boundary
                !
-               a_i(ji,jj,jl) = a_i(ib,jb,jl) ! concentration
-               h_i(ji,jj,jl) = h_i(ib,jb,jl) ! thickness ice
-               h_s(ji,jj,jl) = h_s(ib,jb,jl) ! thickness snw
-               !
-               SELECT CASE( jpbound )
-                  !
-               CASE( 0 )   ! velocity is inward
-                  !
-                  oa_i(ji,jj,  jl) = rn_ice_age(jbdy) * a_i(ji,jj,jl) ! age
-                  a_ip(ji,jj,  jl) = 0._wp                            ! pond concentration
-                  v_ip(ji,jj,  jl) = 0._wp                            ! pond volume
-                  t_su(ji,jj,  jl) = rn_ice_tem(jbdy)                 ! temperature surface
-                  t_s (ji,jj,:,jl) = rn_ice_tem(jbdy)                 ! temperature snw
-                  t_i (ji,jj,:,jl) = rn_ice_tem(jbdy)                 ! temperature ice
-                  s_i (ji,jj,  jl) = rn_ice_sal(jbdy)                 ! salinity
-                  sz_i(ji,jj,:,jl) = rn_ice_sal(jbdy)                 ! salinity profile
-                  !
-               CASE( 1 )   ! velocity is outward
-                  !
-                  oa_i(ji,jj,  jl) = oa_i(ib,jb,  jl) ! age
-                  a_ip(ji,jj,  jl) = a_ip(ib,jb,  jl) ! pond concentration
-                  v_ip(ji,jj,  jl) = v_ip(ib,jb,  jl) ! pond volume
-                  t_su(ji,jj,  jl) = t_su(ib,jb,  jl) ! temperature surface
-                  t_s (ji,jj,:,jl) = t_s (ib,jb,:,jl) ! temperature snw
-                  t_i (ji,jj,:,jl) = t_i (ib,jb,:,jl) ! temperature ice
-                  s_i (ji,jj,  jl) = s_i (ib,jb,  jl) ! salinity
-                  sz_i(ji,jj,:,jl) = sz_i(ib,jb,:,jl) ! salinity profile
-                  !
-               END SELECT
+               a_i (ji,jj,  jl) = a_i (ib,jb,  jl)
+               h_i (ji,jj,  jl) = h_i (ib,jb,  jl)
+               h_s (ji,jj,  jl) = h_s (ib,jb,  jl)
+               t_i (ji,jj,:,jl) = t_i (ib,jb,:,jl)
+               t_s (ji,jj,:,jl) = t_s (ib,jb,:,jl)
+               t_su(ji,jj,  jl) = t_su(ib,jb,  jl)
+               s_i (ji,jj,  jl) = s_i (ib,jb,  jl)
+               a_ip(ji,jj,  jl) = a_ip(ib,jb,  jl)
+               h_ip(ji,jj,  jl) = h_ip(ib,jb,  jl)
+               !
+               sz_i(ji,jj,:,jl) = sz_i(ib,jb,:,jl)
+               !
+               ! ice age
+               IF    ( jpbound == 0 ) THEN  ! velocity is inward
+                  oa_i(ji,jj,jl) = rice_age(jbdy) * a_i(ji,jj,jl)
+               ELSEIF( jpbound == 1 ) THEN  ! velocity is outward
+                  oa_i(ji,jj,jl) = oa_i(ib,jb,jl)
+               ENDIF
                !
                IF( nn_icesal == 1 ) THEN     ! if constant salinity
@@ -214,4 +264,12 @@
                END DO
                !
+               ! melt ponds
+               IF( a_i(ji,jj,jl) > epsi10 ) THEN
+                  a_ip_frac(ji,jj,jl) = a_ip(ji,jj,jl) / a_i (ji,jj,jl)
+               ELSE
+                  a_ip_frac(ji,jj,jl) = 0._wp
+               ENDIF
+               v_ip(ji,jj,jl) = h_ip(ji,jj,jl) * a_ip(ji,jj,jl)
+               !
             ELSE   ! no ice at the boundary
                !
@@ -225,4 +283,9 @@
                t_s (ji,jj,:,jl) = rt0
                t_i (ji,jj,:,jl) = rt0 
+
+               a_ip_frac(ji,jj,jl) = 0._wp
+               h_ip     (ji,jj,jl) = 0._wp
+               a_ip     (ji,jj,jl) = 0._wp
+               v_ip     (ji,jj,jl) = 0._wp
                
                IF( nn_icesal == 1 ) THEN     ! if constant salinity
@@ -246,20 +309,4 @@
          !
       END DO ! jl
-
-      CALL lbc_bdy_lnk( 'bdyice', a_i (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', h_i (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', h_s (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', oa_i(:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', a_ip(:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', v_ip(:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', s_i (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', t_su(:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', v_i (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', v_s (:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', sv_i(:,:,:)  , 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', t_s (:,:,:,:), 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', e_s (:,:,:,:), 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', t_i (:,:,:,:), 'T', 1., jbdy )
-      CALL lbc_bdy_lnk( 'bdyice', e_i (:,:,:,:), 'T', 1., jbdy )
       !      
    END SUBROUTINE bdy_ice_frs
@@ -279,77 +326,132 @@
       CHARACTER(len=1), INTENT(in)  ::   cd_type   ! nature of velocity grid-points
       !
-      INTEGER  ::   i_bdy, jgrd      ! dummy loop indices
-      INTEGER  ::   ji, jj           ! local scalar
-      INTEGER  ::   jbdy             ! BDY set index
+      INTEGER  ::   i_bdy, jgrd       ! dummy loop indices
+      INTEGER  ::   ji, jj            ! local scalar
+      INTEGER  ::   jbdy, ir     ! BDY set index, rim index
+      INTEGER  ::   ibeg, iend   ! length of rim to be treated (rim 0 or rim 1)
       REAL(wp) ::   zmsk1, zmsk2, zflag
+      LOGICAL, DIMENSION(4) :: llsend2, llrecv2, llsend3, llrecv3  ! indicate how communications are to be carried out
       !!------------------------------------------------------------------------------
       IF( ln_timing )   CALL timing_start('bdy_ice_dyn')
       !
-      DO jbdy=1, nb_bdy
+      llsend2(:) = .false.   ;   llrecv2(:) = .false.
+      llsend3(:) = .false.   ;   llrecv3(:) = .false.
+      DO ir = 1, 0, -1
+         DO jbdy = 1, nb_bdy
+            !
+            SELECT CASE( cn_ice(jbdy) )
+               !
+            CASE('none')
+               CYCLE
+               !
+            CASE('frs')
+               !
+               IF( nn_ice_dta(jbdy) == 0 ) CYCLE            ! case ice boundaries = initial conditions 
+               !                                            !      do not change ice velocity (it is only computed by rheology)
+               SELECT CASE ( cd_type )
+                  !     
+               CASE ( 'U' )  
+                  jgrd = 2      ! u velocity
+                  IF( ir == 0 ) THEN   ;   ibeg = 1                                 ;   iend = idx_bdy(jbdy)%nblenrim0(jgrd)
+                  ELSE                 ;   ibeg = idx_bdy(jbdy)%nblenrim0(jgrd)+1   ;   iend = idx_bdy(jbdy)%nblenrim(jgrd)
+                  END IF
+                  DO i_bdy = ibeg, iend
+                     ji    = idx_bdy(jbdy)%nbi(i_bdy,jgrd)
+                     jj    = idx_bdy(jbdy)%nbj(i_bdy,jgrd)
+                     zflag = idx_bdy(jbdy)%flagu(i_bdy,jgrd)
+                     !     i-1  i   i    |  !        i  i i+1 |  !          i  i i+1 |
+                     !      >  ice  >    |  !        o  > ice |  !          o  >  o  |      
+                     ! => set at u_ice(i-1) !  => set to O       !  => unchanged
+                     IF( zflag == -1. .AND. ji > 1 .AND. ji < jpi )   THEN  
+                        IF    ( vt_i(ji  ,jj) > 0. )   THEN   ;   u_ice(ji,jj) = u_ice(ji-1,jj) 
+                        ELSEIF( vt_i(ji+1,jj) > 0. )   THEN   ;   u_ice(ji,jj) = 0._wp
+                        END IF
+                     END IF
+                     ! |    i  i+1 i+1        !  |  i   i i+1        !  | i  i i+1
+                     ! |    >  ice  >         !  | ice  >  o         !  | o  >  o   
+                     ! => set at u_ice(i+1)   !     => set to O      !     =>  unchanged
+                     IF( zflag ==  1. .AND. ji+1 < jpi+1 )   THEN
+                        IF    ( vt_i(ji+1,jj) > 0. )   THEN   ;   u_ice(ji,jj) = u_ice(ji+1,jj)
+                        ELSEIF( vt_i(ji  ,jj) > 0. )   THEN   ;   u_ice(ji,jj) = 0._wp
+                        END IF
+                     END IF
+                     !
+                     IF( zflag ==  0. )   u_ice(ji,jj) = 0._wp   ! u_ice = 0  if north/south bdy  
+                     !
+                  END DO
+                  !
+               CASE ( 'V' )
+                  jgrd = 3      ! v velocity
+                  IF( ir == 0 ) THEN   ;   ibeg = 1                                 ;   iend = idx_bdy(jbdy)%nblenrim0(jgrd)
+                  ELSE                 ;   ibeg = idx_bdy(jbdy)%nblenrim0(jgrd)+1   ;   iend = idx_bdy(jbdy)%nblenrim(jgrd)
+                  END IF
+                  DO i_bdy = ibeg, iend
+                     ji    = idx_bdy(jbdy)%nbi(i_bdy,jgrd)
+                     jj    = idx_bdy(jbdy)%nbj(i_bdy,jgrd)
+                     zflag = idx_bdy(jbdy)%flagv(i_bdy,jgrd)
+                     !                         !      ice   (jj+1)       !       o    (jj+1)
+                     !       ^    (jj  )       !       ^    (jj  )       !       ^    (jj  )       
+                     !      ice   (jj  )       !       o    (jj  )       !       o    (jj  )       
+                     !       ^    (jj-1)       !                         !
+                     ! => set to u_ice(jj-1)   !  =>   set to 0          !   => unchanged        
+                     IF( zflag == -1. .AND. jj > 1 .AND. jj < jpj )   THEN                 
+                        IF    ( vt_i(ji,jj  ) > 0. )   THEN   ;   v_ice(ji,jj) = v_ice(ji,jj-1)
+                        ELSEIF( vt_i(ji,jj+1) > 0. )   THEN   ;   v_ice(ji,jj) = 0._wp
+                        END IF
+                     END IF
+                     !       ^    (jj+1)       !                         !              
+                     !      ice   (jj+1)       !       o    (jj+1)       !       o    (jj+1)       
+                     !       ^    (jj  )       !       ^    (jj  )       !       ^    (jj  )
+                     !   ________________      !  ____ice___(jj  )_      !  _____o____(jj  ) 
+                     ! => set to u_ice(jj+1)   !    => set to 0          !    => unchanged  
+                     IF( zflag ==  1. .AND. jj < jpj )   THEN              
+                        IF    ( vt_i(ji,jj+1) > 0. )   THEN   ;   v_ice(ji,jj) = v_ice(ji,jj+1)
+                        ELSEIF( vt_i(ji,jj  ) > 0. )   THEN   ;   v_ice(ji,jj) = 0._wp
+                        END IF
+                     END IF
+                     !
+                     IF( zflag ==  0. )   v_ice(ji,jj) = 0._wp   ! v_ice = 0  if west/east bdy  
+                     !
+                  END DO
+                  !
+               END SELECT
+               !
+            CASE DEFAULT
+               CALL ctl_stop( 'bdy_ice_dyn : unrecognised option for open boundaries for ice fields' )
+            END SELECT
+            !
+         END DO    ! jbdy
          !
-         SELECT CASE( cn_ice(jbdy) )
-         !
-         CASE('none')
-            CYCLE
-            !
-         CASE('frs')
-            !
-            IF( nn_ice_dta(jbdy) == 0 ) CYCLE            ! case ice boundaries = initial conditions 
-            !                                            !      do not change ice velocity (it is only computed by rheology)
-            SELECT CASE ( cd_type )
-            !     
-            CASE ( 'U' )  
-               jgrd = 2      ! u velocity
-               DO i_bdy = 1, idx_bdy(jbdy)%nblenrim(jgrd)
-                  ji    = idx_bdy(jbdy)%nbi(i_bdy,jgrd)
-                  jj    = idx_bdy(jbdy)%nbj(i_bdy,jgrd)
-                  zflag = idx_bdy(jbdy)%flagu(i_bdy,jgrd)
-                  !
-                  IF ( ABS( zflag ) == 1. ) THEN  ! eastern and western boundaries
-                     ! one of the two zmsk is always 0 (because of zflag)
-                     zmsk1 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji+1,jj) ) ) ! 0 if no ice
-                     zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj) ) )   ! 0 if no ice
-                     !  
-                     ! u_ice = u_ice of the adjacent grid point except if this grid point is ice-free (then do not change u_ice)
-                     u_ice (ji,jj) = u_ice(ji+1,jj) * 0.5_wp * ABS( zflag + 1._wp ) * zmsk1 + &
-                        &            u_ice(ji-1,jj) * 0.5_wp * ABS( zflag - 1._wp ) * zmsk2 + &
-                        &            u_ice(ji  ,jj) * ( 1._wp - MIN( 1._wp, zmsk1 + zmsk2 ) )
-                  ELSE                             ! everywhere else
-                     u_ice(ji,jj) = 0._wp
-                  ENDIF
-                  !
-               END DO
-               CALL lbc_bdy_lnk( 'bdyice', u_ice(:,:), 'U', -1., jbdy )
-               !
-            CASE ( 'V' )
-               jgrd = 3      ! v velocity
-               DO i_bdy = 1, idx_bdy(jbdy)%nblenrim(jgrd)
-                  ji    = idx_bdy(jbdy)%nbi(i_bdy,jgrd)
-                  jj    = idx_bdy(jbdy)%nbj(i_bdy,jgrd)
-                  zflag = idx_bdy(jbdy)%flagv(i_bdy,jgrd)
-                  !
-                  IF ( ABS( zflag ) == 1. ) THEN  ! northern and southern boundaries
-                     ! one of the two zmsk is always 0 (because of zflag)
-                     zmsk1 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj+1) ) ) ! 0 if no ice
-                     zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj) ) )   ! 0 if no ice
-                     !  
-                     ! v_ice = v_ice of the adjacent grid point except if this grid point is ice-free (then do not change v_ice)
-                     v_ice (ji,jj) = v_ice(ji,jj+1) * 0.5_wp * ABS( zflag + 1._wp ) * zmsk1 + &
-                        &            v_ice(ji,jj-1) * 0.5_wp * ABS( zflag - 1._wp ) * zmsk2 + &
-                        &            v_ice(ji,jj  ) * ( 1._wp - MIN( 1._wp, zmsk1 + zmsk2 ) )
-                  ELSE                             ! everywhere else
-                     v_ice(ji,jj) = 0._wp
-                  ENDIF
-                  !
-               END DO
-               CALL lbc_bdy_lnk( 'bdyice', v_ice(:,:), 'V', -1., jbdy )
-               !
-            END SELECT
-            !
-         CASE DEFAULT
-            CALL ctl_stop( 'bdy_ice_dyn : unrecognised option for open boundaries for ice fields' )
+         SELECT CASE ( cd_type )        
+         CASE ( 'U' ) 
+         IF( nn_hls > 1 .AND. ir == 1 ) CYCLE   ! at least 2 halos will be corrected -> no need to correct rim 1 before rim 0
+         IF( nn_hls == 1 ) THEN   ;   llsend2(:) = .false.   ;   llrecv2(:) = .false.   ;   END IF
+            DO jbdy = 1, nb_bdy
+               IF( cn_ice(jbdy) == 'frs' .AND. nn_ice_dta(jbdy) /= 0 ) THEN
+                  llsend2(:) = llsend2(:) .OR. lsend_bdyint(jbdy,2,:,ir)   ! possibly every direction, U points
+                  llsend2(1) = llsend2(1) .OR. lsend_bdyext(jbdy,2,1,ir)   ! neighbour might search point towards its west bdy
+                  llrecv2(:) = llrecv2(:) .OR. lrecv_bdyint(jbdy,2,:,ir)   ! possibly every direction, U points
+                  llrecv2(2) = llrecv2(2) .OR. lrecv_bdyext(jbdy,2,2,ir)   ! might search point towards east bdy
+               END IF
+            END DO
+            IF( ANY(llsend2) .OR. ANY(llrecv2) ) THEN   ! if need to send/recv in at least one direction
+               CALL lbc_lnk( 'bdyice', u_ice, 'U', -1., kfillmode=jpfillnothing ,lsend=llsend2, lrecv=llrecv2 )
+            END IF
+         CASE ( 'V' )
+         IF( nn_hls > 1 .AND. ir == 1 ) CYCLE   ! at least 2 halos will be corrected -> no need to correct rim 1 before rim 0
+         IF( nn_hls == 1 ) THEN   ;   llsend3(:) = .false.   ;   llrecv3(:) = .false.   ;   END IF
+            DO jbdy = 1, nb_bdy
+               IF( cn_ice(jbdy) == 'frs' .AND. nn_ice_dta(jbdy) /= 0 ) THEN
+                  llsend3(:) = llsend3(:) .OR. lsend_bdyint(jbdy,3,:,ir)   ! possibly every direction, V points
+                  llsend3(3) = llsend3(3) .OR. lsend_bdyext(jbdy,3,3,ir)   ! neighbour might search point towards its south bdy
+                  llrecv3(:) = llrecv3(:) .OR. lrecv_bdyint(jbdy,3,:,ir)   ! possibly every direction, V points
+                  llrecv3(4) = llrecv3(4) .OR. lrecv_bdyext(jbdy,3,4,ir)   ! might search point towards north bdy
+               END IF
+            END DO
+            IF( ANY(llsend3) .OR. ANY(llrecv3) ) THEN   ! if need to send/recv in at least one direction
+               CALL lbc_lnk( 'bdyice', v_ice, 'V', -1., kfillmode=jpfillnothing ,lsend=llsend3, lrecv=llrecv3 )
+            END IF
          END SELECT
-         !
-      END DO
+      END DO   ! ir
       !
       IF( ln_timing )   CALL timing_stop('bdy_ice_dyn')
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyini.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyini.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyini.F90	(revision 12143)
@@ -33,9 +33,8 @@
    PRIVATE
 
-   PUBLIC   bdy_init   ! routine called in nemo_init
+   PUBLIC   bdy_init    ! routine called in nemo_init
+   PUBLIC   find_neib   ! routine called in bdy_nmn
 
    INTEGER, PARAMETER ::   jp_nseg = 100   ! 
-   INTEGER, PARAMETER ::   nrimmax =  20   ! maximum rimwidth in structured
-                                               ! open boundary data files
    ! Straight open boundary segment parameters:
    INTEGER  ::   nbdysege, nbdysegw, nbdysegn, nbdysegs 
@@ -68,6 +67,5 @@
          &             ln_tra_dmp, ln_dyn3d_dmp, rn_time_dmp, rn_time_dmp_out, &
          &             cn_ice, nn_ice_dta,                                     &
-         &             rn_ice_tem, rn_ice_sal, rn_ice_age,                     &
-         &             ln_vol, nn_volctl, nn_rimwidth, nb_jpk_bdy
+         &             ln_vol, nn_volctl, nn_rimwidth
          !
       INTEGER  ::   ios                 ! Local integer output status for namelist read
@@ -79,11 +77,28 @@
       REWIND( numnam_ref )              ! Namelist nambdy in reference namelist :Unstructured open boundaries
       READ  ( numnam_ref, nambdy, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist' )
+      ! make sur that all elements of the namelist variables have a default definition from namelist_ref
+      ln_coords_file (2:jp_bdy) = ln_coords_file (1)
+      cn_coords_file (2:jp_bdy) = cn_coords_file (1)
+      cn_dyn2d       (2:jp_bdy) = cn_dyn2d       (1)
+      nn_dyn2d_dta   (2:jp_bdy) = nn_dyn2d_dta   (1)
+      cn_dyn3d       (2:jp_bdy) = cn_dyn3d       (1)
+      nn_dyn3d_dta   (2:jp_bdy) = nn_dyn3d_dta   (1)
+      cn_tra         (2:jp_bdy) = cn_tra         (1)
+      nn_tra_dta     (2:jp_bdy) = nn_tra_dta     (1)    
+      ln_tra_dmp     (2:jp_bdy) = ln_tra_dmp     (1)
+      ln_dyn3d_dmp   (2:jp_bdy) = ln_dyn3d_dmp   (1)
+      rn_time_dmp    (2:jp_bdy) = rn_time_dmp    (1)
+      rn_time_dmp_out(2:jp_bdy) = rn_time_dmp_out(1)
+      cn_ice         (2:jp_bdy) = cn_ice         (1)
+      nn_ice_dta     (2:jp_bdy) = nn_ice_dta     (1)
       REWIND( numnam_cfg )              ! Namelist nambdy in configuration namelist :Unstructured open boundaries
       READ  ( numnam_cfg, nambdy, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist' )
       IF(lwm) WRITE ( numond, nambdy )
 
       IF( .NOT. Agrif_Root() ) ln_bdy = .FALSE.   ! forced for Agrif children
+
+      IF( nb_bdy == 0 ) ln_bdy = .FALSE.
       
       ! -----------------------------------------
@@ -96,5 +111,6 @@
          !
          ! Open boundaries definition (arrays and masks)
-         CALL bdy_segs
+         CALL bdy_def
+         IF( ln_meshmask )   CALL bdy_meshwri()
          !
          ! Open boundaries initialisation of external data arrays
@@ -114,5 +130,5 @@
 
 
-   SUBROUTINE bdy_segs
+   SUBROUTINE bdy_def
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE bdy_init  ***
@@ -125,29 +141,23 @@
       !! ** Input   :  bdy_init.nc, input file for unstructured open boundaries
       !!----------------------------------------------------------------------      
-      INTEGER  ::   ib_bdy, ii, ij, ik, igrd, ib, ir, iseg ! dummy loop indices
-      INTEGER  ::   icount, icountr, ibr_max, ilen1, ibm1  ! local integers
+      INTEGER  ::   ib_bdy, ii, ij, igrd, ib, ir, iseg     ! dummy loop indices
+      INTEGER  ::   icount, icountr, icountr0, ibr_max     ! local integers
+      INTEGER  ::   ilen1                                  !   -       -
       INTEGER  ::   iwe, ies, iso, ino, inum, id_dummy     !   -       -
-      INTEGER  ::   igrd_start, igrd_end, jpbdta           !   -       -
-      INTEGER  ::   jpbdtau, jpbdtas                       !   -       -
+      INTEGER  ::   jpbdta                                 !   -       -
       INTEGER  ::   ib_bdy1, ib_bdy2, ib1, ib2             !   -       -
-      INTEGER  ::   i_offset, j_offset                     !   -       -
-      INTEGER , POINTER  ::  nbi, nbj, nbr                 ! short cuts
-      REAL(wp), POINTER, DIMENSION(:,:)       ::   pmask    ! pointer to 2D mask fields
-      REAL(wp) ::   zefl, zwfl, znfl, zsfl                 ! local scalars
-      INTEGER, DIMENSION (2)                  ::   kdimsz
-      INTEGER, DIMENSION(jpbgrd,jp_bdy)       ::   nblendta         ! Length of index arrays 
-      INTEGER, ALLOCATABLE, DIMENSION(:,:,:)  ::   nbidta, nbjdta   ! Index arrays: i and j indices of bdy dta
-      INTEGER, ALLOCATABLE, DIMENSION(:,:,:)  ::   nbrdta           ! Discrete distance from rim points
-      CHARACTER(LEN=1),DIMENSION(jpbgrd)      ::   cgrid
-      INTEGER :: com_east, com_west, com_south, com_north, jpk_max  ! Flags for boundaries sending
-      INTEGER :: com_east_b, com_west_b, com_south_b, com_north_b  ! Flags for boundaries receiving
-      INTEGER :: iw_b(4), ie_b(4), is_b(4), in_b(4)                ! Arrays for neighbours coordinates
-      REAL(wp), TARGET, DIMENSION(jpi,jpj) ::   zfmask  ! temporary fmask array excluding coastal boundary condition (shlat)
-      !!
-      CHARACTER(LEN=1)                     ::   ctypebdy   !     -        - 
-      INTEGER                              ::   nbdyind, nbdybeg, nbdyend
-      !!
-      NAMELIST/nambdy_index/ ctypebdy, nbdyind, nbdybeg, nbdyend
-      INTEGER  ::   ios                 ! Local integer output status for namelist read
+      INTEGER  ::   ii1, ii2, ii3, ij1, ij2, ij3           !   -       -
+      INTEGER  ::   iibe, ijbe, iibi, ijbi                 !   -       -
+      INTEGER  ::   flagu, flagv                           ! short cuts
+      INTEGER  ::   nbdyind, nbdybeg, nbdyend
+      INTEGER              , DIMENSION(4)             ::   kdimsz
+      INTEGER              , DIMENSION(jpbgrd,jp_bdy) ::   nblendta          ! Length of index arrays 
+      INTEGER,  ALLOCATABLE, DIMENSION(:,:,:)         ::   nbidta, nbjdta    ! Index arrays: i and j indices of bdy dta
+      INTEGER,  ALLOCATABLE, DIMENSION(:,:,:)         ::   nbrdta            ! Discrete distance from rim points
+      CHARACTER(LEN=1)     , DIMENSION(jpbgrd)        ::   cgrid
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     ::   zz_read                 ! work space for 2D global boundary data
+      REAL(wp), POINTER    , DIMENSION(:,:)     ::   zmask                   ! pointer to 2D mask fields
+      REAL(wp)             , DIMENSION(jpi,jpj) ::   zfmask   ! temporary fmask array excluding coastal boundary condition (shlat)
+      REAL(wp)             , DIMENSION(jpi,jpj) ::   ztmask, zumask, zvmask  ! temporary u/v mask array
       !!----------------------------------------------------------------------
       !
@@ -160,247 +170,193 @@
          &                               ' and general open boundary condition are not compatible' )
 
-      IF( nb_bdy == 0 ) THEN 
-        IF(lwp) WRITE(numout,*) 'nb_bdy = 0, NO OPEN BOUNDARIES APPLIED.'
-      ELSE
-        IF(lwp) WRITE(numout,*) 'Number of open boundary sets : ', nb_bdy
+      IF(lwp) WRITE(numout,*) 'Number of open boundary sets : ', nb_bdy
+
+      DO ib_bdy = 1,nb_bdy
+
+         IF(lwp) THEN
+            WRITE(numout,*) ' ' 
+            WRITE(numout,*) '------ Open boundary data set ',ib_bdy,' ------' 
+            IF( ln_coords_file(ib_bdy) ) THEN
+               WRITE(numout,*) 'Boundary definition read from file '//TRIM(cn_coords_file(ib_bdy))
+            ELSE
+               WRITE(numout,*) 'Boundary defined in namelist.'
+            ENDIF
+            WRITE(numout,*)
+         ENDIF
+
+         ! barotropic bdy
+         !----------------
+         IF(lwp) THEN
+            WRITE(numout,*) 'Boundary conditions for barotropic solution:  '
+            SELECT CASE( cn_dyn2d(ib_bdy) )                  
+            CASE( 'none' )           ;   WRITE(numout,*) '      no open boundary condition'        
+            CASE( 'frs' )            ;   WRITE(numout,*) '      Flow Relaxation Scheme'
+            CASE( 'flather' )        ;   WRITE(numout,*) '      Flather radiation condition'
+            CASE( 'orlanski' )       ;   WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
+            CASE( 'orlanski_npo' )   ;   WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
+            CASE DEFAULT             ;   CALL ctl_stop( 'unrecognised value for cn_dyn2d' )
+            END SELECT
+         ENDIF
+
+         dta_bdy(ib_bdy)%lneed_ssh   = cn_dyn2d(ib_bdy) == 'flather'
+         dta_bdy(ib_bdy)%lneed_dyn2d = cn_dyn2d(ib_bdy) /= 'none'
+
+         IF( lwp .AND. dta_bdy(ib_bdy)%lneed_dyn2d ) THEN
+            SELECT CASE( nn_dyn2d_dta(ib_bdy) )                   ! 
+            CASE( 0 )      ;   WRITE(numout,*) '      initial state used for bdy data'        
+            CASE( 1 )      ;   WRITE(numout,*) '      boundary data taken from file'
+            CASE( 2 )      ;   WRITE(numout,*) '      tidal harmonic forcing taken from file'
+            CASE( 3 )      ;   WRITE(numout,*) '      boundary data AND tidal harmonic forcing taken from files'
+            CASE DEFAULT   ;   CALL ctl_stop( 'nn_dyn2d_dta must be between 0 and 3' )
+            END SELECT
+         ENDIF
+         IF ( dta_bdy(ib_bdy)%lneed_dyn2d .AND. nn_dyn2d_dta(ib_bdy) .GE. 2  .AND. .NOT.ln_tide ) THEN
+            CALL ctl_stop( 'You must activate with ln_tide to add tidal forcing at open boundaries' )
+         ENDIF
+         IF(lwp) WRITE(numout,*)
+
+         ! baroclinic bdy
+         !----------------
+         IF(lwp) THEN
+            WRITE(numout,*) 'Boundary conditions for baroclinic velocities:  '
+            SELECT CASE( cn_dyn3d(ib_bdy) )                  
+            CASE('none')           ;   WRITE(numout,*) '      no open boundary condition'        
+            CASE('frs')            ;   WRITE(numout,*) '      Flow Relaxation Scheme'
+            CASE('specified')      ;   WRITE(numout,*) '      Specified value'
+            CASE('neumann')        ;   WRITE(numout,*) '      Neumann conditions'
+            CASE('zerograd')       ;   WRITE(numout,*) '      Zero gradient for baroclinic velocities'
+            CASE('zero')           ;   WRITE(numout,*) '      Zero baroclinic velocities (runoff case)'
+            CASE('orlanski')       ;   WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
+            CASE('orlanski_npo')   ;   WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
+            CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_dyn3d' )
+            END SELECT
+         ENDIF
+
+         dta_bdy(ib_bdy)%lneed_dyn3d = cn_dyn3d(ib_bdy) == 'frs'      .OR. cn_dyn3d(ib_bdy) == 'specified'   &
+            &                     .OR. cn_dyn3d(ib_bdy) == 'orlanski' .OR. cn_dyn3d(ib_bdy) == 'orlanski_npo'
+
+         IF( lwp .AND. dta_bdy(ib_bdy)%lneed_dyn3d ) THEN
+            SELECT CASE( nn_dyn3d_dta(ib_bdy) )                   ! 
+            CASE( 0 )      ;   WRITE(numout,*) '      initial state used for bdy data'        
+            CASE( 1 )      ;   WRITE(numout,*) '      boundary data taken from file'
+            CASE DEFAULT   ;   CALL ctl_stop( 'nn_dyn3d_dta must be 0 or 1' )
+            END SELECT
+         END IF
+
+         IF ( ln_dyn3d_dmp(ib_bdy) ) THEN
+            IF ( cn_dyn3d(ib_bdy) == 'none' ) THEN
+               IF(lwp) WRITE(numout,*) 'No open boundary condition for baroclinic velocities: ln_dyn3d_dmp is set to .false.'
+               ln_dyn3d_dmp(ib_bdy) = .false.
+            ELSEIF ( cn_dyn3d(ib_bdy) == 'frs' ) THEN
+               CALL ctl_stop( 'Use FRS OR relaxation' )
+            ELSE
+               IF(lwp) WRITE(numout,*) '      + baroclinic velocities relaxation zone'
+               IF(lwp) WRITE(numout,*) '      Damping time scale: ',rn_time_dmp(ib_bdy),' days'
+               IF(rn_time_dmp(ib_bdy)<0) CALL ctl_stop( 'Time scale must be positive' )
+               dta_bdy(ib_bdy)%lneed_dyn3d = .TRUE.
+            ENDIF
+         ELSE
+            IF(lwp) WRITE(numout,*) '      NO relaxation on baroclinic velocities'
+         ENDIF
+         IF(lwp) WRITE(numout,*)
+
+         !    tra bdy
+         !----------------
+         IF(lwp) THEN
+            WRITE(numout,*) 'Boundary conditions for temperature and salinity:  '
+            SELECT CASE( cn_tra(ib_bdy) )                  
+            CASE('none')           ;   WRITE(numout,*) '      no open boundary condition'        
+            CASE('frs')            ;   WRITE(numout,*) '      Flow Relaxation Scheme'
+            CASE('specified')      ;   WRITE(numout,*) '      Specified value'
+            CASE('neumann')        ;   WRITE(numout,*) '      Neumann conditions'
+            CASE('runoff')         ;   WRITE(numout,*) '      Runoff conditions : Neumann for T and specified to 0.1 for salinity'
+            CASE('orlanski')       ;   WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
+            CASE('orlanski_npo')   ;   WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
+            CASE DEFAULT           ;   CALL ctl_stop( 'unrecognised value for cn_tra' )
+            END SELECT
+         ENDIF
+
+         dta_bdy(ib_bdy)%lneed_tra = cn_tra(ib_bdy) == 'frs'       .OR. cn_tra(ib_bdy) == 'specified'   &
+            &                   .OR. cn_tra(ib_bdy) == 'orlanski'  .OR. cn_tra(ib_bdy) == 'orlanski_npo' 
+
+         IF( lwp .AND. dta_bdy(ib_bdy)%lneed_tra ) THEN
+            SELECT CASE( nn_tra_dta(ib_bdy) )                   ! 
+            CASE( 0 )      ;   WRITE(numout,*) '      initial state used for bdy data'        
+            CASE( 1 )      ;   WRITE(numout,*) '      boundary data taken from file'
+            CASE DEFAULT   ;   CALL ctl_stop( 'nn_tra_dta must be 0 or 1' )
+            END SELECT
+         ENDIF
+
+         IF ( ln_tra_dmp(ib_bdy) ) THEN
+            IF ( cn_tra(ib_bdy) == 'none' ) THEN
+               IF(lwp) WRITE(numout,*) 'No open boundary condition for tracers: ln_tra_dmp is set to .false.'
+               ln_tra_dmp(ib_bdy) = .false.
+            ELSEIF ( cn_tra(ib_bdy) == 'frs' ) THEN
+               CALL ctl_stop( 'Use FRS OR relaxation' )
+            ELSE
+               IF(lwp) WRITE(numout,*) '      + T/S relaxation zone'
+               IF(lwp) WRITE(numout,*) '      Damping time scale: ',rn_time_dmp(ib_bdy),' days'
+               IF(lwp) WRITE(numout,*) '      Outflow damping time scale: ',rn_time_dmp_out(ib_bdy),' days'
+               IF(lwp.AND.rn_time_dmp(ib_bdy)<0) CALL ctl_stop( 'Time scale must be positive' )
+               dta_bdy(ib_bdy)%lneed_tra = .TRUE.
+            ENDIF
+         ELSE
+            IF(lwp) WRITE(numout,*) '      NO T/S relaxation'
+         ENDIF
+         IF(lwp) WRITE(numout,*)
+
+#if defined key_si3
+         IF(lwp) THEN
+            WRITE(numout,*) 'Boundary conditions for sea ice:  '
+            SELECT CASE( cn_ice(ib_bdy) )                  
+            CASE('none')   ;   WRITE(numout,*) '      no open boundary condition'        
+            CASE('frs')    ;   WRITE(numout,*) '      Flow Relaxation Scheme'
+            CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_ice' )
+            END SELECT
+         ENDIF
+
+         dta_bdy(ib_bdy)%lneed_ice = cn_ice(ib_bdy) /= 'none'
+
+         IF( lwp .AND. dta_bdy(ib_bdy)%lneed_ice ) THEN 
+            SELECT CASE( nn_ice_dta(ib_bdy) )                   ! 
+            CASE( 0 )      ;   WRITE(numout,*) '      initial state used for bdy data'        
+            CASE( 1 )      ;   WRITE(numout,*) '      boundary data taken from file'
+            CASE DEFAULT   ;   CALL ctl_stop( 'nn_ice_dta must be 0 or 1' )
+            END SELECT
+         ENDIF
+#else
+         dta_bdy(ib_bdy)%lneed_ice = .FALSE.
+#endif
+         !
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '      Width of relaxation zone = ', nn_rimwidth(ib_bdy)
+         IF(lwp) WRITE(numout,*)
+         !
+      END DO   ! nb_bdy
+
+      IF( lwp ) THEN
+         IF( ln_vol ) THEN                     ! check volume conservation (nn_volctl value)
+            WRITE(numout,*) 'Volume correction applied at open boundaries'
+            WRITE(numout,*)
+            SELECT CASE ( nn_volctl )
+            CASE( 1 )      ;   WRITE(numout,*) '      The total volume will be constant'
+            CASE( 0 )      ;   WRITE(numout,*) '      The total volume will vary according to the surface E-P flux'
+            CASE DEFAULT   ;   CALL ctl_stop( 'nn_volctl must be 0 or 1' )
+            END SELECT
+            WRITE(numout,*)
+            !
+            ! sanity check if used with tides        
+            IF( ln_tide ) THEN 
+               WRITE(numout,*) ' The total volume correction is not working with tides. '
+               WRITE(numout,*) ' Set ln_vol to .FALSE. '
+               WRITE(numout,*) ' or '
+               WRITE(numout,*) ' equilibriate your bdy input files '
+               CALL ctl_stop( 'The total volume correction is not working with tides.' )
+            END IF
+         ELSE
+            WRITE(numout,*) 'No volume correction applied at open boundaries'
+            WRITE(numout,*)
+         ENDIF
       ENDIF
-
-      DO ib_bdy = 1,nb_bdy
-        IF(lwp) WRITE(numout,*) ' ' 
-        IF(lwp) WRITE(numout,*) '------ Open boundary data set ',ib_bdy,'------' 
-
-        IF( ln_coords_file(ib_bdy) ) THEN
-           IF(lwp) WRITE(numout,*) 'Boundary definition read from file '//TRIM(cn_coords_file(ib_bdy))
-        ELSE
-           IF(lwp) WRITE(numout,*) 'Boundary defined in namelist.'
-        ENDIF
-        IF(lwp) WRITE(numout,*)
-
-        IF(lwp) WRITE(numout,*) 'Boundary conditions for barotropic solution:  '
-        SELECT CASE( cn_dyn2d(ib_bdy) )                  
-          CASE( 'none' )         
-             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
-             dta_bdy(ib_bdy)%ll_ssh = .false.
-             dta_bdy(ib_bdy)%ll_u2d = .false.
-             dta_bdy(ib_bdy)%ll_v2d = .false.
-          CASE( 'frs' )          
-             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
-             dta_bdy(ib_bdy)%ll_ssh = .false.
-             dta_bdy(ib_bdy)%ll_u2d = .true.
-             dta_bdy(ib_bdy)%ll_v2d = .true.
-          CASE( 'flather' )      
-             IF(lwp) WRITE(numout,*) '      Flather radiation condition'
-             dta_bdy(ib_bdy)%ll_ssh = .true.
-             dta_bdy(ib_bdy)%ll_u2d = .true.
-             dta_bdy(ib_bdy)%ll_v2d = .true.
-          CASE( 'orlanski' )     
-             IF(lwp) WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_ssh = .false.
-             dta_bdy(ib_bdy)%ll_u2d = .true.
-             dta_bdy(ib_bdy)%ll_v2d = .true.
-          CASE( 'orlanski_npo' ) 
-             IF(lwp) WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_ssh = .false.
-             dta_bdy(ib_bdy)%ll_u2d = .true.
-             dta_bdy(ib_bdy)%ll_v2d = .true.
-          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_dyn2d' )
-        END SELECT
-        IF( cn_dyn2d(ib_bdy) /= 'none' ) THEN
-           SELECT CASE( nn_dyn2d_dta(ib_bdy) )                   ! 
-              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
-              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
-              CASE( 2 )      ;   IF(lwp) WRITE(numout,*) '      tidal harmonic forcing taken from file'
-              CASE( 3 )      ;   IF(lwp) WRITE(numout,*) '      boundary data AND tidal harmonic forcing taken from files'
-              CASE DEFAULT   ;   CALL ctl_stop( 'nn_dyn2d_dta must be between 0 and 3' )
-           END SELECT
-           IF (( nn_dyn2d_dta(ib_bdy) .ge. 2 ).AND.(.NOT.ln_tide)) THEN
-             CALL ctl_stop( 'You must activate with ln_tide to add tidal forcing at open boundaries' )
-           ENDIF
-        ENDIF
-        IF(lwp) WRITE(numout,*)
-
-        IF(lwp) WRITE(numout,*) 'Boundary conditions for baroclinic velocities:  '
-        SELECT CASE( cn_dyn3d(ib_bdy) )                  
-          CASE('none')
-             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
-             dta_bdy(ib_bdy)%ll_u3d = .false.
-             dta_bdy(ib_bdy)%ll_v3d = .false.
-          CASE('frs')       
-             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
-             dta_bdy(ib_bdy)%ll_u3d = .true.
-             dta_bdy(ib_bdy)%ll_v3d = .true.
-          CASE('specified')
-             IF(lwp) WRITE(numout,*) '      Specified value'
-             dta_bdy(ib_bdy)%ll_u3d = .true.
-             dta_bdy(ib_bdy)%ll_v3d = .true.
-          CASE('neumann')
-             IF(lwp) WRITE(numout,*) '      Neumann conditions'
-             dta_bdy(ib_bdy)%ll_u3d = .false.
-             dta_bdy(ib_bdy)%ll_v3d = .false.
-          CASE('zerograd')
-             IF(lwp) WRITE(numout,*) '      Zero gradient for baroclinic velocities'
-             dta_bdy(ib_bdy)%ll_u3d = .false.
-             dta_bdy(ib_bdy)%ll_v3d = .false.
-          CASE('zero')
-             IF(lwp) WRITE(numout,*) '      Zero baroclinic velocities (runoff case)'
-             dta_bdy(ib_bdy)%ll_u3d = .false.
-             dta_bdy(ib_bdy)%ll_v3d = .false.
-          CASE('orlanski')
-             IF(lwp) WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_u3d = .true.
-             dta_bdy(ib_bdy)%ll_v3d = .true.
-          CASE('orlanski_npo')
-             IF(lwp) WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_u3d = .true.
-             dta_bdy(ib_bdy)%ll_v3d = .true.
-          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_dyn3d' )
-        END SELECT
-        IF( cn_dyn3d(ib_bdy) /= 'none' ) THEN
-           SELECT CASE( nn_dyn3d_dta(ib_bdy) )                   ! 
-              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
-              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
-              CASE DEFAULT   ;   CALL ctl_stop( 'nn_dyn3d_dta must be 0 or 1' )
-           END SELECT
-        ENDIF
-
-        IF ( ln_dyn3d_dmp(ib_bdy) ) THEN
-           IF ( cn_dyn3d(ib_bdy) == 'none' ) THEN
-              IF(lwp) WRITE(numout,*) 'No open boundary condition for baroclinic velocities: ln_dyn3d_dmp is set to .false.'
-              ln_dyn3d_dmp(ib_bdy)=.false.
-           ELSEIF ( cn_dyn3d(ib_bdy) == 'frs' ) THEN
-              CALL ctl_stop( 'Use FRS OR relaxation' )
-           ELSE
-              IF(lwp) WRITE(numout,*) '      + baroclinic velocities relaxation zone'
-              IF(lwp) WRITE(numout,*) '      Damping time scale: ',rn_time_dmp(ib_bdy),' days'
-              IF((lwp).AND.rn_time_dmp(ib_bdy)<0) CALL ctl_stop( 'Time scale must be positive' )
-              dta_bdy(ib_bdy)%ll_u3d = .true.
-              dta_bdy(ib_bdy)%ll_v3d = .true.
-           ENDIF
-        ELSE
-           IF(lwp) WRITE(numout,*) '      NO relaxation on baroclinic velocities'
-        ENDIF
-        IF(lwp) WRITE(numout,*)
-
-        IF(lwp) WRITE(numout,*) 'Boundary conditions for temperature and salinity:  '
-        SELECT CASE( cn_tra(ib_bdy) )                  
-          CASE('none')
-             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
-             dta_bdy(ib_bdy)%ll_tem = .false.
-             dta_bdy(ib_bdy)%ll_sal = .false.
-          CASE('frs')
-             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
-             dta_bdy(ib_bdy)%ll_tem = .true.
-             dta_bdy(ib_bdy)%ll_sal = .true.
-          CASE('specified')
-             IF(lwp) WRITE(numout,*) '      Specified value'
-             dta_bdy(ib_bdy)%ll_tem = .true.
-             dta_bdy(ib_bdy)%ll_sal = .true.
-          CASE('neumann')
-             IF(lwp) WRITE(numout,*) '      Neumann conditions'
-             dta_bdy(ib_bdy)%ll_tem = .false.
-             dta_bdy(ib_bdy)%ll_sal = .false.
-          CASE('runoff')
-             IF(lwp) WRITE(numout,*) '      Runoff conditions : Neumann for T and specified to 0.1 for salinity'
-             dta_bdy(ib_bdy)%ll_tem = .false.
-             dta_bdy(ib_bdy)%ll_sal = .false.
-          CASE('orlanski')
-             IF(lwp) WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_tem = .true.
-             dta_bdy(ib_bdy)%ll_sal = .true.
-          CASE('orlanski_npo')
-             IF(lwp) WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_tem = .true.
-             dta_bdy(ib_bdy)%ll_sal = .true.
-          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_tra' )
-        END SELECT
-        IF( cn_tra(ib_bdy) /= 'none' ) THEN
-           SELECT CASE( nn_tra_dta(ib_bdy) )                   ! 
-              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
-              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
-              CASE DEFAULT   ;   CALL ctl_stop( 'nn_tra_dta must be 0 or 1' )
-           END SELECT
-        ENDIF
-
-        IF ( ln_tra_dmp(ib_bdy) ) THEN
-           IF ( cn_tra(ib_bdy) == 'none' ) THEN
-              IF(lwp) WRITE(numout,*) 'No open boundary condition for tracers: ln_tra_dmp is set to .false.'
-              ln_tra_dmp(ib_bdy)=.false.
-           ELSEIF ( cn_tra(ib_bdy) == 'frs' ) THEN
-              CALL ctl_stop( 'Use FRS OR relaxation' )
-           ELSE
-              IF(lwp) WRITE(numout,*) '      + T/S relaxation zone'
-              IF(lwp) WRITE(numout,*) '      Damping time scale: ',rn_time_dmp(ib_bdy),' days'
-              IF(lwp) WRITE(numout,*) '      Outflow damping time scale: ',rn_time_dmp_out(ib_bdy),' days'
-              IF((lwp).AND.rn_time_dmp(ib_bdy)<0) CALL ctl_stop( 'Time scale must be positive' )
-              dta_bdy(ib_bdy)%ll_tem = .true.
-              dta_bdy(ib_bdy)%ll_sal = .true.
-           ENDIF
-        ELSE
-           IF(lwp) WRITE(numout,*) '      NO T/S relaxation'
-        ENDIF
-        IF(lwp) WRITE(numout,*)
-
-#if defined key_si3
-         IF(lwp) WRITE(numout,*) 'Boundary conditions for sea ice:  '
-         SELECT CASE( cn_ice(ib_bdy) )                  
-         CASE('none')
-             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
-             dta_bdy(ib_bdy)%ll_a_i = .false.
-             dta_bdy(ib_bdy)%ll_h_i = .false.
-             dta_bdy(ib_bdy)%ll_h_s = .false.
-         CASE('frs')
-             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
-             dta_bdy(ib_bdy)%ll_a_i = .true.
-             dta_bdy(ib_bdy)%ll_h_i = .true.
-             dta_bdy(ib_bdy)%ll_h_s = .true.
-         CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_ice' )
-         END SELECT
-        IF( cn_ice(ib_bdy) /= 'none' ) THEN 
-           SELECT CASE( nn_ice_dta(ib_bdy) )                   ! 
-              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
-              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
-              CASE DEFAULT   ;   CALL ctl_stop( 'nn_ice_dta must be 0 or 1' )
-           END SELECT
-        ENDIF
-        IF(lwp) WRITE(numout,*)
-        IF(lwp) WRITE(numout,*) '      tem of bdy sea-ice = ', rn_ice_tem(ib_bdy)         
-        IF(lwp) WRITE(numout,*) '      sal of bdy sea-ice = ', rn_ice_sal(ib_bdy)         
-        IF(lwp) WRITE(numout,*) '      age of bdy sea-ice = ', rn_ice_age(ib_bdy)         
-#endif
-
-        IF(lwp) WRITE(numout,*) '      Width of relaxation zone = ', nn_rimwidth(ib_bdy)
-        IF(lwp) WRITE(numout,*)
-         !
-      END DO
-
-     IF( nb_bdy > 0 ) THEN
-        IF( ln_vol ) THEN                     ! check volume conservation (nn_volctl value)
-          IF(lwp) WRITE(numout,*) 'Volume correction applied at open boundaries'
-          IF(lwp) WRITE(numout,*)
-          SELECT CASE ( nn_volctl )
-            CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      The total volume will be constant'
-            CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      The total volume will vary according to the surface E-P flux'
-            CASE DEFAULT   ;   CALL ctl_stop( 'nn_volctl must be 0 or 1' )
-          END SELECT
-          IF(lwp) WRITE(numout,*)
-          !
-          ! sanity check if used with tides        
-          IF( ln_tide ) THEN 
-             IF(lwp) WRITE(numout,*) ' The total volume correction is not working with tides. '
-             IF(lwp) WRITE(numout,*) ' Set ln_vol to .FALSE. '
-             IF(lwp) WRITE(numout,*) ' or '
-             IF(lwp) WRITE(numout,*) ' equilibriate your bdy input files '
-             CALL ctl_stop( 'The total volume correction is not working with tides.' )
-          END IF
-        ELSE
-          IF(lwp) WRITE(numout,*) 'No volume correction applied at open boundaries'
-          IF(lwp) WRITE(numout,*)
-        ENDIF
-        IF( nb_jpk_bdy(ib_bdy) > 0 ) THEN
-           IF(lwp) WRITE(numout,*) '*** open boundary will be interpolate in the vertical onto the native grid ***'
-        ELSE
-           IF(lwp) WRITE(numout,*) '*** open boundary will be read straight onto the native grid without vertical interpolation ***'
-        ENDIF
-     ENDIF
 
       ! -------------------------------------------------
@@ -408,8 +364,5 @@
       ! -------------------------------------------------
 
-      ! Work out global dimensions of boundary data
-      ! ---------------------------------------------
       REWIND( numnam_cfg )     
-
       nblendta(:,:) = 0
       nbdysege = 0
@@ -417,123 +370,33 @@
       nbdysegn = 0
       nbdysegs = 0
-      icount   = 0 ! count user defined segments
-      ! Dimensions below are used to allocate arrays to read external data
-      jpbdtas = 1 ! Maximum size of boundary data (structured case)
-      jpbdtau = 1 ! Maximum size of boundary data (unstructured case)
-
+
+      ! Define all boundaries 
+      ! ---------------------
       DO ib_bdy = 1, nb_bdy
-
-         IF( .NOT. ln_coords_file(ib_bdy) ) THEN ! Work out size of global arrays from namelist parameters
- 
-            icount = icount + 1
-            ! No REWIND here because may need to read more than one nambdy_index namelist.
-            ! Read only namelist_cfg to avoid unseccessfull overwrite 
-            ! keep full control of the configuration namelist
-            READ  ( numnam_cfg, nambdy_index, IOSTAT = ios, ERR = 904 )
-904         IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_index in configuration namelist', lwp )
-            IF(lwm) WRITE ( numond, nambdy_index )
-
-            SELECT CASE ( TRIM(ctypebdy) )
-              CASE( 'N' )
-                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
-                    nbdyind  = jpjglo - 2  ! set boundary to whole side of model domain.
-                    nbdybeg  = 2
-                    nbdyend  = jpiglo - 1
-                 ENDIF
-                 nbdysegn = nbdysegn + 1
-                 npckgn(nbdysegn) = ib_bdy ! Save bdy package number
-                 jpjnob(nbdysegn) = nbdyind
-                 jpindt(nbdysegn) = nbdybeg
-                 jpinft(nbdysegn) = nbdyend
-                 !
-              CASE( 'S' )
-                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
-                    nbdyind  = 2           ! set boundary to whole side of model domain.
-                    nbdybeg  = 2
-                    nbdyend  = jpiglo - 1
-                 ENDIF
-                 nbdysegs = nbdysegs + 1
-                 npckgs(nbdysegs) = ib_bdy ! Save bdy package number
-                 jpjsob(nbdysegs) = nbdyind
-                 jpisdt(nbdysegs) = nbdybeg
-                 jpisft(nbdysegs) = nbdyend
-                 !
-              CASE( 'E' )
-                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
-                    nbdyind  = jpiglo - 2  ! set boundary to whole side of model domain.
-                    nbdybeg  = 2
-                    nbdyend  = jpjglo - 1
-                 ENDIF
-                 nbdysege = nbdysege + 1 
-                 npckge(nbdysege) = ib_bdy ! Save bdy package number
-                 jpieob(nbdysege) = nbdyind
-                 jpjedt(nbdysege) = nbdybeg
-                 jpjeft(nbdysege) = nbdyend
-                 !
-              CASE( 'W' )
-                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
-                    nbdyind  = 2           ! set boundary to whole side of model domain.
-                    nbdybeg  = 2
-                    nbdyend  = jpjglo - 1
-                 ENDIF
-                 nbdysegw = nbdysegw + 1
-                 npckgw(nbdysegw) = ib_bdy ! Save bdy package number
-                 jpiwob(nbdysegw) = nbdyind
-                 jpjwdt(nbdysegw) = nbdybeg
-                 jpjwft(nbdysegw) = nbdyend
-                 !
-              CASE DEFAULT   ;   CALL ctl_stop( 'ctypebdy must be N, S, E or W' )
-            END SELECT
-
-            ! For simplicity we assume that in case of straight bdy, arrays have the same length
-            ! (even if it is true that last tangential velocity points
-            ! are useless). This simplifies a little bit boundary data format (and agrees with format
-            ! used so far in obc package)
-
-            nblendta(1:jpbgrd,ib_bdy) =  (nbdyend - nbdybeg + 1) * nn_rimwidth(ib_bdy)
-            jpbdtas = MAX(jpbdtas, (nbdyend - nbdybeg + 1))
-            IF (lwp.and.(nn_rimwidth(ib_bdy)>nrimmax)) &
-            & CALL ctl_stop( 'rimwidth must be lower than nrimmax' )
-
-         ELSE            ! Read size of arrays in boundary coordinates file.
+         !
+         IF( .NOT. ln_coords_file(ib_bdy) ) THEN     ! build bdy coordinates with segments defined in namelist
+
+            CALL bdy_read_seg( ib_bdy, nblendta(:,ib_bdy) )
+
+         ELSE                                        ! Read size of arrays in boundary coordinates file.
+            
             CALL iom_open( cn_coords_file(ib_bdy), inum )
             DO igrd = 1, jpbgrd
                id_dummy = iom_varid( inum, 'nbi'//cgrid(igrd), kdimsz=kdimsz )  
                nblendta(igrd,ib_bdy) = MAXVAL(kdimsz)
-               jpbdtau = MAX(jpbdtau, MAXVAL(kdimsz))
             END DO
             CALL iom_close( inum )
-            !
-         ENDIF 
+         ENDIF
          !
       END DO ! ib_bdy
 
-      IF (nb_bdy>0) THEN
-         jpbdta = MAXVAL(nblendta(1:jpbgrd,1:nb_bdy))
-
-         ! Allocate arrays
-         !---------------
-         ALLOCATE( nbidta(jpbdta, jpbgrd, nb_bdy), nbjdta(jpbdta, jpbgrd, nb_bdy),    &
-            &      nbrdta(jpbdta, jpbgrd, nb_bdy) )
-         
-         jpk_max = MAXVAL(nb_jpk_bdy)
-         jpk_max = MAX(jpk_max, jpk)
-
-         ALLOCATE( dta_global(jpbdtau, 1, jpk_max) )
-         ALLOCATE( dta_global_z(jpbdtau, 1, jpk_max) ) ! needed ?? TODO
-         ALLOCATE( dta_global_dz(jpbdtau, 1, jpk_max) )! needed ?? TODO
-
-         IF ( icount>0 ) THEN
-            ALLOCATE( dta_global2(jpbdtas, nrimmax, jpk_max) )
-            ALLOCATE( dta_global2_z(jpbdtas, nrimmax, jpk_max) ) ! needed ?? TODO
-            ALLOCATE( dta_global2_dz(jpbdtas, nrimmax, jpk_max) )! needed ?? TODO  
-         ENDIF
-         ! 
-      ENDIF
-
       ! Now look for crossings in user (namelist) defined open boundary segments:
-      !--------------------------------------------------------------------------
-      IF( icount>0 )   CALL bdy_ctl_seg
-
+      IF( nbdysege > 0 .OR. nbdysegw > 0 .OR. nbdysegn > 0 .OR. nbdysegs > 0)   CALL bdy_ctl_seg
+      
+      ! Allocate arrays
+      !---------------
+      jpbdta = MAXVAL(nblendta(1:jpbgrd,1:nb_bdy))
+      ALLOCATE( nbidta(jpbdta, jpbgrd, nb_bdy), nbjdta(jpbdta, jpbgrd, nb_bdy), nbrdta(jpbdta, jpbgrd, nb_bdy) )
+    
       ! Calculate global boundary index arrays or read in from file
       !------------------------------------------------------------               
@@ -543,17 +406,19 @@
          IF( ln_coords_file(ib_bdy) ) THEN
             !
+            ALLOCATE( zz_read( MAXVAL(nblendta), 1 ) )          
             CALL iom_open( cn_coords_file(ib_bdy), inum )
+            !
             DO igrd = 1, jpbgrd
-               CALL iom_get( inum, jpdom_unknown, 'nbi'//cgrid(igrd), dta_global(1:nblendta(igrd,ib_bdy),:,1) )
+               CALL iom_get( inum, jpdom_unknown, 'nbi'//cgrid(igrd), zz_read(1:nblendta(igrd,ib_bdy),:) )
                DO ii = 1,nblendta(igrd,ib_bdy)
-                  nbidta(ii,igrd,ib_bdy) = INT( dta_global(ii,1,1) )
+                  nbidta(ii,igrd,ib_bdy) = NINT( zz_read(ii,1) )
                END DO
-               CALL iom_get( inum, jpdom_unknown, 'nbj'//cgrid(igrd), dta_global(1:nblendta(igrd,ib_bdy),:,1) )
+               CALL iom_get( inum, jpdom_unknown, 'nbj'//cgrid(igrd), zz_read(1:nblendta(igrd,ib_bdy),:) )
                DO ii = 1,nblendta(igrd,ib_bdy)
-                  nbjdta(ii,igrd,ib_bdy) = INT( dta_global(ii,1,1) )
+                  nbjdta(ii,igrd,ib_bdy) = NINT( zz_read(ii,1) )
                END DO
-               CALL iom_get( inum, jpdom_unknown, 'nbr'//cgrid(igrd), dta_global(1:nblendta(igrd,ib_bdy),:,1) )
+               CALL iom_get( inum, jpdom_unknown, 'nbr'//cgrid(igrd), zz_read(1:nblendta(igrd,ib_bdy),:) )
                DO ii = 1,nblendta(igrd,ib_bdy)
-                  nbrdta(ii,igrd,ib_bdy) = INT( dta_global(ii,1,1) )
+                  nbrdta(ii,igrd,ib_bdy) = NINT( zz_read(ii,1) )
                END DO
                !
@@ -563,192 +428,16 @@
                IF(lwp) WRITE(numout,*) ' nn_rimwidth from namelist is ', nn_rimwidth(ib_bdy)
                IF (ibr_max < nn_rimwidth(ib_bdy))   &
-                     CALL ctl_stop( 'nn_rimwidth is larger than maximum rimwidth in file',cn_coords_file(ib_bdy) )
-            END DO
+                  CALL ctl_stop( 'nn_rimwidth is larger than maximum rimwidth in file',cn_coords_file(ib_bdy) )
+            END DO
+            !
             CALL iom_close( inum )
+            DEALLOCATE( zz_read )
             !
-         ENDIF 
-         !
-      END DO      
-    
+         ENDIF
+         !
+      END DO
+
       ! 2. Now fill indices corresponding to straight open boundary arrays:
-      ! East
-      !-----
-      DO iseg = 1, nbdysege
-         ib_bdy = npckge(iseg)
-         !
-         ! ------------ T points -------------
-         igrd=1
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ij = jpjedt(iseg), jpjeft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 2 - ir
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ U points -------------
-         igrd=2
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ij = jpjedt(iseg), jpjeft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 1 - ir
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ V points -------------
-         igrd=3
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-!            DO ij = jpjedt(iseg), jpjeft(iseg) - 1
-            DO ij = jpjedt(iseg), jpjeft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 2 - ir
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-         ENDDO
-      ENDDO
-      !
-      ! West
-      !-----
-      DO iseg = 1, nbdysegw
-         ib_bdy = npckgw(iseg)
-         !
-         ! ------------ T points -------------
-         igrd=1
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ij = jpjwdt(iseg), jpjwft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ U points -------------
-         igrd=2
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ij = jpjwdt(iseg), jpjwft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ V points -------------
-         igrd=3
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-!            DO ij = jpjwdt(iseg), jpjwft(iseg) - 1
-            DO ij = jpjwdt(iseg), jpjwft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-         ENDDO
-      ENDDO
-      !
-      ! North
-      !-----
-      DO iseg = 1, nbdysegn
-         ib_bdy = npckgn(iseg)
-         !
-         ! ------------ T points -------------
-         igrd=1
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ii = jpindt(iseg), jpinft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 2 - ir 
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ U points -------------
-         igrd=2
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-!            DO ii = jpindt(iseg), jpinft(iseg) - 1
-            DO ii = jpindt(iseg), jpinft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 2 - ir
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-         ENDDO
-         !
-         ! ------------ V points -------------
-         igrd=3
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ii = jpindt(iseg), jpinft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 1 - ir
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-      ENDDO
-      !
-      ! South
-      !-----
-      DO iseg = 1, nbdysegs
-         ib_bdy = npckgs(iseg)
-         !
-         ! ------------ T points -------------
-         igrd=1
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ii = jpisdt(iseg), jpisft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ U points -------------
-         igrd=2
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-!            DO ii = jpisdt(iseg), jpisft(iseg) - 1
-            DO ii = jpisdt(iseg), jpisft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-         ENDDO
-         !
-         ! ------------ V points -------------
-         igrd=3
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ii = jpisdt(iseg), jpisft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-      ENDDO
+      CALL bdy_coords_seg( nbidta, nbjdta, nbrdta )
 
       !  Deal with duplicated points
@@ -764,19 +453,19 @@
                      DO ib2 = 1, nblendta(igrd,ib_bdy2)
                         IF ((nbidta(ib1, igrd, ib_bdy1)==nbidta(ib2, igrd, ib_bdy2)).AND. &
-                        &   (nbjdta(ib1, igrd, ib_bdy1)==nbjdta(ib2, igrd, ib_bdy2))) THEN
-!                           IF ((lwp).AND.(igrd==1)) WRITE(numout,*) ' found coincident point ji, jj:', & 
-!                                                       &              nbidta(ib1, igrd, ib_bdy1),      & 
-!                                                       &              nbjdta(ib2, igrd, ib_bdy2)
+                           &   (nbjdta(ib1, igrd, ib_bdy1)==nbjdta(ib2, igrd, ib_bdy2))) THEN
+                           !                           IF ((lwp).AND.(igrd==1)) WRITE(numout,*) ' found coincident point ji, jj:', & 
+                           !                                                       &              nbidta(ib1, igrd, ib_bdy1),      & 
+                           !                                                       &              nbjdta(ib2, igrd, ib_bdy2)
                            ! keep only points with the lowest distance to boundary:
                            IF (nbrdta(ib1, igrd, ib_bdy1)<nbrdta(ib2, igrd, ib_bdy2)) THEN
-                             nbidta(ib2, igrd, ib_bdy2) =-ib_bdy2
-                             nbjdta(ib2, igrd, ib_bdy2) =-ib_bdy2
+                              nbidta(ib2, igrd, ib_bdy2) =-ib_bdy2
+                              nbjdta(ib2, igrd, ib_bdy2) =-ib_bdy2
                            ELSEIF (nbrdta(ib1, igrd, ib_bdy1)>nbrdta(ib2, igrd, ib_bdy2)) THEN
-                             nbidta(ib1, igrd, ib_bdy1) =-ib_bdy1
-                             nbjdta(ib1, igrd, ib_bdy1) =-ib_bdy1
-                           ! Arbitrary choice if distances are the same:
+                              nbidta(ib1, igrd, ib_bdy1) =-ib_bdy1
+                              nbjdta(ib1, igrd, ib_bdy1) =-ib_bdy1
+                              ! Arbitrary choice if distances are the same:
                            ELSE
-                             nbidta(ib1, igrd, ib_bdy1) =-ib_bdy1
-                             nbjdta(ib1, igrd, ib_bdy1) =-ib_bdy1
+                              nbidta(ib1, igrd, ib_bdy1) =-ib_bdy1
+                              nbjdta(ib1, igrd, ib_bdy1) =-ib_bdy1
                            ENDIF
                         END IF
@@ -787,88 +476,29 @@
          END DO
       END DO
-
-      ! Work out dimensions of boundary data on each processor
-      ! ------------------------------------------------------
-
-      ! Rather assume that boundary data indices are given on global domain
-      ! TO BE DISCUSSED ?
-!      iw = mig(1) + 1            ! if monotasking and no zoom, iw=2
-!      ie = mig(1) + nlci-1 - 1   ! if monotasking and no zoom, ie=jpim1
-!      is = mjg(1) + 1            ! if monotasking and no zoom, is=2
-!      in = mjg(1) + nlcj-1 - 1   ! if monotasking and no zoom, in=jpjm1      
-      iwe = mig(1) - 1 + 2         ! if monotasking and no zoom, iw=2
-      ies = mig(1) + nlci-1 - 1  ! if monotasking and no zoom, ie=jpim1
-      iso = mjg(1) - 1 + 2         ! if monotasking and no zoom, is=2
-      ino = mjg(1) + nlcj-1 - 1  ! if monotasking and no zoom, in=jpjm1
-
-      ALLOCATE( nbondi_bdy(nb_bdy))
-      ALLOCATE( nbondj_bdy(nb_bdy))
-      nbondi_bdy(:)=2
-      nbondj_bdy(:)=2
-      ALLOCATE( nbondi_bdy_b(nb_bdy))
-      ALLOCATE( nbondj_bdy_b(nb_bdy))
-      nbondi_bdy_b(:)=2
-      nbondj_bdy_b(:)=2
-
-      ! Work out dimensions of boundary data on each neighbour process
-      IF(nbondi == 0) THEN
-         iw_b(1) = 1 + nimppt(nowe+1)
-         ie_b(1) = 1 + nimppt(nowe+1)+nlcit(nowe+1)-3
-         is_b(1) = 1 + njmppt(nowe+1)
-         in_b(1) = 1 + njmppt(nowe+1)+nlcjt(nowe+1)-3
-
-         iw_b(2) = 1 + nimppt(noea+1)
-         ie_b(2) = 1 + nimppt(noea+1)+nlcit(noea+1)-3
-         is_b(2) = 1 + njmppt(noea+1)
-         in_b(2) = 1 + njmppt(noea+1)+nlcjt(noea+1)-3
-      ELSEIF(nbondi == 1) THEN
-         iw_b(1) = 1 + nimppt(nowe+1)
-         ie_b(1) = 1 + nimppt(nowe+1)+nlcit(nowe+1)-3
-         is_b(1) = 1 + njmppt(nowe+1)
-         in_b(1) = 1 + njmppt(nowe+1)+nlcjt(nowe+1)-3
-      ELSEIF(nbondi == -1) THEN
-         iw_b(2) = 1 + nimppt(noea+1)
-         ie_b(2) = 1 + nimppt(noea+1)+nlcit(noea+1)-3
-         is_b(2) = 1 + njmppt(noea+1)
-         in_b(2) = 1 + njmppt(noea+1)+nlcjt(noea+1)-3
-      ENDIF
-
-      IF(nbondj == 0) THEN
-         iw_b(3) = 1 + nimppt(noso+1)
-         ie_b(3) = 1 + nimppt(noso+1)+nlcit(noso+1)-3
-         is_b(3) = 1 + njmppt(noso+1)
-         in_b(3) = 1 + njmppt(noso+1)+nlcjt(noso+1)-3
-
-         iw_b(4) = 1 + nimppt(nono+1)
-         ie_b(4) = 1 + nimppt(nono+1)+nlcit(nono+1)-3
-         is_b(4) = 1 + njmppt(nono+1)
-         in_b(4) = 1 + njmppt(nono+1)+nlcjt(nono+1)-3
-      ELSEIF(nbondj == 1) THEN
-         iw_b(3) = 1 + nimppt(noso+1)
-         ie_b(3) = 1 + nimppt(noso+1)+nlcit(noso+1)-3
-         is_b(3) = 1 + njmppt(noso+1)
-         in_b(3) = 1 + njmppt(noso+1)+nlcjt(noso+1)-3
-      ELSEIF(nbondj == -1) THEN
-         iw_b(4) = 1 + nimppt(nono+1)
-         ie_b(4) = 1 + nimppt(nono+1)+nlcit(nono+1)-3
-         is_b(4) = 1 + njmppt(nono+1)
-         in_b(4) = 1 + njmppt(nono+1)+nlcjt(nono+1)-3
-      ENDIF
-
+      !
+      ! Find lenght of boundaries and rim on local mpi domain
+      !------------------------------------------------------
+      !
+      iwe = mig(1)
+      ies = mig(jpi)
+      iso = mjg(1) 
+      ino = mjg(jpj) 
+      !
       DO ib_bdy = 1, nb_bdy
          DO igrd = 1, jpbgrd
-            icount  = 0
-            icountr = 0
-            idx_bdy(ib_bdy)%nblen(igrd)    = 0
-            idx_bdy(ib_bdy)%nblenrim(igrd) = 0
+            icount   = 0   ! initialization of local bdy length
+            icountr  = 0   ! initialization of local rim 0 and rim 1 bdy length
+            icountr0 = 0   ! initialization of local rim 0 bdy length
+            idx_bdy(ib_bdy)%nblen(igrd)     = 0
+            idx_bdy(ib_bdy)%nblenrim(igrd)  = 0
+            idx_bdy(ib_bdy)%nblenrim0(igrd) = 0
             DO ib = 1, nblendta(igrd,ib_bdy)
                ! check that data is in correct order in file
-               ibm1 = MAX(1,ib-1)
-               IF(lwp) THEN         ! Since all procs read global data only need to do this check on one proc...
-                  IF( nbrdta(ib,igrd,ib_bdy) < nbrdta(ibm1,igrd,ib_bdy) ) THEN
+               IF( ib > 1 ) THEN
+                  IF( nbrdta(ib,igrd,ib_bdy) < nbrdta(ib-1,igrd,ib_bdy) ) THEN
                      CALL ctl_stop('bdy_segs : ERROR : boundary data in file must be defined ', &
-                          &        ' in order of distance from edge nbr A utility for re-ordering ', &
-                          &        ' boundary coordinates and data files exists in the TOOLS/OBC directory')
-                  ENDIF    
+                        &        ' in order of distance from edge nbr A utility for re-ordering ', &
+                        &        ' boundary coordinates and data files exists in the TOOLS/OBC directory')
+                  ENDIF
                ENDIF
                ! check if point is in local domain
@@ -876,12 +506,13 @@
                   & nbjdta(ib,igrd,ib_bdy) >= iso .AND. nbjdta(ib,igrd,ib_bdy) <= ino      ) THEN
                   !
-                  icount = icount  + 1
-                  !
-                  IF( nbrdta(ib,igrd,ib_bdy) == 1 )   icountr = icountr+1
+                  icount = icount + 1
+                  IF( nbrdta(ib,igrd,ib_bdy) == 1 .OR. nbrdta(ib,igrd,ib_bdy) == 0 )   icountr = icountr + 1
+                  IF( nbrdta(ib,igrd,ib_bdy) == 0 )   icountr0 = icountr0 + 1
                ENDIF
             END DO
-            idx_bdy(ib_bdy)%nblenrim(igrd) = icountr !: length of rim boundary data on each proc
-            idx_bdy(ib_bdy)%nblen   (igrd) = icount  !: length of boundary data on each proc        
-         END DO  ! igrd
+            idx_bdy(ib_bdy)%nblen    (igrd) = icount   !: length of boundary data on each proc
+            idx_bdy(ib_bdy)%nblenrim (igrd) = icountr  !: length of rim 0 and rim 1 boundary data on each proc   
+            idx_bdy(ib_bdy)%nblenrim0(igrd) = icountr0 !: length of rim 0 boundary data on each proc     
+         END DO   ! igrd
 
          ! Allocate index arrays for this boundary set
@@ -893,4 +524,5 @@
             &      idx_bdy(ib_bdy)%nbd   (ilen1,jpbgrd) ,   &
             &      idx_bdy(ib_bdy)%nbdout(ilen1,jpbgrd) ,   &
+            &      idx_bdy(ib_bdy)%ntreat(ilen1,jpbgrd) ,   &
             &      idx_bdy(ib_bdy)%nbmap (ilen1,jpbgrd) ,   &
             &      idx_bdy(ib_bdy)%nbw   (ilen1,jpbgrd) ,   &
@@ -900,19 +532,8 @@
          ! Dispatch mapping indices and discrete distances on each processor
          ! -----------------------------------------------------------------
-
-         com_east  = 0
-         com_west  = 0
-         com_south = 0
-         com_north = 0
-
-         com_east_b  = 0
-         com_west_b  = 0
-         com_south_b = 0
-         com_north_b = 0
-
          DO igrd = 1, jpbgrd
             icount  = 0
-            ! Loop on rimwidth to ensure outermost points come first in the local arrays.
-            DO ir=1, nn_rimwidth(ib_bdy)
+            ! Outer loop on rimwidth to ensure outermost points come first in the local arrays.
+            DO ir = 0, nn_rimwidth(ib_bdy)
                DO ib = 1, nblendta(igrd,ib_bdy)
                   ! check if point is in local domain and equals ir
@@ -922,167 +543,52 @@
                      !
                      icount = icount  + 1
-
-                     ! Rather assume that boundary data indices are given on global domain
-                     ! TO BE DISCUSSED ?
-!                     idx_bdy(ib_bdy)%nbi(icount,igrd)   = nbidta(ib,igrd,ib_bdy)- mig(1)+1
-!                     idx_bdy(ib_bdy)%nbj(icount,igrd)   = nbjdta(ib,igrd,ib_bdy)- mjg(1)+1
-                     idx_bdy(ib_bdy)%nbi(icount,igrd)   = nbidta(ib,igrd,ib_bdy)- mig(1)+1
-                     idx_bdy(ib_bdy)%nbj(icount,igrd)   = nbjdta(ib,igrd,ib_bdy)- mjg(1)+1
-                     ! check if point has to be sent
-                     ii = idx_bdy(ib_bdy)%nbi(icount,igrd)
-                     ij = idx_bdy(ib_bdy)%nbj(icount,igrd)
-                     if((com_east .ne. 1) .and. (ii == (nlci-1)) .and. (nbondi .le. 0)) then
-                        com_east = 1
-                     elseif((com_west .ne. 1) .and. (ii == 2) .and. (nbondi .ge. 0) .and. (nbondi .ne. 2)) then
-                        com_west = 1
-                     endif 
-                     if((com_south .ne. 1) .and. (ij == 2) .and. (nbondj .ge. 0) .and. (nbondj .ne. 2)) then
-                        com_south = 1
-                     elseif((com_north .ne. 1) .and. (ij == (nlcj-1)) .and. (nbondj .le. 0)) then
-                        com_north = 1
-                     endif 
+                     idx_bdy(ib_bdy)%nbi(icount,igrd)   = nbidta(ib,igrd,ib_bdy)- mig(1)+1   ! global to local indexes
+                     idx_bdy(ib_bdy)%nbj(icount,igrd)   = nbjdta(ib,igrd,ib_bdy)- mjg(1)+1   ! global to local indexes
                      idx_bdy(ib_bdy)%nbr(icount,igrd)   = nbrdta(ib,igrd,ib_bdy)
                      idx_bdy(ib_bdy)%nbmap(icount,igrd) = ib
                   ENDIF
-                  ! check if point has to be received from a neighbour
-                  IF(nbondi == 0) THEN
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(1) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(1) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(1) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(1) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(1)+2
-                       if( ii == (nlcit(nowe+1)-1) ) then
-                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(1)+2
-                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
-                            com_south = 1
-                          elseif((ij == nlcjt(nowe+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
-                            com_north = 1
-                          endif
-                          com_west_b = 1
-                       endif 
-                     ENDIF
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(2) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(2) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(2) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(2) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(2)+2
-                       if( ii == 2 ) then
-                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(2)+2
-                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
-                            com_south = 1
-                          elseif((ij == nlcjt(noea+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
-                            com_north = 1
-                          endif
-                          com_east_b = 1
-                       endif 
-                     ENDIF
-                  ELSEIF(nbondi == 1) THEN
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(1) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(1) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(1) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(1) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(1)+2
-                       if( ii == (nlcit(nowe+1)-1) ) then
-                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(1)+2
-                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
-                            com_south = 1
-                          elseif((ij == nlcjt(nowe+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
-                            com_north = 1
-                          endif
-                          com_west_b = 1
-                       endif 
-                     ENDIF
-                  ELSEIF(nbondi == -1) THEN
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(2) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(2) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(2) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(2) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(2)+2
-                       if( ii == 2 ) then
-                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(2)+2
-                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
-                            com_south = 1
-                          elseif((ij == nlcjt(noea+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
-                            com_north = 1
-                          endif
-                          com_east_b = 1
-                       endif 
-                     ENDIF
-                  ENDIF
-                  IF(nbondj == 0) THEN
-                     IF(com_north_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(4)-1  &
-                       & .OR. nbidta(ib,igrd,ib_bdy) == ie_b(4)+1) .AND. &
-                       & nbjdta(ib,igrd,ib_bdy) == is_b(4) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
-                       com_north_b = 1 
-                     ENDIF
-                     IF(com_south_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(3)-1  &
-                       &.OR. nbidta(ib,igrd,ib_bdy) == ie_b(3)+1) .AND. &
-                       & nbjdta(ib,igrd,ib_bdy) == in_b(3) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
-                       com_south_b = 1 
-                     ENDIF
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(3) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(3) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(3) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(3) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(3)+2
-                       if((com_south_b .ne. 1) .and. (ij == (nlcjt(noso+1)-1))) then
-                          com_south_b = 1
-                       endif 
-                     ENDIF
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(4) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(4) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(4) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(4) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(4)+2
-                       if((com_north_b .ne. 1) .and. (ij == 2)) then
-                          com_north_b = 1
-                       endif 
-                     ENDIF
-                  ELSEIF(nbondj == 1) THEN
-                     IF( com_south_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(3)-1 .OR. &
-                       & nbidta(ib,igrd,ib_bdy) == ie_b(3)+1) .AND. &
-                       & nbjdta(ib,igrd,ib_bdy) == in_b(3) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
-                       com_south_b = 1 
-                     ENDIF
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(3) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(3) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(3) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(3) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(3)+2
-                       if((com_south_b .ne. 1) .and. (ij == (nlcjt(noso+1)-1))) then
-                          com_south_b = 1
-                       endif 
-                     ENDIF
-                  ELSEIF(nbondj == -1) THEN
-                     IF(com_north_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(4)-1  &
-                       & .OR. nbidta(ib,igrd,ib_bdy) == ie_b(4)+1) .AND. &
-                       & nbjdta(ib,igrd,ib_bdy) == is_b(4) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
-                       com_north_b = 1 
-                     ENDIF
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(4) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(4) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(4) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(4) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(4)+2
-                       if((com_north_b .ne. 1) .and. (ij == 2)) then
-                          com_north_b = 1
-                       endif 
-                     ENDIF
-                  ENDIF
-               ENDDO
-            ENDDO
-         ENDDO 
-
-         ! definition of the i- and j- direction local boundaries arrays used for sending the boundaries
-         IF(     (com_east  == 1) .and. (com_west  == 1) ) THEN   ;   nbondi_bdy(ib_bdy) =  0
-         ELSEIF( (com_east  == 1) .and. (com_west  == 0) ) THEN   ;   nbondi_bdy(ib_bdy) = -1
-         ELSEIF( (com_east  == 0) .and. (com_west  == 1) ) THEN   ;   nbondi_bdy(ib_bdy) =  1
-         ENDIF
-         IF(     (com_north == 1) .and. (com_south == 1) ) THEN   ;   nbondj_bdy(ib_bdy) =  0
-         ELSEIF( (com_north == 1) .and. (com_south == 0) ) THEN   ;   nbondj_bdy(ib_bdy) = -1
-         ELSEIF( (com_north == 0) .and. (com_south == 1) ) THEN   ;   nbondj_bdy(ib_bdy) =  1
-         ENDIF
-
-         ! definition of the i- and j- direction local boundaries arrays used for receiving the boundaries
-         IF(     (com_east_b  == 1) .and. (com_west_b  == 1) ) THEN   ;   nbondi_bdy_b(ib_bdy) =  0
-         ELSEIF( (com_east_b  == 1) .and. (com_west_b  == 0) ) THEN   ;   nbondi_bdy_b(ib_bdy) = -1
-         ELSEIF( (com_east_b  == 0) .and. (com_west_b  == 1) ) THEN   ;   nbondi_bdy_b(ib_bdy) =  1
-         ENDIF
-         IF(     (com_north_b == 1) .and. (com_south_b == 1) ) THEN   ;   nbondj_bdy_b(ib_bdy) =  0
-         ELSEIF( (com_north_b == 1) .and. (com_south_b == 0) ) THEN   ;   nbondj_bdy_b(ib_bdy) = -1
-         ELSEIF( (com_north_b == 0) .and. (com_south_b == 1) ) THEN   ;   nbondj_bdy_b(ib_bdy) =  1
-         ENDIF
+               END DO
+            END DO
+         END DO   ! igrd
+
+      END DO   ! ib_bdy
+
+      ! Initialize array indicating communications in bdy
+      ! -------------------------------------------------
+      ALLOCATE( lsend_bdy(nb_bdy,jpbgrd,4,0:1), lrecv_bdy(nb_bdy,jpbgrd,4,0:1) )
+      lsend_bdy(:,:,:,:) = .false.
+      lrecv_bdy(:,:,:,:) = .false. 
+
+      DO ib_bdy = 1, nb_bdy
+         DO igrd = 1, jpbgrd
+            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)   ! only the rim triggers communications, see bdy routines
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               IF( ib .LE. idx_bdy(ib_bdy)%nblenrim0(igrd) ) THEN   ;   ir = 0
+               ELSE                                                 ;   ir = 1
+               END IF
+               !
+               ! check if point has to be sent     to   a neighbour
+               ! W neighbour and on the inner left  side
+               IF( ii == 2     .and. (nbondi == 0 .or. nbondi ==  1) )   lsend_bdy(ib_bdy,igrd,1,ir) = .true.
+               ! E neighbour and on the inner right side
+               IF( ii == jpi-1 .and. (nbondi == 0 .or. nbondi == -1) )   lsend_bdy(ib_bdy,igrd,2,ir) = .true.
+               ! S neighbour and on the inner down side
+               IF( ij == 2     .and. (nbondj == 0 .or. nbondj ==  1) )   lsend_bdy(ib_bdy,igrd,3,ir) = .true.
+               ! N neighbour and on the inner up   side
+               IF( ij == jpj-1 .and. (nbondj == 0 .or. nbondj == -1) )   lsend_bdy(ib_bdy,igrd,4,ir) = .true.
+               !
+               ! check if point has to be received from a neighbour
+               ! W neighbour and on the outter left  side
+               IF( ii == 1     .and. (nbondi == 0 .or. nbondi ==  1) )   lrecv_bdy(ib_bdy,igrd,1,ir) = .true.
+               ! E neighbour and on the outter right side
+               IF( ii == jpi   .and. (nbondi == 0 .or. nbondi == -1) )   lrecv_bdy(ib_bdy,igrd,2,ir) = .true.
+               ! S neighbour and on the outter down side
+               IF( ij == 1     .and. (nbondj == 0 .or. nbondj ==  1) )   lrecv_bdy(ib_bdy,igrd,3,ir) = .true.
+               ! N neighbour and on the outter up   side
+               IF( ij == jpj   .and. (nbondj == 0 .or. nbondj == -1) )   lrecv_bdy(ib_bdy,igrd,4,ir) = .true.
+               !
+            END DO
+         END DO  ! igrd
 
          ! Compute rim weights for FRS scheme
@@ -1090,10 +596,10 @@
          DO igrd = 1, jpbgrd
             DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
-               nbr => idx_bdy(ib_bdy)%nbr(ib,igrd)
-               idx_bdy(ib_bdy)%nbw(ib,igrd) = 1.- TANH( REAL( nbr - 1 ) *0.5 )      ! tanh formulation
-!               idx_bdy(ib_bdy)%nbw(ib,igrd) = (REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy)))**2.  ! quadratic
-!               idx_bdy(ib_bdy)%nbw(ib,igrd) =  REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy))       ! linear
-            END DO
-         END DO 
+               ir = MAX( 1, idx_bdy(ib_bdy)%nbr(ib,igrd) )   ! both rim 0 and rim 1 have the same weights
+               idx_bdy(ib_bdy)%nbw(ib,igrd) = 1.- TANH( REAL( ir - 1 ) *0.5 )      ! tanh formulation
+               !               idx_bdy(ib_bdy)%nbw(ib,igrd) = (REAL(nn_rimwidth(ib_bdy)+1-ir)/REAL(nn_rimwidth(ib_bdy)))**2.  ! quadratic
+               !               idx_bdy(ib_bdy)%nbw(ib,igrd) =  REAL(nn_rimwidth(ib_bdy)+1-ir)/REAL(nn_rimwidth(ib_bdy))       ! linear
+            END DO
+         END DO
 
          ! Compute damping coefficients
@@ -1101,17 +607,32 @@
          DO igrd = 1, jpbgrd
             DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
-               nbr => idx_bdy(ib_bdy)%nbr(ib,igrd)
+               ir = MAX( 1, idx_bdy(ib_bdy)%nbr(ib,igrd) )   ! both rim 0 and rim 1 have the same damping coefficients
                idx_bdy(ib_bdy)%nbd(ib,igrd) = 1. / ( rn_time_dmp(ib_bdy) * rday ) & 
-               & *(REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy)))**2.   ! quadratic
+                  & *(REAL(nn_rimwidth(ib_bdy)+1-ir)/REAL(nn_rimwidth(ib_bdy)))**2.   ! quadratic
                idx_bdy(ib_bdy)%nbdout(ib,igrd) = 1. / ( rn_time_dmp_out(ib_bdy) * rday ) & 
-               & *(REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy)))**2.   ! quadratic
-            END DO
-         END DO 
-
-      END DO
+                  & *(REAL(nn_rimwidth(ib_bdy)+1-ir)/REAL(nn_rimwidth(ib_bdy)))**2.   ! quadratic
+            END DO
+         END DO
+
+      END DO ! ib_bdy
 
       ! ------------------------------------------------------
       ! Initialise masks and find normal/tangential directions
       ! ------------------------------------------------------
+
+      ! ------------------------------------------
+      ! handle rim0, do as if rim 1 was free ocean
+      ! ------------------------------------------
+
+      ztmask(:,:) = tmask(:,:,1)   ;   zumask(:,:) = umask(:,:,1)   ;   zvmask(:,:) = vmask(:,:,1)
+      ! For the flagu/flagv calculation below we require a version of fmask without
+      ! the land boundary condition (shlat) included:
+      DO ij = 1, jpjm1
+         DO ii = 1, jpim1
+            zfmask(ii,ij) =  ztmask(ii,ij  ) * ztmask(ii+1,ij  )   &
+               &           * ztmask(ii,ij+1) * ztmask(ii+1,ij+1)
+         END DO
+      END DO
+      CALL lbc_lnk( 'bdyini', zfmask, 'F', 1. )
 
       ! Read global 2D mask at T-points: bdytmask
@@ -1119,60 +640,193 @@
       ! bdytmask = 1  on the computational domain AND on open boundaries
       !          = 0  elsewhere   
- 
+
       bdytmask(:,:) = ssmask(:,:)
 
       ! Derive mask on U and V grid from mask on T grid
-
-      bdyumask(:,:) = 0._wp
-      bdyvmask(:,:) = 0._wp
       DO ij = 1, jpjm1
          DO ii = 1, jpim1
-            bdyumask(ii,ij) = bdytmask(ii,ij) * bdytmask(ii+1, ij )
+            bdyumask(ii,ij) = bdytmask(ii,ij) * bdytmask(ii+1,ij  )
             bdyvmask(ii,ij) = bdytmask(ii,ij) * bdytmask(ii  ,ij+1)  
          END DO
       END DO
-      CALL lbc_lnk_multi( 'bdyini', bdyumask, 'U', 1. , bdyvmask, 'V', 1. )   ! Lateral boundary cond. 
-
-      ! bdy masks are now set to zero on boundary points:
-      !
-      igrd = 1
+      CALL lbc_lnk_multi( 'bdyini', bdyumask, 'U', 1., bdyvmask, 'V', 1. )   ! Lateral boundary cond.
+
+      ! bdy masks are now set to zero on rim 0 points:
       DO ib_bdy = 1, nb_bdy
-        DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)      
-          bdytmask(idx_bdy(ib_bdy)%nbi(ib,igrd), idx_bdy(ib_bdy)%nbj(ib,igrd)) = 0._wp
-        END DO
-      END DO
-      !
-      igrd = 2
+         DO ib = 1, idx_bdy(ib_bdy)%nblenrim0(1)   ! extent of rim 0
+            bdytmask(idx_bdy(ib_bdy)%nbi(ib,1), idx_bdy(ib_bdy)%nbj(ib,1)) = 0._wp
+         END DO
+         DO ib = 1, idx_bdy(ib_bdy)%nblenrim0(2)   ! extent of rim 0
+            bdyumask(idx_bdy(ib_bdy)%nbi(ib,2), idx_bdy(ib_bdy)%nbj(ib,2)) = 0._wp
+         END DO
+         DO ib = 1, idx_bdy(ib_bdy)%nblenrim0(3)   ! extent of rim 0
+            bdyvmask(idx_bdy(ib_bdy)%nbi(ib,3), idx_bdy(ib_bdy)%nbj(ib,3)) = 0._wp
+         END DO
+      END DO
+
+      CALL bdy_rim_treat( zumask, zvmask, zfmask, .true. )   ! compute flagu, flagv, ntreat on rim 0
+
+      ! ------------------------------------
+      ! handle rim1, do as if rim 0 was land
+      ! ------------------------------------
+      
+      ! z[tuv]mask are now set to zero on rim 0 points:
       DO ib_bdy = 1, nb_bdy
-        DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
-          bdyumask(idx_bdy(ib_bdy)%nbi(ib,igrd), idx_bdy(ib_bdy)%nbj(ib,igrd)) = 0._wp
-        END DO
-      END DO
-      !
-      igrd = 3
+         DO ib = 1, idx_bdy(ib_bdy)%nblenrim0(1)   ! extent of rim 0
+            ztmask(idx_bdy(ib_bdy)%nbi(ib,1), idx_bdy(ib_bdy)%nbj(ib,1)) = 0._wp
+         END DO
+         DO ib = 1, idx_bdy(ib_bdy)%nblenrim0(2)   ! extent of rim 0
+            zumask(idx_bdy(ib_bdy)%nbi(ib,2), idx_bdy(ib_bdy)%nbj(ib,2)) = 0._wp
+         END DO
+         DO ib = 1, idx_bdy(ib_bdy)%nblenrim0(3)   ! extent of rim 0
+            zvmask(idx_bdy(ib_bdy)%nbi(ib,3), idx_bdy(ib_bdy)%nbj(ib,3)) = 0._wp
+         END DO
+      END DO
+
+      ! Recompute zfmask
+      DO ij = 1, jpjm1
+         DO ii = 1, jpim1
+            zfmask(ii,ij) =  ztmask(ii,ij  ) * ztmask(ii+1,ij  )   &
+               &           * ztmask(ii,ij+1) * ztmask(ii+1,ij+1)
+         END DO
+      END DO
+      CALL lbc_lnk( 'bdyini', zfmask, 'F', 1. )
+
+      ! bdy masks are now set to zero on rim1 points:
       DO ib_bdy = 1, nb_bdy
-        DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
-          bdyvmask(idx_bdy(ib_bdy)%nbi(ib,igrd), idx_bdy(ib_bdy)%nbj(ib,igrd)) = 0._wp
-        END DO
-      END DO
-
-      ! For the flagu/flagv calculation below we require a version of fmask without
-      ! the land boundary condition (shlat) included:
-      zfmask(:,:) = 0
-      DO ij = 2, jpjm1
-         DO ii = 2, jpim1
-            zfmask(ii,ij) = tmask(ii,ij  ,1) * tmask(ii+1,ij  ,1)   &
-           &              * tmask(ii,ij+1,1) * tmask(ii+1,ij+1,1)
-         END DO      
-      END DO
-
-      ! Lateral boundary conditions
-      CALL lbc_lnk( 'bdyini', zfmask, 'F', 1. ) 
-      CALL lbc_lnk_multi( 'bdyini', bdyumask, 'U', 1. , bdyvmask, 'V', 1., bdytmask, 'T', 1. )
+         DO ib = idx_bdy(ib_bdy)%nblenrim0(1) + 1,  idx_bdy(ib_bdy)%nblenrim(1)   ! extent of rim 1
+            bdytmask(idx_bdy(ib_bdy)%nbi(ib,1), idx_bdy(ib_bdy)%nbj(ib,1)) = 0._wp
+         END DO
+         DO ib = idx_bdy(ib_bdy)%nblenrim0(2) + 1,  idx_bdy(ib_bdy)%nblenrim(2)   ! extent of rim 1
+            bdyumask(idx_bdy(ib_bdy)%nbi(ib,2), idx_bdy(ib_bdy)%nbj(ib,2)) = 0._wp
+         END DO
+         DO ib = idx_bdy(ib_bdy)%nblenrim0(3) + 1,  idx_bdy(ib_bdy)%nblenrim(3)   ! extent of rim 1
+            bdyvmask(idx_bdy(ib_bdy)%nbi(ib,3), idx_bdy(ib_bdy)%nbj(ib,3)) = 0._wp
+         END DO
+      END DO
+
+      CALL bdy_rim_treat( zumask, zvmask, zfmask, .false. )   ! compute flagu, flagv, ntreat on rim 1
+      !
+      ! Check which boundaries might need communication
+      ALLOCATE( lsend_bdyint(nb_bdy,jpbgrd,4,0:1), lrecv_bdyint(nb_bdy,jpbgrd,4,0:1) )
+      lsend_bdyint(:,:,:,:) = .false.
+      lrecv_bdyint(:,:,:,:) = .false. 
+      ALLOCATE( lsend_bdyext(nb_bdy,jpbgrd,4,0:1), lrecv_bdyext(nb_bdy,jpbgrd,4,0:1) )
+      lsend_bdyext(:,:,:,:) = .false.
+      lrecv_bdyext(:,:,:,:) = .false.
+      !
+      DO igrd = 1, jpbgrd
+         DO ib_bdy = 1, nb_bdy
+            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
+               IF( idx_bdy(ib_bdy)%ntreat(ib,igrd) == -1 ) CYCLE
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               ir = idx_bdy(ib_bdy)%nbr(ib,igrd)
+               flagu = NINT(idx_bdy(ib_bdy)%flagu(ib,igrd))
+               flagv = NINT(idx_bdy(ib_bdy)%flagv(ib,igrd))
+               iibe = ii - flagu   ! neighbouring point towards the exterior of the computational domain
+               ijbe = ij - flagv
+               iibi = ii + flagu   ! neighbouring point towards the interior of the computational domain
+               ijbi = ij + flagv
+               CALL find_neib( ii, ij, idx_bdy(ib_bdy)%ntreat(ib,igrd), ii1, ij1, ii2, ij2, ii3, ij3 )   ! free ocean neighbours
+               !
+               ! search neighbour in the  west/east  direction
+               ! Rim is on the halo and computed ocean is towards exterior of mpi domain  
+               !      <--    (o exterior)     -->  
+               ! (1)  o|x         OR    (2)   x|o
+               !       |___                 ___| 
+               IF( iibi == 0     .OR. ii1 == 0     .OR. ii2 == 0     .OR. ii3 == 0     )   lrecv_bdyint(ib_bdy,igrd,1,ir) = .true.
+               IF( iibi == jpi+1 .OR. ii1 == jpi+1 .OR. ii2 == jpi+1 .OR. ii3 == jpi+1 )   lrecv_bdyint(ib_bdy,igrd,2,ir) = .true.  
+               IF( iibe == 0                                                           )   lrecv_bdyext(ib_bdy,igrd,1,ir) = .true.
+               IF( iibe == jpi+1                                                       )   lrecv_bdyext(ib_bdy,igrd,2,ir) = .true.  
+               ! Check if neighbour has its rim parallel to its mpi subdomain border and located next to its halo
+               ! :¨¨¨¨¨|¨¨-->    |                                             |    <--¨¨|¨¨¨¨¨: 
+               ! :     |  x:o    |    neighbour limited by ... would need o    |    o:x  |     :
+               ! :.....|_._:_____|   (1) W neighbour         E neighbour (2)   |_____:_._|.....:
+               IF( ii == 2     .AND. ( nbondi ==  1 .OR. nbondi == 0 ) .AND. &
+                  & ( iibi == 3     .OR. ii1 == 3     .OR. ii2 == 3     .OR. ii3 == 3    ) )   lsend_bdyint(ib_bdy,igrd,1,ir)=.true.
+               IF( ii == jpi-1 .AND. ( nbondi == -1 .OR. nbondi == 0 ) .AND. &
+                  & ( iibi == jpi-2 .OR. ii1 == jpi-2 .OR. ii2 == jpi-2 .OR. ii3 == jpi-2) )   lsend_bdyint(ib_bdy,igrd,2,ir)=.true.
+               IF( ii == 2     .AND. ( nbondi ==  1 .OR. nbondi == 0 ) .AND. iibe == 3     )   lsend_bdyext(ib_bdy,igrd,1,ir)=.true.
+               IF( ii == jpi-1 .AND. ( nbondi == -1 .OR. nbondi == 0 ) .AND. iibe == jpi-2 )   lsend_bdyext(ib_bdy,igrd,2,ir)=.true.
+               !
+               ! search neighbour in the north/south direction   
+               ! Rim is on the halo and computed ocean is towards exterior of mpi domain
+               !(3)   |       |         ^   ___o___     
+               !  |   |___x___|   OR    |  |   x   |
+               !  v       o           (4)  |       |
+               IF( ijbi == 0     .OR. ij1 == 0     .OR. ij2 == 0     .OR. ij3 == 0     )   lrecv_bdyint(ib_bdy,igrd,3,ir) = .true.
+               IF( ijbi == jpj+1 .OR. ij1 == jpj+1 .OR. ij2 == jpj+1 .OR. ij3 == jpj+1 )   lrecv_bdyint(ib_bdy,igrd,4,ir) = .true.
+               IF( ijbe == 0                                                           )   lrecv_bdyext(ib_bdy,igrd,3,ir) = .true.
+               IF( ijbe == jpj+1                                                       )   lrecv_bdyext(ib_bdy,igrd,4,ir) = .true.
+               ! Check if neighbour has its rim parallel to its mpi subdomain     _________  border and next to its halo
+               !   ^  |    o    |                                                :         : 
+               !   |  |¨¨¨¨x¨¨¨¨|   neighbour limited by ... would need o     |  |....x....|
+               !      :_________:  (3) S neighbour          N neighbour (4)   v  |    o    |   
+               IF( ij == 2     .AND. ( nbondj ==  1 .OR. nbondj == 0 ) .AND. &
+                  & ( ijbi == 3     .OR. ij1 == 3     .OR. ij2 == 3     .OR. ij3 == 3    ) )   lsend_bdyint(ib_bdy,igrd,3,ir)=.true.
+               IF( ij == jpj-1 .AND. ( nbondj == -1 .OR. nbondj == 0 ) .AND. &
+                  & ( ijbi == jpj-2 .OR. ij1 == jpj-2 .OR. ij2 == jpj-2 .OR. ij3 == jpj-2) )   lsend_bdyint(ib_bdy,igrd,4,ir)=.true.
+               IF( ij == 2     .AND. ( nbondj ==  1 .OR. nbondj == 0 ) .AND. ijbe == 3     )   lsend_bdyext(ib_bdy,igrd,3,ir)=.true.
+               IF( ij == jpj-1 .AND. ( nbondj == -1 .OR. nbondj == 0 ) .AND. ijbe == jpj-2 )   lsend_bdyext(ib_bdy,igrd,4,ir)=.true.
+            END DO
+         END DO
+      END DO
+
+      DO ib_bdy = 1,nb_bdy
+         IF(  cn_dyn2d(ib_bdy) == 'orlanski' .OR. cn_dyn2d(ib_bdy) == 'orlanski_npo' .OR. &
+            & cn_dyn3d(ib_bdy) == 'orlanski' .OR. cn_dyn3d(ib_bdy) == 'orlanski_npo' .OR. &
+            & cn_tra(ib_bdy)   == 'orlanski' .OR. cn_tra(ib_bdy)   == 'orlanski_npo'      ) THEN
+            DO igrd = 1, jpbgrd
+               DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
+                  ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+                  ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+                  IF(  mig(ii) > 2 .AND. mig(ii) < jpiglo-2 .AND. mjg(ij) > 2 .AND. mjg(ij) < jpjglo-2  ) THEN
+                     WRITE(ctmp1,*) ' Orlanski is not safe when the open boundaries are on the interior of the computational domain'
+                     CALL ctl_stop( ctmp1 )
+                  END IF
+               END DO
+            END DO
+         END IF
+      END DO
+      !
+      DEALLOCATE( nbidta, nbjdta, nbrdta )
+      !
+   END SUBROUTINE bdy_def
+
+
+   SUBROUTINE bdy_rim_treat( pumask, pvmask, pfmask, lrim0 )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE bdy_rim_treat  ***
+      !!
+      !! ** Purpose :   Initialize structures ( flagu, flagv, ntreat ) indicating how rim points
+      !!                  are to be handled in the boundary condition treatment
+      !!
+      !! ** Method  :   - to handle rim 0 zmasks must indicate ocean points      (set at one on rim 0 and rim 1 and interior)
+      !!                            and bdymasks must be set at 0 on rim 0       (set at one on rim 1 and interior)
+      !!                    (as if rim 1 was free ocean)
+      !!                - to handle rim 1 zmasks must be set at 0 on rim 0       (set at one on rim 1 and interior)
+      !!                            and bdymasks must indicate free ocean points (set at one on interior)
+      !!                    (as if rim 0 was land)
+      !!                - we can then check in which direction the interior of the computational domain is with the difference
+      !!                         mask array values on both sides to compute flagu and flagv
+      !!                - and look at the ocean neighbours to compute ntreat
+      !!----------------------------------------------------------------------
+      REAL(wp), TARGET, DIMENSION(jpi,jpj), INTENT (in   ) :: pfmask   ! temporary fmask excluding coastal boundary condition (shlat)
+      REAL(wp), TARGET, DIMENSION(jpi,jpj), INTENT (in   ) :: pumask, pvmask   ! temporary t/u/v mask array
+      LOGICAL                             , INTENT (in   ) :: lrim0    ! .true. -> rim 0   .false. -> rim 1
+      INTEGER  ::   ib_bdy, ii, ij, igrd, ib, icount       ! dummy loop indices
+      INTEGER  ::   i_offset, j_offset, inn                ! local integer
+      INTEGER  ::   ibeg, iend                             ! local integer
+      LOGICAL  ::   llnon, llson, llean, llwen             ! local logicals indicating the presence of a ocean neighbour
+      REAL(wp), POINTER, DIMENSION(:,:)       ::   zmask   ! pointer to 2D mask fields
+      REAL(wp) ::   zefl, zwfl, znfl, zsfl                 ! local scalars
+      CHARACTER(LEN=1), DIMENSION(jpbgrd)     ::   cgrid
+      REAL(wp)        , DIMENSION(jpi,jpj)    ::   ztmp
+      !!----------------------------------------------------------------------
+
+      cgrid = (/'t','u','v'/)
+
       DO ib_bdy = 1, nb_bdy       ! Indices and directions of rim velocity components
-
-         idx_bdy(ib_bdy)%flagu(:,:) = 0._wp
-         idx_bdy(ib_bdy)%flagv(:,:) = 0._wp
-         icount = 0 
 
          ! Calculate relationship of U direction to the local orientation of the boundary
@@ -1180,31 +834,46 @@
          ! flagu =  0 : u is tangential
          ! flagu =  1 : u is normal to the boundary and is direction is inward
-  
          DO igrd = 1, jpbgrd 
             SELECT CASE( igrd )
-               CASE( 1 )   ;   pmask => umask   (:,:,1)   ;   i_offset = 0
-               CASE( 2 )   ;   pmask => bdytmask(:,:)     ;   i_offset = 1
-               CASE( 3 )   ;   pmask => zfmask  (:,:)     ;   i_offset = 0
+               CASE( 1 )   ;   zmask => pumask     ;   i_offset = 0
+               CASE( 2 )   ;   zmask => bdytmask   ;   i_offset = 1
+               CASE( 3 )   ;   zmask => pfmask     ;   i_offset = 0
             END SELECT 
             icount = 0
-            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)  
-               nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
-               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
-               zefl = pmask(nbi+i_offset-1,nbj)
-               zwfl = pmask(nbi+i_offset,nbj)
+            ztmp(:,:) = -999._wp
+            IF( lrim0 ) THEN   ! extent of rim 0
+               ibeg = 1                                     ;   iend = idx_bdy(ib_bdy)%nblenrim0(igrd)
+            ELSE               ! extent of rim 1
+               ibeg = idx_bdy(ib_bdy)%nblenrim0(igrd) + 1   ;   iend = idx_bdy(ib_bdy)%nblenrim(igrd)
+            END IF
+            DO ib = ibeg, iend 
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE
+               zwfl = zmask(ii+i_offset-1,ij)
+               zefl = zmask(ii+i_offset  ,ij)
                ! This error check only works if you are using the bdyXmask arrays
-               IF( i_offset == 1 .and. zefl + zwfl == 2 ) THEN
+               IF( i_offset == 1 .and. zefl + zwfl == 2. ) THEN
                   icount = icount + 1
-                  IF(lwp) WRITE(numout,*) 'Problem with igrd = ',igrd,' at (global) nbi, nbj : ',mig(nbi),mjg(nbj)
+                  IF(lwp) WRITE(numout,*) 'Problem with igrd = ',igrd,' at (global) nbi, nbj : ',mig(ii),mjg(ij)
                ELSE
-                  idx_bdy(ib_bdy)%flagu(ib,igrd) = -zefl + zwfl
+                  ztmp(ii,ij) = -zwfl + zefl
                ENDIF
             END DO
             IF( icount /= 0 ) THEN
-               WRITE(ctmp1,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
+               WRITE(ctmp1,*) 'Some ',cgrid(igrd),' grid points,',   &
                   ' are not boundary points (flagu calculation). Check nbi, nbj, indices for boundary set ',ib_bdy
-               WRITE(ctmp2,*) ' ========== '
-               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+               CALL ctl_stop( ctmp1 )
             ENDIF 
+            SELECT CASE( igrd )
+               CASE( 1 )   ;   CALL lbc_lnk( 'bdyini', ztmp, 'T', 1. ) 
+               CASE( 2 )   ;   CALL lbc_lnk( 'bdyini', ztmp, 'U', 1. ) 
+               CASE( 3 )   ;   CALL lbc_lnk( 'bdyini', ztmp, 'V', 1. ) 
+            END SELECT 
+            DO ib = ibeg, iend
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               idx_bdy(ib_bdy)%flagu(ib,igrd) = ztmp(ii,ij)
+            END DO
          END DO
 
@@ -1213,41 +882,274 @@
          ! flagv =  0 : v is tangential
          ! flagv =  1 : v is normal to the boundary and is direction is inward
-
          DO igrd = 1, jpbgrd 
             SELECT CASE( igrd )
-               CASE( 1 )   ;   pmask => vmask (:,:,1)   ;   j_offset = 0
-               CASE( 2 )   ;   pmask => zfmask(:,:)     ;   j_offset = 0
-               CASE( 3 )   ;   pmask => bdytmask        ;   j_offset = 1
+               CASE( 1 )   ;   zmask => pvmask     ;   j_offset = 0
+               CASE( 2 )   ;   zmask => pfmask     ;   j_offset = 0
+               CASE( 3 )   ;   zmask => bdytmask   ;   j_offset = 1
             END SELECT 
             icount = 0
-            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)  
-               nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
-               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
-               znfl = pmask(nbi,nbj+j_offset-1)
-               zsfl = pmask(nbi,nbj+j_offset  )
+            ztmp(:,:) = -999._wp
+            IF( lrim0 ) THEN   ! extent of rim 0
+               ibeg = 1                                     ;   iend = idx_bdy(ib_bdy)%nblenrim0(igrd)
+            ELSE               ! extent of rim 1
+               ibeg = idx_bdy(ib_bdy)%nblenrim0(igrd) + 1   ;   iend = idx_bdy(ib_bdy)%nblenrim(igrd)
+            END IF
+            DO ib = ibeg, iend
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE
+               zsfl = zmask(ii,ij+j_offset-1)
+               znfl = zmask(ii,ij+j_offset  )
                ! This error check only works if you are using the bdyXmask arrays
-               IF( j_offset == 1 .and. znfl + zsfl == 2 ) THEN
-                  IF(lwp) WRITE(numout,*) 'Problem with igrd = ',igrd,' at (global) nbi, nbj : ',mig(nbi),mjg(nbj)
+               IF( j_offset == 1 .and. znfl + zsfl == 2. ) THEN
+                  IF(lwp) WRITE(numout,*) 'Problem with igrd = ',igrd,' at (global) nbi, nbj : ',mig(ii),mjg(ij)
                   icount = icount + 1
                ELSE
-                  idx_bdy(ib_bdy)%flagv(ib,igrd) = -znfl + zsfl
+                  ztmp(ii,ij) = -zsfl + znfl
                END IF
             END DO
             IF( icount /= 0 ) THEN
-               WRITE(ctmp1,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
+               WRITE(ctmp1,*) 'Some ',cgrid(igrd),' grid points,',   &
                   ' are not boundary points (flagv calculation). Check nbi, nbj, indices for boundary set ',ib_bdy
-               WRITE(ctmp2,*) ' ========== '
-               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
-            ENDIF 
-         END DO
-         !
-      END DO
-      !
-      ! Tidy up
-      !--------
-      IF( nb_bdy>0 )   DEALLOCATE( nbidta, nbjdta, nbrdta )
-      !
-   END SUBROUTINE bdy_segs
-
+               CALL ctl_stop( ctmp1 )
+            ENDIF
+            SELECT CASE( igrd )
+               CASE( 1 )   ;   CALL lbc_lnk( 'bdyini', ztmp, 'T', 1. ) 
+               CASE( 2 )   ;   CALL lbc_lnk( 'bdyini', ztmp, 'U', 1. ) 
+               CASE( 3 )   ;   CALL lbc_lnk( 'bdyini', ztmp, 'V', 1. ) 
+            END SELECT 
+            DO ib = ibeg, iend
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               idx_bdy(ib_bdy)%flagv(ib,igrd) = ztmp(ii,ij)
+            END DO
+         END DO
+         !
+      END DO ! ib_bdy
+      
+      DO ib_bdy = 1, nb_bdy
+         DO igrd = 1, jpbgrd
+            SELECT CASE( igrd )
+               CASE( 1 )   ;   zmask => bdytmask 
+               CASE( 2 )   ;   zmask => bdyumask 
+               CASE( 3 )   ;   zmask => bdyvmask 
+            END SELECT
+            ztmp(:,:) = -999._wp
+            IF( lrim0 ) THEN   ! extent of rim 0
+               ibeg = 1                                     ;   iend = idx_bdy(ib_bdy)%nblenrim0(igrd)
+            ELSE               ! extent of rim 1
+               ibeg = idx_bdy(ib_bdy)%nblenrim0(igrd) + 1   ;   iend = idx_bdy(ib_bdy)%nblenrim(igrd)
+            END IF
+            DO ib = ibeg, iend
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )   CYCLE
+               llnon = zmask(ii  ,ij+1) == 1.  
+               llson = zmask(ii  ,ij-1) == 1. 
+               llean = zmask(ii+1,ij  ) == 1. 
+               llwen = zmask(ii-1,ij  ) == 1. 
+               inn  = COUNT( (/ llnon, llson, llean, llwen /) )
+               IF( inn == 0 ) THEN   ! no neighbours -> interior of a corner  or  cluster of rim points
+                  !               !              !     _____     !     _____    !    __     __
+                  !  1 |   o      !  2  o   |    !  3 | x        !  4     x |   !      |   |   -> error
+                  !    |_x_ _     !    _ _x_|    !    |   o      !      o   |   !      |x_x|
+                  IF(     zmask(ii+1,ij+1) == 1. ) THEN   ;   ztmp(ii,ij) = 1.
+                  ELSEIF( zmask(ii-1,ij+1) == 1. ) THEN   ;   ztmp(ii,ij) = 2.
+                  ELSEIF( zmask(ii+1,ij-1) == 1. ) THEN   ;   ztmp(ii,ij) = 3.
+                  ELSEIF( zmask(ii-1,ij-1) == 1. ) THEN   ;   ztmp(ii,ij) = 4.
+                  ELSE                                    ;   ztmp(ii,ij) = -1.
+                     WRITE(ctmp1,*) 'Problem with  ',cgrid(igrd) ,' grid point', ii, ij,   &
+                       ' on boundary set ', ib_bdy, ' has no free ocean neighbour'
+                     IF( lrim0 ) THEN
+                        WRITE(ctmp2,*) ' There seems to be a cluster of rim 0 points.'
+                     ELSE
+                        WRITE(ctmp2,*) ' There seems to be a cluster of rim 1 points.'
+                     END IF
+                     CALL ctl_warn( ctmp1, ctmp2 )
+                  END IF
+               END IF
+               IF( inn == 1 ) THEN   ! middle of linear bdy  or incomplete corner  ! ___ o
+                  !    |         !         |   !      o     !    ______            !    |x___
+                  ! 5  | x o     ! 6   o x |   ! 7  __x__   ! 8    x
+                  !    |         !         |   !            !      o
+                  IF( llean )   ztmp(ii,ij) = 5.
+                  IF( llwen )   ztmp(ii,ij) = 6.
+                  IF( llnon )   ztmp(ii,ij) = 7.
+                  IF( llson )   ztmp(ii,ij) = 8.
+               END IF
+               IF( inn == 2 ) THEN   ! exterior of a corner
+                  !        o      !        o      !    _____|       !       |_____  
+                  !  9 ____x o    ! 10   o x___   ! 11     x o      ! 12   o x      
+                  !         |     !       |       !        o        !        o 
+                  IF( llnon .AND. llean )   ztmp(ii,ij) =  9.
+                  IF( llnon .AND. llwen )   ztmp(ii,ij) = 10.
+                  IF( llson .AND. llean )   ztmp(ii,ij) = 11.
+                  IF( llson .AND. llwen )   ztmp(ii,ij) = 12.
+               END IF
+               IF( inn == 3 ) THEN   ! 3 neighbours     __   __
+                  !    |_  o      !        o  _|  !       |_|     !       o         
+                  ! 13  _| x o    ! 14   o x |_   ! 15   o x o    ! 16  o x o       
+                  !    |   o      !        o   |  !        o      !    __|¨|__    
+                  IF( llnon .AND. llean .AND. llson )   ztmp(ii,ij) = 13.
+                  IF( llnon .AND. llwen .AND. llson )   ztmp(ii,ij) = 14.
+                  IF( llwen .AND. llson .AND. llean )   ztmp(ii,ij) = 15.
+                  IF( llwen .AND. llnon .AND. llean )   ztmp(ii,ij) = 16.
+               END IF
+               IF( inn == 4 ) THEN
+                  WRITE(ctmp1,*)  'Problem with  ',cgrid(igrd) ,' grid point', ii, ij,   &
+                       ' on boundary set ', ib_bdy, ' have 4 neighbours'
+                  CALL ctl_stop( ctmp1 )
+               END IF
+            END DO
+            SELECT CASE( igrd )
+               CASE( 1 )   ;   CALL lbc_lnk( 'bdyini', ztmp, 'T', 1. ) 
+               CASE( 2 )   ;   CALL lbc_lnk( 'bdyini', ztmp, 'U', 1. ) 
+               CASE( 3 )   ;   CALL lbc_lnk( 'bdyini', ztmp, 'V', 1. ) 
+            END SELECT 
+            DO ib = ibeg, iend
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               idx_bdy(ib_bdy)%ntreat(ib,igrd) = NINT(ztmp(ii,ij))
+            END DO
+         END DO
+      END DO
+
+    END SUBROUTINE bdy_rim_treat
+
+   
+    SUBROUTINE find_neib( ii, ij, itreat, ii1, ij1, ii2, ij2, ii3, ij3 )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE find_neib  ***
+      !!
+      !! ** Purpose :   get ii1, ij1, ii2, ij2, ii3, ij3, the indices of
+      !!               the free ocean neighbours of (ii,ij) for bdy treatment
+      !!
+      !! ** Method  :  use itreat input to select a case
+      !!               N.B. ntreat is defined for all bdy points in routine bdy_rim_treat
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in   )      ::   ii, ij, itreat
+      INTEGER, INTENT(  out)      ::   ii1, ij1, ii2, ij2, ii3, ij3
+      !!----------------------------------------------------------------------
+      SELECT CASE( itreat )   ! points that will be used by bdy routines, -1 will be discarded
+         !               !               !     _____     !     _____     
+         !  1 |   o      !  2  o   |     !  3 | x        !  4     x |    
+         !    |_x_ _     !    _ _x_|     !    |   o      !      o   |
+      CASE( 1 )    ;   ii1 = ii+1   ;   ij1 = ij+1   ;   ii2 = -1     ;   ij2 = -1     ;   ii3 = -1     ;   ij3 = -1
+      CASE( 2 )    ;   ii1 = ii-1   ;   ij1 = ij+1   ;   ii2 = -1     ;   ij2 = -1     ;   ii3 = -1     ;   ij3 = -1
+      CASE( 3 )    ;   ii1 = ii+1   ;   ij1 = ij-1   ;   ii2 = -1     ;   ij2 = -1     ;   ii3 = -1     ;   ij3 = -1
+      CASE( 4 )    ;   ii1 = ii-1   ;   ij1 = ij-1   ;   ii2 = -1     ;   ij2 = -1     ;   ii3 = -1     ;   ij3 = -1
+         !    |          !         |     !      o        !    ______                   ! or incomplete corner
+         ! 5  | x o      ! 6   o x |     ! 7  __x__      ! 8    x                      !  7  ____ o
+         !    |          !         |     !               !      o                      !         |x___
+      CASE( 5 )    ;   ii1 = ii+1   ;   ij1 = ij     ;   ii2 = -1     ;   ij2 = -1     ;   ii3 = -1     ;   ij3 = -1
+      CASE( 6 )    ;   ii1 = ii-1   ;   ij1 = ij     ;   ii2 = -1     ;   ij2 = -1     ;   ii3 = -1     ;   ij3 = -1
+      CASE( 7 )    ;   ii1 = ii     ;   ij1 = ij+1   ;   ii2 = -1     ;   ij2 = -1     ;   ii3 = -1     ;   ij3 = -1
+      CASE( 8 )    ;   ii1 = ii     ;   ij1 = ij-1   ;   ii2 = -1     ;   ij2 = -1     ;   ii3 = -1     ;   ij3 = -1
+         !        o      !        o      !    _____|     !       |_____  
+         !  9 ____x o    ! 10   o x___   ! 11     x o    ! 12   o x      
+         !         |     !       |       !        o      !        o      
+      CASE( 9  )   ;   ii1 = ii     ;   ij1 = ij+1   ;   ii2 = ii+1   ;   ij2 = ij     ;   ii3 = -1     ;   ij3 = -1 
+      CASE( 10 )   ;   ii1 = ii     ;   ij1 = ij+1   ;   ii2 = ii-1   ;   ij2 = ij     ;   ii3 = -1     ;   ij3 = -1
+      CASE( 11 )   ;   ii1 = ii     ;   ij1 = ij-1   ;   ii2 = ii+1   ;   ij2 = ij     ;   ii3 = -1     ;   ij3 = -1
+      CASE( 12 )   ;   ii1 = ii     ;   ij1 = ij-1   ;   ii2 = ii-1   ;   ij2 = ij     ;   ii3 = -1     ;   ij3 = -1
+         !    |_  o      !        o  _|  !     ¨¨|_|¨¨   !       o         
+         ! 13  _| x o    !  14  o x |_   !  15  o x o    ! 16  o x o       
+         !    |   o      !        o   |  !        o      !    __|¨|__ 
+      CASE( 13 )   ;   ii1 = ii     ;   ij1 = ij+1   ;   ii2 = ii+1   ;   ij2 = ij     ;   ii3 = ii     ;   ij3 = ij-1   
+      CASE( 14 )   ;   ii1 = ii     ;   ij1 = ij+1   ;   ii2 = ii-1   ;   ij2 = ij     ;   ii3 = ii     ;   ij3 = ij-1 
+      CASE( 15 )   ;   ii1 = ii-1   ;   ij1 = ij     ;   ii2 = ii     ;   ij2 = ij-1   ;   ii3 = ii+1   ;   ij3 = ij   
+      CASE( 16 )   ;   ii1 = ii-1   ;   ij1 = ij     ;   ii2 = ii     ;   ij2 = ij+1   ;   ii3 = ii+1   ;   ij3 = ij
+      END SELECT
+   END SUBROUTINE find_neib
+    
+
+   SUBROUTINE bdy_read_seg( kb_bdy, knblendta ) 
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE bdy_coords_seg  ***
+      !!
+      !! ** Purpose :  build bdy coordinates with segments defined in namelist
+      !!
+      !! ** Method  :  read namelist nambdy_index blocks
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER                   , INTENT (in   ) ::   kb_bdy           ! bdy number
+      INTEGER, DIMENSION(jpbgrd), INTENT (  out) ::   knblendta        ! length of index arrays 
+      !!
+      INTEGER          ::   ios                 ! Local integer output status for namelist read
+      INTEGER          ::   nbdyind, nbdybeg, nbdyend
+      CHARACTER(LEN=1) ::   ctypebdy   !     -        - 
+      NAMELIST/nambdy_index/ ctypebdy, nbdyind, nbdybeg, nbdyend
+      !!----------------------------------------------------------------------
+
+      ! No REWIND here because may need to read more than one nambdy_index namelist.
+      ! Read only namelist_cfg to avoid unseccessfull overwrite 
+      ! keep full control of the configuration namelist
+      READ  ( numnam_cfg, nambdy_index, IOSTAT = ios, ERR = 904 )
+904   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_index in configuration namelist' )
+      IF(lwm) WRITE ( numond, nambdy_index )
+      
+      SELECT CASE ( TRIM(ctypebdy) )
+      CASE( 'N' )
+         IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
+            nbdyind  = jpjglo - 2  ! set boundary to whole side of model domain.
+            nbdybeg  = 2
+            nbdyend  = jpiglo - 1
+         ENDIF
+         nbdysegn = nbdysegn + 1
+         npckgn(nbdysegn) = kb_bdy ! Save bdy package number
+         jpjnob(nbdysegn) = nbdyind
+         jpindt(nbdysegn) = nbdybeg
+         jpinft(nbdysegn) = nbdyend
+         !
+      CASE( 'S' )
+         IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
+            nbdyind  = 2           ! set boundary to whole side of model domain.
+            nbdybeg  = 2
+            nbdyend  = jpiglo - 1
+         ENDIF
+         nbdysegs = nbdysegs + 1
+         npckgs(nbdysegs) = kb_bdy ! Save bdy package number
+         jpjsob(nbdysegs) = nbdyind
+         jpisdt(nbdysegs) = nbdybeg
+         jpisft(nbdysegs) = nbdyend
+         !
+      CASE( 'E' )
+         IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
+            nbdyind  = jpiglo - 2  ! set boundary to whole side of model domain.
+            nbdybeg  = 2
+            nbdyend  = jpjglo - 1
+         ENDIF
+         nbdysege = nbdysege + 1 
+         npckge(nbdysege) = kb_bdy ! Save bdy package number
+         jpieob(nbdysege) = nbdyind
+         jpjedt(nbdysege) = nbdybeg
+         jpjeft(nbdysege) = nbdyend
+         !
+      CASE( 'W' )
+         IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
+            nbdyind  = 2           ! set boundary to whole side of model domain.
+            nbdybeg  = 2
+            nbdyend  = jpjglo - 1
+         ENDIF
+         nbdysegw = nbdysegw + 1
+         npckgw(nbdysegw) = kb_bdy ! Save bdy package number
+         jpiwob(nbdysegw) = nbdyind
+         jpjwdt(nbdysegw) = nbdybeg
+         jpjwft(nbdysegw) = nbdyend
+         !
+      CASE DEFAULT   ;   CALL ctl_stop( 'ctypebdy must be N, S, E or W' )
+      END SELECT
+      
+      ! For simplicity we assume that in case of straight bdy, arrays have the same length
+      ! (even if it is true that last tangential velocity points
+      ! are useless). This simplifies a little bit boundary data format (and agrees with format
+      ! used so far in obc package)
+      
+      knblendta(1:jpbgrd) =  (nbdyend - nbdybeg + 1) * nn_rimwidth(kb_bdy)
+      
+   END SUBROUTINE bdy_read_seg
+
+   
    SUBROUTINE bdy_ctl_seg
       !!----------------------------------------------------------------------
@@ -1279,6 +1181,6 @@
             &(jpjnob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
          IF (jpindt(ib).ge.jpinft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
-         IF (jpindt(ib).le.1     )     CALL ctl_stop( 'Start index out of domain' )
-         IF (jpinft(ib).ge.jpiglo)     CALL ctl_stop( 'End index out of domain' )
+         IF (jpindt(ib).lt.1     )     CALL ctl_stop( 'Start index out of domain' )
+         IF (jpinft(ib).gt.jpiglo)     CALL ctl_stop( 'End index out of domain' )
       END DO
       !
@@ -1288,6 +1190,6 @@
             &(jpjsob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
          IF (jpisdt(ib).ge.jpisft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
-         IF (jpisdt(ib).le.1     )     CALL ctl_stop( 'Start index out of domain' )
-         IF (jpisft(ib).ge.jpiglo)     CALL ctl_stop( 'End index out of domain' )
+         IF (jpisdt(ib).lt.1     )     CALL ctl_stop( 'Start index out of domain' )
+         IF (jpisft(ib).gt.jpiglo)     CALL ctl_stop( 'End index out of domain' )
       END DO
       !
@@ -1297,6 +1199,6 @@
             &(jpieob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
          IF (jpjedt(ib).ge.jpjeft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
-         IF (jpjedt(ib).le.1     )     CALL ctl_stop( 'Start index out of domain' )
-         IF (jpjeft(ib).ge.jpjglo)     CALL ctl_stop( 'End index out of domain' )
+         IF (jpjedt(ib).lt.1     )     CALL ctl_stop( 'Start index out of domain' )
+         IF (jpjeft(ib).gt.jpjglo)     CALL ctl_stop( 'End index out of domain' )
       END DO
       !
@@ -1306,6 +1208,6 @@
             &(jpiwob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
          IF (jpjwdt(ib).ge.jpjwft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
-         IF (jpjwdt(ib).le.1     )     CALL ctl_stop( 'Start index out of domain' )
-         IF (jpjwft(ib).ge.jpjglo)     CALL ctl_stop( 'End index out of domain' )
+         IF (jpjwdt(ib).lt.1     )     CALL ctl_stop( 'Start index out of domain' )
+         IF (jpjwft(ib).gt.jpjglo)     CALL ctl_stop( 'End index out of domain' )
       ENDDO
       !
@@ -1336,15 +1238,15 @@
                      icorns(ib2,1) = npckgw(ib1)
                   ELSEIF ((jpisft(ib2)==jpiwob(ib1)).AND.(jpjwft(ib1)==jpjsob(ib2))) THEN
-                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     WRITE(ctmp1,*) ' Found an acute open boundary corner at point (i,j)= ', &
                         &                                     jpisft(ib2), jpjwft(ib1)
-                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
-                     WRITE(ctmp3,*) '             Crossing problem with West segment: ',npckgw(ib1), & 
-                        &                                        ' and South segment: ',npckgs(ib2)
-                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
+                     WRITE(ctmp2,*) ' Not allowed yet'
+                     WRITE(ctmp3,*) ' Crossing problem with West segment: ',npckgw(ib1), & 
+                        &                            ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ctmp1, ctmp2, ctmp3 )
                   ELSE
-                     WRITE(ctmp1,*) ' E R R O R : Check South and West Open boundary indices'
-                     WRITE(ctmp2,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1) , &
-                        &                                         ' and South segment: ',npckgs(ib2)
-                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+                     WRITE(ctmp1,*) ' Check South and West Open boundary indices'
+                     WRITE(ctmp2,*) ' Crossing problem with West segment: ',npckgw(ib1) , &
+                        &                            ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ctmp1, ctmp2 )
                   END IF
                END IF
@@ -1368,15 +1270,15 @@
                      icorns(ib2,2) = npckge(ib1)
                   ELSEIF ((jpjeft(ib1)==jpjsob(ib2)).AND.(jpisdt(ib2)==jpieob(ib1)+1)) THEN
-                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     WRITE(ctmp1,*) ' Found an acute open boundary corner at point (i,j)= ', &
                         &                                     jpisdt(ib2), jpjeft(ib1)
-                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
-                     WRITE(ctmp3,*) '             Crossing problem with East segment: ',npckge(ib1), &
-                        &                                        ' and South segment: ',npckgs(ib2)
-                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
+                     WRITE(ctmp2,*) ' Not allowed yet'
+                     WRITE(ctmp3,*) ' Crossing problem with East segment: ',npckge(ib1), &
+                        &                            ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ctmp1, ctmp2, ctmp3 )
                   ELSE
-                     WRITE(ctmp1,*) ' E R R O R : Check South and East Open boundary indices'
-                     WRITE(ctmp2,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
-                     &                                           ' and South segment: ',npckgs(ib2)
-                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+                     WRITE(ctmp1,*) ' Check South and East Open boundary indices'
+                     WRITE(ctmp2,*) ' Crossing problem with East segment: ',npckge(ib1), &
+                     &                               ' and South segment: ',npckgs(ib2)
+                     CALL ctl_stop( ctmp1, ctmp2 )
                   END IF
                END IF
@@ -1400,15 +1302,15 @@
                      icornn(ib2,1) = npckgw(ib1)
                   ELSEIF ((jpjwdt(ib1)==jpjnob(ib2)+1).AND.(jpinft(ib2)==jpiwob(ib1))) THEN
-                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     WRITE(ctmp1,*) ' Found an acute open boundary corner at point (i,j)= ', &
                      &                                     jpinft(ib2), jpjwdt(ib1)
-                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
-                     WRITE(ctmp3,*) '             Crossing problem with West segment: ',npckgw(ib1), &
-                     &                                                    ' and North segment: ',npckgn(ib2)
-                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
+                     WRITE(ctmp2,*) ' Not allowed yet'
+                     WRITE(ctmp3,*) ' Crossing problem with West segment: ',npckgw(ib1), &
+                     &                               ' and North segment: ',npckgn(ib2)
+                     CALL ctl_stop( ctmp1, ctmp2, ctmp3 )
                   ELSE
-                     WRITE(ctmp1,*) ' E R R O R : Check North and West Open boundary indices'
-                     WRITE(ctmp2,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1), &
-                     &                                                    ' and North segment: ',npckgn(ib2)
-                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+                     WRITE(ctmp1,*) ' Check North and West Open boundary indices'
+                     WRITE(ctmp2,*) ' Crossing problem with West segment: ',npckgw(ib1), &
+                     &                               ' and North segment: ',npckgn(ib2)
+                     CALL ctl_stop( ctmp1, ctmp2 )
                   END IF
                END IF
@@ -1432,15 +1334,15 @@
                      icornn(ib2,2) = npckge(ib1)
                   ELSEIF ((jpjedt(ib1)==jpjnob(ib2)+1).AND.(jpindt(ib2)==jpieob(ib1)+1)) THEN
-                     WRITE(ctmp1,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     WRITE(ctmp1,*) ' Found an acute open boundary corner at point (i,j)= ', &
                      &                                     jpindt(ib2), jpjedt(ib1)
-                     WRITE(ctmp2,*) ' ==========  Not allowed yet'
-                     WRITE(ctmp3,*) '             Crossing problem with East segment: ',npckge(ib1), &
-                     &                                           ' and North segment: ',npckgn(ib2)
-                     CALL ctl_stop( ' ', ctmp1, ctmp2, ctmp3, ' ' )
+                     WRITE(ctmp2,*) ' Not allowed yet'
+                     WRITE(ctmp3,*) ' Crossing problem with East segment: ',npckge(ib1), &
+                     &                               ' and North segment: ',npckgn(ib2)
+                     CALL ctl_stop( ctmp1, ctmp2, ctmp3 )
                   ELSE
-                     WRITE(ctmp1,*) ' E R R O R : Check North and East Open boundary indices'
-                     WRITE(ctmp2,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
-                     &                                           ' and North segment: ',npckgn(ib2)
-                     CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+                     WRITE(ctmp1,*) ' Check North and East Open boundary indices'
+                     WRITE(ctmp2,*) ' Crossing problem with East segment: ',npckge(ib1), &
+                     &                               ' and North segment: ',npckgn(ib2)
+                     CALL ctl_stop( ctmp1, ctmp2 )
                   END IF
                END IF
@@ -1468,7 +1370,6 @@
          IF (ztestmask(1)==1) THEN 
             IF (icornw(ib,1)==0) THEN
-               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgw(ib)
-               WRITE(ctmp2,*) ' ==========  does not start on land or on a corner'                                                  
-               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+               WRITE(ctmp1,*) ' Open boundary segment ', npckgw(ib)
+               CALL ctl_stop( ctmp1, ' does not start on land or on a corner' )
             ELSE
                ! This is a corner
@@ -1480,7 +1381,6 @@
          IF (ztestmask(2)==1) THEN
             IF (icornw(ib,2)==0) THEN
-               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgw(ib)
-               WRITE(ctmp2,*) ' ==========  does not end on land or on a corner'                                                  
-               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+               WRITE(ctmp1,*) ' Open boundary segment ', npckgw(ib)
+               CALL ctl_stop( ' ', ctmp1, ' does not end on land or on a corner' )
             ELSE
                ! This is a corner
@@ -1508,7 +1408,6 @@
          IF (ztestmask(1)==1) THEN
             IF (icorne(ib,1)==0) THEN
-               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckge(ib)
-               WRITE(ctmp2,*) ' ==========  does not start on land or on a corner'                                                  
-               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+               WRITE(ctmp1,*) ' Open boundary segment ', npckge(ib)
+               CALL ctl_stop( ctmp1, ' does not start on land or on a corner' )
             ELSE
                ! This is a corner
@@ -1520,7 +1419,6 @@
          IF (ztestmask(2)==1) THEN
             IF (icorne(ib,2)==0) THEN
-               WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckge(ib)
-               WRITE(ctmp2,*) ' ==========  does not end on land or on a corner'                                                  
-               CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+               WRITE(ctmp1,*) ' Open boundary segment ', npckge(ib)
+               CALL ctl_stop( ctmp1, ' does not end on land or on a corner' )
             ELSE
                ! This is a corner
@@ -1547,12 +1445,10 @@
 
          IF ((ztestmask(1)==1).AND.(icorns(ib,1)==0)) THEN
-            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgs(ib)
-            WRITE(ctmp2,*) ' ==========  does not start on land or on a corner'                                                  
-            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+            WRITE(ctmp1,*) ' Open boundary segment ', npckgs(ib)
+            CALL ctl_stop( ctmp1, ' does not start on land or on a corner' )
          ENDIF
          IF ((ztestmask(2)==1).AND.(icorns(ib,2)==0)) THEN
-            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgs(ib)
-            WRITE(ctmp2,*) ' ==========  does not end on land or on a corner'                                                  
-            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+            WRITE(ctmp1,*) ' Open boundary segment ', npckgs(ib)
+            CALL ctl_stop( ctmp1, ' does not end on land or on a corner' )
          ENDIF
       END DO
@@ -1573,12 +1469,10 @@
 
          IF ((ztestmask(1)==1).AND.(icornn(ib,1)==0)) THEN
-            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgn(ib)
-            WRITE(ctmp2,*) ' ==========  does not start on land'                                                  
-            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+            WRITE(ctmp1,*) ' Open boundary segment ', npckgn(ib)
+            CALL ctl_stop( ctmp1, ' does not start on land' )
          ENDIF
          IF ((ztestmask(2)==1).AND.(icornn(ib,2)==0)) THEN
-            WRITE(ctmp1,*) ' E R R O R : Open boundary segment ', npckgn(ib)
-            WRITE(ctmp2,*) ' ==========  does not end on land'                                                  
-            CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+            WRITE(ctmp1,*) ' Open boundary segment ', npckgn(ib)
+            CALL ctl_stop( ctmp1, ' does not end on land' )
          ENDIF
       END DO
@@ -1593,5 +1487,206 @@
    END SUBROUTINE bdy_ctl_seg
 
-
+   
+   SUBROUTINE bdy_coords_seg( nbidta, nbjdta, nbrdta ) 
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE bdy_coords_seg  ***
+      !!
+      !! ** Purpose :  build nbidta, nbidta, nbrdta for bdy built with segments
+      !!
+      !! ** Method  :  
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, DIMENSION(:,:,:), intent(  out)  ::   nbidta, nbjdta, nbrdta   ! Index arrays: i and j indices of bdy dta
+      !!
+      INTEGER  ::   ii, ij, ir, iseg
+      INTEGER  ::   igrd         ! grid type (t=1, u=2, v=3)
+      INTEGER  ::   icount       ! 
+      INTEGER  ::   ib_bdy       ! bdy number
+      !!----------------------------------------------------------------------
+
+      ! East
+      !-----
+      DO iseg = 1, nbdysege
+         ib_bdy = npckge(iseg)
+         !
+         ! ------------ T points -------------
+         igrd=1
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ij = jpjedt(iseg), jpjeft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 2 - ir
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ U points -------------
+         igrd=2
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ij = jpjedt(iseg), jpjeft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 1 - ir
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ V points -------------
+         igrd=3
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            !            DO ij = jpjedt(iseg), jpjeft(iseg) - 1
+            DO ij = jpjedt(iseg), jpjeft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 2 - ir
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+         ENDDO
+      ENDDO
+      !
+      ! West
+      !-----
+      DO iseg = 1, nbdysegw
+         ib_bdy = npckgw(iseg)
+         !
+         ! ------------ T points -------------
+         igrd=1
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ij = jpjwdt(iseg), jpjwft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ U points -------------
+         igrd=2
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ij = jpjwdt(iseg), jpjwft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ V points -------------
+         igrd=3
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            !            DO ij = jpjwdt(iseg), jpjwft(iseg) - 1
+            DO ij = jpjwdt(iseg), jpjwft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+         ENDDO
+      ENDDO
+      !
+      ! North
+      !-----
+      DO iseg = 1, nbdysegn
+         ib_bdy = npckgn(iseg)
+         !
+         ! ------------ T points -------------
+         igrd=1
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ii = jpindt(iseg), jpinft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 2 - ir 
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ U points -------------
+         igrd=2
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            !            DO ii = jpindt(iseg), jpinft(iseg) - 1
+            DO ii = jpindt(iseg), jpinft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 2 - ir
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+         ENDDO
+         !
+         ! ------------ V points -------------
+         igrd=3
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ii = jpindt(iseg), jpinft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 1 - ir
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+      ENDDO
+      !
+      ! South
+      !-----
+      DO iseg = 1, nbdysegs
+         ib_bdy = npckgs(iseg)
+         !
+         ! ------------ T points -------------
+         igrd=1
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ii = jpisdt(iseg), jpisft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ U points -------------
+         igrd=2
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            !            DO ii = jpisdt(iseg), jpisft(iseg) - 1
+            DO ii = jpisdt(iseg), jpisft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+         ENDDO
+         !
+         ! ------------ V points -------------
+         igrd=3
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ii = jpisdt(iseg), jpisft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+      ENDDO
+
+      
+   END SUBROUTINE bdy_coords_seg
+   
+   
    SUBROUTINE bdy_ctl_corn( ib1, ib2 )
       !!----------------------------------------------------------------------
@@ -1619,11 +1714,79 @@
       !
       IF( itest>0 ) THEN
-         WRITE(ctmp1,*) ' E R R O R : Segments ', ib1, 'and ', ib2
-         WRITE(ctmp2,*) ' ==========  have different open bdy schemes'                                                  
-         CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+         WRITE(ctmp1,*) ' Segments ', ib1, 'and ', ib2
+         CALL ctl_stop( ctmp1, ' have different open bdy schemes' )
       ENDIF
       !
    END SUBROUTINE bdy_ctl_corn
 
+
+   SUBROUTINE bdy_meshwri()
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE bdy_meshwri  ***
+      !!         
+      !! ** Purpose :   write netcdf file with nbr, flagu, flagv, ntreat for T, U 
+      !!                and V points in 2D arrays for easier visualisation/control
+      !!
+      !! ** Method  :   use iom_rstput as in domwri.F
+      !!----------------------------------------------------------------------      
+      INTEGER  ::   ib_bdy, ii, ij, igrd, ib     ! dummy loop indices
+      INTEGER  ::   inum                                   !   -       -
+      REAL(wp), POINTER, DIMENSION(:,:)     ::   zmask                   ! pointer to 2D mask fields
+      REAL(wp)         , DIMENSION(jpi,jpj) ::   ztmp
+      CHARACTER(LEN=1) , DIMENSION(jpbgrd)  ::   cgrid
+      !!----------------------------------------------------------------------      
+      cgrid = (/'t','u','v'/)
+      CALL iom_open( 'bdy_mesh', inum, ldwrt = .TRUE. )
+      DO igrd = 1, jpbgrd
+         SELECT CASE( igrd )
+         CASE( 1 )   ;   zmask => tmask(:,:,1)
+         CASE( 2 )   ;   zmask => umask(:,:,1)
+         CASE( 3 )   ;   zmask => vmask(:,:,1)
+         END SELECT
+         ztmp(:,:) = zmask(:,:)
+         DO ib_bdy = 1, nb_bdy
+            DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)      ! nbr deined for all rims
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               ztmp(ii,ij) = REAL(idx_bdy(ib_bdy)%nbr(ib,igrd), wp) + 10.
+               IF( zmask(ii,ij) == 0. ) ztmp(ii,ij) = - ztmp(ii,ij)
+            END DO
+         END DO
+         CALL iom_rstput( 0, 0, inum, 'bdy_nbr_'//cgrid(igrd), ztmp(:,:), ktype = jp_i4 )
+         ztmp(:,:) = zmask(:,:)
+         DO ib_bdy = 1, nb_bdy
+            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)   ! flagu defined only for rims 0 and 1
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               ztmp(ii,ij) = REAL(idx_bdy(ib_bdy)%flagu(ib,igrd), wp) + 10.
+               IF( zmask(ii,ij) == 0. ) ztmp(ii,ij) = - ztmp(ii,ij)
+            END DO
+         END DO
+         CALL iom_rstput( 0, 0, inum, 'flagu_'//cgrid(igrd), ztmp(:,:), ktype = jp_i4 )
+         ztmp(:,:) = zmask(:,:)
+         DO ib_bdy = 1, nb_bdy
+            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)   ! flagv defined only for rims 0 and 1
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               ztmp(ii,ij) = REAL(idx_bdy(ib_bdy)%flagv(ib,igrd), wp) + 10.
+               IF( zmask(ii,ij) == 0. ) ztmp(ii,ij) = - ztmp(ii,ij)
+            END DO
+         END DO
+         CALL iom_rstput( 0, 0, inum, 'flagv_'//cgrid(igrd), ztmp(:,:), ktype = jp_i4 )
+         ztmp(:,:) = zmask(:,:)
+         DO ib_bdy = 1, nb_bdy
+            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)   ! ntreat defined only for rims 0 and 1
+               ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
+               ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+               ztmp(ii,ij) = REAL(idx_bdy(ib_bdy)%ntreat(ib,igrd), wp) + 10.
+               IF( zmask(ii,ij) == 0. ) ztmp(ii,ij) = - ztmp(ii,ij)
+            END DO
+         END DO
+         CALL iom_rstput( 0, 0, inum, 'ntreat_'//cgrid(igrd), ztmp(:,:), ktype = jp_i4 )
+      END DO
+      CALL iom_close( inum )
+
+   END SUBROUTINE bdy_meshwri
+   
    !!=================================================================================
 END MODULE bdyini
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdylib.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdylib.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdylib.F90	(revision 12143)
@@ -15,4 +15,5 @@
    USE bdy_oce        ! ocean open boundary conditions
    USE phycst         ! physical constants
+   USE bdyini
    !
    USE in_out_manager !
@@ -75,5 +76,4 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pta  ! tracer trend
       !!
-      REAL(wp) ::   zwgt           ! boundary weight
       INTEGER  ::   ib, ik, igrd   ! dummy loop indices
       INTEGER  ::   ii, ij         ! 2D addresses
@@ -92,5 +92,5 @@
 
 
-   SUBROUTINE bdy_orl( idx, ptb, pta, dta, ll_npo )
+   SUBROUTINE bdy_orl( idx, ptb, pta, dta, lrim0, ll_npo )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_orl  ***
@@ -104,4 +104,5 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   ptb  ! before tracer field
       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pta  ! tracer trend
+      LOGICAL                 , OPTIONAL,  INTENT(in) ::   lrim0   ! indicate if rim 0 is treated
       LOGICAL,                             INTENT(in) ::   ll_npo  ! switch for NPO version
       !!
@@ -111,10 +112,10 @@
       igrd = 1                       ! Everything is at T-points here
       !
-      CALL bdy_orlanski_3d( idx, igrd, ptb(:,:,:), pta(:,:,:), dta, ll_npo )
+      CALL bdy_orlanski_3d( idx, igrd, ptb(:,:,:), pta(:,:,:), dta, lrim0, ll_npo )
       !
    END SUBROUTINE bdy_orl
 
 
-   SUBROUTINE bdy_orlanski_2d( idx, igrd, phib, phia, phi_ext, ll_npo )
+   SUBROUTINE bdy_orlanski_2d( idx, igrd, phib, phia, phi_ext, lrim0, ll_npo )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_orlanski_2d  ***
@@ -132,4 +133,5 @@
       REAL(wp), DIMENSION(:,:), INTENT(inout) ::   phia     ! model after 2D field (to be updated)
       REAL(wp), DIMENSION(:)  , INTENT(in   ) ::   phi_ext  ! external forcing data
+      LOGICAL, OPTIONAL,        INTENT(in   ) ::   lrim0    ! indicate if rim 0 is treated
       LOGICAL ,                 INTENT(in   ) ::   ll_npo   ! switch for NPO version
       !
@@ -140,4 +142,5 @@
       INTEGER  ::   ii_offset, ij_offset                   ! offsets for mask indices
       INTEGER  ::   flagu, flagv                           ! short cuts
+      INTEGER  ::   ibeg, iend                             ! length of rim to be treated (rim 0 or rim 1 or both)
       REAL(wp) ::   zmask_x, zmask_y1, zmask_y2
       REAL(wp) ::   zex1, zex2, zey, zey1, zey2
@@ -146,7 +149,7 @@
       REAL(wp) ::   zdy_1, zdy_2, zsign_ups
       REAL(wp), PARAMETER :: zepsilon = 1.e-30                 ! local small value
-      REAL(wp), POINTER, DIMENSION(:,:)          :: pmask      ! land/sea mask for field
-      REAL(wp), POINTER, DIMENSION(:,:)          :: pmask_xdif ! land/sea mask for x-derivatives
-      REAL(wp), POINTER, DIMENSION(:,:)          :: pmask_ydif ! land/sea mask for y-derivatives
+      REAL(wp), POINTER, DIMENSION(:,:)          :: zmask      ! land/sea mask for field
+      REAL(wp), POINTER, DIMENSION(:,:)          :: zmask_xdif ! land/sea mask for x-derivatives
+      REAL(wp), POINTER, DIMENSION(:,:)          :: zmask_ydif ! land/sea mask for y-derivatives
       REAL(wp), POINTER, DIMENSION(:,:)          :: pe_xdif    ! scale factors for x-derivatives
       REAL(wp), POINTER, DIMENSION(:,:)          :: pe_ydif    ! scale factors for y-derivatives
@@ -159,7 +162,7 @@
       SELECT CASE(igrd)
          CASE(1)
-            pmask      => tmask(:,:,1)
-            pmask_xdif => umask(:,:,1)
-            pmask_ydif => vmask(:,:,1)
+            zmask      => tmask(:,:,1)
+            zmask_xdif => umask(:,:,1)
+            zmask_ydif => vmask(:,:,1)
             pe_xdif    => e1u(:,:)
             pe_ydif    => e2v(:,:)
@@ -167,7 +170,7 @@
             ij_offset = 0
          CASE(2)
-            pmask      => umask(:,:,1)
-            pmask_xdif => tmask(:,:,1)
-            pmask_ydif => fmask(:,:,1)
+            zmask      => umask(:,:,1)
+            zmask_xdif => tmask(:,:,1)
+            zmask_ydif => fmask(:,:,1)
             pe_xdif    => e1t(:,:)
             pe_ydif    => e2f(:,:)
@@ -175,7 +178,7 @@
             ij_offset = 0
          CASE(3)
-            pmask      => vmask(:,:,1)
-            pmask_xdif => fmask(:,:,1)
-            pmask_ydif => tmask(:,:,1)
+            zmask      => vmask(:,:,1)
+            zmask_xdif => fmask(:,:,1)
+            zmask_ydif => tmask(:,:,1)
             pe_xdif    => e1f(:,:)
             pe_ydif    => e2t(:,:)
@@ -185,7 +188,15 @@
       END SELECT
       !
-      DO jb = 1, idx%nblenrim(igrd)
+      IF( PRESENT(lrim0) ) THEN
+         IF( lrim0 ) THEN   ;   ibeg = 1                       ;   iend = idx%nblenrim0(igrd)   ! rim 0
+         ELSE               ;   ibeg = idx%nblenrim0(igrd)+1   ;   iend = idx%nblenrim(igrd)    ! rim 1
+         END IF
+      ELSE                  ;   ibeg = 1                       ;   iend = idx%nblenrim(igrd)    ! both
+      END IF
+      !
+      DO jb = ibeg, iend
          ii  = idx%nbi(jb,igrd)
          ij  = idx%nbj(jb,igrd) 
+         IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )   CYCLE
          flagu = int( idx%flagu(jb,igrd) )
          flagv = int( idx%flagv(jb,igrd) )
@@ -203,12 +214,12 @@
          !
          ! Calculate scale factors for calculation of spatial derivatives.        
-         zex1 = ( abs(iibm1-iibm2) * pe_xdif(iibm1+ii_offset,ijbm1          )         &
-        &       + abs(ijbm1-ijbm2) * pe_ydif(iibm1          ,ijbm1+ij_offset) ) 
-         zex2 = ( abs(iibm1-iibm2) * pe_xdif(iibm2+ii_offset,ijbm2          )         &
-        &       + abs(ijbm1-ijbm2) * pe_ydif(iibm2          ,ijbm2+ij_offset) ) 
-         zey1 = ( (iibm1-iibm1jm1) * pe_xdif(iibm1jm1+ii_offset,ijbm1jm1          )  & 
+         zex1 = ( abs(iibm1-iibm2) * pe_xdif(iibm1   +ii_offset,ijbm1             )   &
+        &       + abs(ijbm1-ijbm2) * pe_ydif(iibm1             ,ijbm1   +ij_offset) ) 
+         zex2 = ( abs(iibm1-iibm2) * pe_xdif(iibm2   +ii_offset,ijbm2             )   &
+        &       + abs(ijbm1-ijbm2) * pe_ydif(iibm2             ,ijbm2   +ij_offset) ) 
+         zey1 = ( (iibm1-iibm1jm1) * pe_xdif(iibm1jm1+ii_offset,ijbm1jm1          )   & 
         &      +  (ijbm1-ijbm1jm1) * pe_ydif(iibm1jm1          ,ijbm1jm1+ij_offset) ) 
-         zey2 = ( (iibm1jp1-iibm1) * pe_xdif(iibm1+ii_offset,ijbm1)                  &
-        &      +  (ijbm1jp1-ijbm1) * pe_ydif(iibm1          ,ijbm1+ij_offset) ) 
+         zey2 = ( (iibm1jp1-iibm1) * pe_xdif(iibm1   +ii_offset,ijbm1             )   &
+        &      +  (ijbm1jp1-ijbm1) * pe_ydif(iibm1             ,ijbm1   +ij_offset) ) 
          ! make sure scale factors are nonzero
          if( zey1 .lt. rsmall ) zey1 = zey2
@@ -217,11 +228,11 @@
          zey1 = max(zey1,rsmall); zey2 = max(zey2,rsmall); 
          !
-         ! Calculate masks for calculation of spatial derivatives.        
-         zmask_x = ( abs(iibm1-iibm2) * pmask_xdif(iibm2+ii_offset,ijbm2          )         &
-        &          + abs(ijbm1-ijbm2) * pmask_ydif(iibm2          ,ijbm2+ij_offset) ) 
-         zmask_y1 = ( (iibm1-iibm1jm1) * pmask_xdif(iibm1jm1+ii_offset,ijbm1jm1          )  & 
-        &          +  (ijbm1-ijbm1jm1) * pmask_ydif(iibm1jm1          ,ijbm1jm1+ij_offset) ) 
-         zmask_y2 = ( (iibm1jp1-iibm1) * pmask_xdif(iibm1+ii_offset,ijbm1)                  &
-        &          +  (ijbm1jp1-ijbm1) * pmask_ydif(iibm1          ,ijbm1+ij_offset) ) 
+         ! Calculate masks for calculation of spatial derivatives.
+         zmask_x  = ( abs(iibm1-iibm2) * zmask_xdif(iibm2   +ii_offset,ijbm2               )   &
+        &           + abs(ijbm1-ijbm2) * zmask_ydif(iibm2             ,ijbm2   +ij_offset) ) 
+         zmask_y1 = ( (iibm1-iibm1jm1) * zmask_xdif(iibm1jm1+ii_offset,ijbm1jm1            )   & 
+        &          +  (ijbm1-ijbm1jm1) * zmask_ydif(iibm1jm1          ,ijbm1jm1+ij_offset) ) 
+         zmask_y2 = ( (iibm1jp1-iibm1) * zmask_xdif(iibm1   +ii_offset,ijbm1               )   &
+        &          +  (ijbm1jp1-ijbm1) * zmask_ydif(iibm1             ,ijbm1   +ij_offset) ) 
 
          ! Calculation of terms required for both versions of the scheme. 
@@ -231,8 +242,8 @@
          ! Note no rdt factor in expression for zdt because it cancels in the expressions for 
          ! zrx and zry.
-         zdt = phia(iibm1,ijbm1) - phib(iibm1,ijbm1)
-         zdx = ( ( phia(iibm1,ijbm1) - phia(iibm2,ijbm2) ) / zex2 ) * zmask_x 
+         zdt   =     phia(iibm1   ,ijbm1   ) - phib(iibm1   ,ijbm1   )
+         zdx   = ( ( phia(iibm1   ,ijbm1   ) - phia(iibm2   ,ijbm2   ) ) / zex2 ) * zmask_x 
          zdy_1 = ( ( phib(iibm1   ,ijbm1   ) - phib(iibm1jm1,ijbm1jm1) ) / zey1 ) * zmask_y1    
-         zdy_2 = ( ( phib(iibm1jp1,ijbm1jp1) - phib(iibm1   ,ijbm1)    ) / zey2 ) * zmask_y2 
+         zdy_2 = ( ( phib(iibm1jp1,ijbm1jp1) - phib(iibm1   ,ijbm1   ) ) / zey2 ) * zmask_y2 
          zdy_centred = 0.5 * ( zdy_1 + zdy_2 )
 !!$         zdy_centred = phib(iibm1jp1,ijbm1jp1) - phib(iibm1jm1,ijbm1jm1)
@@ -265,5 +276,5 @@
            &                    + zwgt * ( phi_ext(jb) - phib(ii,ij) ) ) / ( 1. + zrx ) 
          end if
-         phia(ii,ij) = phia(ii,ij) * pmask(ii,ij)
+         phia(ii,ij) = phia(ii,ij) * zmask(ii,ij)
       END DO
       !
@@ -271,5 +282,5 @@
 
 
-   SUBROUTINE bdy_orlanski_3d( idx, igrd, phib, phia, phi_ext, ll_npo )
+   SUBROUTINE bdy_orlanski_3d( idx, igrd, phib, phia, phi_ext, lrim0, ll_npo )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_orlanski_3d  ***
@@ -287,4 +298,5 @@
       REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   phia     ! model after 3D field (to be updated)
       REAL(wp), DIMENSION(:,:)  , INTENT(in   ) ::   phi_ext  ! external forcing data
+      LOGICAL, OPTIONAL,          INTENT(in   ) ::   lrim0    ! indicate if rim 0 is treated
       LOGICAL ,                   INTENT(in   ) ::   ll_npo   ! switch for NPO version
       !
@@ -295,4 +307,5 @@
       INTEGER  ::   ii_offset, ij_offset                   ! offsets for mask indices
       INTEGER  ::   flagu, flagv                           ! short cuts
+      INTEGER  ::   ibeg, iend                             ! length of rim to be treated (rim 0 or rim 1 or both)
       REAL(wp) ::   zmask_x, zmask_y1, zmask_y2
       REAL(wp) ::   zex1, zex2, zey, zey1, zey2
@@ -301,7 +314,7 @@
       REAL(wp) ::   zdy_1, zdy_2,  zsign_ups
       REAL(wp), PARAMETER :: zepsilon = 1.e-30                 ! local small value
-      REAL(wp), POINTER, DIMENSION(:,:,:)        :: pmask      ! land/sea mask for field
-      REAL(wp), POINTER, DIMENSION(:,:,:)        :: pmask_xdif ! land/sea mask for x-derivatives
-      REAL(wp), POINTER, DIMENSION(:,:,:)        :: pmask_ydif ! land/sea mask for y-derivatives
+      REAL(wp), POINTER, DIMENSION(:,:,:)        :: zmask      ! land/sea mask for field
+      REAL(wp), POINTER, DIMENSION(:,:,:)        :: zmask_xdif ! land/sea mask for x-derivatives
+      REAL(wp), POINTER, DIMENSION(:,:,:)        :: zmask_ydif ! land/sea mask for y-derivatives
       REAL(wp), POINTER, DIMENSION(:,:)          :: pe_xdif    ! scale factors for x-derivatives
       REAL(wp), POINTER, DIMENSION(:,:)          :: pe_ydif    ! scale factors for y-derivatives
@@ -314,7 +327,7 @@
       SELECT CASE(igrd)
          CASE(1)
-            pmask      => tmask(:,:,:)
-            pmask_xdif => umask(:,:,:)
-            pmask_ydif => vmask(:,:,:)
+            zmask      => tmask(:,:,:)
+            zmask_xdif => umask(:,:,:)
+            zmask_ydif => vmask(:,:,:)
             pe_xdif    => e1u(:,:)
             pe_ydif    => e2v(:,:)
@@ -322,7 +335,7 @@
             ij_offset = 0
          CASE(2)
-            pmask      => umask(:,:,:)
-            pmask_xdif => tmask(:,:,:)
-            pmask_ydif => fmask(:,:,:)
+            zmask      => umask(:,:,:)
+            zmask_xdif => tmask(:,:,:)
+            zmask_ydif => fmask(:,:,:)
             pe_xdif    => e1t(:,:)
             pe_ydif    => e2f(:,:)
@@ -330,7 +343,7 @@
             ij_offset = 0
          CASE(3)
-            pmask      => vmask(:,:,:)
-            pmask_xdif => fmask(:,:,:)
-            pmask_ydif => tmask(:,:,:)
+            zmask      => vmask(:,:,:)
+            zmask_xdif => fmask(:,:,:)
+            zmask_ydif => tmask(:,:,:)
             pe_xdif    => e1f(:,:)
             pe_ydif    => e2t(:,:)
@@ -339,10 +352,18 @@
          CASE DEFAULT ;   CALL ctl_stop( 'unrecognised value for igrd in bdy_orlanksi_2d' )
       END SELECT
-
+      !
+      IF( PRESENT(lrim0) ) THEN
+         IF( lrim0 ) THEN   ;   ibeg = 1                       ;   iend = idx%nblenrim0(igrd)   ! rim 0
+         ELSE               ;   ibeg = idx%nblenrim0(igrd)+1   ;   iend = idx%nblenrim(igrd)    ! rim 1
+         END IF
+      ELSE                  ;   ibeg = 1                       ;   iend = idx%nblenrim(igrd)    ! both
+      END IF
+      !
       DO jk = 1, jpk
          !            
-         DO jb = 1, idx%nblenrim(igrd)
+         DO jb = ibeg, iend
             ii  = idx%nbi(jb,igrd)
             ij  = idx%nbj(jb,igrd) 
+            IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )   CYCLE
             flagu = int( idx%flagu(jb,igrd) )
             flagv = int( idx%flagv(jb,igrd) )
@@ -360,12 +381,12 @@
             !
             ! Calculate scale factors for calculation of spatial derivatives.        
-            zex1 = ( abs(iibm1-iibm2) * pe_xdif(iibm1+ii_offset,ijbm1          )         &
-           &       + abs(ijbm1-ijbm2) * pe_ydif(iibm1          ,ijbm1+ij_offset) ) 
-            zex2 = ( abs(iibm1-iibm2) * pe_xdif(iibm2+ii_offset,ijbm2          )         &
-           &       + abs(ijbm1-ijbm2) * pe_ydif(iibm2          ,ijbm2+ij_offset) ) 
-            zey1 = ( (iibm1-iibm1jm1) * pe_xdif(iibm1jm1+ii_offset,ijbm1jm1          )  & 
+            zex1 = ( abs(iibm1-iibm2) * pe_xdif(iibm1   +ii_offset,ijbm1             )   &
+           &       + abs(ijbm1-ijbm2) * pe_ydif(iibm1             ,ijbm1+ij_offset   ) ) 
+            zex2 = ( abs(iibm1-iibm2) * pe_xdif(iibm2   +ii_offset,ijbm2             )   &
+           &       + abs(ijbm1-ijbm2) * pe_ydif(iibm2             ,ijbm2+ij_offset   ) ) 
+            zey1 = ( (iibm1-iibm1jm1) * pe_xdif(iibm1jm1+ii_offset,ijbm1jm1          )   & 
            &      +  (ijbm1-ijbm1jm1) * pe_ydif(iibm1jm1          ,ijbm1jm1+ij_offset) ) 
-            zey2 = ( (iibm1jp1-iibm1) * pe_xdif(iibm1+ii_offset,ijbm1)                  &
-           &      +  (ijbm1jp1-ijbm1) * pe_ydif(iibm1          ,ijbm1+ij_offset) ) 
+            zey2 = ( (iibm1jp1-iibm1) * pe_xdif(iibm1   +ii_offset,ijbm1             )   &
+           &      +  (ijbm1jp1-ijbm1) * pe_ydif(iibm1             ,ijbm1+ij_offset   ) ) 
             ! make sure scale factors are nonzero
             if( zey1 .lt. rsmall ) zey1 = zey2
@@ -375,10 +396,10 @@
             !
             ! Calculate masks for calculation of spatial derivatives.        
-            zmask_x = ( abs(iibm1-iibm2) * pmask_xdif(iibm2+ii_offset,ijbm2          ,jk)          &
-           &          + abs(ijbm1-ijbm2) * pmask_ydif(iibm2          ,ijbm2+ij_offset,jk) ) 
-            zmask_y1 = ( (iibm1-iibm1jm1) * pmask_xdif(iibm1jm1+ii_offset,ijbm1jm1          ,jk)   & 
-           &          +  (ijbm1-ijbm1jm1) * pmask_ydif(iibm1jm1          ,ijbm1jm1+ij_offset,jk) ) 
-            zmask_y2 = ( (iibm1jp1-iibm1) * pmask_xdif(iibm1+ii_offset,ijbm1          ,jk)         &
-           &          +  (ijbm1jp1-ijbm1) * pmask_ydif(iibm1          ,ijbm1+ij_offset,jk) ) 
+            zmask_x  = ( abs(iibm1-iibm2) * zmask_xdif(iibm2   +ii_offset,ijbm2             ,jk)   &
+           &           + abs(ijbm1-ijbm2) * zmask_ydif(iibm2             ,ijbm2   +ij_offset,jk) ) 
+            zmask_y1 = ( (iibm1-iibm1jm1) * zmask_xdif(iibm1jm1+ii_offset,ijbm1jm1          ,jk)   & 
+           &          +  (ijbm1-ijbm1jm1) * zmask_ydif(iibm1jm1          ,ijbm1jm1+ij_offset,jk) ) 
+            zmask_y2 = ( (iibm1jp1-iibm1) * zmask_xdif(iibm1   +ii_offset,ijbm1             ,jk)   &
+           &          +  (ijbm1jp1-ijbm1) * zmask_ydif(iibm1             ,ijbm1   +ij_offset,jk) ) 
             !
             ! Calculate normal (zrx) and tangential (zry) components of radiation velocities.
@@ -386,6 +407,6 @@
             ! Centred derivative is calculated as average of "left" and "right" derivatives for 
             ! this reason. 
-            zdt = phia(iibm1,ijbm1,jk) - phib(iibm1,ijbm1,jk)
-            zdx = ( ( phia(iibm1,ijbm1,jk) - phia(iibm2,ijbm2,jk) ) / zex2 ) * zmask_x                  
+            zdt   =     phia(iibm1   ,ijbm1   ,jk) - phib(iibm1   ,ijbm1   ,jk)
+            zdx   = ( ( phia(iibm1   ,ijbm1   ,jk) - phia(iibm2   ,ijbm2   ,jk) ) / zex2 ) * zmask_x                  
             zdy_1 = ( ( phib(iibm1   ,ijbm1   ,jk) - phib(iibm1jm1,ijbm1jm1,jk) ) / zey1 ) * zmask_y1  
             zdy_2 = ( ( phib(iibm1jp1,ijbm1jp1,jk) - phib(iibm1   ,ijbm1   ,jk) ) / zey2 ) * zmask_y2      
@@ -421,5 +442,5 @@
               &                       + zwgt * ( phi_ext(jb,jk) - phib(ii,ij,jk) ) ) / ( 1. + zrx ) 
             end if
-            phia(ii,ij,jk) = phia(ii,ij,jk) * pmask(ii,ij,jk)
+            phia(ii,ij,jk) = phia(ii,ij,jk) * zmask(ii,ij,jk)
          END DO
          !
@@ -428,5 +449,5 @@
    END SUBROUTINE bdy_orlanski_3d
 
-   SUBROUTINE bdy_nmn( idx, igrd, phia )
+   SUBROUTINE bdy_nmn( idx, igrd, phia, lrim0 )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_nmn  ***
@@ -434,63 +455,69 @@
       !! ** Purpose : Duplicate the value at open boundaries, zero gradient.
       !! 
-      !!----------------------------------------------------------------------
-      INTEGER,                    INTENT(in)     ::   igrd     ! grid index
-      REAL(wp), DIMENSION(:,:,:), INTENT(inout)  ::   phia     ! model after 3D field (to be updated)
-      TYPE(OBC_INDEX), INTENT(in) ::   idx  ! OBC indices
+      !!
+      !! ** Method  : - take the average of free ocean neighbours
+      !!
+      !!      ___   !   |_____|   !   ___|    !   __|x o   !   |_   _|     ! |      
+      !!   __|x     !      x      !     x o   !      o     !     |_|       ! |x o   
+      !!      o     !      o      !     o     !            !    o x o      ! |x_x_ 
+      !!                                                   !      o      
+      !!----------------------------------------------------------------------
+      INTEGER,                    INTENT(in   )  ::   igrd     ! grid index
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout)  ::   phia     ! model after 3D field (to be updated), must be masked
+      TYPE(OBC_INDEX),            INTENT(in   )  ::   idx      ! OBC indices
+      LOGICAL, OPTIONAL,          INTENT(in   )  ::   lrim0    ! indicate if rim 0 is treated
       !! 
-      REAL(wp) ::   zcoef, zcoef1, zcoef2
-      REAL(wp), POINTER, DIMENSION(:,:,:)        :: pmask      ! land/sea mask for field
-      REAL(wp), POINTER, DIMENSION(:,:)        :: bdypmask      ! land/sea mask for field
+      REAL(wp) ::   zweight
+      REAL(wp), POINTER, DIMENSION(:,:,:)      :: zmask         ! land/sea mask for field
       INTEGER  ::   ib, ik   ! dummy loop indices
-      INTEGER  ::   ii, ij, ip, jp   ! 2D addresses
-      !!----------------------------------------------------------------------
+      INTEGER  ::   ii, ij   ! 2D addresses
+      INTEGER  ::   ipkm1    ! size of phia third dimension minus 1
+      INTEGER  ::   ibeg, iend                          ! length of rim to be treated (rim 0 or rim 1 or both)
+      INTEGER  ::   ii1, ii2, ii3, ij1, ij2, ij3, itreat
+      !!----------------------------------------------------------------------
+      !
+      ipkm1 = MAX( SIZE(phia,3) - 1, 1 ) 
       !
       SELECT CASE(igrd)
-         CASE(1)
-            pmask => tmask(:,:,:)
-            bdypmask => bdytmask(:,:)
-         CASE(2)
-            pmask => umask(:,:,:)
-            bdypmask => bdyumask(:,:)
-         CASE(3)
-            pmask => vmask(:,:,:)
-            bdypmask => bdyvmask(:,:)
+         CASE(1)   ;   zmask => tmask(:,:,:)
+         CASE(2)   ;   zmask => umask(:,:,:)
+         CASE(3)   ;   zmask => vmask(:,:,:)
          CASE DEFAULT ;   CALL ctl_stop( 'unrecognised value for igrd in bdy_nmn' )
       END SELECT
-      DO ib = 1, idx%nblenrim(igrd)
+      !
+      IF( PRESENT(lrim0) ) THEN
+         IF( lrim0 ) THEN   ;   ibeg = 1                       ;   iend = idx%nblenrim0(igrd)   ! rim 0
+         ELSE               ;   ibeg = idx%nblenrim0(igrd)+1   ;   iend = idx%nblenrim(igrd)    ! rim 1
+         END IF
+      ELSE                  ;   ibeg = 1                       ;   iend = idx%nblenrim(igrd)    ! both
+      END IF
+      !
+      DO ib = ibeg, iend
          ii = idx%nbi(ib,igrd)
          ij = idx%nbj(ib,igrd)
-         DO ik = 1, jpkm1
-            ! search the sense of the gradient
-            zcoef1 = bdypmask(ii-1,ij  )*pmask(ii-1,ij,ik) +  bdypmask(ii+1,ij  )*pmask(ii+1,ij,ik)
-            zcoef2 = bdypmask(ii  ,ij-1)*pmask(ii,ij-1,ik) +  bdypmask(ii  ,ij+1)*pmask(ii,ij+1,ik)
-            IF ( nint(zcoef1+zcoef2) == 0) THEN
-               ! corner **** we probably only want to set the tangentail component for the dynamics here
-               zcoef = pmask(ii-1,ij,ik) + pmask(ii+1,ij,ik) +  pmask(ii,ij-1,ik) +  pmask(ii,ij+1,ik)
-               IF (zcoef > .5_wp) THEN ! Only set none isolated points.
-                 phia(ii,ij,ik) = phia(ii-1,ij  ,ik) * pmask(ii-1,ij  ,ik) + &
-                   &              phia(ii+1,ij  ,ik) * pmask(ii+1,ij  ,ik) + &
-                   &              phia(ii  ,ij-1,ik) * pmask(ii  ,ij-1,ik) + &
-                   &              phia(ii  ,ij+1,ik) * pmask(ii  ,ij+1,ik)
-                 phia(ii,ij,ik) = ( phia(ii,ij,ik) / zcoef ) * pmask(ii,ij,ik)
-               ELSE
-                 phia(ii,ij,ik) = phia(ii,ij  ,ik) * pmask(ii,ij  ,ik)
-               ENDIF
-            ELSEIF ( nint(zcoef1+zcoef2) == 2) THEN
-               ! oblique corner **** we probably only want to set the normal component for the dynamics here
-               zcoef = pmask(ii-1,ij,ik)*bdypmask(ii-1,ij  ) + pmask(ii+1,ij,ik)*bdypmask(ii+1,ij  ) + &
-                   &   pmask(ii,ij-1,ik)*bdypmask(ii,ij -1 ) +  pmask(ii,ij+1,ik)*bdypmask(ii,ij+1  )
-               phia(ii,ij,ik) = phia(ii-1,ij  ,ik) * pmask(ii-1,ij  ,ik)*bdypmask(ii-1,ij  ) + &
-                   &            phia(ii+1,ij  ,ik) * pmask(ii+1,ij  ,ik)*bdypmask(ii+1,ij  )  + &
-                   &            phia(ii  ,ij-1,ik) * pmask(ii  ,ij-1,ik)*bdypmask(ii,ij -1 ) + &
-                   &            phia(ii  ,ij+1,ik) * pmask(ii  ,ij+1,ik)*bdypmask(ii,ij+1  )
- 
-               phia(ii,ij,ik) = ( phia(ii,ij,ik) / MAX(1._wp, zcoef) ) * pmask(ii,ij,ik)
-            ELSE
-               ip = nint(bdypmask(ii+1,ij  )*pmask(ii+1,ij,ik) - bdypmask(ii-1,ij  )*pmask(ii-1,ij,ik))
-               jp = nint(bdypmask(ii  ,ij+1)*pmask(ii,ij+1,ik) - bdypmask(ii  ,ij-1)*pmask(ii,ij-1,ik))
-               phia(ii,ij,ik) = phia(ii+ip,ij+jp,ik) * pmask(ii+ip,ij+jp,ik)
-            ENDIF
-         END DO
+         itreat = idx%ntreat(ib,igrd)
+         CALL find_neib( ii, ij, itreat, ii1, ij1, ii2, ij2, ii3, ij3 )   ! find free ocean neighbours
+         SELECT CASE( itreat )
+         CASE( 1:8 )
+            IF( ii1 < 1 .OR. ii1 > jpi .OR. ij1 < 1 .OR. ij1 > jpj )   CYCLE
+            DO ik = 1, ipkm1
+               IF( zmask(ii1,ij1,ik) /= 0. )   phia(ii,ij,ik) = phia(ii1,ij1,ik)  
+            END DO
+         CASE( 9:12 )
+            IF( ii1 < 1 .OR. ii1 > jpi .OR. ij1 < 1 .OR. ij1 > jpj )   CYCLE
+            IF( ii2 < 1 .OR. ii2 > jpi .OR. ij2 < 1 .OR. ij2 > jpj )   CYCLE
+            DO ik = 1, ipkm1
+               zweight = zmask(ii1,ij1,ik) + zmask(ii2,ij2,ik)
+               IF( zweight /= 0. )   phia(ii,ij,ik) = ( phia(ii1,ij1,ik) + phia(ii2,ij2,ik) ) / zweight
+            END DO
+         CASE( 13:16 )
+            IF( ii1 < 1 .OR. ii1 > jpi .OR. ij1 < 1 .OR. ij1 > jpj )   CYCLE
+            IF( ii2 < 1 .OR. ii2 > jpi .OR. ij2 < 1 .OR. ij2 > jpj )   CYCLE
+            IF( ii3 < 1 .OR. ii3 > jpi .OR. ij3 < 1 .OR. ij3 > jpj )   CYCLE
+            DO ik = 1, ipkm1
+               zweight = zmask(ii1,ij1,ik) + zmask(ii2,ij2,ik) + zmask(ii3,ij3,ik)
+               IF( zweight /= 0. )   phia(ii,ij,ik) = ( phia(ii1,ij1,ik) + phia(ii2,ij2,ik) + phia(ii3,ij3,ik) ) / zweight
+            END DO
+         END SELECT
       END DO
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdytides.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdytides.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdytides.F90	(revision 12143)
@@ -70,5 +70,4 @@
       INTEGER                                   ::   inum, igrd
       INTEGER, DIMENSION(3)                     ::   ilen0       !: length of boundary data (from OBC arrays)
-      INTEGER, POINTER, DIMENSION(:)            ::   nblen, nblenrim     ! short cuts
       INTEGER                                   ::   ios                 ! Local integer output status for namelist read
       CHARACTER(len=80)                         ::   clfile              !: full file name for tidal input file 
@@ -77,14 +76,11 @@
       !!
       TYPE(TIDES_DATA),  POINTER                ::   td                  !: local short cut   
-      TYPE(MAP_POINTER), DIMENSION(jpbgrd)      ::   ibmap_ptr           !: array of pointers to nbmap
       !!
       NAMELIST/nambdy_tide/filtide, ln_bdytide_2ddta, ln_bdytide_conj
       !!----------------------------------------------------------------------
       !
-      IF (nb_bdy>0) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'bdytide_init : initialization of tidal harmonic forcing at open boundaries'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
-      ENDIF
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'bdytide_init : initialization of tidal harmonic forcing at open boundaries'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
 
       REWIND(numnam_cfg)
@@ -94,15 +90,14 @@
             !
             td => tides(ib_bdy)
-            nblen => idx_bdy(ib_bdy)%nblen
-            nblenrim => idx_bdy(ib_bdy)%nblenrim
 
             ! Namelist nambdy_tide : tidal harmonic forcing at open boundaries
             filtide(:) = ''
 
+            REWIND( numnam_ref )
+            READ  ( numnam_ref, nambdy_tide, IOSTAT = ios, ERR = 901)
+901         IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_tide in reference namelist' )
             ! Don't REWIND here - may need to read more than one of these namelists. 
-            READ  ( numnam_ref, nambdy_tide, IOSTAT = ios, ERR = 901)
-901         IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_tide in reference namelist', lwp )
             READ  ( numnam_cfg, nambdy_tide, IOSTAT = ios, ERR = 902 )
-902         IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy_tide in configuration namelist', lwp )
+902         IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy_tide in configuration namelist' )
             IF(lwm) WRITE ( numond, nambdy_tide )
             !                                               ! Parameter control and print
@@ -125,6 +120,6 @@
             ! JC: If FRS scheme is used, we assume that tidal is needed over the whole
             ! relaxation area      
-            IF( cn_dyn2d(ib_bdy) == 'frs' ) THEN   ;   ilen0(:) = nblen   (:)
-            ELSE                                   ;   ilen0(:) = nblenrim(:)
+            IF( cn_dyn2d(ib_bdy) == 'frs' ) THEN   ;   ilen0(:) = idx_bdy(ib_bdy)%nblen   (:)
+            ELSE                                   ;   ilen0(:) = idx_bdy(ib_bdy)%nblenrim(:)
             ENDIF
 
@@ -161,4 +156,5 @@
                      ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
                      ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+                     IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE   ! to remove?
                      td%ssh0(ib,itide,1) = ztr(ii,ij)
                      td%ssh0(ib,itide,2) = zti(ii,ij)
@@ -177,4 +173,5 @@
                      ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
                      ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+                     IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE   ! to remove?
                      td%u0(ib,itide,1) = ztr(ii,ij)
                      td%u0(ib,itide,2) = zti(ii,ij)
@@ -193,4 +190,5 @@
                      ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
                      ij = idx_bdy(ib_bdy)%nbj(ib,igrd)
+                     IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE   ! to remove?
                      td%v0(ib,itide,1) = ztr(ii,ij)
                      td%v0(ib,itide,2) = zti(ii,ij)
@@ -207,9 +205,4 @@
                ALLOCATE( dta_read( MAXVAL(ilen0(1:3)), 1, 1 ) )
                !
-               ! Set map structure
-               ibmap_ptr(1)%ptr => idx_bdy(ib_bdy)%nbmap(:,1)   ;   ibmap_ptr(1)%ll_unstruc = ln_coords_file(ib_bdy)
-               ibmap_ptr(2)%ptr => idx_bdy(ib_bdy)%nbmap(:,2)   ;   ibmap_ptr(2)%ll_unstruc = ln_coords_file(ib_bdy)
-               ibmap_ptr(3)%ptr => idx_bdy(ib_bdy)%nbmap(:,3)   ;   ibmap_ptr(3)%ll_unstruc = ln_coords_file(ib_bdy)
-
                ! Open files and read in tidal forcing data
                ! -----------------------------------------
@@ -219,7 +212,7 @@
                   clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_T.nc'
                   CALL iom_open( clfile, inum )
-                  CALL fld_map( inum, 'z1' , dta_read(1:ilen0(1),1:1,1:1) , 1,  ibmap_ptr(1) )
+                  CALL fld_map( inum, 'z1' , dta_read(1:ilen0(1),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,1) )
                   td%ssh0(:,itide,1) = dta_read(1:ilen0(1),1,1)
-                  CALL fld_map( inum, 'z2' , dta_read(1:ilen0(1),1:1,1:1) , 1,  ibmap_ptr(1) )
+                  CALL fld_map( inum, 'z2' , dta_read(1:ilen0(1),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,1) )
                   td%ssh0(:,itide,2) = dta_read(1:ilen0(1),1,1)
                   CALL iom_close( inum )
@@ -227,7 +220,7 @@
                   clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_U.nc'
                   CALL iom_open( clfile, inum )
-                  CALL fld_map( inum, 'u1' , dta_read(1:ilen0(2),1:1,1:1) , 1, ibmap_ptr(2) )
+                  CALL fld_map( inum, 'u1' , dta_read(1:ilen0(2),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,2) )
                   td%u0(:,itide,1) = dta_read(1:ilen0(2),1,1)
-                  CALL fld_map( inum, 'u2' , dta_read(1:ilen0(2),1:1,1:1) , 1, ibmap_ptr(2) )
+                  CALL fld_map( inum, 'u2' , dta_read(1:ilen0(2),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,2) )
                   td%u0(:,itide,2) = dta_read(1:ilen0(2),1,1)
                   CALL iom_close( inum )
@@ -235,7 +228,7 @@
                   clfile = TRIM(filtide)//TRIM(Wave(ntide(itide))%cname_tide)//'_grid_V.nc'
                   CALL iom_open( clfile, inum )
-                  CALL fld_map( inum, 'v1' , dta_read(1:ilen0(3),1:1,1:1) , 1, ibmap_ptr(3) )
+                  CALL fld_map( inum, 'v1' , dta_read(1:ilen0(3),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,3) )
                   td%v0(:,itide,1) = dta_read(1:ilen0(3),1,1)
-                  CALL fld_map( inum, 'v2' , dta_read(1:ilen0(3),1:1,1:1) , 1, ibmap_ptr(3) )
+                  CALL fld_map( inum, 'v2' , dta_read(1:ilen0(3),1:1,1:1) , 1, idx_bdy(ib_bdy)%nbmap(:,3) )
                   td%v0(:,itide,2) = dta_read(1:ilen0(3),1,1)
                   CALL iom_close( inum )
@@ -269,5 +262,5 @@
 
 
-   SUBROUTINE bdytide_update( kt, idx, dta, td, jit, time_offset )
+   SUBROUTINE bdytide_update( kt, idx, dta, td, kit, kt_offset )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdytide_update  ***
@@ -280,10 +273,10 @@
       TYPE(OBC_DATA)   , INTENT(inout) ::   dta         ! OBC external data
       TYPE(TIDES_DATA) , INTENT(inout) ::   td          ! tidal harmonics data
-      INTEGER, OPTIONAL, INTENT(in   ) ::   jit         ! Barotropic timestep counter (for timesplitting option)
-      INTEGER, OPTIONAL, INTENT(in   ) ::   time_offset ! time offset in units of timesteps. NB. if jit
+      INTEGER, OPTIONAL, INTENT(in   ) ::   kit         ! Barotropic timestep counter (for timesplitting option)
+      INTEGER, OPTIONAL, INTENT(in   ) ::   kt_offset   ! time offset in units of timesteps. NB. if kit
       !                                                 ! is present then units = subcycle timesteps.
-      !                                                 ! time_offset = 0  => get data at "now"    time level
-      !                                                 ! time_offset = -1 => get data at "before" time level
-      !                                                 ! time_offset = +1 => get data at "after"  time level
+      !                                                 ! kt_offset = 0  => get data at "now"    time level
+      !                                                 ! kt_offset = -1 => get data at "before" time level
+      !                                                 ! kt_offset = +1 => get data at "after"  time level
       !                                                 ! etc.
       !
@@ -300,6 +293,6 @@
 
       zflag=1
-      IF ( PRESENT(jit) ) THEN
-        IF ( jit /= 1 ) zflag=0
+      IF ( PRESENT(kit) ) THEN
+        IF ( kit /= 1 ) zflag=0
       ENDIF
 
@@ -320,10 +313,10 @@
 
       time_add = 0
-      IF( PRESENT(time_offset) ) THEN
-         time_add = time_offset
+      IF( PRESENT(kt_offset) ) THEN
+         time_add = kt_offset
       ENDIF
          
-      IF( PRESENT(jit) ) THEN  
-         z_arg = ((kt-kt_tide) * rdt + (jit+0.5_wp*(time_add-1)) * rdt / REAL(nn_baro,wp) )
+      IF( PRESENT(kit) ) THEN  
+         z_arg = ((kt-kt_tide) * rdt + (kit+0.5_wp*(time_add-1)) * rdt / REAL(nn_baro,wp) )
       ELSE                              
          z_arg = ((kt-kt_tide)+time_add) * rdt
@@ -358,5 +351,5 @@
 
 
-   SUBROUTINE bdy_dta_tides( kt, kit, time_offset )
+   SUBROUTINE bdy_dta_tides( kt, kit, kt_offset )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_dta_tides  ***
@@ -367,9 +360,9 @@
       INTEGER,           INTENT(in) ::   kt          ! Main timestep counter
       INTEGER, OPTIONAL, INTENT(in) ::   kit         ! Barotropic timestep counter (for timesplitting option)
-      INTEGER, OPTIONAL, INTENT(in) ::   time_offset ! time offset in units of timesteps. NB. if kit
+      INTEGER, OPTIONAL, INTENT(in) ::   kt_offset   ! time offset in units of timesteps. NB. if kit
       !                                              ! is present then units = subcycle timesteps.
-      !                                              ! time_offset = 0  => get data at "now"    time level
-      !                                              ! time_offset = -1 => get data at "before" time level
-      !                                              ! time_offset = +1 => get data at "after"  time level
+      !                                              ! kt_offset = 0  => get data at "now"    time level
+      !                                              ! kt_offset = -1 => get data at "before" time level
+      !                                              ! kt_offset = +1 => get data at "after"  time level
       !                                              ! etc.
       !
@@ -386,6 +379,6 @@
 
       time_add = 0
-      IF( PRESENT(time_offset) ) THEN
-         time_add = time_offset
+      IF( PRESENT(kt_offset) ) THEN
+         time_add = kt_offset
       ENDIF
       
@@ -432,7 +425,7 @@
             ! If time splitting, initialize arrays from slow varying open boundary data:
             IF ( PRESENT(kit) ) THEN           
-               IF ( dta_bdy(ib_bdy)%ll_ssh ) dta_bdy(ib_bdy)%ssh(1:ilen0(1)) = dta_bdy_s(ib_bdy)%ssh(1:ilen0(1))
-               IF ( dta_bdy(ib_bdy)%ll_u2d ) dta_bdy(ib_bdy)%u2d(1:ilen0(2)) = dta_bdy_s(ib_bdy)%u2d(1:ilen0(2))
-               IF ( dta_bdy(ib_bdy)%ll_v2d ) dta_bdy(ib_bdy)%v2d(1:ilen0(3)) = dta_bdy_s(ib_bdy)%v2d(1:ilen0(3))
+               IF ( dta_bdy(ib_bdy)%lneed_ssh   ) dta_bdy(ib_bdy)%ssh(1:ilen0(1)) = dta_bdy_s(ib_bdy)%ssh(1:ilen0(1))
+               IF ( dta_bdy(ib_bdy)%lneed_dyn2d ) dta_bdy(ib_bdy)%u2d(1:ilen0(2)) = dta_bdy_s(ib_bdy)%u2d(1:ilen0(2))
+               IF ( dta_bdy(ib_bdy)%lneed_dyn2d ) dta_bdy(ib_bdy)%v2d(1:ilen0(3)) = dta_bdy_s(ib_bdy)%v2d(1:ilen0(3))
             ENDIF
             !
@@ -444,5 +437,5 @@
                z_sist = zramp * SIN( z_sarg )
                !
-               IF ( dta_bdy(ib_bdy)%ll_ssh ) THEN
+               IF ( dta_bdy(ib_bdy)%lneed_ssh ) THEN
                   igrd=1                              ! SSH on tracer grid
                   DO ib = 1, ilen0(igrd)
@@ -453,5 +446,5 @@
                ENDIF
                !
-               IF ( dta_bdy(ib_bdy)%ll_u2d ) THEN
+               IF ( dta_bdy(ib_bdy)%lneed_dyn2d ) THEN
                   igrd=2                              ! U grid
                   DO ib = 1, ilen0(igrd)
@@ -460,7 +453,4 @@
                         &                        tides(ib_bdy)%u(ib,itide,2)*z_sist )
                   END DO
-               ENDIF
-               !
-               IF ( dta_bdy(ib_bdy)%ll_v2d ) THEN
                   igrd=3                              ! V grid
                   DO ib = 1, ilen0(igrd) 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdytra.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdytra.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdytra.F90	(revision 12143)
@@ -49,36 +49,62 @@
       INTEGER, INTENT(in) ::   kt   ! Main time step counter
       !
-      INTEGER                        :: ib_bdy, jn, igrd   ! Loop indeces
-      TYPE(ztrabdy), DIMENSION(jpts) :: zdta               ! Temporary data structure
+      INTEGER                        :: ib_bdy, jn, igrd, ir   ! Loop indeces
+      TYPE(ztrabdy), DIMENSION(jpts) :: zdta                   ! Temporary data structure
+      LOGICAL                        :: llrim0                 ! indicate if rim 0 is treated
+      LOGICAL, DIMENSION(4)          :: llsend1, llrecv1       ! indicate how communications are to be carried out
       !!----------------------------------------------------------------------
       igrd = 1 
-
-      DO ib_bdy=1, nb_bdy
+      llsend1(:) = .false.  ;   llrecv1(:) = .false.
+      DO ir = 1, 0, -1   ! treat rim 1 before rim 0
+         IF( ir == 0 ) THEN   ;   llrim0 = .TRUE.
+         ELSE                 ;   llrim0 = .FALSE.
+         END IF
+         DO ib_bdy=1, nb_bdy
+            !
+            zdta(1)%tra => dta_bdy(ib_bdy)%tem
+            zdta(2)%tra => dta_bdy(ib_bdy)%sal
+            !
+            DO jn = 1, jpts
+               !
+               SELECT CASE( TRIM(cn_tra(ib_bdy)) )
+               CASE('none'        )   ;   CYCLE
+               CASE('frs'         )   ! treat the whole boundary at once
+                  IF( ir == 0 ) CALL bdy_frs ( idx_bdy(ib_bdy),                tsa(:,:,:,jn), zdta(jn)%tra )
+               CASE('specified'   )   ! treat the whole rim      at once
+                  IF( ir == 0 ) CALL bdy_spe ( idx_bdy(ib_bdy),                tsa(:,:,:,jn), zdta(jn)%tra )
+               CASE('neumann'     )   ;   CALL bdy_nmn ( idx_bdy(ib_bdy), igrd         , tsa(:,:,:,jn), llrim0 )   ! tsa masked
+               CASE('orlanski'    )   ;   CALL bdy_orl ( idx_bdy(ib_bdy), tsb(:,:,:,jn), tsa(:,:,:,jn), &
+                    & zdta(jn)%tra, llrim0, ll_npo=.false. )
+               CASE('orlanski_npo')   ;   CALL bdy_orl ( idx_bdy(ib_bdy), tsb(:,:,:,jn), tsa(:,:,:,jn), &
+                    & zdta(jn)%tra, llrim0, ll_npo=.true.  )
+               CASE('runoff'      )   ;   CALL bdy_rnf ( idx_bdy(ib_bdy),                tsa(:,:,:,jn), jn, llrim0 )
+               CASE DEFAULT           ;   CALL ctl_stop( 'bdy_tra : unrecognised option for open boundaries for T and S' )
+               END SELECT
+               ! 
+            END DO
+         END DO
          !
-         zdta(1)%tra => dta_bdy(ib_bdy)%tem
-         zdta(2)%tra => dta_bdy(ib_bdy)%sal
+         IF( nn_hls > 1 .AND. ir == 1 ) CYCLE   ! at least 2 halos will be corrected -> no need to correct rim 1 before rim 0
+         IF( nn_hls == 1 ) THEN   ;   llsend1(:) = .false.   ;   llrecv1(:) = .false.   ;   END IF
+         DO ib_bdy=1, nb_bdy
+            SELECT CASE( TRIM(cn_tra(ib_bdy)) )
+            CASE('neumann','runoff')
+               llsend1(:) = llsend1(:) .OR. lsend_bdyint(ib_bdy,1,:,ir)   ! possibly every direction, T points
+               llrecv1(:) = llrecv1(:) .OR. lrecv_bdyint(ib_bdy,1,:,ir)   ! possibly every direction, T points
+            CASE('orlanski', 'orlanski_npo')
+               llsend1(:) = llsend1(:) .OR. lsend_bdy(ib_bdy,1,:,ir)   ! possibly every direction, T points
+               llrecv1(:) = llrecv1(:) .OR. lrecv_bdy(ib_bdy,1,:,ir)   ! possibly every direction, T points
+            END SELECT
+         END DO
+         IF( ANY(llsend1) .OR. ANY(llrecv1) ) THEN   ! if need to send/recv in at least one direction
+            CALL lbc_lnk( 'bdytra', tsa, 'T',  1., kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
+         END IF
          !
-         DO jn = 1, jpts
-            !
-            SELECT CASE( TRIM(cn_tra(ib_bdy)) )
-            CASE('none'        )   ;   CYCLE
-            CASE('frs'         )   ;   CALL bdy_frs ( idx_bdy(ib_bdy),                tsa(:,:,:,jn), zdta(jn)%tra )
-            CASE('specified'   )   ;   CALL bdy_spe ( idx_bdy(ib_bdy),                tsa(:,:,:,jn), zdta(jn)%tra )
-            CASE('neumann'     )   ;   CALL bdy_nmn ( idx_bdy(ib_bdy), igrd         , tsa(:,:,:,jn)               )
-            CASE('orlanski'    )   ;   CALL bdy_orl ( idx_bdy(ib_bdy), tsb(:,:,:,jn), tsa(:,:,:,jn), zdta(jn)%tra, ll_npo=.false. )
-            CASE('orlanski_npo')   ;   CALL bdy_orl ( idx_bdy(ib_bdy), tsb(:,:,:,jn), tsa(:,:,:,jn), zdta(jn)%tra, ll_npo=.true. )
-            CASE('runoff'      )   ;   CALL bdy_rnf ( idx_bdy(ib_bdy),                tsa(:,:,:,jn),               jn )
-            CASE DEFAULT           ;   CALL ctl_stop( 'bdy_tra : unrecognised option for open boundaries for T and S' )
-            END SELECT
-            ! Boundary points should be updated
-            CALL lbc_bdy_lnk( 'bdytra', tsa(:,:,:,jn), 'T', 1., ib_bdy )
-            ! 
-         END DO
-      END DO
+      END DO   ! ir
       !
    END SUBROUTINE bdy_tra
 
 
-   SUBROUTINE bdy_rnf( idx, pta, jpa )
+   SUBROUTINE bdy_rnf( idx, pta, jpa, llrim0 )
       !!----------------------------------------------------------------------
       !!                 ***  SUBROUTINE bdy_rnf  ***
@@ -89,24 +115,24 @@
       !! 
       !!----------------------------------------------------------------------
-      TYPE(OBC_INDEX),                     INTENT(in) ::   idx  ! OBC indices
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pta  ! tracer trend
-      INTEGER,                             INTENT(in) ::   jpa  ! TRA index
+      TYPE(OBC_INDEX),                     INTENT(in) ::   idx      ! OBC indices
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pta      ! tracer trend
+      INTEGER,                             INTENT(in) ::   jpa      ! TRA index
+      LOGICAL,                             INTENT(in) ::   llrim0   ! indicate if rim 0 is treated
       !
-      REAL(wp) ::   zwgt           ! boundary weight
-      INTEGER  ::   ib, ik, igrd   ! dummy loop indices
-      INTEGER  ::   ii, ij, ip, jp ! 2D addresses
+      INTEGER  ::   ib, ii, ij, igrd   ! dummy loop indices
+      INTEGER  ::   ik, ip, jp ! 2D addresses
       !!----------------------------------------------------------------------
       !
       igrd = 1                       ! Everything is at T-points here
-      DO ib = 1, idx%nblenrim(igrd)
-         ii = idx%nbi(ib,igrd)
-         ij = idx%nbj(ib,igrd)
-         DO ik = 1, jpkm1
-            ip = bdytmask(ii+1,ij  ) - bdytmask(ii-1,ij  )
-            jp = bdytmask(ii  ,ij+1) - bdytmask(ii  ,ij-1)
-            if (jpa == jp_tem) pta(ii,ij,ik) = pta(ii+ip,ij+jp,ik) * tmask(ii,ij,ik)
-            if (jpa == jp_sal) pta(ii,ij,ik) =                 0.1 * tmask(ii,ij,ik)
+      IF(      jpa == jp_tem ) THEN
+         CALL bdy_nmn( idx, igrd, pta, llrim0 )
+      ELSE IF( jpa == jp_sal ) THEN
+         IF( .NOT. llrim0 )   RETURN
+         DO ib = 1, idx%nblenrim(igrd)   ! if llrim0 then treat the whole rim
+            ii = idx%nbi(ib,igrd)
+            ij = idx%nbj(ib,igrd)
+            pta(ii,ij,1:jpkm1) = 0.1 * tmask(ii,ij,1:jpkm1)
          END DO
-      END DO
+      END IF
       !
    END SUBROUTINE bdy_rnf
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyvol.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyvol.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/BDY/bdyvol.F90	(revision 12143)
@@ -99,4 +99,5 @@
             ii = idx%nbi(jb,jgrd)
             ij = idx%nbj(jb,jgrd)
+            IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE   ! sum : else halo couted twice
             zubtpecor = zubtpecor + idx%flagu(jb,jgrd) * pua2d(ii,ij) * e2u(ii,ij) * phu(ii,ij) * tmask_i(ii,ij) * tmask_i(ii+1,ij)
          END DO
@@ -105,4 +106,5 @@
             ii = idx%nbi(jb,jgrd)
             ij = idx%nbj(jb,jgrd)
+            IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE   ! sum : else halo couted twice
             zubtpecor = zubtpecor + idx%flagv(jb,jgrd) * pva2d(ii,ij) * e1v(ii,ij) * phv(ii,ij) * tmask_i(ii,ij) * tmask_i(ii,ij+1)
          END DO
@@ -126,4 +128,5 @@
                ii = idx%nbi(jb,jgrd)
                ij = idx%nbj(jb,jgrd)
+               !IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE   ! to remove ?
                pua2d(ii,ij) = pua2d(ii,ij) - idx%flagu(jb,jgrd) * zubtpecor * tmask_i(ii,ij) * tmask_i(ii+1,ij)
          END DO
@@ -132,4 +135,5 @@
                ii = idx%nbi(jb,jgrd)
                ij = idx%nbj(jb,jgrd)
+               !IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE   ! to remove ?
                pva2d(ii,ij) = pva2d(ii,ij) - idx%flagv(jb,jgrd) * zubtpecor * tmask_i(ii,ij) * tmask_i(ii,ij+1)
          END DO
@@ -139,5 +143,5 @@
       ! Check the cumulated transport through unstructured OBC once barotropic velocities corrected
       ! ------------------------------------------------------
-      IF( MOD( kt, nwrite ) == 0 .AND. ( kc == 1 ) ) THEN
+      IF( MOD( kt, nn_write ) == 0 .AND. ( kc == 1 ) ) THEN
          !
          ! compute residual transport across boundary
@@ -150,4 +154,5 @@
                   ii = idx%nbi(jb,jgrd)
                   ij = idx%nbj(jb,jgrd)
+                  IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE
                   ztranst = ztranst + idx%flagu(jb,jgrd) * pua2d(ii,ij) * e2u(ii,ij) * phu(ii,ij) * tmask_i(ii,ij) * tmask_i(ii+1,ij)
             END DO
@@ -156,4 +161,5 @@
                   ii = idx%nbi(jb,jgrd)
                   ij = idx%nbj(jb,jgrd)
+                  IF( ii == 1 .OR. ii == jpi .OR. ij == 1 .OR. ij == jpj )  CYCLE
                   ztranst = ztranst + idx%flagv(jb,jgrd) * pva2d(ii,ij) * e1v(ii,ij) * phv(ii,ij) * tmask_i(ii,ij) * tmask_i(ii,ij+1)
             END DO
@@ -195,4 +201,5 @@
             nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
             nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
+            IF( nbi == 1 .OR. nbi == jpi .OR. nbj == 1 .OR. nbj == jpj )  CYCLE
             zflagu => idx_bdy(ib_bdy)%flagu(ib,igrd)
             bdy_segs_surf = bdy_segs_surf + phu(nbi, nbj)                              &
@@ -207,4 +214,5 @@
             nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
             nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
+            IF( nbi == 1 .OR. nbi == jpi .OR. nbj == 1 .OR. nbj == jpj )  CYCLE
             zflagv => idx_bdy(ib_bdy)%flagv(ib,igrd)
             bdy_segs_surf = bdy_segs_surf + phv(nbi, nbj)                              &
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/C1D/c1d.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/C1D/c1d.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/C1D/c1d.F90	(revision 12143)
@@ -52,9 +52,9 @@
       REWIND( numnam_ref )              ! Namelist namc1d in reference namelist : Tracer advection scheme
       READ  ( numnam_ref, namc1d, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc1d in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc1d in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namtra_adv in configuration namelist : Tracer advection scheme
       READ  ( numnam_cfg, namc1d, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc1d in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc1d in configuration namelist' )
       IF(lwm) WRITE ( numond, namc1d )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/C1D/dtauvd.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/C1D/dtauvd.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/C1D/dtauvd.F90	(revision 12143)
@@ -62,9 +62,9 @@
       REWIND( numnam_ref )              ! Namelist namc1d_uvd in reference namelist : 
       READ  ( numnam_ref, namc1d_uvd, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc1d_uvd in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc1d_uvd in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namc1d_uvd in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, namc1d_uvd, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc1d_uvd in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc1d_uvd in configuration namelist' )
       IF(lwm) WRITE ( numond, namc1d_uvd )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/C1D/dyndmp.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/C1D/dyndmp.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/C1D/dyndmp.F90	(revision 12143)
@@ -81,8 +81,8 @@
       REWIND( numnam_ref )              ! Namelist namc1d_dyndmp in reference namelist : 
       READ  ( numnam_ref, namc1d_dyndmp, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc1d_dyndmp in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc1d_dyndmp in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namc1d_dyndmp in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, namc1d_dyndmp, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc1d_dyndmp in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc1d_dyndmp in configuration namelist' )
       IF(lwm) WRITE ( numond, namc1d_dyndmp )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/README.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/README.rst	(revision 12143)
@@ -2,4 +2,8 @@
 On line biogeochemistry coarsening
 **********************************
+
+.. todo::
+
+
 
 .. contents::
@@ -63,6 +67,6 @@
 	                           ! 1, MAX of KZ
 	                           ! 2, MIN of KZ
-	                           ! 3, 10^(MEAN(LOG(KZ)) 
-	                           ! 4, MEDIANE of KZ 
+	                           ! 3, 10^(MEAN(LOG(KZ))
+	                           ! 4, MEDIANE of KZ
 	   ln_crs_wn   = .false.   ! wn coarsened (T) or computed using horizontal divergence ( F )
 	                           !                           !
@@ -73,5 +77,5 @@
   the north-fold lateral boundary condition (ORCA025, ORCA12, ORCA36, ...).
 - ``nn_msh_crs = 1`` will activate the generation of the coarsened grid meshmask.
-- ``nn_crs_kz`` is the operator to coarsen the vertical mixing coefficient. 
+- ``nn_crs_kz`` is the operator to coarsen the vertical mixing coefficient.
 - ``ln_crs_wn``
 
@@ -80,5 +84,5 @@
   - when ``key_vvl`` is not activated,
 
-    - coarsened vertical velocities are computed using horizontal divergence (``ln_crs_wn = .false.``) 
+    - coarsened vertical velocities are computed using horizontal divergence (``ln_crs_wn = .false.``)
     - or coarsened vertical velocities are computed with an average operator (``ln_crs_wn = .true.``)
 - ``ln_crs_top = .true.``: should be activated to run BCG model in coarsened space;
@@ -97,5 +101,5 @@
 
 In the [attachment:iodef.xml iodef.xml]  file, a "nemo" context is defined and
-some variable defined in [attachment:file_def.xml file_def.xml] are writted on the ocean-dynamic grid.  
+some variable defined in [attachment:file_def.xml file_def.xml] are writted on the ocean-dynamic grid.
 To write variables on the coarsened grid, and in particular the passive tracers,
 a "nemo_crs" context should be defined in [attachment:iodef.xml iodef.xml] and
@@ -111,5 +115,5 @@
   interpolated `on-the-fly <http://forge.ipsl.jussieu.fr/nemo/wiki/Users/SetupNewConfiguration/Weight-creator>`_.
   Example of namelist for PISCES :
-  
+
 	.. code-block:: fortran
 
@@ -134,5 +138,5 @@
 	   	rn_trfac(14)  =   1.0e-06  !  -      -      -     -
 		   rn_trfac(23)  =   7.6e-06  !  -      -      -     -
-		
+
 	   	cn_dir        =  './'      !  root directory for the location of the data files
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/crsdom.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/crsdom.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/crsdom.F90	(revision 12143)
@@ -296,6 +296,6 @@
       ENDDO
 
-      CALL crs_lbc_lnk( p_e1_crs, cd_type, 1.0, pval=1.0 )
-      CALL crs_lbc_lnk( p_e2_crs, cd_type, 1.0, pval=1.0 )
+      CALL crs_lbc_lnk( p_e1_crs, cd_type, 1.0, pfillval=1.0 )
+      CALL crs_lbc_lnk( p_e2_crs, cd_type, 1.0, pfillval=1.0 )
 
    END SUBROUTINE crs_dom_hgr
@@ -579,5 +579,5 @@
                   ENDDO  
                CASE DEFAULT
-                    STOP
+                  CALL ctl_stop( 'STOP', 'error from crs_dom_ope_3d, you should not be there...' )
                END SELECT
 
@@ -1748,6 +1748,6 @@
        ENDDO
                   
-       CALL crs_lbc_lnk( p_e3_crs    , cd_type, 1.0, pval=1.0 )  
-       CALL crs_lbc_lnk( p_e3_max_crs, cd_type, 1.0, pval=1.0 )  
+       CALL crs_lbc_lnk( p_e3_crs    , cd_type, 1.0, pfillval=1.0 )  
+       CALL crs_lbc_lnk( p_e3_max_crs, cd_type, 1.0, pfillval=1.0 )  
        !              
        !
@@ -1857,6 +1857,6 @@
       ENDDO   
 
-      CALL crs_lbc_lnk( p_surf_crs    , cd_type, 1.0, pval=1.0 )
-      CALL crs_lbc_lnk( p_surf_crs_msk, cd_type, 1.0, pval=1.0 )
+      CALL crs_lbc_lnk( p_surf_crs    , cd_type, 1.0, pfillval=1.0 )
+      CALL crs_lbc_lnk( p_surf_crs_msk, cd_type, 1.0, pfillval=1.0 )
 
    END SUBROUTINE crs_dom_sfc
@@ -1947,5 +1947,5 @@
                 
               CASE DEFAULT
-                 STOP
+                 CALL ctl_stop( 'STOP', 'error from crs_dom_def, you should not be there (1) ...' )
            END SELECT
            IF( nlcjt_crs(jn) > jpj_crs )     jpj_crs = jpj_crs + 1
@@ -1996,5 +1996,5 @@
 
               CASE DEFAULT
-                 STOP
+                 CALL ctl_stop( 'STOP', 'error from crs_dom_def, you should not be there (2) ...' )
            END SELECT
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/crsini.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/crsini.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/crsini.F90	(revision 12143)
@@ -82,8 +82,8 @@
       REWIND( numnam_ref )              ! Namelist namrun in reference namelist : Parameters of the run
       READ  ( numnam_ref, namcrs, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcrs in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcrs in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namrun in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, namcrs, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcrs in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcrs in configuration namelist' )
       IF(lwm) WRITE ( numond, namcrs )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/crslbclnk.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/crslbclnk.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/CRS/crslbclnk.F90	(revision 12143)
@@ -27,5 +27,5 @@
 CONTAINS
 
-   SUBROUTINE crs_lbc_lnk_3d( pt3d1, cd_type1, psgn, cd_mpp, pval )
+   SUBROUTINE crs_lbc_lnk_3d( pt3d1, cd_type1, psgn, kfillmode, pfillval  )
       !!---------------------------------------------------------------------
       !!                  ***  SUBROUTINE crs_lbc_lnk  ***
@@ -40,22 +40,15 @@
       REAL(wp)                                , INTENT(in   ) ::   psgn     ! control of the sign
       REAL(wp), DIMENSION(jpi_crs,jpj_crs,jpk), INTENT(inout) ::   pt3d1    ! 3D array on which the lbc is applied
-      REAL(wp)                      , OPTIONAL, INTENT(in   ) ::   pval     ! valeur sur les halo
-      CHARACTER(len=3)              , OPTIONAL, INTENT(in   ) ::   cd_mpp   ! MPP only (here do nothing)
+      INTEGER                     , OPTIONAL  , INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = cst)
+      REAL(wp)                    , OPTIONAL  , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
       !
       LOGICAL  ::   ll_grid_crs
-      REAL(wp) ::   zval   ! valeur sur les halo
       !!----------------------------------------------------------------------
       !
       ll_grid_crs = ( jpi == jpi_crs )
       !
-      IF( PRESENT(pval) ) THEN   ;   zval = pval
-      ELSE                       ;   zval = 0._wp
-      ENDIF
-      !
       IF( .NOT.ll_grid_crs )   CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
       !
-      IF( PRESENT( cd_mpp ) ) THEN   ;   CALL lbc_lnk( 'crslbclnk', pt3d1, cd_type1, psgn, cd_mpp, pval=zval  )
-      ELSE                           ;   CALL lbc_lnk( 'crslbclnk', pt3d1, cd_type1, psgn        , pval=zval  )
-      ENDIF
+      CALL lbc_lnk( 'crslbclnk', pt3d1, cd_type1, psgn, kfillmode, pfillval )
       !
       IF( .NOT.ll_grid_crs )   CALL dom_grid_glo   ! Return to parent grid domain
@@ -64,5 +57,5 @@
    
    
-   SUBROUTINE crs_lbc_lnk_2d(pt2d, cd_type, psgn, cd_mpp, pval)
+   SUBROUTINE crs_lbc_lnk_2d(pt2d, cd_type, psgn, kfillmode, pfillval )
       !!---------------------------------------------------------------------
       !!                  ***  SUBROUTINE crs_lbc_lnk  ***
@@ -77,22 +70,15 @@
       REAL(wp)                            , INTENT(in   ) ::   psgn     ! control of the sign
       REAL(wp), DIMENSION(jpi_crs,jpj_crs), INTENT(inout) ::   pt2d     ! 2D array on which the lbc is applied
-      REAL(wp)                  , OPTIONAL, INTENT(in   ) ::   pval     ! valeur sur les halo
-      CHARACTER(len=3)          , OPTIONAL, INTENT(in   ) ::   cd_mpp   ! MPP only (here do nothing)
+      INTEGER                 , OPTIONAL  , INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
+      REAL(wp)                , OPTIONAL  , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
       !      
       LOGICAL  ::   ll_grid_crs
-      REAL(wp) ::   zval     ! valeur sur les halo
       !!----------------------------------------------------------------------
       !
       ll_grid_crs = ( jpi == jpi_crs )
       !
-      IF( PRESENT(pval) ) THEN   ;   zval = pval
-      ELSE                       ;   zval = 0._wp
-      ENDIF
-      !
       IF( .NOT.ll_grid_crs )   CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
       !
-      IF( PRESENT( cd_mpp ) ) THEN   ;   CALL lbc_lnk( 'crslbclnk', pt2d, cd_type, psgn, cd_mpp, pval=zval  )
-      ELSE                           ;   CALL lbc_lnk( 'crslbclnk', pt2d, cd_type, psgn        , pval=zval  )
-      ENDIF
+      CALL lbc_lnk( 'crslbclnk', pt2d, cd_type, psgn, kfillmode, pfillval )
       !
       IF( .NOT.ll_grid_crs )   CALL dom_grid_glo   ! Return to parent grid domain
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/dia25h.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/dia25h.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/dia25h.F90	(revision 12143)
@@ -55,8 +55,8 @@
       REWIND ( numnam_ref )              ! Read Namelist nam_dia25h in reference namelist : 25hour mean diagnostics
       READ   ( numnam_ref, nam_dia25h, IOSTAT=ios, ERR= 901 )
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_dia25h in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_dia25h in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist nam_dia25h in configuration namelist  25hour diagnostics
       READ  ( numnam_cfg, nam_dia25h, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_dia25h in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_dia25h in configuration namelist' )
       IF(lwm) WRITE ( numond, nam_dia25h )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diacfl.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diacfl.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diacfl.F90	(revision 12143)
@@ -29,9 +29,4 @@
    REAL(wp)              ::   rCu_max, rCv_max, rCw_max   ! associated run max Courant number 
 
-!!gm CAUTION: need to declare these arrays here, otherwise the calculation fails in multi-proc !
-!!gm          I don't understand why.
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   zCu_cfl, zCv_cfl, zCw_cfl         ! workspace
-!!gm end
-
    PUBLIC   dia_cfl       ! routine called by step.F90
    PUBLIC   dia_cfl_init  ! routine called by nemogcm
@@ -55,8 +50,8 @@
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
       !
-      INTEGER                ::   ji, jj, jk                            ! dummy loop indices
-      REAL(wp)               ::   z2dt, zCu_max, zCv_max, zCw_max       ! local scalars
-      INTEGER , DIMENSION(3) ::   iloc_u , iloc_v , iloc_w , iloc       ! workspace
-!!gm this does not work      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zCu_cfl, zCv_cfl, zCw_cfl         ! workspace
+      INTEGER                          ::   ji, jj, jk                       ! dummy loop indices
+      REAL(wp)                         ::   z2dt, zCu_max, zCv_max, zCw_max  ! local scalars
+      INTEGER , DIMENSION(3)           ::   iloc_u , iloc_v , iloc_w , iloc  ! workspace
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zCu_cfl, zCv_cfl, zCw_cfl        ! workspace
       !!----------------------------------------------------------------------
       !
@@ -71,5 +66,5 @@
       DO jk = 1, jpk       ! calculate Courant numbers
          DO jj = 1, jpj
-            DO ji = 1, fs_jpim1   ! vector opt.
+            DO ji = 1, jpi
                zCu_cfl(ji,jj,jk) = ABS( un(ji,jj,jk) ) * z2dt / e1u  (ji,jj)      ! for i-direction
                zCv_cfl(ji,jj,jk) = ABS( vn(ji,jj,jk) ) * z2dt / e2v  (ji,jj)      ! for j-direction
@@ -111,5 +106,5 @@
       !                    ! write out to file
       IF( lwp ) THEN
-         WRITE(numcfl,FMT='(2x,i4,5x,a6,4x,f7.4,1x,i4,1x,i4,1x,i4)') kt, 'Max Cu', zCu_max, iloc_u(1), iloc_u(2), iloc_u(3)
+         WRITE(numcfl,FMT='(2x,i6,3x,a6,4x,f7.4,1x,i4,1x,i4,1x,i4)') kt, 'Max Cu', zCu_max, iloc_u(1), iloc_u(2), iloc_u(3)
          WRITE(numcfl,FMT='(11x,     a6,4x,f7.4,1x,i4,1x,i4,1x,i4)')     'Max Cv', zCv_max, iloc_v(1), iloc_v(2), iloc_v(3)
          WRITE(numcfl,FMT='(11x,     a6,4x,f7.4,1x,i4,1x,i4,1x,i4)')     'Max Cw', zCw_max, iloc_w(1), iloc_w(2), iloc_w(3)
@@ -172,8 +167,4 @@
       rCw_max = 0._wp
       !
-!!gm required to work
-      ALLOCATE ( zCu_cfl(jpi,jpj,jpk), zCv_cfl(jpi,jpj,jpk), zCw_cfl(jpi,jpj,jpk) )
-!!gm end
-      !      
    END SUBROUTINE dia_cfl_init
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diadct.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diadct.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diadct.F90	(revision 12143)
@@ -11,8 +11,6 @@
    !!            3.4  ! 09/2011 (C Bricaud)
    !!----------------------------------------------------------------------
-#if defined key_diadct
-   !!----------------------------------------------------------------------
-   !!   'key_diadct' :
-   !!----------------------------------------------------------------------
+   !! does not work with agrif
+#if ! defined key_agrif
    !!----------------------------------------------------------------------
    !!   dia_dct      :  Compute the transport through a sec.
@@ -42,16 +40,11 @@
 
    PUBLIC   dia_dct      ! routine called by step.F90
-   PUBLIC   dia_dct_init ! routine called by opa.F90
-   PUBLIC   diadct_alloc ! routine called by nemo_init in nemogcm.F90 
-   PRIVATE  readsec
-   PRIVATE  removepoints
-   PRIVATE  transport
-   PRIVATE  dia_dct_wri
-
-   LOGICAL, PUBLIC, PARAMETER ::   lk_diadct = .TRUE.   !: model-data diagnostics flag
-
-   INTEGER :: nn_dct        ! Frequency of computation
-   INTEGER :: nn_dctwri     ! Frequency of output
-   INTEGER :: nn_secdebug   ! Number of the section to debug
+   PUBLIC   dia_dct_init ! routine called by nemogcm.F90
+
+   !                         !!** namelist variables **
+   LOGICAL, PUBLIC ::   ln_diadct     !: Calculate transport thru a section or not
+   INTEGER         ::   nn_dct        !  Frequency of computation
+   INTEGER         ::   nn_dctwri     !  Frequency of output
+   INTEGER         ::   nn_secdebug   !  Number of the section to debug
    
    INTEGER, PARAMETER :: nb_class_max  = 10
@@ -104,19 +97,16 @@
 CONTAINS
  
-  INTEGER FUNCTION diadct_alloc() 
-     !!---------------------------------------------------------------------- 
-     !!                   ***  FUNCTION diadct_alloc  *** 
-     !!---------------------------------------------------------------------- 
-     INTEGER :: ierr(2) 
-     !!---------------------------------------------------------------------- 
-
-     ALLOCATE(transports_3d(nb_3d_vars,nb_sec_max,nb_point_max,jpk), STAT=ierr(1) ) 
-     ALLOCATE(transports_2d(nb_2d_vars,nb_sec_max,nb_point_max)    , STAT=ierr(2) ) 
-
-     diadct_alloc = MAXVAL( ierr ) 
-     IF( diadct_alloc /= 0 )   CALL ctl_stop( 'STOP', 'diadct_alloc: failed to allocate arrays' ) 
- 
-  END FUNCTION diadct_alloc 
-
+   INTEGER FUNCTION diadct_alloc() 
+      !!---------------------------------------------------------------------- 
+      !!                   ***  FUNCTION diadct_alloc  *** 
+      !!---------------------------------------------------------------------- 
+
+      ALLOCATE( transports_3d(nb_3d_vars,nb_sec_max,nb_point_max,jpk), &
+         &      transports_2d(nb_2d_vars,nb_sec_max,nb_point_max)    , STAT=diadct_alloc ) 
+
+      CALL mpp_sum( 'diadct', diadct_alloc ) 
+      IF( diadct_alloc /= 0 )   CALL ctl_stop( 'STOP', 'diadct_alloc: failed to allocate arrays' ) 
+
+   END FUNCTION diadct_alloc
 
    SUBROUTINE dia_dct_init
@@ -130,15 +120,15 @@
       INTEGER  ::   ios                 ! Local integer output status for namelist read
       !!
-      NAMELIST/namdct/nn_dct,nn_dctwri,nn_secdebug
+      NAMELIST/nam_diadct/ln_diadct, nn_dct, nn_dctwri, nn_secdebug
       !!---------------------------------------------------------------------
 
-     REWIND( numnam_ref )              ! Namelist namdct in reference namelist : Diagnostic: transport through sections
-     READ  ( numnam_ref, namdct, IOSTAT = ios, ERR = 901)
-901  IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdct in reference namelist', lwp )
-
-     REWIND( numnam_cfg )              ! Namelist namdct in configuration namelist : Diagnostic: transport through sections
-     READ  ( numnam_cfg, namdct, IOSTAT = ios, ERR = 902 )
-902  IF( ios >  0 ) CALL ctl_nam ( ios , 'namdct in configuration namelist', lwp )
-     IF(lwm) WRITE ( numond, namdct )
+     REWIND( numnam_ref )              ! Namelist nam_diadct in reference namelist : Diagnostic: transport through sections
+     READ  ( numnam_ref, nam_diadct, IOSTAT = ios, ERR = 901)
+901  IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diadct in reference namelist' )
+
+     REWIND( numnam_cfg )              ! Namelist nam_diadct in configuration namelist : Diagnostic: transport through sections
+     READ  ( numnam_cfg, nam_diadct, IOSTAT = ios, ERR = 902 )
+902  IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_diadct in configuration namelist' )
+     IF(lwm) WRITE ( numond, nam_diadct )
 
      IF( lwp ) THEN
@@ -146,6 +136,7 @@
         WRITE(numout,*) "diadct_init: compute transports through sections "
         WRITE(numout,*) "~~~~~~~~~~~~~~~~~~~~~"
-        WRITE(numout,*) "       Frequency of computation: nn_dct    = ",nn_dct
-        WRITE(numout,*) "       Frequency of write:       nn_dctwri = ",nn_dctwri
+        WRITE(numout,*) "       Calculate transport thru sections: ln_diadct = ", ln_diadct
+        WRITE(numout,*) "       Frequency of computation:          nn_dct    = ", nn_dct
+        WRITE(numout,*) "       Frequency of write:                nn_dctwri = ", nn_dctwri
 
         IF      ( nn_secdebug .GE. 1 .AND. nn_secdebug .LE. nb_sec_max )THEN
@@ -155,23 +146,29 @@
         ELSE                              ; WRITE(numout,*)"       Wrong value for nn_secdebug : ",nn_secdebug
         ENDIF
-
+     ENDIF
+
+     IF( ln_diadct ) THEN
+        ! control
         IF(nn_dct .GE. nn_dctwri .AND. MOD(nn_dct,nn_dctwri) .NE. 0)  &
-          &  CALL ctl_stop( 'diadct: nn_dct should be smaller and a multiple of nn_dctwri' )
-
+           &  CALL ctl_stop( 'diadct: nn_dct should be smaller and a multiple of nn_dctwri' )
+
+        ! allocate dia_dct arrays
+        IF( diadct_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'diadct_alloc: failed to allocate arrays' )
+
+        !Read section_ijglobal.diadct
+        CALL readsec
+
+        !open output file
+        IF( lwm ) THEN
+           CALL ctl_opn( numdct_vol,  'volume_transport', 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
+           CALL ctl_opn( numdct_heat, 'heat_transport'  , 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
+           CALL ctl_opn( numdct_salt, 'salt_transport'  , 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
+        ENDIF
+
+        ! Initialise arrays to zero 
+        transports_3d(:,:,:,:)=0.0 
+        transports_2d(:,:,:)  =0.0 
+        !
      ENDIF
-
-     !Read section_ijglobal.diadct
-     CALL readsec
-
-     !open output file
-     IF( lwm ) THEN
-        CALL ctl_opn( numdct_vol,  'volume_transport', 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
-        CALL ctl_opn( numdct_heat, 'heat_transport'  , 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
-        CALL ctl_opn( numdct_salt, 'salt_transport'  , 'NEW', 'FORMATTED', 'SEQUENTIAL', -1, numout,  .FALSE. )
-     ENDIF
-
-     ! Initialise arrays to zero 
-     transports_3d(:,:,:,:)=0.0 
-     transports_2d(:,:,:)  =0.0 
      !
   END SUBROUTINE dia_dct_init
@@ -1241,21 +1238,16 @@
 #else
    !!----------------------------------------------------------------------
-   !!   Default option :                                       Dummy module
+   !!   Dummy module                                             
    !!----------------------------------------------------------------------
-   LOGICAL, PUBLIC, PARAMETER ::   lk_diadct = .FALSE.    !: diamht flag
-   PUBLIC 
-   !! $Id$
+   LOGICAL, PUBLIC ::   ln_diadct = .FALSE.
 CONTAINS
-
-   SUBROUTINE dia_dct_init          ! Dummy routine
+   SUBROUTINE dia_dct_init
       IMPLICIT NONE
-      WRITE(*,*) 'dia_dct_init: You should not have seen this print! error?'
    END SUBROUTINE dia_dct_init
-
-   SUBROUTINE dia_dct( kt )         ! Dummy routine
+   SUBROUTINE dia_dct( kt )
       IMPLICIT NONE
-      INTEGER, INTENT( in ) :: kt   ! ocean time-step index
-      WRITE(*,*) 'dia_dct: You should not have seen this print! error?', kt
+      INTEGER, INTENT(in) ::   kt
    END SUBROUTINE dia_dct
+   !
 #endif
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diaharm.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diaharm.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diaharm.F90	(revision 12143)
@@ -5,8 +5,4 @@
    !!======================================================================
    !! History :  3.1  !  2007  (O. Le Galloudec, J. Chanut)  Original code
-   !!----------------------------------------------------------------------
-#if defined key_diaharm
-   !!----------------------------------------------------------------------
-   !!   'key_diaharm'
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and tracers variables
@@ -26,6 +22,4 @@
    IMPLICIT NONE
    PRIVATE
-
-   LOGICAL, PUBLIC, PARAMETER :: lk_diaharm  = .TRUE.
    
    INTEGER, PARAMETER :: jpincomax    = 2.*jpmax_harmo
@@ -33,8 +27,9 @@
 
    !                         !!** namelist variables **
-   INTEGER ::   nit000_han    ! First time step used for harmonic analysis
-   INTEGER ::   nitend_han    ! Last time step used for harmonic analysis
-   INTEGER ::   nstep_han     ! Time step frequency for harmonic analysis
-   INTEGER ::   nb_ana        ! Number of harmonics to analyse
+   LOGICAL, PUBLIC ::   ln_diaharm    ! Choose tidal harmonic output or not
+   INTEGER         ::   nit000_han    ! First time step used for harmonic analysis
+   INTEGER         ::   nitend_han    ! Last time step used for harmonic analysis
+   INTEGER         ::   nstep_han     ! Time step frequency for harmonic analysis
+   INTEGER         ::   nb_ana        ! Number of harmonics to analyse
 
    INTEGER , ALLOCATABLE, DIMENSION(:)       ::   name
@@ -53,5 +48,6 @@
    CHARACTER (LEN=4), DIMENSION(jpmax_harmo) ::   tname   ! Names of tidal constituents ('M2', 'K1',...)
 
-   PUBLIC   dia_harm   ! routine called by step.F90
+   PUBLIC   dia_harm        ! routine called by step.F90
+   PUBLIC   dia_harm_init   ! routine called by nemogcm.F90
 
    !!----------------------------------------------------------------------
@@ -71,8 +67,8 @@
       !!
       !!--------------------------------------------------------------------
-      INTEGER :: jh, nhan, jk, ji
+      INTEGER ::   jh, nhan, ji
       INTEGER ::   ios                 ! Local integer output status for namelist read
 
-      NAMELIST/nam_diaharm/ nit000_han, nitend_han, nstep_han, tname
+      NAMELIST/nam_diaharm/ ln_diaharm, nit000_han, nitend_han, nstep_han, tname
       !!----------------------------------------------------------------------
 
@@ -83,79 +79,84 @@
       ENDIF
       !
-      IF( .NOT. ln_tide )   CALL ctl_stop( 'dia_harm_init : ln_tide must be true for harmonic analysis')
-      !
-      CALL tide_init_Wave
-      !
       REWIND( numnam_ref )              ! Namelist nam_diaharm in reference namelist : Tidal harmonic analysis
       READ  ( numnam_ref, nam_diaharm, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_diaharm in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_diaharm in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist nam_diaharm in configuration namelist : Tidal harmonic analysis
       READ  ( numnam_cfg, nam_diaharm, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_diaharm in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_diaharm in configuration namelist' )
       IF(lwm) WRITE ( numond, nam_diaharm )
       !
       IF(lwp) THEN
-         WRITE(numout,*) 'First time step used for analysis:  nit000_han= ', nit000_han
-         WRITE(numout,*) 'Last  time step used for analysis:  nitend_han= ', nitend_han
-         WRITE(numout,*) 'Time step frequency for harmonic analysis:  nstep_han= ', nstep_han
+         WRITE(numout,*) 'Tidal diagnostics = ', ln_diaharm
+         WRITE(numout,*) '   First time step used for analysis:         nit000_han= ', nit000_han
+         WRITE(numout,*) '   Last  time step used for analysis:         nitend_han= ', nitend_han
+         WRITE(numout,*) '   Time step frequency for harmonic analysis: nstep_han = ', nstep_han
       ENDIF
 
-      ! Basic checks on harmonic analysis time window:
-      ! ----------------------------------------------
-      IF( nit000 > nit000_han )   CALL ctl_stop( 'dia_harm_init : nit000_han must be greater than nit000',   &
-         &                                       ' restart capability not implemented' )
-      IF( nitend < nitend_han )   CALL ctl_stop( 'dia_harm_init : nitend_han must be lower than nitend',   &
-         &                                       'restart capability not implemented' )
-
-      IF( MOD( nitend_han-nit000_han+1 , nstep_han ) /= 0 )   &
-         &                        CALL ctl_stop( 'dia_harm_init : analysis time span must be a multiple of nstep_han' )
-
-      nb_ana = 0
-      DO jk=1,jpmax_harmo
-         DO ji=1,jpmax_harmo
-            IF(TRIM(tname(jk)) == Wave(ji)%cname_tide) THEN
-               nb_ana=nb_ana+1
-            ENDIF
-         END DO
-      END DO
-      !
-      IF(lwp) THEN
-         WRITE(numout,*) '        Namelist nam_diaharm'
-         WRITE(numout,*) '        nb_ana    = ', nb_ana
-         CALL flush(numout)
+      IF( ln_diaharm .AND. .NOT.ln_tide )   CALL ctl_stop( 'dia_harm_init : ln_tide must be true for harmonic analysis')
+
+      IF( ln_diaharm ) THEN
+
+         CALL tide_init_Wave
+         !
+         ! Basic checks on harmonic analysis time window:
+         ! ----------------------------------------------
+         IF( nit000 > nit000_han )   CALL ctl_stop( 'dia_harm_init : nit000_han must be greater than nit000',   &
+            &                                       ' restart capability not implemented' )
+         IF( nitend < nitend_han )   CALL ctl_stop( 'dia_harm_init : nitend_han must be lower than nitend',   &
+            &                                       'restart capability not implemented' )
+
+         IF( MOD( nitend_han-nit000_han+1 , nstep_han ) /= 0 )   &
+            &                        CALL ctl_stop( 'dia_harm_init : analysis time span must be a multiple of nstep_han' )
+         !
+         nb_ana = 0
+         DO jh=1,jpmax_harmo
+            DO ji=1,jpmax_harmo
+               IF(TRIM(tname(jh)) == Wave(ji)%cname_tide) THEN
+                  nb_ana=nb_ana+1
+               ENDIF
+            END DO
+         END DO
+         !
+         IF(lwp) THEN
+            WRITE(numout,*) '        Namelist nam_diaharm'
+            WRITE(numout,*) '        nb_ana    = ', nb_ana
+            CALL flush(numout)
+         ENDIF
+         !
+         IF (nb_ana > jpmax_harmo) THEN
+            WRITE(ctmp1,*) ' nb_ana must be lower than jpmax_harmo'
+            WRITE(ctmp2,*) ' jpmax_harmo= ', jpmax_harmo
+            CALL ctl_stop( 'dia_harm_init', ctmp1, ctmp2 )
+         ENDIF
+
+         ALLOCATE(name    (nb_ana))
+         DO jh=1,nb_ana
+            DO ji=1,jpmax_harmo
+               IF (TRIM(tname(jh)) ==  Wave(ji)%cname_tide) THEN
+                  name(jh) = ji
+                  EXIT
+               END IF
+            END DO
+         END DO
+
+         ! Initialize frequency array:
+         ! ---------------------------
+         ALLOCATE( ana_freq(nb_ana), ut(nb_ana), vt(nb_ana), ft(nb_ana) )
+
+         CALL tide_harmo( ana_freq, vt, ut, ft, name, nb_ana )
+
+         IF(lwp) WRITE(numout,*) 'Analysed frequency  : ',nb_ana ,'Frequency '
+
+         DO jh = 1, nb_ana
+            IF(lwp) WRITE(numout,*) '                    : ',tname(jh),' ',ana_freq(jh)
+         END DO
+
+         ! Initialize temporary arrays:
+         ! ----------------------------
+         ALLOCATE( ana_temp(jpi,jpj,2*nb_ana,3) )
+         ana_temp(:,:,:,:) = 0._wp
+
       ENDIF
-      !
-      IF (nb_ana > jpmax_harmo) THEN
-         WRITE(ctmp1,*) ' nb_ana must be lower than jpmax_harmo'
-         WRITE(ctmp2,*) ' jpmax_harmo= ', jpmax_harmo
-         CALL ctl_stop( 'dia_harm_init', ctmp1, ctmp2 )
-      ENDIF
-
-      ALLOCATE(name    (nb_ana))
-      DO jk=1,nb_ana
-       DO ji=1,jpmax_harmo
-          IF (TRIM(tname(jk)) ==  Wave(ji)%cname_tide) THEN
-             name(jk) = ji
-             EXIT
-          END IF
-       END DO
-      END DO
-
-      ! Initialize frequency array:
-      ! ---------------------------
-      ALLOCATE( ana_freq(nb_ana), ut(nb_ana), vt(nb_ana), ft(nb_ana) )
-
-      CALL tide_harmo( ana_freq, vt, ut, ft, name, nb_ana )
-
-      IF(lwp) WRITE(numout,*) 'Analysed frequency  : ',nb_ana ,'Frequency '
-
-      DO jh = 1, nb_ana
-        IF(lwp) WRITE(numout,*) '                    : ',tname(jh),' ',ana_freq(jh)
-      END DO
-
-      ! Initialize temporary arrays:
-      ! ----------------------------
-      ALLOCATE( ana_temp(jpi,jpj,2*nb_ana,3) )
-      ana_temp(:,:,:,:) = 0._wp
 
    END SUBROUTINE dia_harm_init
@@ -177,6 +178,4 @@
       !!--------------------------------------------------------------------
       IF( ln_timing )   CALL timing_start('dia_harm')
-      !
-      IF( kt == nit000 )   CALL dia_harm_init
       !
       IF( kt >= nit000_han .AND. kt <= nitend_han .AND. MOD(kt,nstep_han) == 0 ) THEN
@@ -422,5 +421,5 @@
       INTEGER, INTENT(in) ::   init 
       !
-      INTEGER                         :: ji_sd, jj_sd, ji1_sd, ji2_sd, jk1_sd, jk2_sd
+      INTEGER                         :: ji_sd, jj_sd, ji1_sd, ji2_sd, jh1_sd, jh2_sd
       REAL(wp)                        :: zval1, zval2, zx1
       REAL(wp), DIMENSION(jpincomax) :: ztmpx, zcol1, zcol2
@@ -434,11 +433,11 @@
          ztmp3(:,:) = 0._wp
          !
-         DO jk1_sd = 1, nsparse
-            DO jk2_sd = 1, nsparse
-               nisparse(jk2_sd) = nisparse(jk2_sd)
-               njsparse(jk2_sd) = njsparse(jk2_sd)
-               IF( nisparse(jk2_sd) == nisparse(jk1_sd) ) THEN
-                  ztmp3(njsparse(jk1_sd),njsparse(jk2_sd)) = ztmp3(njsparse(jk1_sd),njsparse(jk2_sd))  &
-                     &                                     + valuesparse(jk1_sd)*valuesparse(jk2_sd)
+         DO jh1_sd = 1, nsparse
+            DO jh2_sd = 1, nsparse
+               nisparse(jh2_sd) = nisparse(jh2_sd)
+               njsparse(jh2_sd) = njsparse(jh2_sd)
+               IF( nisparse(jh2_sd) == nisparse(jh1_sd) ) THEN
+                  ztmp3(njsparse(jh1_sd),njsparse(jh2_sd)) = ztmp3(njsparse(jh1_sd),njsparse(jh2_sd))  &
+                     &                                     + valuesparse(jh1_sd)*valuesparse(jh2_sd)
                ENDIF
             END DO
@@ -515,16 +514,4 @@
    END SUBROUTINE SUR_DETERMINE
 
-#else
-   !!----------------------------------------------------------------------
-   !!   Default case :   Empty module
-   !!----------------------------------------------------------------------
-   LOGICAL, PUBLIC, PARAMETER ::   lk_diaharm = .FALSE.
-CONTAINS
-   SUBROUTINE dia_harm ( kt )     ! Empty routine
-      INTEGER, INTENT( IN ) :: kt  
-      WRITE(*,*) 'dia_harm: you should not have seen this print'
-   END SUBROUTINE dia_harm
-#endif
-
    !!======================================================================
 END MODULE diaharm
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diahsb.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diahsb.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diahsb.F90	(revision 12143)
@@ -367,8 +367,8 @@
       REWIND( numnam_ref )              ! Namelist namhsb in reference namelist
       READ  ( numnam_ref, namhsb, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namhsb in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namhsb in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namhsb in configuration namelist
       READ  ( numnam_cfg, namhsb, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namhsb in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namhsb in configuration namelist' )
       IF(lwm) WRITE( numond, namhsb )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diaptr.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diaptr.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diaptr.F90	(revision 12143)
@@ -393,9 +393,9 @@
       REWIND( numnam_ref )              ! Namelist namptr in reference namelist : Poleward transport
       READ  ( numnam_ref, namptr, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namptr in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namptr in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namptr in configuration namelist : Poleward transport
       READ  ( numnam_cfg, namptr, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namptr in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namptr in configuration namelist' )
       IF(lwm) WRITE ( numond, namptr )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diatmb.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diatmb.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diatmb.F90	(revision 12143)
@@ -43,9 +43,9 @@
       REWIND( numnam_ref )              ! Read Namelist nam_diatmb in reference namelist : TMB diagnostics
       READ  ( numnam_ref, nam_diatmb, IOSTAT=ios, ERR= 901 )
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diatmb in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diatmb in reference namelist' )
  
       REWIND( numnam_cfg )              ! Namelist nam_diatmb in configuration namelist  TMB diagnostics
       READ  ( numnam_cfg, nam_diatmb, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_diatmb in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_diatmb in configuration namelist' )
       IF(lwm) WRITE ( numond, nam_diatmb )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diawri.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diawri.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIA/diawri.F90	(revision 12143)
@@ -212,4 +212,6 @@
       ENDIF
 
+      IF( ln_zad_Aimp ) wn = wn + wi               ! Recombine explicit and implicit parts of vertical velocity for diagnostic output
+      !
       CALL iom_put( "woce", wn )                   ! vertical velocity
       IF( iom_use('w_masstr') .OR. iom_use('w_masstr2') ) THEN   ! vertical mass transport & its square value
@@ -222,4 +224,6 @@
          IF( iom_use('w_masstr2') )   CALL iom_put( "w_masstr2", z3d(:,:,:) * z3d(:,:,:) )
       ENDIF
+      !
+      IF( ln_zad_Aimp ) wn = wn - wi               ! Remove implicit part of vertical velocity that was added for diagnostic output
 
       CALL iom_put( "avt" , avt )                  ! T vert. eddy diff. coef.
@@ -428,5 +432,5 @@
       !!      define all the NETCDF files and fields
       !!      At each time step call histdef to compute the mean if ncessary
-      !!      Each nwrite time step, output the instantaneous or mean fields
+      !!      Each nn_write time step, output the instantaneous or mean fields
       !!----------------------------------------------------------------------
       INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
@@ -444,6 +448,4 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk) :: zw3d       ! 3D workspace
       !!----------------------------------------------------------------------
-      ! 
-      IF( ln_timing )   CALL timing_start('dia_wri')
       !
       IF( ninist == 1 ) THEN     !==  Output the initial state and forcings  ==!
@@ -452,4 +454,8 @@
       ENDIF
       !
+      IF( nn_write == -1 )   RETURN   ! we will never do any output
+      ! 
+      IF( ln_timing )   CALL timing_start('dia_wri')
+      !
       ! 0. Initialisation
       ! -----------------
@@ -461,5 +467,5 @@
       clop = "x"         ! no use of the mask value (require less cpu time and otherwise the model crashes)
 #if defined key_diainstant
-      zsto = nwrite * rdt
+      zsto = nn_write * rdt
       clop = "inst("//TRIM(clop)//")"
 #else
@@ -467,5 +473,5 @@
       clop = "ave("//TRIM(clop)//")"
 #endif
-      zout = nwrite * rdt
+      zout = nn_write * rdt
       zmax = ( nitend - nit000 + 1 ) * rdt
 
@@ -498,5 +504,5 @@
          ! WRITE root name in date.file for use by postpro
          IF(lwp) THEN
-            CALL dia_nam( clhstnam, nwrite,' ' )
+            CALL dia_nam( clhstnam, nn_write,' ' )
             CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
             WRITE(inum,*) clhstnam
@@ -506,5 +512,5 @@
          ! Define the T grid FILE ( nid_T )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_T' )
+         CALL dia_nam( clhstnam, nn_write, 'grid_T' )
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
          CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
@@ -542,5 +548,5 @@
          ! Define the U grid FILE ( nid_U )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_U' )
+         CALL dia_nam( clhstnam, nn_write, 'grid_U' )
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
          CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu,           &  ! Horizontal grid: glamu and gphiu
@@ -555,5 +561,5 @@
          ! Define the V grid FILE ( nid_V )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_V' )                   ! filename
+         CALL dia_nam( clhstnam, nn_write, 'grid_V' )                   ! filename
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
          CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv,           &  ! Horizontal grid: glamv and gphiv
@@ -568,5 +574,5 @@
          ! Define the W grid FILE ( nid_W )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_W' )                   ! filename
+         CALL dia_nam( clhstnam, nn_write, 'grid_W' )                   ! filename
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
          CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
@@ -659,5 +665,5 @@
          ENDIF
 
-         IF( .NOT. ln_cpl ) THEN
+         IF( ln_ssr ) THEN
             CALL histdef( nid_T, "sohefldp", "Surface Heat Flux: Damping"         , "W/m2"   ,   &  ! qrp
                &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
@@ -667,14 +673,5 @@
                &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
          ENDIF
-
-         IF( ln_cpl .AND. nn_ice <= 1 ) THEN
-            CALL histdef( nid_T, "sohefldp", "Surface Heat Flux: Damping"         , "W/m2"   ,   &  ! qrp
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-            CALL histdef( nid_T, "sowafldp", "Surface Water Flux: Damping"        , "Kg/m2/s",   &  ! erp
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-            CALL histdef( nid_T, "sosafldp", "Surface salt flux: Damping"         , "Kg/m2/s",   &  ! erp * sn
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         ENDIF
-         
+       
          clmx ="l_max(only(x))"    ! max index on a period
 !         CALL histdef( nid_T, "sobowlin", "Bowl Index"                         , "W-point",   &  ! bowl INDEX 
@@ -752,5 +749,5 @@
       ! donne le nombre d'elements, et ndex la liste des indices a sortir
 
-      IF( lwp .AND. MOD( itmod, nwrite ) == 0 ) THEN 
+      IF( lwp .AND. MOD( itmod, nn_write ) == 0 ) THEN 
          WRITE(numout,*) 'dia_wri : write model outputs in NetCDF files at ', kt, 'time-step'
          WRITE(numout,*) '~~~~~~ '
@@ -816,14 +813,8 @@
       ENDIF
 
-      IF( .NOT. ln_cpl ) THEN
+      IF( ln_ssr ) THEN
          CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping
          CALL histwrite( nid_T, "sowafldp", it, erp           , ndim_hT, ndex_hT )   ! freshwater flux damping
-         IF( ln_ssr ) zw2d(:,:) = erp(:,:) * tsn(:,:,1,jp_sal) * tmask(:,:,1)
-         CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
-      ENDIF
-      IF( ln_cpl .AND. nn_ice <= 1 ) THEN
-         CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping
-         CALL histwrite( nid_T, "sowafldp", it, erp           , ndim_hT, ndex_hT )   ! freshwater flux damping
-         IF( ln_ssr ) zw2d(:,:) = erp(:,:) * tsn(:,:,1,jp_sal) * tmask(:,:,1)
+         zw2d(:,:) = erp(:,:) * tsn(:,:,1,jp_sal) * tmask(:,:,1)
          CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
       ENDIF
@@ -844,5 +835,9 @@
       CALL histwrite( nid_V, "sometauy", it, vtau          , ndim_hV, ndex_hV )   ! j-wind stress
 
-      CALL histwrite( nid_W, "vovecrtz", it, wn             , ndim_T, ndex_T )    ! vert. current
+      IF( ln_zad_Aimp ) THEN
+         CALL histwrite( nid_W, "vovecrtz", it, wn + wi     , ndim_T, ndex_T )    ! vert. current
+      ELSE
+         CALL histwrite( nid_W, "vovecrtz", it, wn          , ndim_T, ndex_T )    ! vert. current
+      ENDIF
       CALL histwrite( nid_W, "votkeavt", it, avt            , ndim_T, ndex_T )    ! T vert. eddy diff. coef.
       CALL histwrite( nid_W, "votkeavm", it, avm            , ndim_T, ndex_T )    ! T vert. eddy visc. coef.
@@ -906,5 +901,9 @@
       CALL iom_rstput( 0, 0, inum, 'vozocrtx', un                )    ! now i-velocity
       CALL iom_rstput( 0, 0, inum, 'vomecrty', vn                )    ! now j-velocity
-      CALL iom_rstput( 0, 0, inum, 'vovecrtz', wn                )    ! now k-velocity
+      IF( ln_zad_Aimp ) THEN
+         CALL iom_rstput( 0, 0, inum, 'vovecrtz', wn + wi        )    ! now k-velocity
+      ELSE
+         CALL iom_rstput( 0, 0, inum, 'vovecrtz', wn             )    ! now k-velocity
+      ENDIF
       CALL iom_rstput( 0, 0, inum, 'risfdep', risfdep            )    ! now k-velocity
       CALL iom_rstput( 0, 0, inum, 'ht_n'   , ht_n               )    ! now k-velocity
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIU/diurnal_bulk.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIU/diurnal_bulk.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DIU/diurnal_bulk.F90	(revision 12143)
@@ -54,8 +54,8 @@
       REWIND( numnam_ref )
       READ  ( numnam_ref, namdiu, IOSTAT = ios, ERR = 901 )
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdiu in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdiu in reference namelist' )
       REWIND( numnam_cfg )
       READ  ( numnam_cfg, namdiu, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdiu in configuration namelist', lwp )      
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdiu in configuration namelist' )      
       !
       IF( ln_diurnal_only .AND. ( .NOT. ln_diurnal ) ) THEN
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domain.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domain.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domain.F90	(revision 12143)
@@ -101,5 +101,5 @@
          CASE( 0 )   ;   WRITE(numout,*) '         (i.e. closed)'
          CASE( 1 )   ;   WRITE(numout,*) '         (i.e. cyclic east-west)'
-         CASE( 2 )   ;   WRITE(numout,*) '         (i.e. equatorial symmetric)'
+         CASE( 2 )   ;   WRITE(numout,*) '         (i.e. cyclic north-south)'
          CASE( 3 )   ;   WRITE(numout,*) '         (i.e. north fold with T-point pivot)'
          CASE( 4 )   ;   WRITE(numout,*) '         (i.e. cyclic east-west and north fold with T-point pivot)'
@@ -300,8 +300,8 @@
       REWIND( numnam_ref )              ! Namelist namrun in reference namelist : Parameters of the run
       READ  ( numnam_ref, namrun, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namrun in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namrun in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namrun in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, namrun, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namrun in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namrun in configuration namelist' )
       IF(lwm) WRITE ( numond, namrun )
       !
@@ -328,5 +328,7 @@
             WRITE(numout,*) '      frequency of restart file       nn_stock        = ', nn_stock
          ENDIF
+#if ! defined key_iomput
          WRITE(numout,*) '      frequency of output file        nn_write        = ', nn_write
+#endif
          WRITE(numout,*) '      mask land points                ln_mskland      = ', ln_mskland
          WRITE(numout,*) '      additional CF standard metadata ln_cfmeta       = ', ln_cfmeta
@@ -349,7 +351,4 @@
       nleapy = nn_leapy
       ninist = nn_istate
-      nstock = nn_stock
-      nstocklist = nn_stocklist
-      nwrite = nn_write
       neuler = nn_euler
       IF( neuler == 1 .AND. .NOT. ln_rstart ) THEN
@@ -360,14 +359,20 @@
       ENDIF
       !                             ! control of output frequency
-      IF( nstock == 0 .OR. nstock > nitend ) THEN
-         WRITE(ctmp1,*) 'nstock = ', nstock, ' it is forced to ', nitend
+      IF( .NOT. ln_rst_list ) THEN     ! we use nn_stock
+         IF( nn_stock == -1 )   CALL ctl_warn( 'nn_stock = -1 --> no restart will be done' )
+         IF( nn_stock == 0 .OR. nn_stock > nitend ) THEN
+            WRITE(ctmp1,*) 'nn_stock = ', nn_stock, ' it is forced to ', nitend
+            CALL ctl_warn( ctmp1 )
+            nn_stock = nitend
+         ENDIF
+      ENDIF
+#if ! defined key_iomput
+      IF( nn_write == -1 )   CALL ctl_warn( 'nn_write = -1 --> no output files will be done' )
+      IF ( nn_write == 0 ) THEN
+         WRITE(ctmp1,*) 'nn_write = ', nn_write, ' it is forced to ', nitend
          CALL ctl_warn( ctmp1 )
-         nstock = nitend
-      ENDIF
-      IF ( nwrite == 0 ) THEN
-         WRITE(ctmp1,*) 'nwrite = ', nwrite, ' it is forced to ', nitend
-         CALL ctl_warn( ctmp1 )
-         nwrite = nitend
-      ENDIF
+         nn_write = nitend
+      ENDIF
+#endif
 
 #if defined key_agrif
@@ -392,8 +397,8 @@
       REWIND( numnam_ref )              ! Namelist namdom in reference namelist : space & time domain (bathymetry, mesh, timestep)
       READ  ( numnam_ref, namdom, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdom in reference namelist', lwp )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdom in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namdom in configuration namelist : space & time domain (bathymetry, mesh, timestep)
       READ  ( numnam_cfg, namdom, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdom in configuration namelist', lwp )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdom in configuration namelist' )
       IF(lwm) WRITE( numond, namdom )
       !
@@ -423,8 +428,8 @@
       REWIND( numnam_ref )              ! Namelist namnc4 in reference namelist : NETCDF
       READ  ( numnam_ref, namnc4, IOSTAT = ios, ERR = 907)
-907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namnc4 in reference namelist', lwp )
+907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namnc4 in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namnc4 in configuration namelist : NETCDF
       READ  ( numnam_cfg, namnc4, IOSTAT = ios, ERR = 908 )
-908   IF( ios >  0 )   CALL ctl_nam ( ios , 'namnc4 in configuration namelist', lwp )
+908   IF( ios >  0 )   CALL ctl_nam ( ios , 'namnc4 in configuration namelist' )
       IF(lwm) WRITE( numond, namnc4 )
 
@@ -501,5 +506,5 @@
 
 
-   SUBROUTINE domain_cfg( ldtxt, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE domain_cfg( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -509,5 +514,4 @@
       !! ** Method  :   read the cn_domcfg NetCDF file
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt           ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -515,13 +519,15 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   inum, ii   ! local integer
+      INTEGER ::   inum   ! local integer
       REAL(wp) ::   zorca_res                     ! local scalars
-      REAL(wp) ::   ziglo, zjglo, zkglo, zperio   !   -      -
-      !!----------------------------------------------------------------------
-      !
-      ii = 1
-      WRITE(ldtxt(ii),*) '           '                                                    ;   ii = ii+1
-      WRITE(ldtxt(ii),*) 'domain_cfg : domain size read in ', TRIM( cn_domcfg ), ' file'  ;   ii = ii+1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~ '                                                    ;   ii = ii+1
+      REAL(wp) ::   zperio                        !   -      -
+      INTEGER, DIMENSION(4) ::   idvar, idimsz    ! size   of dimensions
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) THEN
+         WRITE(numout,*) '           '
+         WRITE(numout,*) 'domain_cfg : domain size read in ', TRIM( cn_domcfg ), ' file'
+         WRITE(numout,*) '~~~~~~~~~~ '
+      ENDIF
       !
       CALL iom_open( cn_domcfg, inum )
@@ -534,7 +540,9 @@
          CALL iom_get( inum, 'ORCA_index', zorca_res )   ;   kk_cfg = NINT( zorca_res )
          !
-         WRITE(ldtxt(ii),*) '   .'                                                     ;   ii = ii+1
-         WRITE(ldtxt(ii),*) '   ==>>>   ORCA configuration '                           ;   ii = ii+1
-         WRITE(ldtxt(ii),*) '   .'                                                     ;   ii = ii+1
+         IF(lwp) THEN
+            WRITE(numout,*) '   .'
+            WRITE(numout,*) '   ==>>>   ORCA configuration '
+            WRITE(numout,*) '   .'
+         ENDIF
          !
       ELSE                                !- cd_cfg & k_cfg are not used
@@ -549,16 +557,19 @@
          !
       ENDIF
-      !
-      CALL iom_get( inum, 'jpiglo', ziglo  )   ;   kpi = NINT( ziglo )
-      CALL iom_get( inum, 'jpjglo', zjglo  )   ;   kpj = NINT( zjglo )
-      CALL iom_get( inum, 'jpkglo', zkglo  )   ;   kpk = NINT( zkglo )
+       !
+      idvar = iom_varid( inum, 'e3t_0', kdimsz = idimsz )   ! use e3t_0, that must exist, to get jp(ijk)glo
+      kpi = idimsz(1)
+      kpj = idimsz(2)
+      kpk = idimsz(3)
       CALL iom_get( inum, 'jperio', zperio )   ;   kperio = NINT( zperio )
       CALL iom_close( inum )
       !
-      WRITE(ldtxt(ii),*) '      cn_cfg = ', TRIM(cd_cfg), '   nn_cfg = ', kk_cfg             ;   ii = ii+1
-      WRITE(ldtxt(ii),*) '      jpiglo = ', kpi                                              ;   ii = ii+1
-      WRITE(ldtxt(ii),*) '      jpjglo = ', kpj                                              ;   ii = ii+1
-      WRITE(ldtxt(ii),*) '      jpkglo = ', kpk                                              ;   ii = ii+1
-      WRITE(ldtxt(ii),*) '      type of global domain lateral boundary   jperio = ', kperio  ;   ii = ii+1
+      IF(lwp) THEN
+         WRITE(numout,*) '      cn_cfg = ', TRIM(cd_cfg), '   nn_cfg = ', kk_cfg
+         WRITE(numout,*) '      jpiglo = ', kpi
+         WRITE(numout,*) '      jpjglo = ', kpj
+         WRITE(numout,*) '      jpkglo = ', kpk
+         WRITE(numout,*) '      type of global domain lateral boundary   jperio = ', kperio
+      ENDIF
       !        
    END SUBROUTINE domain_cfg
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/dommsk.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/dommsk.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/dommsk.F90	(revision 12143)
@@ -100,14 +100,13 @@
          &             ln_tra_dmp, ln_dyn3d_dmp, rn_time_dmp, rn_time_dmp_out, &
          &             cn_ice, nn_ice_dta,                                     &
-         &             rn_ice_tem, rn_ice_sal, rn_ice_age,                     &
-         &             ln_vol, nn_volctl, nn_rimwidth, nb_jpk_bdy
+         &             ln_vol, nn_volctl, nn_rimwidth
       !!---------------------------------------------------------------------
       !
       REWIND( numnam_ref )              ! Namelist namlbc in reference namelist : Lateral momentum boundary condition
       READ  ( numnam_ref, namlbc, IOSTAT = ios, ERR = 901 )
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlbc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlbc in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namlbc in configuration namelist : Lateral momentum boundary condition
       READ  ( numnam_cfg, namlbc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlbc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlbc in configuration namelist' )
       IF(lwm) WRITE ( numond, namlbc )
       
@@ -151,8 +150,8 @@
       REWIND( numnam_ref )              ! Namelist nambdy in reference namelist :Unstructured open boundaries
       READ  ( numnam_ref, nambdy, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist', lwp )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist nambdy in configuration namelist :Unstructured open boundaries
       READ  ( numnam_cfg, nambdy, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist', lwp )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist' )
       ! ------------------------
       IF ( ln_bdy .AND. ln_mask_file ) THEN
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domvvl.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domvvl.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domvvl.F90	(revision 12143)
@@ -353,6 +353,6 @@
       END DO
       !
-      IF( ln_vvl_ztilde .OR. ln_vvl_layer .AND. ll_do_bclinic ) THEN   ! z_tilde or layer coordinate !
-         !                                                            ! ------baroclinic part------ !
+      IF( (ln_vvl_ztilde .OR. ln_vvl_layer) .AND. ll_do_bclinic ) THEN   ! z_tilde or layer coordinate !
+         !                                                               ! ------baroclinic part------ !
          ! I - initialization
          ! ==================
@@ -1021,8 +1021,8 @@
       REWIND( numnam_ref )              ! Namelist nam_vvl in reference namelist : 
       READ  ( numnam_ref, nam_vvl, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_vvl in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_vvl in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist nam_vvl in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, nam_vvl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist' )
       IF(lwm) WRITE ( numond, nam_vvl )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domwri.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domwri.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/domwri.F90	(revision 12143)
@@ -161,8 +161,14 @@
       CALL iom_rstput( 0, 0, inum, 'misf', zprt, ktype = jp_i4 )       !    ! nb of ocean T-points
       !															             ! vertical mesh
-      CALL iom_rstput( 0, 0, inum, 'e3t_0', e3t_0, ktype = jp_r8  )    !    ! scale factors
-      CALL iom_rstput( 0, 0, inum, 'e3u_0', e3u_0, ktype = jp_r8  )
-      CALL iom_rstput( 0, 0, inum, 'e3v_0', e3v_0, ktype = jp_r8  )
-      CALL iom_rstput( 0, 0, inum, 'e3w_0', e3w_0, ktype = jp_r8  )
+      CALL iom_rstput( 0, 0, inum, 'e3t_1d', e3t_1d, ktype = jp_r8  )    !    ! scale factors
+      CALL iom_rstput( 0, 0, inum, 'e3w_1d', e3w_1d, ktype = jp_r8  )
+      
+      CALL iom_rstput( 0, 0, inum, 'e3t_0' , e3t_0 , ktype = jp_r8  )
+      CALL iom_rstput( 0, 0, inum, 'e3u_0' , e3u_0 , ktype = jp_r8  )
+      CALL iom_rstput( 0, 0, inum, 'e3v_0' , e3v_0 , ktype = jp_r8  )
+      CALL iom_rstput( 0, 0, inum, 'e3f_0' , e3f_0 , ktype = jp_r8  )
+      CALL iom_rstput( 0, 0, inum, 'e3w_0' , e3w_0 , ktype = jp_r8  )
+      CALL iom_rstput( 0, 0, inum, 'e3uw_0', e3uw_0, ktype = jp_r8  )
+      CALL iom_rstput( 0, 0, inum, 'e3vw_0', e3vw_0, ktype = jp_r8  )
       !
       CALL iom_rstput( 0, 0, inum, 'gdept_1d' , gdept_1d , ktype = jp_r8 )  ! stretched system
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/dtatsd.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/dtatsd.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DOM/dtatsd.F90	(revision 12143)
@@ -67,8 +67,8 @@
       REWIND( numnam_ref )              ! Namelist namtsd in reference namelist : 
       READ  ( numnam_ref, namtsd, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtsd in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtsd in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namtsd in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, namtsd, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtsd in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtsd in configuration namelist' )
       IF(lwm) WRITE ( numond, namtsd )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynadv.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynadv.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynadv.F90	(revision 12143)
@@ -106,8 +106,8 @@
       REWIND( numnam_ref )              ! Namelist namdyn_adv in reference namelist : Momentum advection scheme
       READ  ( numnam_ref, namdyn_adv, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_adv in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_adv in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namdyn_adv in configuration namelist : Momentum advection scheme
       READ  ( numnam_cfg, namdyn_adv, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_adv in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_adv in configuration namelist' )
       IF(lwm) WRITE ( numond, namdyn_adv )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynhpg.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynhpg.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynhpg.F90	(revision 12143)
@@ -39,5 +39,5 @@
    USE trd_oce         ! trends: ocean variables
    USE trddyn          ! trend manager: dynamics
-!jc   USE zpshde          ! partial step: hor. derivative     (zps_hde routine)
+   USE zpshde          ! partial step: hor. derivative     (zps_hde routine)
    !
    USE in_out_manager  ! I/O manager
@@ -154,9 +154,9 @@
       REWIND( numnam_ref )              ! Namelist namdyn_hpg in reference namelist : Hydrostatic pressure gradient
       READ  ( numnam_ref, namdyn_hpg, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_hpg in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_hpg in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namdyn_hpg in configuration namelist : Hydrostatic pressure gradient
       READ  ( numnam_cfg, namdyn_hpg, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_hpg in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_hpg in configuration namelist' )
       IF(lwm) WRITE ( numond, namdyn_hpg )
       !
@@ -299,4 +299,5 @@
       REAL(wp) ::   zcoef0, zcoef1, zcoef2, zcoef3   ! temporary scalars
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::  zhpi, zhpj
+      REAL(wp), DIMENSION(jpi,jpj) :: zgtsu, zgtsv, zgru, zgrv
       !!----------------------------------------------------------------------
       !
@@ -307,6 +308,6 @@
       ENDIF
 
-      ! Partial steps: bottom before horizontal gradient of t, s, rd at the last ocean level
-!jc      CALL zps_hde    ( kt, jpts, tsn, gtsu, gtsv, rhd, gru , grv )
+      ! Partial steps: Compute NOW horizontal gradient of t, s, rd at the last ocean level
+      CALL zps_hde( kt, jpts, tsn, zgtsu, zgtsv, rhd, zgru , zgrv )
 
       ! Local constant initialization
@@ -346,5 +347,5 @@
       END DO
 
-      ! partial steps correction at the last level  (use gru & grv computed in zpshde.F90)
+      ! partial steps correction at the last level  (use zgru & zgrv computed in zpshde.F90)
       DO jj = 2, jpjm1
          DO ji = 2, jpim1
@@ -356,5 +357,5 @@
                ua  (ji,jj,iku) = ua(ji,jj,iku) - zhpi(ji,jj,iku)         ! subtract old value
                zhpi(ji,jj,iku) = zhpi(ji,jj,iku-1)                   &   ! compute the new one
-                  &            + zcoef2 * ( rhd(ji+1,jj,iku-1) - rhd(ji,jj,iku-1) + gru(ji,jj) ) * r1_e1u(ji,jj)
+                  &            + zcoef2 * ( rhd(ji+1,jj,iku-1) - rhd(ji,jj,iku-1) + zgru(ji,jj) ) * r1_e1u(ji,jj)
                ua  (ji,jj,iku) = ua(ji,jj,iku) + zhpi(ji,jj,iku)         ! add the new one to the general momentum trend
             ENDIF
@@ -362,5 +363,5 @@
                va  (ji,jj,ikv) = va(ji,jj,ikv) - zhpj(ji,jj,ikv)         ! subtract old value
                zhpj(ji,jj,ikv) = zhpj(ji,jj,ikv-1)                   &   ! compute the new one
-                  &            + zcoef3 * ( rhd(ji,jj+1,ikv-1) - rhd(ji,jj,ikv-1) + grv(ji,jj) ) * r1_e2v(ji,jj)
+                  &            + zcoef3 * ( rhd(ji,jj+1,ikv-1) - rhd(ji,jj,ikv-1) + zgrv(ji,jj) ) * r1_e2v(ji,jj)
                va  (ji,jj,ikv) = va(ji,jj,ikv) + zhpj(ji,jj,ikv)         ! add the new one to the general momentum trend
             ENDIF
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynkeg.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynkeg.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynkeg.F90	(revision 12143)
@@ -74,10 +74,8 @@
       INTEGER, INTENT( in ) ::   kscheme   ! =0/1   type of KEG scheme 
       !
-      INTEGER  ::   ji, jj, jk, jb           ! dummy loop indices
-      INTEGER  ::   ifu, ifv, igrd, ib_bdy   ! local integers
+      INTEGER  ::   ji, jj, jk             ! dummy loop indices
       REAL(wp) ::   zu, zv                   ! local scalars
       REAL(wp), DIMENSION(jpi,jpj,jpk)        ::   zhke
       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrdu, ztrdv 
-      REAL(wp)  :: zweightu, zweightv
       !!----------------------------------------------------------------------
       !
@@ -112,29 +110,4 @@
             END DO
          END DO
-         !
-         IF (ln_bdy) THEN
-            ! Maria Luneva & Fred Wobus: July-2016
-            ! compensate for lack of turbulent kinetic energy on liquid bdy points
-            DO ib_bdy = 1, nb_bdy
-               IF( cn_dyn3d(ib_bdy) /= 'none' ) THEN
-                  igrd = 1           ! compensating null velocity on the bdy
-                  DO jb = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
-                     ji   = idx_bdy(ib_bdy)%nbi(jb,igrd)   ! maximum extent : from 2 to jpi-1
-                     jj   = idx_bdy(ib_bdy)%nbj(jb,igrd)   ! maximum extent : from 2 to jpj-1
-                     DO jk = 1, jpkm1
-                        zhke(ji,jj,jk) = 0._wp
-                        zweightu = umask(ji-1,jj  ,jk) + umask(ji,jj,jk)
-                        zweightv = vmask(ji  ,jj-1,jk) + vmask(ji,jj,jk)
-                        zu = un(ji-1,jj  ,jk) * un(ji-1,jj  ,jk)  +  un(ji  ,jj  ,jk) * un(ji  ,jj  ,jk)
-                        zv = vn(ji  ,jj-1,jk) * vn(ji  ,jj-1,jk)  +  vn(ji  ,jj  ,jk) * vn(ji  ,jj  ,jk)
-                        IF( zweightu > 0._wp )   zhke(ji,jj,jk) =  zhke(ji,jj,jk) + zu / (2._wp * zweightu) 
-                        IF( zweightv > 0._wp )   zhke(ji,jj,jk) =  zhke(ji,jj,jk) + zv / (2._wp * zweightv) 
-                     END DO
-                  END DO
-               END IF
-               CALL lbc_bdy_lnk( 'dynkeg', zhke, 'T', 1., ib_bdy )   ! send 2 and recv jpi, jpj used in the computation of the speed tendencies
-            END DO
-         END IF
-         !
       CASE ( nkeg_HW )                          !--  Hollingsworth scheme  --!
          DO jk = 1, jpkm1
@@ -154,34 +127,4 @@
             END DO
          END DO
-         IF (ln_bdy) THEN
-            ! Maria Luneva & Fred Wobus: July-2016
-            ! compensate for lack of turbulent kinetic energy on liquid bdy points
-            DO ib_bdy = 1, nb_bdy
-               IF( cn_dyn3d(ib_bdy) /= 'none' ) THEN
-                  igrd = 1           ! compensation null velocity on land at the bdy
-                  DO jb = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
-                     ji   = idx_bdy(ib_bdy)%nbi(jb,igrd)   ! maximum extent : from 2 to jpi-1
-                     jj   = idx_bdy(ib_bdy)%nbj(jb,igrd)   ! maximum extent : from 2 to jpj-1
-                     DO jk = 1, jpkm1
-                        zhke(ji,jj,jk) = 0._wp
-                        zweightu = 8._wp * ( umask(ji-1,jj  ,jk) + umask(ji  ,jj  ,jk) ) &
-                             &   + 2._wp * ( umask(ji-1,jj-1,jk) + umask(ji-1,jj+1,jk) + umask(ji  ,jj-1,jk) + umask(ji  ,jj+1,jk) ) 
-                        zweightv = 8._wp * ( vmask(ji  ,jj-1,jk) + vmask(ji  ,jj-1,jk) ) &
-                             &   + 2._wp * ( vmask(ji-1,jj-1,jk) + vmask(ji+1,jj-1,jk) + vmask(ji-1,jj  ,jk) + vmask(ji+1,jj  ,jk) )
-                        zu = 8._wp * ( un(ji-1,jj  ,jk) * un(ji-1,jj  ,jk)    &
-                           &         + un(ji  ,jj  ,jk) * un(ji  ,jj  ,jk) )  &
-                           &   +     ( un(ji-1,jj-1,jk) + un(ji-1,jj+1,jk) ) * ( un(ji-1,jj-1,jk) + un(ji-1,jj+1,jk) )   &
-                           &   +     ( un(ji  ,jj-1,jk) + un(ji  ,jj+1,jk) ) * ( un(ji  ,jj-1,jk) + un(ji  ,jj+1,jk) )
-                        zv = 8._wp * ( vn(ji  ,jj-1,jk) * vn(ji  ,jj-1,jk)    &
-                           &         + vn(ji  ,jj  ,jk) * vn(ji  ,jj  ,jk) )  &
-                           &  +      ( vn(ji-1,jj-1,jk) + vn(ji+1,jj-1,jk) ) * ( vn(ji-1,jj-1,jk) + vn(ji+1,jj-1,jk) )   &
-                           &  +      ( vn(ji-1,jj  ,jk) + vn(ji+1,jj  ,jk) ) * ( vn(ji-1,jj  ,jk) + vn(ji+1,jj  ,jk) )
-                        IF( zweightu > 0._wp )   zhke(ji,jj,jk) =  zhke(ji,jj,jk) +  zu / ( 2._wp * zweightu )
-                        IF( zweightv > 0._wp )   zhke(ji,jj,jk) =  zhke(ji,jj,jk) +  zv / ( 2._wp * zweightv )
-                     END DO
-                  END DO
-               END IF
-            END DO
-         END IF
          CALL lbc_lnk( 'dynkeg', zhke, 'T', 1. )
          !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynnxt.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynnxt.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynnxt.F90	(revision 12143)
@@ -176,4 +176,6 @@
       IF( neuler == 0 .AND. kt == nit000 ) THEN        !* Euler at first time-step: only swap
          DO jk = 1, jpkm1
+            ub(:,:,jk) = un(:,:,jk)                         ! ub <-- un
+            vb(:,:,jk) = vn(:,:,jk)
             un(:,:,jk) = ua(:,:,jk)                         ! un <-- ua
             vn(:,:,jk) = va(:,:,jk)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynspg.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynspg.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynspg.F90	(revision 12143)
@@ -202,9 +202,9 @@
       REWIND( numnam_ref )              ! Namelist namdyn_spg in reference namelist : Free surface
       READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namdyn_spg in configuration namelist : Free surface
       READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist' )
       IF(lwm) WRITE ( numond, namdyn_spg )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynspg_ts.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynspg_ts.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynspg_ts.F90	(revision 12143)
@@ -64,4 +64,6 @@
    USE diatmb          ! Top,middle,bottom output
 
+   USE iom   ! to remove
+
    IMPLICIT NONE
    PRIVATE
@@ -104,8 +106,6 @@
       !
       ALLOCATE( wgtbtp1(3*nn_baro), wgtbtp2(3*nn_baro), zwz(jpi,jpj), STAT=ierr(1) )
-      !
       IF( ln_dynvor_een .OR. ln_dynvor_eeT )   &
-         &     ALLOCATE( ftnw(jpi,jpj) , ftne(jpi,jpj) , & 
-         &               ftsw(jpi,jpj) , ftse(jpi,jpj) , STAT=ierr(2) )
+         &     ALLOCATE( ftnw(jpi,jpj) , ftne(jpi,jpj) , ftsw(jpi,jpj) , ftse(jpi,jpj), STAT=ierr(2)   )
          !
       ALLOCATE( un_adv(jpi,jpj), vn_adv(jpi,jpj)                    , STAT=ierr(3) )
@@ -149,18 +149,16 @@
       LOGICAL  ::   ll_fw_start           ! =T : forward integration 
       LOGICAL  ::   ll_init               ! =T : special startup of 2d equations
-      LOGICAL  ::   ll_tmp1, ll_tmp2      ! local logical variables used in W/D
-      INTEGER  ::   ikbu, iktu, noffset   ! local integers
-      INTEGER  ::   ikbv, iktv            !   -      -
-      REAL(wp) ::   r1_2dt_b, z2dt_bf               ! local scalars
-      REAL(wp) ::   zx1, zx2, zu_spg, zhura, z1_hu  !   -      -
-      REAL(wp) ::   zy1, zy2, zv_spg, zhvra, z1_hv  !   -      -
+      INTEGER  ::   noffset               ! local integers  : time offset for bdy update
+      REAL(wp) ::   r1_2dt_b, z1_hu, z1_hv          ! local scalars
       REAL(wp) ::   za0, za1, za2, za3              !   -      -
-      REAL(wp) ::   zmdi, zztmp            , z1_ht  !   -      -
-      REAL(wp), DIMENSION(jpi,jpj) :: zsshp2_e, zhf
-      REAL(wp), DIMENSION(jpi,jpj) :: zwx, zu_trd, zu_frc, zssh_frc
-      REAL(wp), DIMENSION(jpi,jpj) :: zwy, zv_trd, zv_frc, zhdiv
-      REAL(wp), DIMENSION(jpi,jpj) :: zsshu_a, zhup2_e, zhust_e, zhtp2_e
-      REAL(wp), DIMENSION(jpi,jpj) :: zsshv_a, zhvp2_e, zhvst_e
+      REAL(wp) ::   zmdi, zztmp, zldg               !   -      -
+      REAL(wp) ::   zhu_bck, zhv_bck, zhdiv         !   -      -
+      REAL(wp) ::   zun_save, zvn_save              !   -      -
+      REAL(wp), DIMENSION(jpi,jpj) :: zu_trd, zu_frc, zu_spg, zssh_frc
+      REAL(wp), DIMENSION(jpi,jpj) :: zv_trd, zv_frc, zv_spg
+      REAL(wp), DIMENSION(jpi,jpj) :: zsshu_a, zhup2_e, zhtp2_e
+      REAL(wp), DIMENSION(jpi,jpj) :: zsshv_a, zhvp2_e, zsshp2_e
       REAL(wp), DIMENSION(jpi,jpj) :: zCdU_u, zCdU_v   ! top/bottom stress at u- & v-points
+      REAL(wp), DIMENSION(jpi,jpj) :: zhU, zhV         ! fluxes
       !
       REAL(wp) ::   zwdramp                     ! local scalar - only used if ln_wd_dl = .True. 
@@ -182,9 +180,8 @@
       zwdramp = r_rn_wdmin1               ! simplest ramp 
 !     zwdramp = 1._wp / (rn_wdmin2 - rn_wdmin1) ! more general ramp
-      !                                         ! reciprocal of baroclinic time step 
-      IF( kt == nit000 .AND. neuler == 0 ) THEN   ;   z2dt_bf =          rdt
-      ELSE                                        ;   z2dt_bf = 2.0_wp * rdt
-      ENDIF
-      r1_2dt_b = 1.0_wp / z2dt_bf 
+      !                                         ! inverse of baroclinic time step 
+      IF( kt == nit000 .AND. neuler == 0 ) THEN   ;   r1_2dt_b = 1._wp / (         rdt )
+      ELSE                                        ;   r1_2dt_b = 1._wp / ( 2._wp * rdt )
+      ENDIF
       !
       ll_init     = ln_bt_av                    ! if no time averaging, then no specific restart 
@@ -210,134 +207,7 @@
             ll_fw_start =.FALSE.
          ENDIF
-         !
-         ! Set averaging weights and cycle length:
+         !                    ! Set averaging weights and cycle length:
          CALL ts_wgt( ln_bt_av, ll_fw_start, icycle, wgtbtp1, wgtbtp2 )
          !
-      ENDIF
-      !
-      IF( ln_isfcav ) THEN    ! top+bottom friction (ocean cavities)
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zCdU_u(ji,jj) = r1_2*( rCdU_bot(ji+1,jj)+rCdU_bot(ji,jj) + rCdU_top(ji+1,jj)+rCdU_top(ji,jj) )
-               zCdU_v(ji,jj) = r1_2*( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj) + rCdU_top(ji,jj+1)+rCdU_top(ji,jj) )
-            END DO
-         END DO
-      ELSE                    ! bottom friction only
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zCdU_u(ji,jj) = r1_2*( rCdU_bot(ji+1,jj)+rCdU_bot(ji,jj) )
-               zCdU_v(ji,jj) = r1_2*( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj) )
-            END DO
-         END DO
-      ENDIF
-      !
-      ! Set arrays to remove/compute coriolis trend.
-      ! Do it once at kt=nit000 if volume is fixed, else at each long time step.
-      ! Note that these arrays are also used during barotropic loop. These are however frozen
-      ! although they should be updated in the variable volume case. Not a big approximation.
-      ! To remove this approximation, copy lines below inside barotropic loop
-      ! and update depths at T-F points (ht and zhf resp.) at each barotropic time step
-      !
-      IF( kt == nit000 .OR. .NOT.ln_linssh ) THEN
-         !
-         SELECT CASE( nvor_scheme )
-         CASE( np_EEN )                != EEN scheme using e3f (energy & enstrophy scheme)
-            SELECT CASE( nn_een_e3f )              !* ff_f/e3 at F-point
-            CASE ( 0 )                                   ! original formulation  (masked averaging of e3t divided by 4)
-               DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
-                     zwz(ji,jj) =   ( ht_n(ji  ,jj+1) + ht_n(ji+1,jj+1) +                    &
-                        &             ht_n(ji  ,jj  ) + ht_n(ji+1,jj  )   ) * 0.25_wp  
-                     IF( zwz(ji,jj) /= 0._wp )   zwz(ji,jj) = ff_f(ji,jj) / zwz(ji,jj)
-                  END DO
-               END DO
-            CASE ( 1 )                                   ! new formulation  (masked averaging of e3t divided by the sum of mask)
-               DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
-                     zwz(ji,jj) =             (  ht_n  (ji  ,jj+1) + ht_n  (ji+1,jj+1)      &
-                        &                      + ht_n  (ji  ,jj  ) + ht_n  (ji+1,jj  )  )   &
-                        &       / ( MAX( 1._wp,  ssmask(ji  ,jj+1) + ssmask(ji+1,jj+1)      &
-                        &                      + ssmask(ji  ,jj  ) + ssmask(ji+1,jj  )  )   )
-                     IF( zwz(ji,jj) /= 0._wp )   zwz(ji,jj) = ff_f(ji,jj) / zwz(ji,jj)
-                  END DO
-               END DO
-            END SELECT
-            CALL lbc_lnk( 'dynspg_ts', zwz, 'F', 1._wp )
-            !
-            ftne(1,:) = 0._wp ; ftnw(1,:) = 0._wp ; ftse(1,:) = 0._wp ; ftsw(1,:) = 0._wp
-            DO jj = 2, jpj
-               DO ji = 2, jpi
-                  ftne(ji,jj) = zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1)
-                  ftnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  )
-                  ftse(ji,jj) = zwz(ji  ,jj  ) + zwz(ji  ,jj-1) + zwz(ji-1,jj-1)
-                  ftsw(ji,jj) = zwz(ji  ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj  )
-               END DO
-            END DO
-            !
-         CASE( np_EET )                  != EEN scheme using e3t (energy conserving scheme)
-            ftne(1,:) = 0._wp ; ftnw(1,:) = 0._wp ; ftse(1,:) = 0._wp ; ftsw(1,:) = 0._wp
-            DO jj = 2, jpj
-               DO ji = 2, jpi
-                  z1_ht = ssmask(ji,jj) / ( ht_n(ji,jj) + 1._wp - ssmask(ji,jj) )
-                  ftne(ji,jj) = ( ff_f(ji-1,jj  ) + ff_f(ji  ,jj  ) + ff_f(ji  ,jj-1) ) * z1_ht
-                  ftnw(ji,jj) = ( ff_f(ji-1,jj-1) + ff_f(ji-1,jj  ) + ff_f(ji  ,jj  ) ) * z1_ht
-                  ftse(ji,jj) = ( ff_f(ji  ,jj  ) + ff_f(ji  ,jj-1) + ff_f(ji-1,jj-1) ) * z1_ht
-                  ftsw(ji,jj) = ( ff_f(ji  ,jj-1) + ff_f(ji-1,jj-1) + ff_f(ji-1,jj  ) ) * z1_ht
-               END DO
-            END DO
-            !
-         CASE( np_ENE, np_ENS , np_MIX )  != all other schemes (ENE, ENS, MIX) except ENT !
-            !
-            zwz(:,:) = 0._wp
-            zhf(:,:) = 0._wp
-            
-!!gm  assume 0 in both cases (which is almost surely WRONG ! ) as hvatf has been removed 
-!!gm    A priori a better value should be something like :
-!!gm          zhf(i,j) = masked sum of  ht(i,j) , ht(i+1,j) , ht(i,j+1) , (i+1,j+1) 
-!!gm                     divided by the sum of the corresponding mask 
-!!gm 
-!!            
-            IF( .NOT.ln_sco ) THEN
-  
-   !!gm  agree the JC comment  : this should be done in a much clear way
-  
-   ! JC: It not clear yet what should be the depth at f-points over land in z-coordinate case
-   !     Set it to zero for the time being 
-   !              IF( rn_hmin < 0._wp ) THEN    ;   jk = - INT( rn_hmin )                                      ! from a nb of level
-   !              ELSE                          ;   jk = MINLOC( gdepw_0, mask = gdepw_0 > rn_hmin, dim = 1 )  ! from a depth
-   !              ENDIF
-   !              zhf(:,:) = gdepw_0(:,:,jk+1)
-               !
-            ELSE
-               !
-               !zhf(:,:) = hbatf(:,:)
-               DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
-                     zhf(ji,jj) =    (   ht_0  (ji,jj  ) + ht_0  (ji+1,jj  )          &
-                        &              + ht_0  (ji,jj+1) + ht_0  (ji+1,jj+1)   )      &
-                        &       / MAX(   ssmask(ji,jj  ) + ssmask(ji+1,jj  )          &
-                        &              + ssmask(ji,jj+1) + ssmask(ji+1,jj+1) , 1._wp  )
-                  END DO
-               END DO
-            ENDIF
-            !
-            DO jj = 1, jpjm1
-               zhf(:,jj) = zhf(:,jj) * (1._wp- umask(:,jj,1) * umask(:,jj+1,1))
-            END DO
-            !
-            DO jk = 1, jpkm1
-               DO jj = 1, jpjm1
-                  zhf(:,jj) = zhf(:,jj) + e3f_n(:,jj,jk) * umask(:,jj,jk) * umask(:,jj+1,jk)
-               END DO
-            END DO
-            CALL lbc_lnk( 'dynspg_ts', zhf, 'F', 1._wp )
-            ! JC: TBC. hf should be greater than 0 
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  IF( zhf(ji,jj) /= 0._wp )   zwz(ji,jj) = 1._wp / zhf(ji,jj) ! zhf is actually hf here but it saves an array
-               END DO
-            END DO
-            zwz(:,:) = ff_f(:,:) * zwz(:,:)
-         END SELECT
       ENDIF
       !
@@ -348,4 +218,5 @@
          CALL ts_wgt( ln_bt_av, ll_fw_start, icycle, wgtbtp1, wgtbtp2 )
       ENDIF
+      !
                           
       ! -----------------------------------------------------------------------------
@@ -354,26 +225,14 @@
       !      
       !
-      !                                   !* e3*d/dt(Ua) (Vertically integrated)
-      !                                   ! --------------------------------------------------
-      zu_frc(:,:) = 0._wp
-      zv_frc(:,:) = 0._wp
-      !
-      DO jk = 1, jpkm1
-         zu_frc(:,:) = zu_frc(:,:) + e3u_n(:,:,jk) * ua(:,:,jk) * umask(:,:,jk)
-         zv_frc(:,:) = zv_frc(:,:) + e3v_n(:,:,jk) * va(:,:,jk) * vmask(:,:,jk)         
-      END DO
-      !
-      zu_frc(:,:) = zu_frc(:,:) * r1_hu_n(:,:)
-      zv_frc(:,:) = zv_frc(:,:) * r1_hv_n(:,:)
-      !
-      !
-      !                                   !* baroclinic momentum trend (remove the vertical mean trend)
-      DO jk = 1, jpkm1                    ! -----------------------------------------------------------
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               ua(ji,jj,jk) = ua(ji,jj,jk) - zu_frc(ji,jj) * umask(ji,jj,jk)
-               va(ji,jj,jk) = va(ji,jj,jk) - zv_frc(ji,jj) * vmask(ji,jj,jk)
-            END DO
-         END DO
+      !                                   !=  zu_frc =  1/H e3*d/dt(Ua)  =!  (Vertical mean of Ua, the 3D trends)
+      !                                   !  ---------------------------  !
+      zu_frc(:,:) = SUM( e3u_n(:,:,:) * ua(:,:,:) * umask(:,:,:) , DIM=3 ) * r1_hu_n(:,:)
+      zv_frc(:,:) = SUM( e3v_n(:,:,:) * va(:,:,:) * vmask(:,:,:) , DIM=3 ) * r1_hv_n(:,:)
+      !
+      !
+      !                                   !=  Ua => baroclinic trend  =!   (remove its vertical mean)
+      DO jk = 1, jpkm1                    !  ------------------------  !
+         ua(:,:,jk) = ( ua(:,:,jk) - zu_frc(:,:) ) * umask(:,:,jk)
+         va(:,:,jk) = ( va(:,:,jk) - zv_frc(:,:) ) * vmask(:,:,jk)
       END DO
       
@@ -381,113 +240,23 @@
 !!gm  Is it correct to do so ?   I think so...
       
-      !
-      !                                   !* barotropic Coriolis trends (vorticity scheme dependent)
-      !                                   ! --------------------------------------------------------
-      !
-      zwx(:,:) = un_b(:,:) * hu_n(:,:) * e2u(:,:)        ! now fluxes 
-      zwy(:,:) = vn_b(:,:) * hv_n(:,:) * e1v(:,:)
-      !
-      SELECT CASE( nvor_scheme )
-      CASE( np_ENT )                ! enstrophy conserving scheme (f-point)
-         DO jj = 2, jpjm1
-            DO ji = 2, jpim1   ! vector opt.
-               zu_trd(ji,jj) = + r1_4 * r1_e1e2u(ji,jj) * r1_hu_n(ji,jj)                    &
-                  &               * (  e1e2t(ji+1,jj)*ht_n(ji+1,jj)*ff_t(ji+1,jj) * ( vn_b(ji+1,jj) + vn_b(ji+1,jj-1) )   &
-                  &                  + e1e2t(ji  ,jj)*ht_n(ji  ,jj)*ff_t(ji  ,jj) * ( vn_b(ji  ,jj) + vn_b(ji  ,jj-1) )   )
-                  !
-               zv_trd(ji,jj) = - r1_4 * r1_e1e2v(ji,jj) * r1_hv_n(ji,jj)                    &
-                  &               * (  e1e2t(ji,jj+1)*ht_n(ji,jj+1)*ff_t(ji,jj+1) * ( un_b(ji,jj+1) + un_b(ji-1,jj+1) )   & 
-                  &                  + e1e2t(ji,jj  )*ht_n(ji,jj  )*ff_t(ji,jj  ) * ( un_b(ji,jj  ) + un_b(ji-1,jj  ) )   ) 
-            END DO  
-         END DO  
-         !         
-      CASE( np_ENE , np_MIX )        ! energy conserving scheme (t-point) ENE or MIX
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zy1 = ( zwy(ji,jj-1) + zwy(ji+1,jj-1) ) * r1_e1u(ji,jj)
-               zy2 = ( zwy(ji,jj  ) + zwy(ji+1,jj  ) ) * r1_e1u(ji,jj)
-               zx1 = ( zwx(ji-1,jj) + zwx(ji-1,jj+1) ) * r1_e2v(ji,jj)
-               zx2 = ( zwx(ji  ,jj) + zwx(ji  ,jj+1) ) * r1_e2v(ji,jj)
-               ! energy conserving formulation for planetary vorticity term
-               zu_trd(ji,jj) =   r1_4 * ( zwz(ji  ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
-               zv_trd(ji,jj) = - r1_4 * ( zwz(ji-1,jj  ) * zx1 + zwz(ji,jj) * zx2 )
-            END DO
-         END DO
-         !
-      CASE( np_ENS )                ! enstrophy conserving scheme (f-point)
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zy1 =   r1_8 * ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1) &
-                 &            + zwy(ji  ,jj  ) + zwy(ji+1,jj  ) ) * r1_e1u(ji,jj)
-               zx1 = - r1_8 * ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1) &
-                 &            + zwx(ji  ,jj  ) + zwx(ji  ,jj+1) ) * r1_e2v(ji,jj)
-               zu_trd(ji,jj)  = zy1 * ( zwz(ji  ,jj-1) + zwz(ji,jj) )
-               zv_trd(ji,jj)  = zx1 * ( zwz(ji-1,jj  ) + zwz(ji,jj) )
-            END DO
-         END DO
-         !
-      CASE( np_EET , np_EEN )      ! energy & enstrophy scheme (using e3t or e3f)         
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zu_trd(ji,jj) = + r1_12 * r1_e1u(ji,jj) * (  ftne(ji,jj  ) * zwy(ji  ,jj  ) &
-                &                                         + ftnw(ji+1,jj) * zwy(ji+1,jj  ) &
-                &                                         + ftse(ji,jj  ) * zwy(ji  ,jj-1) &
-                &                                         + ftsw(ji+1,jj) * zwy(ji+1,jj-1) )
-               zv_trd(ji,jj) = - r1_12 * r1_e2v(ji,jj) * (  ftsw(ji,jj+1) * zwx(ji-1,jj+1) &
-                &                                         + ftse(ji,jj+1) * zwx(ji  ,jj+1) &
-                &                                         + ftnw(ji,jj  ) * zwx(ji-1,jj  ) &
-                &                                         + ftne(ji,jj  ) * zwx(ji  ,jj  ) )
-            END DO
-         END DO
-         !
-      END SELECT
-      !
-      !                                   !* Right-Hand-Side of the barotropic momentum equation
-      !                                   ! ----------------------------------------------------
-      IF( .NOT.ln_linssh ) THEN                 ! Variable volume : remove surface pressure gradient
-         IF( ln_wd_il ) THEN                        ! Calculating and applying W/D gravity filters
+      !                                   !=  remove 2D Coriolis and pressure gradient trends  =!
+      !                                   !  -------------------------------------------------  !
+      !
+      IF( kt == nit000 .OR. .NOT. ln_linssh )   CALL dyn_cor_2D_init   ! Set zwz, the barotropic Coriolis force coefficient
+      !       ! recompute zwz = f/depth  at every time step for (.NOT.ln_linssh) as the water colomn height changes
+      !
+      !                                         !* 2D Coriolis trends
+      zhU(:,:) = un_b(:,:) * hu_n(:,:) * e2u(:,:)        ! now fluxes 
+      zhV(:,:) = vn_b(:,:) * hv_n(:,:) * e1v(:,:)        ! NB: FULL domain : put a value in last row and column
+      !
+      CALL dyn_cor_2d( hu_n, hv_n, un_b, vn_b, zhU, zhV,  &   ! <<== in
+         &                               zu_trd, zv_trd   )   ! ==>> out
+      !
+      IF( .NOT.ln_linssh ) THEN                 !* surface pressure gradient   (variable volume only)
+         !
+         IF( ln_wd_il ) THEN                       ! W/D : limiter applied to spgspg
+            CALL wad_spg( sshn, zcpx, zcpy )          ! Calculating W/D gravity filters, zcpx and zcpy
             DO jj = 2, jpjm1
-               DO ji = 2, jpim1 
-                  ll_tmp1 = MIN(  sshn(ji,jj)               ,  sshn(ji+1,jj) ) >                &
-                     &      MAX( -ht_0(ji,jj)               , -ht_0(ji+1,jj) ) .AND.            &
-                     &      MAX(  sshn(ji,jj) + ht_0(ji,jj) ,  sshn(ji+1,jj) + ht_0(ji+1,jj) )  &
-                     &                                                         > rn_wdmin1 + rn_wdmin2
-                  ll_tmp2 = ( ABS( sshn(ji+1,jj)            -  sshn(ji  ,jj))  > 1.E-12 ).AND.( &
-                     &      MAX(   sshn(ji,jj)              ,  sshn(ji+1,jj) ) >                &
-                     &      MAX(  -ht_0(ji,jj)              , -ht_0(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2 )
-                  IF(ll_tmp1) THEN
-                     zcpx(ji,jj) = 1.0_wp
-                  ELSEIF(ll_tmp2) THEN
-                     ! no worries about  sshn(ji+1,jj) -  sshn(ji  ,jj) = 0, it won't happen ! here
-                     zcpx(ji,jj) = ABS( (sshn(ji+1,jj) + ht_0(ji+1,jj) - sshn(ji,jj) - ht_0(ji,jj)) &
-                                 &    / (sshn(ji+1,jj) - sshn(ji  ,jj)) )
-                     zcpx(ji,jj) = max(min( zcpx(ji,jj) , 1.0_wp),0.0_wp)
-                  ELSE
-                     zcpx(ji,jj) = 0._wp
-                  ENDIF
-                  !
-                  ll_tmp1 = MIN(  sshn(ji,jj)               ,  sshn(ji,jj+1) ) >                &
-                     &      MAX( -ht_0(ji,jj)               , -ht_0(ji,jj+1) ) .AND.            &
-                     &      MAX(  sshn(ji,jj) + ht_0(ji,jj) ,  sshn(ji,jj+1) + ht_0(ji,jj+1) )  &
-                     &                                                       > rn_wdmin1 + rn_wdmin2
-                  ll_tmp2 = ( ABS( sshn(ji,jj)              -  sshn(ji,jj+1))  > 1.E-12 ).AND.( &
-                     &      MAX(   sshn(ji,jj)              ,  sshn(ji,jj+1) ) >                &
-                     &      MAX(  -ht_0(ji,jj)              , -ht_0(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2 )
-  
-                  IF(ll_tmp1) THEN
-                     zcpy(ji,jj) = 1.0_wp
-                  ELSE IF(ll_tmp2) THEN
-                     ! no worries about  sshn(ji,jj+1) -  sshn(ji,jj  ) = 0, it won't happen ! here
-                     zcpy(ji,jj) = ABS( (sshn(ji,jj+1) + ht_0(ji,jj+1) - sshn(ji,jj) - ht_0(ji,jj)) &
-                        &             / (sshn(ji,jj+1) - sshn(ji,jj  )) )
-                     zcpy(ji,jj) = MAX(  0._wp , MIN( zcpy(ji,jj) , 1.0_wp )  )
-                  ELSE
-                     zcpy(ji,jj) = 0._wp
-                  ENDIF
-               END DO
-            END DO
-            !
-            DO jj = 2, jpjm1
-               DO ji = 2, jpim1
+               DO ji = 2, jpim1                ! SPG with the application of W/D gravity filters
                   zu_trd(ji,jj) = zu_trd(ji,jj) - grav * ( sshn(ji+1,jj  ) - sshn(ji  ,jj ) )   &
                      &                          * r1_e1u(ji,jj) * zcpx(ji,jj)  * wdrampu(ji,jj)  !jth
@@ -496,7 +265,5 @@
                END DO
             END DO
-            !
-         ELSE
-            !
+         ELSE                                      ! now suface pressure gradient
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -516,75 +283,33 @@
       END DO 
       !
-      !                                         ! Add bottom stress contribution from baroclinic velocities:      
-      IF (ln_bt_fw) THEN
-         DO jj = 2, jpjm1                          
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               ikbu = mbku(ji,jj)       
-               ikbv = mbkv(ji,jj)    
-               zwx(ji,jj) = un(ji,jj,ikbu) - un_b(ji,jj) ! NOW bottom baroclinic velocities
-               zwy(ji,jj) = vn(ji,jj,ikbv) - vn_b(ji,jj)
-            END DO
-         END DO
-      ELSE
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               ikbu = mbku(ji,jj)       
-               ikbv = mbkv(ji,jj)    
-               zwx(ji,jj) = ub(ji,jj,ikbu) - ub_b(ji,jj) ! BEFORE bottom baroclinic velocities
-               zwy(ji,jj) = vb(ji,jj,ikbv) - vb_b(ji,jj)
-            END DO
-         END DO
-      ENDIF
-      !
-      ! Note that the "unclipped" bottom friction parameter is used even with explicit drag
-      IF( ln_wd_il ) THEN
-         zztmp = -1._wp / rdtbt
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zu_frc(ji,jj) = zu_frc(ji,jj) + & 
-               & MAX(r1_hu_n(ji,jj) * r1_2 * ( rCdU_bot(ji+1,jj)+rCdU_bot(ji,jj) ), zztmp ) * zwx(ji,jj) *  wdrampu(ji,jj)
-               zv_frc(ji,jj) = zv_frc(ji,jj) + & 
-               & MAX(r1_hv_n(ji,jj) * r1_2 * ( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj) ), zztmp ) * zwy(ji,jj) *  wdrampv(ji,jj)
-            END DO
-         END DO
-      ELSE
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zu_frc(ji,jj) = zu_frc(ji,jj) + r1_hu_n(ji,jj) * r1_2 * ( rCdU_bot(ji+1,jj)+rCdU_bot(ji,jj) ) * zwx(ji,jj)
-               zv_frc(ji,jj) = zv_frc(ji,jj) + r1_hv_n(ji,jj) * r1_2 * ( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj) ) * zwy(ji,jj)
-            END DO
-         END DO
-      END IF
-      !
-      IF( ln_isfcav ) THEN       ! Add TOP stress contribution from baroclinic velocities:      
-         IF( ln_bt_fw ) THEN
-            DO jj = 2, jpjm1
+      !                                   !=  Add bottom stress contribution from baroclinic velocities  =!
+      !                                   !  -----------------------------------------------------------  !
+      CALL dyn_drg_init( zu_frc, zv_frc,  zCdU_u, zCdU_v )      ! also provide the barotropic drag coefficients
+      !
+      !                                   !=  Add atmospheric pressure forcing  =!
+      !                                   !  ----------------------------------  !
+      IF( ln_apr_dyn ) THEN
+         IF( ln_bt_fw ) THEN                          ! FORWARD integration: use kt+1/2 pressure (NOW+1/2)
+            DO jj = 2, jpjm1              
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  iktu = miku(ji,jj)
-                  iktv = mikv(ji,jj)
-                  zwx(ji,jj) = un(ji,jj,iktu) - un_b(ji,jj) ! NOW top baroclinic velocities
-                  zwy(ji,jj) = vn(ji,jj,iktv) - vn_b(ji,jj)
-               END DO
-            END DO
-         ELSE
-            DO jj = 2, jpjm1
+                  zu_frc(ji,jj) = zu_frc(ji,jj) + grav * (  ssh_ib (ji+1,jj  ) - ssh_ib (ji,jj) ) * r1_e1u(ji,jj)
+                  zv_frc(ji,jj) = zv_frc(ji,jj) + grav * (  ssh_ib (ji  ,jj+1) - ssh_ib (ji,jj) ) * r1_e2v(ji,jj)
+               END DO
+            END DO
+         ELSE                                         ! CENTRED integration: use kt-1/2 + kt+1/2 pressure (NOW)
+            zztmp = grav * r1_2
+            DO jj = 2, jpjm1              
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  iktu = miku(ji,jj)
-                  iktv = mikv(ji,jj)
-                  zwx(ji,jj) = ub(ji,jj,iktu) - ub_b(ji,jj) ! BEFORE top baroclinic velocities
-                  zwy(ji,jj) = vb(ji,jj,iktv) - vb_b(ji,jj)
-               END DO
-            END DO
-         ENDIF
-         !
-         ! Note that the "unclipped" top friction parameter is used even with explicit drag
-         DO jj = 2, jpjm1              
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zu_frc(ji,jj) = zu_frc(ji,jj) + r1_hu_n(ji,jj) * r1_2 * ( rCdU_top(ji+1,jj)+rCdU_top(ji,jj) ) * zwx(ji,jj)
-               zv_frc(ji,jj) = zv_frc(ji,jj) + r1_hv_n(ji,jj) * r1_2 * ( rCdU_top(ji,jj+1)+rCdU_top(ji,jj) ) * zwy(ji,jj)
-            END DO
-         END DO
-      ENDIF
-      !       
+                  zu_frc(ji,jj) = zu_frc(ji,jj) + zztmp * (  ssh_ib (ji+1,jj  ) - ssh_ib (ji,jj)  &
+                       &                                   + ssh_ibb(ji+1,jj  ) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
+                  zv_frc(ji,jj) = zv_frc(ji,jj) + zztmp * (  ssh_ib (ji  ,jj+1) - ssh_ib (ji,jj)  &
+                       &                                   + ssh_ibb(ji  ,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
+               END DO
+            END DO
+         ENDIF 
+      ENDIF
+      !
+      !                                   !=  Add atmospheric pressure forcing  =!
+      !                                   !  ----------------------------------  !
       IF( ln_bt_fw ) THEN                        ! Add wind forcing
          DO jj = 2, jpjm1
@@ -604,34 +329,12 @@
       ENDIF  
       !
-      IF( ln_apr_dyn ) THEN                     ! Add atm pressure forcing
-         IF( ln_bt_fw ) THEN
-            DO jj = 2, jpjm1              
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zu_spg =  grav * (  ssh_ib (ji+1,jj  ) - ssh_ib (ji,jj) ) * r1_e1u(ji,jj)
-                  zv_spg =  grav * (  ssh_ib (ji  ,jj+1) - ssh_ib (ji,jj) ) * r1_e2v(ji,jj)
-                  zu_frc(ji,jj) = zu_frc(ji,jj) + zu_spg
-                  zv_frc(ji,jj) = zv_frc(ji,jj) + zv_spg
-               END DO
-            END DO
-         ELSE
-            zztmp = grav * r1_2
-            DO jj = 2, jpjm1              
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zu_spg = zztmp * (  ssh_ib (ji+1,jj  ) - ssh_ib (ji,jj)    &
-                      &             + ssh_ibb(ji+1,jj  ) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
-                  zv_spg = zztmp * (  ssh_ib (ji  ,jj+1) - ssh_ib (ji,jj)    &
-                      &             + ssh_ibb(ji  ,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
-                  zu_frc(ji,jj) = zu_frc(ji,jj) + zu_spg
-                  zv_frc(ji,jj) = zv_frc(ji,jj) + zv_spg
-               END DO
-            END DO
-         ENDIF 
-      ENDIF
-      !                                   !* Right-Hand-Side of the barotropic ssh equation
-      !                                   ! -----------------------------------------------
-      !                                         ! Surface net water flux, rivers and ice shelves
-      IF (ln_bt_fw) THEN
+      !              !----------------!
+      !              !==  sssh_frc  ==!   Right-Hand-Side of the barotropic ssh equation   (over the FULL domain)
+      !              !----------------!
+      !                                   !=  Net water flux forcing applied to a water column  =!
+      !                                   ! ---------------------------------------------------  !
+      IF (ln_bt_fw) THEN                          ! FORWARD integration: use kt+1/2 fluxes (NOW+1/2)
          zssh_frc(:,:) = r1_rau0 * ( emp(:,:) - rnf(:,:) + fwfisf_cav(:,:) + fwfisf_par(:,:) )
-      ELSE
+      ELSE                                        ! CENTRED integration: use kt-1/2 + kt+1/2 fluxes (NOW)
          zztmp = r1_rau0 * r1_2
          zssh_frc(:,:) = zztmp * (  emp(:,:)        + emp_b(:,:)                    &
@@ -640,6 +343,6 @@
                 &                 + fwfisf_par(:,:) + fwfisf_par_b(:,:)             )
       ENDIF
-      !
-      IF( ln_sdw ) THEN                         ! Stokes drift divergence added if necessary
+      !                                   !=  Add Stokes drift divergence  =!   (if exist)
+      IF( ln_sdw ) THEN                   !  -----------------------------  !
          zssh_frc(:,:) = zssh_frc(:,:) + div_sd(:,:)
       ENDIF
@@ -661,10 +364,11 @@
       !
 #if defined key_asminc
-      !                                         ! Include the IAU weighted SSH increment
+      !                                   !=  Add the IAU weighted SSH increment  =!
+      !                                   !  ------------------------------------  !
       IF( lk_asminc .AND. ln_sshinc .AND. ln_asmiau ) THEN
          zssh_frc(:,:) = zssh_frc(:,:) - ssh_iau(:,:)
       ENDIF
 #endif
-      !                                   !* Fill boundary data arrays for AGRIF
+      !                                   != Fill boundary data arrays for AGRIF
       !                                   ! ------------------------------------
 #if defined key_agrif
@@ -688,5 +392,10 @@
          vb_e   (:,:) = 0._wp
       ENDIF
-
+      !
+      IF( ln_linssh ) THEN    ! mid-step ocean depth is fixed (hup2_e=hu_n=hu_0)
+         zhup2_e(:,:) = hu_n(:,:)
+         zhvp2_e(:,:) = hv_n(:,:)
+         zhtp2_e(:,:) = ht_n(:,:)
+      ENDIF
       !
       IF (ln_bt_fw) THEN                  ! FORWARD integration: start from NOW fields                    
@@ -710,6 +419,4 @@
       ENDIF
       !
-      !
-      !
       ! Initialize sums:
       ua_b  (:,:) = 0._wp       ! After barotropic velocities (or transport if flux form)          
@@ -731,12 +438,13 @@
          !
          l_full_nf_update = jn == icycle   ! false: disable full North fold update (performances) for jn = 1 to icycle-1
-         !                                                !  ------------------
-         !                                                !* Update the forcing (BDY and tides)
-         !                                                !  ------------------
-         ! Update only tidal forcing at open boundaries
-         IF( ln_bdy      .AND. ln_tide )   CALL bdy_dta_tides( kt, kit=jn, time_offset= noffset+1 )
-         IF( ln_tide_pot .AND. ln_tide )   CALL upd_tide     ( kt, kit=jn, time_offset= noffset   )
-         !
-         ! Set extrapolation coefficients for predictor step:
+         !
+         !                    !==  Update the forcing ==! (BDY and tides)
+         !
+         IF( ln_bdy      .AND. ln_tide )   CALL bdy_dta_tides( kt, kit=jn, kt_offset= noffset+1 )
+         IF( ln_tide_pot .AND. ln_tide )   CALL upd_tide     ( kt, kit=jn, kt_offset= noffset   )
+         !
+         !                    !==  extrapolation at mid-step  ==!   (jn+1/2)
+         !
+         !                       !* Set extrapolation coefficients for predictor step:
          IF ((jn<3).AND.ll_init) THEN      ! Forward           
            za1 = 1._wp                                          
@@ -748,6 +456,9 @@
            za3 =  0.281105_wp              ! za3 = bet
          ENDIF
-
-         ! Extrapolate barotropic velocities at step jit+0.5:
+         !
+         !                       !* Extrapolate barotropic velocities at mid-step (jn+1/2)
+         !--        m+1/2               m                m-1           m-2       --!
+         !--       u      = (3/2+beta) u   -(1/2+2beta) u      + beta u          --!
+         !-------------------------------------------------------------------------!
          ua_e(:,:) = za1 * un_e(:,:) + za2 * ub_e(:,:) + za3 * ubb_e(:,:)
          va_e(:,:) = za1 * vn_e(:,:) + za2 * vb_e(:,:) + za3 * vbb_e(:,:)
@@ -756,64 +467,42 @@
             !                                             !  ------------------
             ! Extrapolate Sea Level at step jit+0.5:
+            !--         m+1/2                 m                  m-1             m-2       --!
+            !--      ssh      = (3/2+beta) ssh   -(1/2+2beta) ssh      + beta ssh          --!
+            !--------------------------------------------------------------------------------!
             zsshp2_e(:,:) = za1 * sshn_e(:,:)  + za2 * sshb_e(:,:) + za3 * sshbb_e(:,:)
             
-            ! set wetting & drying mask at tracer points for this barotropic sub-step 
-            IF ( ln_wd_dl ) THEN 
-               !
-               IF ( ln_wd_dl_rmp ) THEN 
-                  DO jj = 1, jpj                                 
-                     DO ji = 1, jpi   ! vector opt.  
-                        IF ( zsshp2_e(ji,jj) + ht_0(ji,jj) >  2._wp * rn_wdmin1 ) THEN 
-!                        IF ( zsshp2_e(ji,jj) + ht_0(ji,jj) >  rn_wdmin2 ) THEN 
-                           ztwdmask(ji,jj) = 1._wp
-                        ELSE IF ( zsshp2_e(ji,jj) + ht_0(ji,jj) >  rn_wdmin1 ) THEN
-                           ztwdmask(ji,jj) = (tanh(50._wp*( ( zsshp2_e(ji,jj) + ht_0(ji,jj) -  rn_wdmin1 )*r_rn_wdmin1)) ) 
-                        ELSE 
-                           ztwdmask(ji,jj) = 0._wp
-                        END IF
-                     END DO
-                  END DO
-               ELSE
-                  DO jj = 1, jpj                                 
-                     DO ji = 1, jpi   ! vector opt.  
-                        IF ( zsshp2_e(ji,jj) + ht_0(ji,jj) >  rn_wdmin1 ) THEN 
-                           ztwdmask(ji,jj) = 1._wp
-                        ELSE 
-                           ztwdmask(ji,jj) = 0._wp
-                        ENDIF
-                     END DO
-                  END DO
-               ENDIF 
-               !
-            ENDIF 
+            ! set wetting & drying mask at tracer points for this barotropic mid-step
+            IF( ln_wd_dl )   CALL wad_tmsk( zsshp2_e, ztwdmask )
             !
-            DO jj = 2, jpjm1                                    ! Sea Surface Height at u- & v-points
-               DO ji = 2, fs_jpim1   ! Vector opt.
-                  zwx(ji,jj) = r1_2 * ssumask(ji,jj)  * r1_e1e2u(ji,jj)     &
-                     &              * ( e1e2t(ji  ,jj) * zsshp2_e(ji  ,jj)  &
-                     &              +   e1e2t(ji+1,jj) * zsshp2_e(ji+1,jj) )
-                  zwy(ji,jj) = r1_2 * ssvmask(ji,jj)  * r1_e1e2v(ji,jj)     &
-                     &              * ( e1e2t(ji,jj  ) * zsshp2_e(ji,jj  )  &
-                     &              +   e1e2t(ji,jj+1) * zsshp2_e(ji,jj+1) )
-               END DO
-            END DO
-            CALL lbc_lnk_multi( 'dynspg_ts', zwx, 'U', 1._wp, zwy, 'V', 1._wp )
+            !                          ! ocean t-depth at mid-step
+            zhtp2_e(:,:) = ht_0(:,:) + zsshp2_e(:,:)
             !
-            zhup2_e(:,:) = hu_0(:,:) + zwx(:,:)                ! Ocean depth at U- and V-points
-            zhvp2_e(:,:) = hv_0(:,:) + zwy(:,:)
-            zhtp2_e(:,:) = ht_0(:,:) + zsshp2_e(:,:)
-         ELSE
-            zhup2_e(:,:) = hu_n(:,:)
-            zhvp2_e(:,:) = hv_n(:,:)
-            zhtp2_e(:,:) = ht_n(:,:)
-         ENDIF
-         !                                                !* after ssh
-         !                                                !  -----------
-         !
-         ! Enforce volume conservation at open boundaries:
+            !                          ! ocean u- and v-depth at mid-step   (separate DO-loops remove the need of a lbc_lnk)
+            DO jj = 1, jpj
+               DO ji = 1, jpim1   ! not jpi-column
+                  zhup2_e(ji,jj) = hu_0(ji,jj) + r1_2 * r1_e1e2u(ji,jj)                        &
+                       &                              * (  e1e2t(ji  ,jj) * zsshp2_e(ji  ,jj)  &
+                       &                                 + e1e2t(ji+1,jj) * zsshp2_e(ji+1,jj)  ) * ssumask(ji,jj)
+               END DO
+            END DO
+            DO jj = 1, jpjm1        ! not jpj-row
+               DO ji = 1, jpi
+                  zhvp2_e(ji,jj) = hv_0(ji,jj) + r1_2 * r1_e1e2v(ji,jj)                        &
+                       &                              * (  e1e2t(ji,jj  ) * zsshp2_e(ji,jj  )  &
+                       &                                 + e1e2t(ji,jj+1) * zsshp2_e(ji,jj+1)  ) * ssvmask(ji,jj)
+               END DO
+            END DO
+            !
+         ENDIF
+         !
+         !                    !==  after SSH  ==!   (jn+1)
+         !
+         !                             ! update (ua_e,va_e) to enforce volume conservation at open boundaries
+         !                             ! values of zhup2_e and zhvp2_e on the halo are not needed in bdy_vol2d
          IF( ln_bdy .AND. ln_vol ) CALL bdy_vol2d( kt, jn, ua_e, va_e, zhup2_e, zhvp2_e )
          !
-         zwx(:,:) = e2u(:,:) * ua_e(:,:) * zhup2_e(:,:)         ! fluxes at jn+0.5
-         zwy(:,:) = e1v(:,:) * va_e(:,:) * zhvp2_e(:,:)
+         !                             ! resulting flux at mid-step (not over the full domain)
+         zhU(1:jpim1,1:jpj  ) = e2u(1:jpim1,1:jpj  ) * ua_e(1:jpim1,1:jpj  ) * zhup2_e(1:jpim1,1:jpj  )   ! not jpi-column
+         zhV(1:jpi  ,1:jpjm1) = e1v(1:jpi  ,1:jpjm1) * va_e(1:jpi  ,1:jpjm1) * zhvp2_e(1:jpi  ,1:jpjm1)   ! not jpj-row
          !
 #if defined key_agrif
@@ -822,78 +511,60 @@
             IF((nbondi == -1).OR.(nbondi == 2)) THEN
                DO jj = 1, jpj
-                  zwx(2:nbghostcells+1,jj) = ubdy_w(1:nbghostcells,jj) * e2u(2:nbghostcells+1,jj)
-                  zwy(2:nbghostcells+1,jj) = vbdy_w(1:nbghostcells,jj) * e1v(2:nbghostcells+1,jj)
+                  zhU(2:nbghostcells+1,jj) = ubdy_w(1:nbghostcells,jj) * e2u(2:nbghostcells+1,jj)
+                  zhV(2:nbghostcells+1,jj) = vbdy_w(1:nbghostcells,jj) * e1v(2:nbghostcells+1,jj)
                END DO
             ENDIF
             IF((nbondi ==  1).OR.(nbondi == 2)) THEN
                DO jj=1,jpj
-                  zwx(nlci-nbghostcells-1:nlci-2,jj) = ubdy_e(1:nbghostcells,jj) * e2u(nlci-nbghostcells-1:nlci-2,jj)
-                  zwy(nlci-nbghostcells  :nlci-1,jj) = vbdy_e(1:nbghostcells,jj) * e1v(nlci-nbghostcells  :nlci-1,jj)
+                  zhU(nlci-nbghostcells-1:nlci-2,jj) = ubdy_e(1:nbghostcells,jj) * e2u(nlci-nbghostcells-1:nlci-2,jj)
+                  zhV(nlci-nbghostcells  :nlci-1,jj) = vbdy_e(1:nbghostcells,jj) * e1v(nlci-nbghostcells  :nlci-1,jj)
                END DO
             ENDIF
             IF((nbondj == -1).OR.(nbondj == 2)) THEN
                DO ji=1,jpi
-                  zwy(ji,2:nbghostcells+1) = vbdy_s(ji,1:nbghostcells) * e1v(ji,2:nbghostcells+1)
-                  zwx(ji,2:nbghostcells+1) = ubdy_s(ji,1:nbghostcells) * e2u(ji,2:nbghostcells+1)
+                  zhV(ji,2:nbghostcells+1) = vbdy_s(ji,1:nbghostcells) * e1v(ji,2:nbghostcells+1)
+                  zhU(ji,2:nbghostcells+1) = ubdy_s(ji,1:nbghostcells) * e2u(ji,2:nbghostcells+1)
                END DO
             ENDIF
             IF((nbondj ==  1).OR.(nbondj == 2)) THEN
                DO ji=1,jpi
-                  zwy(ji,nlcj-nbghostcells-1:nlcj-2) = vbdy_n(ji,1:nbghostcells) * e1v(ji,nlcj-nbghostcells-1:nlcj-2)
-                  zwx(ji,nlcj-nbghostcells  :nlcj-1) = ubdy_n(ji,1:nbghostcells) * e2u(ji,nlcj-nbghostcells  :nlcj-1)
+                  zhV(ji,nlcj-nbghostcells-1:nlcj-2) = vbdy_n(ji,1:nbghostcells) * e1v(ji,nlcj-nbghostcells-1:nlcj-2)
+                  zhU(ji,nlcj-nbghostcells  :nlcj-1) = ubdy_n(ji,1:nbghostcells) * e2u(ji,nlcj-nbghostcells  :nlcj-1)
                END DO
             ENDIF
          ENDIF
 #endif
-         IF( ln_wd_il )   CALL wad_lmt_bt(zwx, zwy, sshn_e, zssh_frc, rdtbt)
-
-         IF ( ln_wd_dl ) THEN 
-            !
-            ! un_e and vn_e are set to zero at faces where the direction of the flow is from dry cells 
-            !
-            DO jj = 1, jpjm1                                 
-               DO ji = 1, jpim1   
-                  IF ( zwx(ji,jj) > 0.0 ) THEN 
-                     zuwdmask(ji, jj) = ztwdmask(ji  ,jj) 
-                  ELSE 
-                     zuwdmask(ji, jj) = ztwdmask(ji+1,jj)  
-                  END IF 
-                  zwx(ji, jj) = zuwdmask(ji,jj)*zwx(ji, jj)
-                  un_e(ji,jj) = zuwdmask(ji,jj)*un_e(ji,jj)
-
-                  IF ( zwy(ji,jj) > 0.0 ) THEN
-                     zvwdmask(ji, jj) = ztwdmask(ji, jj  )
-                  ELSE 
-                     zvwdmask(ji, jj) = ztwdmask(ji, jj+1)  
-                  END IF 
-                  zwy(ji, jj) = zvwdmask(ji,jj)*zwy(ji,jj) 
-                  vn_e(ji,jj) = zvwdmask(ji,jj)*vn_e(ji,jj)
-               END DO
-            END DO
+         IF( ln_wd_il )   CALL wad_lmt_bt(zhU, zhV, sshn_e, zssh_frc, rdtbt)    !!gm wad_lmt_bt use of lbc_lnk on zhU, zhV
+
+         IF( ln_wd_dl ) THEN           ! un_e and vn_e are set to zero at faces where 
+            !                          ! the direction of the flow is from dry cells
+            CALL wad_Umsk( ztwdmask, zhU, zhV, un_e, vn_e, zuwdmask, zvwdmask )   ! not jpi colomn for U, not jpj row for V
             !
          ENDIF    
-         
-         ! Sum over sub-time-steps to compute advective velocities
-         za2 = wgtbtp2(jn)
-         un_adv(:,:) = un_adv(:,:) + za2 * zwx(:,:) * r1_e2u(:,:)
-         vn_adv(:,:) = vn_adv(:,:) + za2 * zwy(:,:) * r1_e1v(:,:)
-         
-         ! sum over sub-time-steps to decide which baroclinic velocities to set to zero (zuwdav2 is only used when ln_wd_dl_bc = True) 
+         !
+         !
+         !     Compute Sea Level at step jit+1
+         !--           m+1        m                               m+1/2          --!
+         !--        ssh    =  ssh   - delta_t' * [ frc + div( flux      ) ]      --!
+         !-------------------------------------------------------------------------!
+         DO jj = 2, jpjm1        ! INNER domain                             
+            DO ji = 2, jpim1
+               zhdiv = (   zhU(ji,jj) - zhU(ji-1,jj) + zhV(ji,jj) - zhV(ji,jj-1)   ) * r1_e1e2t(ji,jj)
+               ssha_e(ji,jj) = (  sshn_e(ji,jj) - rdtbt * ( zssh_frc(ji,jj) + zhdiv )  ) * ssmask(ji,jj)
+            END DO
+         END DO
+         !
+         CALL lbc_lnk_multi( 'dynspg_ts', ssha_e, 'T', 1._wp,  zhU, 'U', -1._wp,  zhV, 'V', -1._wp )
+         !
+         !                             ! Sum over sub-time-steps to compute advective velocities
+         za2 = wgtbtp2(jn)             ! zhU, zhV hold fluxes extrapolated at jn+0.5
+         un_adv(:,:) = un_adv(:,:) + za2 * zhU(:,:) * r1_e2u(:,:)
+         vn_adv(:,:) = vn_adv(:,:) + za2 * zhV(:,:) * r1_e1v(:,:)
+         ! sum over sub-time-steps to decide which baroclinic velocities to set to zero (zuwdav2 is only used when ln_wd_dl_bc=True) 
          IF ( ln_wd_dl_bc ) THEN
-            zuwdav2(:,:) = zuwdav2(:,:) + za2 * zuwdmask(:,:)
-            zvwdav2(:,:) = zvwdav2(:,:) + za2 * zvwdmask(:,:)
-         END IF 
-
-         ! Set next sea level:
-         DO jj = 2, jpjm1                                 
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zhdiv(ji,jj) = (   zwx(ji,jj) - zwx(ji-1,jj)   &
-                  &             + zwy(ji,jj) - zwy(ji,jj-1)   ) * r1_e1e2t(ji,jj)
-            END DO
-         END DO
-         ssha_e(:,:) = (  sshn_e(:,:) - rdtbt * ( zssh_frc(:,:) + zhdiv(:,:) )  ) * ssmask(:,:)
-         
-         CALL lbc_lnk( 'dynspg_ts', ssha_e, 'T',  1._wp )
-
+            zuwdav2(1:jpim1,1:jpj  ) = zuwdav2(1:jpim1,1:jpj  ) + za2 * zuwdmask(1:jpim1,1:jpj  )   ! not jpi-column
+            zvwdav2(1:jpi  ,1:jpjm1) = zvwdav2(1:jpi  ,1:jpjm1) + za2 * zvwdmask(1:jpi  ,1:jpjm1)   ! not jpj-row
+         END IF
+         !
          ! Duplicate sea level across open boundaries (this is only cosmetic if linssh=T)
          IF( ln_bdy )   CALL bdy_ssh( ssha_e )
@@ -904,5 +575,5 @@
          ! Sea Surface Height at u-,v-points (vvl case only)
          IF( .NOT.ln_linssh ) THEN                                
-            DO jj = 2, jpjm1
+            DO jj = 2, jpjm1   ! INNER domain, will be extended to whole domain later
                DO ji = 2, jpim1      ! NO Vector Opt.
                   zsshu_a(ji,jj) = r1_2 * ssumask(ji,jj) * r1_e1e2u(ji,jj)    &
@@ -914,96 +585,26 @@
                END DO
             END DO
-            CALL lbc_lnk_multi( 'dynspg_ts', zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp )
          ENDIF   
-         !                                 
-         ! Half-step back interpolation of SSH for surface pressure computation:
-         !----------------------------------------------------------------------
-         IF ((jn==1).AND.ll_init) THEN
-           za0=1._wp                        ! Forward-backward
-           za1=0._wp                           
-           za2=0._wp
-           za3=0._wp
-         ELSEIF ((jn==2).AND.ll_init) THEN  ! AB2-AM3 Coefficients; bet=0 ; gam=-1/6 ; eps=1/12
-           za0= 1.0833333333333_wp          ! za0 = 1-gam-eps
-           za1=-0.1666666666666_wp          ! za1 = gam
-           za2= 0.0833333333333_wp          ! za2 = eps
-           za3= 0._wp              
-         ELSE                               ! AB3-AM4 Coefficients; bet=0.281105 ; eps=0.013 ; gam=0.0880 
-            IF (rn_bt_alpha==0._wp) THEN
-               za0=0.614_wp                 ! za0 = 1/2 +   gam + 2*eps
-               za1=0.285_wp                 ! za1 = 1/2 - 2*gam - 3*eps
-               za2=0.088_wp                 ! za2 = gam
-               za3=0.013_wp                 ! za3 = eps
-            ELSE
-               zepsilon = 0.00976186_wp - 0.13451357_wp * rn_bt_alpha
-               zgamma = 0.08344500_wp - 0.51358400_wp * rn_bt_alpha
-               za0 = 0.5_wp + zgamma + 2._wp * rn_bt_alpha + 2._wp * zepsilon
-               za1 = 1._wp - za0 - zgamma - zepsilon
-               za2 = zgamma
-               za3 = zepsilon
-            ENDIF 
-         ENDIF
-         !
+         !         
+         ! Half-step back interpolation of SSH for surface pressure computation at step jit+1/2
+         !--            m+1/2           m+1              m               m-1              m-2     --!
+         !--        ssh'    =  za0 * ssh     +  za1 * ssh   +  za2 * ssh      +  za3 * ssh        --!
+         !------------------------------------------------------------------------------------------!
+         CALL ts_bck_interp( jn, ll_init, za0, za1, za2, za3 )   ! coeficients of the interpolation
          zsshp2_e(:,:) = za0 *  ssha_e(:,:) + za1 *  sshn_e (:,:)   &
             &          + za2 *  sshb_e(:,:) + za3 *  sshbb_e(:,:)
-         
-         IF( ln_wd_il ) THEN                   ! Calculating and applying W/D gravity filters
-           DO jj = 2, jpjm1
-              DO ji = 2, jpim1 
-                ll_tmp1 = MIN( zsshp2_e(ji,jj)               , zsshp2_e(ji+1,jj) ) >                &
-                     &    MAX(    -ht_0(ji,jj)               ,    -ht_0(ji+1,jj) ) .AND.            &
-                     &    MAX( zsshp2_e(ji,jj) + ht_0(ji,jj) , zsshp2_e(ji+1,jj) + ht_0(ji+1,jj) ) &
-                     &                                                             > rn_wdmin1 + rn_wdmin2
-                ll_tmp2 = (ABS(zsshp2_e(ji,jj)               - zsshp2_e(ji+1,jj))  > 1.E-12 ).AND.( &
-                     &    MAX( zsshp2_e(ji,jj)               , zsshp2_e(ji+1,jj) ) >                &
-                     &    MAX(    -ht_0(ji,jj)               ,    -ht_0(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2 )
-   
-                IF(ll_tmp1) THEN
-                  zcpx(ji,jj) = 1.0_wp
-                ELSE IF(ll_tmp2) THEN
-                  ! no worries about  zsshp2_e(ji+1,jj) - zsshp2_e(ji  ,jj) = 0, it won't happen ! here
-                  zcpx(ji,jj) = ABS( (zsshp2_e(ji+1,jj) +     ht_0(ji+1,jj) - zsshp2_e(ji,jj) - ht_0(ji,jj)) &
-                              &    / (zsshp2_e(ji+1,jj) - zsshp2_e(ji  ,jj)) )
-                ELSE
-                  zcpx(ji,jj) = 0._wp
-                ENDIF
-                !
-                ll_tmp1 = MIN( zsshp2_e(ji,jj)               , zsshp2_e(ji,jj+1) ) >                &
-                     &    MAX(    -ht_0(ji,jj)               ,    -ht_0(ji,jj+1) ) .AND.            &
-                     &    MAX( zsshp2_e(ji,jj) + ht_0(ji,jj) , zsshp2_e(ji,jj+1) + ht_0(ji,jj+1) ) &
-                     &                                                             > rn_wdmin1 + rn_wdmin2
-                ll_tmp2 = (ABS(zsshp2_e(ji,jj)               - zsshp2_e(ji,jj+1))  > 1.E-12 ).AND.( &
-                     &    MAX( zsshp2_e(ji,jj)               , zsshp2_e(ji,jj+1) ) >                &
-                     &    MAX(    -ht_0(ji,jj)               ,    -ht_0(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2 )
-   
-                IF(ll_tmp1) THEN
-                  zcpy(ji,jj) = 1.0_wp
-                ELSEIF(ll_tmp2) THEN
-                  ! no worries about  zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj  ) = 0, it won't happen ! here
-                  zcpy(ji,jj) = ABS( (zsshp2_e(ji,jj+1) +     ht_0(ji,jj+1) - zsshp2_e(ji,jj) - ht_0(ji,jj)) &
-                              &    / (zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj  )) )
-                ELSE
-                  zcpy(ji,jj) = 0._wp
-                ENDIF
-              END DO
-           END DO
-         ENDIF
-         !
-         ! Compute associated depths at U and V points:
-         IF( .NOT.ln_linssh  .AND. .NOT.ln_dynadv_vec ) THEN     !* Vector form
-            !                                        
-            DO jj = 2, jpjm1                            
-               DO ji = 2, jpim1
-                  zx1 = r1_2 * ssumask(ji  ,jj) *  r1_e1e2u(ji  ,jj)    &
-                     &      * ( e1e2t(ji  ,jj  ) * zsshp2_e(ji  ,jj)    &
-                     &      +   e1e2t(ji+1,jj  ) * zsshp2_e(ji+1,jj  ) )
-                  zy1 = r1_2 * ssvmask(ji  ,jj) *  r1_e1e2v(ji  ,jj  )  &
-                     &       * ( e1e2t(ji ,jj  ) * zsshp2_e(ji  ,jj  )  &
-                     &       +   e1e2t(ji ,jj+1) * zsshp2_e(ji  ,jj+1) )
-                  zhust_e(ji,jj) = hu_0(ji,jj) + zx1 
-                  zhvst_e(ji,jj) = hv_0(ji,jj) + zy1
-               END DO
-            END DO
-            !
+         !
+         !                             ! Surface pressure gradient
+         zldg = ( 1._wp - rn_scal_load ) * grav    ! local factor
+         DO jj = 2, jpjm1                            
+            DO ji = 2, jpim1
+               zu_spg(ji,jj) = - zldg * ( zsshp2_e(ji+1,jj) - zsshp2_e(ji,jj) ) * r1_e1u(ji,jj)
+               zv_spg(ji,jj) = - zldg * ( zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj) ) * r1_e2v(ji,jj)
+            END DO
+         END DO
+         IF( ln_wd_il ) THEN        ! W/D : gravity filters applied on pressure gradient
+            CALL wad_spg( zsshp2_e, zcpx, zcpy )   ! Calculating W/D gravity filters
+            zu_spg(2:jpim1,2:jpjm1) = zu_spg(2:jpim1,2:jpjm1) * zcpx(2:jpim1,2:jpjm1)
+            zv_spg(2:jpim1,2:jpjm1) = zv_spg(2:jpim1,2:jpjm1) * zcpy(2:jpim1,2:jpjm1)
          ENDIF
          !
@@ -1011,65 +612,6 @@
          ! zwz array below or triads normally depend on sea level with ln_linssh=F and should be updated
          ! at each time step. We however keep them constant here for optimization.
-         ! Recall that zwx and zwy arrays hold fluxes at this stage:
-         ! zwx(:,:) = e2u(:,:) * ua_e(:,:) * zhup2_e(:,:)   ! fluxes at jn+0.5
-         ! zwy(:,:) = e1v(:,:) * va_e(:,:) * zhvp2_e(:,:)
-         !
-         SELECT CASE( nvor_scheme )
-         CASE( np_ENT )             ! energy conserving scheme (t-point)
-         DO jj = 2, jpjm1
-            DO ji = 2, jpim1   ! vector opt.
-
-               z1_hu = ssumask(ji,jj) / ( zhup2_e(ji,jj) + 1._wp - ssumask(ji,jj) )
-               z1_hv = ssvmask(ji,jj) / ( zhvp2_e(ji,jj) + 1._wp - ssvmask(ji,jj) )
-            
-               zu_trd(ji,jj) = + r1_4 * r1_e1e2u(ji,jj) * z1_hu                   &
-                  &               * (  e1e2t(ji+1,jj)*zhtp2_e(ji+1,jj)*ff_t(ji+1,jj) * ( va_e(ji+1,jj) + va_e(ji+1,jj-1) )   &
-                  &                  + e1e2t(ji  ,jj)*zhtp2_e(ji  ,jj)*ff_t(ji  ,jj) * ( va_e(ji  ,jj) + va_e(ji  ,jj-1) )   )
-                  !
-               zv_trd(ji,jj) = - r1_4 * r1_e1e2v(ji,jj) * z1_hv                    &
-                  &               * (  e1e2t(ji,jj+1)*zhtp2_e(ji,jj+1)*ff_t(ji,jj+1) * ( ua_e(ji,jj+1) + ua_e(ji-1,jj+1) )   & 
-                  &                  + e1e2t(ji,jj  )*zhtp2_e(ji,jj  )*ff_t(ji,jj  ) * ( ua_e(ji,jj  ) + ua_e(ji-1,jj  ) )   ) 
-            END DO  
-         END DO  
-         !         
-         CASE( np_ENE, np_MIX )     ! energy conserving scheme (f-point)
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zy1 = ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1) ) * r1_e1u(ji,jj)
-                  zy2 = ( zwy(ji  ,jj  ) + zwy(ji+1,jj  ) ) * r1_e1u(ji,jj)
-                  zx1 = ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1) ) * r1_e2v(ji,jj)
-                  zx2 = ( zwx(ji  ,jj  ) + zwx(ji  ,jj+1) ) * r1_e2v(ji,jj)
-                  zu_trd(ji,jj) = r1_4 * ( zwz(ji  ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
-                  zv_trd(ji,jj) =-r1_4 * ( zwz(ji-1,jj  ) * zx1 + zwz(ji,jj) * zx2 )
-               END DO
-            END DO
-            !
-         CASE( np_ENS )             ! enstrophy conserving scheme (f-point)
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zy1 =   r1_8 * ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1) &
-                   &             + zwy(ji  ,jj  ) + zwy(ji+1,jj  ) ) * r1_e1u(ji,jj)
-                  zx1 = - r1_8 * ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1) &
-                   &             + zwx(ji  ,jj  ) + zwx(ji  ,jj+1) ) * r1_e2v(ji,jj)
-                  zu_trd(ji,jj)  = zy1 * ( zwz(ji  ,jj-1) + zwz(ji,jj) )
-                  zv_trd(ji,jj)  = zx1 * ( zwz(ji-1,jj  ) + zwz(ji,jj) )
-               END DO
-            END DO
-            !
-         CASE( np_EET , np_EEN )   ! energy & enstrophy scheme (using e3t or e3f)
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zu_trd(ji,jj) = + r1_12 * r1_e1u(ji,jj) * (  ftne(ji,jj  ) * zwy(ji  ,jj  )  &
-                     &                                       + ftnw(ji+1,jj) * zwy(ji+1,jj  )  &
-                     &                                       + ftse(ji,jj  ) * zwy(ji  ,jj-1)  & 
-                     &                                       + ftsw(ji+1,jj) * zwy(ji+1,jj-1)  )
-                  zv_trd(ji,jj) = - r1_12 * r1_e2v(ji,jj) * (  ftsw(ji,jj+1) * zwx(ji-1,jj+1)  & 
-                     &                                       + ftse(ji,jj+1) * zwx(ji  ,jj+1)  &
-                     &                                       + ftnw(ji,jj  ) * zwx(ji-1,jj  )  & 
-                     &                                       + ftne(ji,jj  ) * zwx(ji  ,jj  )  )
-               END DO
-            END DO
-            ! 
-         END SELECT
+         ! Recall that zhU and zhV hold fluxes at jn+0.5 (extrapolated not backward interpolated)
+         CALL dyn_cor_2d( zhup2_e, zhvp2_e, ua_e, va_e, zhU, zhV,    zu_trd, zv_trd   )
          !
          ! Add tidal astronomical forcing if defined
@@ -1077,8 +619,6 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zu_spg = grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
-                  zv_spg = grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
-                  zu_trd(ji,jj) = zu_trd(ji,jj) + zu_spg
-                  zv_trd(ji,jj) = zv_trd(ji,jj) + zv_spg
+                  zu_trd(ji,jj) = zu_trd(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
+                  zv_trd(ji,jj) = zv_trd(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
                END DO
             END DO
@@ -1094,36 +634,22 @@
                END DO
             END DO
-         ENDIF 
-         !
-         ! Surface pressure trend:
-         IF( ln_wd_il ) THEN
-           DO jj = 2, jpjm1
-              DO ji = 2, jpim1 
-                 ! Add surface pressure gradient
-                 zu_spg = - grav * ( zsshp2_e(ji+1,jj) - zsshp2_e(ji,jj) ) * r1_e1u(ji,jj)
-                 zv_spg = - grav * ( zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj) ) * r1_e2v(ji,jj)
-                 zwx(ji,jj) = (1._wp - rn_scal_load) * zu_spg * zcpx(ji,jj) 
-                 zwy(ji,jj) = (1._wp - rn_scal_load) * zv_spg * zcpy(ji,jj)
-              END DO
-           END DO
-         ELSE
-           DO jj = 2, jpjm1
-              DO ji = fs_2, fs_jpim1   ! vector opt.
-                 ! Add surface pressure gradient
-                 zu_spg = - grav * ( zsshp2_e(ji+1,jj) - zsshp2_e(ji,jj) ) * r1_e1u(ji,jj)
-                 zv_spg = - grav * ( zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj) ) * r1_e2v(ji,jj)
-                 zwx(ji,jj) = (1._wp - rn_scal_load) * zu_spg
-                 zwy(ji,jj) = (1._wp - rn_scal_load) * zv_spg
-              END DO
-           END DO
-         END IF
-
+         ENDIF
          !
          ! Set next velocities:
+         !     Compute barotropic speeds at step jit+1    (h : total height of the water colomn)
+         !--                              VECTOR FORM
+         !--   m+1                 m               /                                                       m+1/2           \    --!
+         !--  u     =             u   + delta_t' * \         (1-r)*g * grad_x( ssh') -         f * k vect u      +     frc /    --!
+         !--                                                                                                                    --!
+         !--                             FLUX FORM                                                                              --!
+         !--  m+1   __1__  /  m    m               /  m+1/2                             m+1/2              m+1/2    n      \ \  --!
+         !-- u    =   m+1 |  h  * u   + delta_t' * \ h     * (1-r)*g * grad_x( ssh') - h     * f * k vect u      + h * frc /  | --!
+         !--         h     \                                                                                                 /  --!
+         !------------------------------------------------------------------------------------------------------------------------!
          IF( ln_dynadv_vec .OR. ln_linssh ) THEN      !* Vector form
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
                   ua_e(ji,jj) = (                                 un_e(ji,jj)   & 
-                            &     + rdtbt * (                      zwx(ji,jj)   &
+                            &     + rdtbt * (                   zu_spg(ji,jj)   &
                             &                                 + zu_trd(ji,jj)   &
                             &                                 + zu_frc(ji,jj) ) & 
@@ -1131,9 +657,8 @@
 
                   va_e(ji,jj) = (                                 vn_e(ji,jj)   &
-                            &     + rdtbt * (                      zwy(ji,jj)   &
+                            &     + rdtbt * (                   zv_spg(ji,jj)   &
                             &                                 + zv_trd(ji,jj)   &
                             &                                 + zv_frc(ji,jj) ) &
                             &   ) * ssvmask(ji,jj)
- 
                END DO
             END DO
@@ -1141,23 +666,24 @@
          ELSE                           !* Flux form
             DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-
-                  zhura = hu_0(ji,jj) + zsshu_a(ji,jj)
-                  zhvra = hv_0(ji,jj) + zsshv_a(ji,jj)
-
-                  zhura = ssumask(ji,jj)/(zhura + 1._wp - ssumask(ji,jj))
-                  zhvra = ssvmask(ji,jj)/(zhvra + 1._wp - ssvmask(ji,jj))
-
-                  ua_e(ji,jj) = (                hu_e(ji,jj)  *   un_e(ji,jj)   & 
-                            &     + rdtbt * ( zhust_e(ji,jj)  *    zwx(ji,jj)   & 
-                            &               + zhup2_e(ji,jj)  * zu_trd(ji,jj)   &
-                            &               +    hu_n(ji,jj)  * zu_frc(ji,jj) ) &
-                            &   ) * zhura
-
-                  va_e(ji,jj) = (                hv_e(ji,jj)  *   vn_e(ji,jj)   &
-                            &     + rdtbt * ( zhvst_e(ji,jj)  *    zwy(ji,jj)   &
-                            &               + zhvp2_e(ji,jj)  * zv_trd(ji,jj)   &
-                            &               +    hv_n(ji,jj)  * zv_frc(ji,jj) ) &
-                            &   ) * zhvra
+               DO ji = 2, jpim1
+                  !                    ! hu_e, hv_e hold depth at jn,  zhup2_e, zhvp2_e hold extrapolated depth at jn+1/2
+                  !                    ! backward interpolated depth used in spg terms at jn+1/2
+                  zhu_bck = hu_0(ji,jj) + r1_2*r1_e1e2u(ji,jj) * (  e1e2t(ji  ,jj) * zsshp2_e(ji  ,jj)    &
+                       &                                          + e1e2t(ji+1,jj) * zsshp2_e(ji+1,jj)  ) * ssumask(ji,jj)
+                  zhv_bck = hv_0(ji,jj) + r1_2*r1_e1e2v(ji,jj) * (  e1e2t(ji,jj  ) * zsshp2_e(ji,jj  )    &
+                       &                                          + e1e2t(ji,jj+1) * zsshp2_e(ji,jj+1)  ) * ssvmask(ji,jj)
+                  !                    ! inverse depth at jn+1
+                  z1_hu = ssumask(ji,jj) / ( hu_0(ji,jj) + zsshu_a(ji,jj) + 1._wp - ssumask(ji,jj) )
+                  z1_hv = ssvmask(ji,jj) / ( hv_0(ji,jj) + zsshv_a(ji,jj) + 1._wp - ssvmask(ji,jj) )
+                  !
+                  ua_e(ji,jj) = (               hu_e  (ji,jj) *   un_e (ji,jj)      & 
+                       &            + rdtbt * (  zhu_bck        * zu_spg (ji,jj)  &   !
+                       &                       + zhup2_e(ji,jj) * zu_trd (ji,jj)  &   !
+                       &                       +  hu_n  (ji,jj) * zu_frc (ji,jj)  )   ) * z1_hu
+                  !
+                  va_e(ji,jj) = (               hv_e  (ji,jj) *   vn_e (ji,jj)      &
+                       &            + rdtbt * (  zhv_bck        * zv_spg (ji,jj)  &   !
+                       &                       + zhvp2_e(ji,jj) * zv_trd (ji,jj)  &   !
+                       &                       +  hv_n  (ji,jj) * zv_frc (ji,jj)  )   ) * z1_hv
                END DO
             END DO
@@ -1172,15 +698,17 @@
             END DO
          ENDIF
-
-         
-         IF( .NOT.ln_linssh ) THEN                     !* Update ocean depth (variable volume case only)
-            hu_e (:,:) = hu_0(:,:) + zsshu_a(:,:)
-            hv_e (:,:) = hv_0(:,:) + zsshv_a(:,:)
-            hur_e(:,:) = ssumask(:,:) / ( hu_e(:,:) + 1._wp - ssumask(:,:) )
-            hvr_e(:,:) = ssvmask(:,:) / ( hv_e(:,:) + 1._wp - ssvmask(:,:) )
-            !
-         ENDIF
-         !                                             !* domain lateral boundary
-         CALL lbc_lnk_multi( 'dynspg_ts', ua_e, 'U', -1._wp, va_e , 'V', -1._wp )
+       
+         IF( .NOT.ln_linssh ) THEN   !* Update ocean depth (variable volume case only)
+            hu_e (2:jpim1,2:jpjm1) = hu_0(2:jpim1,2:jpjm1) + zsshu_a(2:jpim1,2:jpjm1)
+            hur_e(2:jpim1,2:jpjm1) = ssumask(2:jpim1,2:jpjm1) / ( hu_e(2:jpim1,2:jpjm1) + 1._wp - ssumask(2:jpim1,2:jpjm1) )
+            hv_e (2:jpim1,2:jpjm1) = hv_0(2:jpim1,2:jpjm1) + zsshv_a(2:jpim1,2:jpjm1)
+            hvr_e(2:jpim1,2:jpjm1) = ssvmask(2:jpim1,2:jpjm1) / ( hv_e(2:jpim1,2:jpjm1) + 1._wp - ssvmask(2:jpim1,2:jpjm1) )
+            CALL lbc_lnk_multi( 'dynspg_ts', ua_e , 'U', -1._wp, va_e , 'V', -1._wp  &
+                 &                         , hu_e , 'U',  1._wp, hv_e , 'V',  1._wp  &
+                 &                         , hur_e, 'U',  1._wp, hvr_e, 'V',  1._wp  )
+         ELSE
+            CALL lbc_lnk_multi( 'dynspg_ts', ua_e , 'U', -1._wp, va_e , 'V', -1._wp  )
+         ENDIF
+         !
          !
          !                                                 ! open boundaries
@@ -1230,20 +758,26 @@
       ! Set advection velocity correction:
       IF (ln_bt_fw) THEN
-         zwx(:,:) = un_adv(:,:)
-         zwy(:,:) = vn_adv(:,:)
          IF( .NOT.( kt == nit000 .AND. neuler==0 ) ) THEN
-            un_adv(:,:) = r1_2 * ( ub2_b(:,:) + zwx(:,:) - atfp * un_bf(:,:) )
-            vn_adv(:,:) = r1_2 * ( vb2_b(:,:) + zwy(:,:) - atfp * vn_bf(:,:) )
-            !
-            ! Update corrective fluxes for next time step:
-            un_bf(:,:)  = atfp * un_bf(:,:) + (zwx(:,:) - ub2_b(:,:))
-            vn_bf(:,:)  = atfp * vn_bf(:,:) + (zwy(:,:) - vb2_b(:,:))
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zun_save = un_adv(ji,jj)
+                  zvn_save = vn_adv(ji,jj)
+                  !                          ! apply the previously computed correction 
+                  un_adv(ji,jj) = r1_2 * ( ub2_b(ji,jj) + zun_save - atfp * un_bf(ji,jj) )
+                  vn_adv(ji,jj) = r1_2 * ( vb2_b(ji,jj) + zvn_save - atfp * vn_bf(ji,jj) )
+                  !                          ! Update corrective fluxes for next time step
+                  un_bf(ji,jj)  = atfp * un_bf(ji,jj) + ( zun_save - ub2_b(ji,jj) )
+                  vn_bf(ji,jj)  = atfp * vn_bf(ji,jj) + ( zvn_save - vb2_b(ji,jj) )
+                  !                          ! Save integrated transport for next computation
+                  ub2_b(ji,jj) = zun_save
+                  vb2_b(ji,jj) = zvn_save
+               END DO
+            END DO
          ELSE
-            un_bf(:,:) = 0._wp
-            vn_bf(:,:) = 0._wp 
-         END IF         
-         ! Save integrated transport for next computation
-         ub2_b(:,:) = zwx(:,:)
-         vb2_b(:,:) = zwy(:,:)
+            un_bf(:,:) = 0._wp            ! corrective fluxes for next time step set to zero
+            vn_bf(:,:) = 0._wp
+            ub2_b(:,:) = un_adv(:,:)      ! Save integrated transport for next computation
+            vb2_b(:,:) = vn_adv(:,:)
+         END IF
       ENDIF
 
@@ -1287,4 +821,6 @@
 
       IF ( ln_wd_dl .and. ln_wd_dl_bc) THEN 
+         ! need to set lbc here because not done prior time averaging
+         CALL lbc_lnk_multi( 'dynspg_ts', zuwdav2, 'U', 1._wp, zvwdav2, 'V', 1._wp)
          DO jk = 1, jpkm1
             un(:,:,jk) = ( un_adv(:,:)*r1_hu_n(:,:) &
@@ -1490,4 +1026,5 @@
       REAL(wp) ::   zxr2, zyr2, zcmax   ! local scalar
       REAL(wp), DIMENSION(jpi,jpj) ::   zcu
+      INTEGER  :: inum
       !!----------------------------------------------------------------------
       !
@@ -1596,4 +1133,498 @@
    END SUBROUTINE dyn_spg_ts_init
 
+   
+   SUBROUTINE dyn_cor_2d_init
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE dyn_cor_2d_init  ***
+      !!
+      !! ** Purpose : Set time splitting options
+      !! Set arrays to remove/compute coriolis trend.
+      !! Do it once during initialization if volume is fixed, else at each long time step.
+      !! Note that these arrays are also used during barotropic loop. These are however frozen
+      !! although they should be updated in the variable volume case. Not a big approximation.
+      !! To remove this approximation, copy lines below inside barotropic loop
+      !! and update depths at T-F points (ht and zhf resp.) at each barotropic time step
+      !!
+      !! Compute zwz = f / ( height of the water colomn )
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji ,jj, jk              ! dummy loop indices
+      REAL(wp) ::   z1_ht
+      REAL(wp), DIMENSION(jpi,jpj) :: zhf
+      !!----------------------------------------------------------------------
+      !
+      SELECT CASE( nvor_scheme )
+      CASE( np_EEN )                != EEN scheme using e3f (energy & enstrophy scheme)
+         SELECT CASE( nn_een_e3f )              !* ff_f/e3 at F-point
+         CASE ( 0 )                                   ! original formulation  (masked averaging of e3t divided by 4)
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                  zwz(ji,jj) =   ( ht_n(ji  ,jj+1) + ht_n(ji+1,jj+1) +                    &
+                       &             ht_n(ji  ,jj  ) + ht_n(ji+1,jj  )   ) * 0.25_wp  
+                  IF( zwz(ji,jj) /= 0._wp )   zwz(ji,jj) = ff_f(ji,jj) / zwz(ji,jj)
+               END DO
+            END DO
+         CASE ( 1 )                                   ! new formulation  (masked averaging of e3t divided by the sum of mask)
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                  zwz(ji,jj) =             (  ht_n  (ji  ,jj+1) + ht_n  (ji+1,jj+1)      &
+                       &                      + ht_n  (ji  ,jj  ) + ht_n  (ji+1,jj  )  )   &
+                       &       / ( MAX( 1._wp,  ssmask(ji  ,jj+1) + ssmask(ji+1,jj+1)      &
+                       &                      + ssmask(ji  ,jj  ) + ssmask(ji+1,jj  )  )   )
+                  IF( zwz(ji,jj) /= 0._wp )   zwz(ji,jj) = ff_f(ji,jj) / zwz(ji,jj)
+               END DO
+            END DO
+         END SELECT
+         CALL lbc_lnk( 'dynspg_ts', zwz, 'F', 1._wp )
+         !
+         ftne(1,:) = 0._wp ; ftnw(1,:) = 0._wp ; ftse(1,:) = 0._wp ; ftsw(1,:) = 0._wp
+         DO jj = 2, jpj
+            DO ji = 2, jpi
+               ftne(ji,jj) = zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1)
+               ftnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  )
+               ftse(ji,jj) = zwz(ji  ,jj  ) + zwz(ji  ,jj-1) + zwz(ji-1,jj-1)
+               ftsw(ji,jj) = zwz(ji  ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj  )
+            END DO
+         END DO
+         !
+      CASE( np_EET )                  != EEN scheme using e3t (energy conserving scheme)
+         ftne(1,:) = 0._wp ; ftnw(1,:) = 0._wp ; ftse(1,:) = 0._wp ; ftsw(1,:) = 0._wp
+         DO jj = 2, jpj
+            DO ji = 2, jpi
+               z1_ht = ssmask(ji,jj) / ( ht_n(ji,jj) + 1._wp - ssmask(ji,jj) )
+               ftne(ji,jj) = ( ff_f(ji-1,jj  ) + ff_f(ji  ,jj  ) + ff_f(ji  ,jj-1) ) * z1_ht
+               ftnw(ji,jj) = ( ff_f(ji-1,jj-1) + ff_f(ji-1,jj  ) + ff_f(ji  ,jj  ) ) * z1_ht
+               ftse(ji,jj) = ( ff_f(ji  ,jj  ) + ff_f(ji  ,jj-1) + ff_f(ji-1,jj-1) ) * z1_ht
+               ftsw(ji,jj) = ( ff_f(ji  ,jj-1) + ff_f(ji-1,jj-1) + ff_f(ji-1,jj  ) ) * z1_ht
+            END DO
+         END DO
+         !
+      CASE( np_ENE, np_ENS , np_MIX )  != all other schemes (ENE, ENS, MIX) except ENT !
+         !
+         zwz(:,:) = 0._wp
+         zhf(:,:) = 0._wp
+         
+         !!gm  assume 0 in both cases (which is almost surely WRONG ! ) as hvatf has been removed 
+!!gm    A priori a better value should be something like :
+!!gm          zhf(i,j) = masked sum of  ht(i,j) , ht(i+1,j) , ht(i,j+1) , (i+1,j+1) 
+!!gm                     divided by the sum of the corresponding mask 
+!!gm 
+!!            
+         IF( .NOT.ln_sco ) THEN
+  
+   !!gm  agree the JC comment  : this should be done in a much clear way
+  
+   ! JC: It not clear yet what should be the depth at f-points over land in z-coordinate case
+   !     Set it to zero for the time being 
+   !              IF( rn_hmin < 0._wp ) THEN    ;   jk = - INT( rn_hmin )                                      ! from a nb of level
+   !              ELSE                          ;   jk = MINLOC( gdepw_0, mask = gdepw_0 > rn_hmin, dim = 1 )  ! from a depth
+   !              ENDIF
+   !              zhf(:,:) = gdepw_0(:,:,jk+1)
+            !
+         ELSE
+            !
+            !zhf(:,:) = hbatf(:,:)
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                  zhf(ji,jj) =    (   ht_0  (ji,jj  ) + ht_0  (ji+1,jj  )          &
+                       &            + ht_0  (ji,jj+1) + ht_0  (ji+1,jj+1)   )      &
+                       &     / MAX(   ssmask(ji,jj  ) + ssmask(ji+1,jj  )          &
+                       &            + ssmask(ji,jj+1) + ssmask(ji+1,jj+1) , 1._wp  )
+               END DO
+            END DO
+         ENDIF
+         !
+         DO jj = 1, jpjm1
+            zhf(:,jj) = zhf(:,jj) * (1._wp- umask(:,jj,1) * umask(:,jj+1,1))
+         END DO
+         !
+         DO jk = 1, jpkm1
+            DO jj = 1, jpjm1
+               zhf(:,jj) = zhf(:,jj) + e3f_n(:,jj,jk) * umask(:,jj,jk) * umask(:,jj+1,jk)
+            END DO
+         END DO
+         CALL lbc_lnk( 'dynspg_ts', zhf, 'F', 1._wp )
+         ! JC: TBC. hf should be greater than 0 
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( zhf(ji,jj) /= 0._wp )   zwz(ji,jj) = 1._wp / zhf(ji,jj)
+            END DO
+         END DO
+         zwz(:,:) = ff_f(:,:) * zwz(:,:)
+      END SELECT
+      
+   END SUBROUTINE dyn_cor_2d_init
+
+
+
+   SUBROUTINE dyn_cor_2d( hu_n, hv_n, un_b, vn_b, zhU, zhV,    zu_trd, zv_trd   )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE dyn_cor_2d  ***
+      !!
+      !! ** Purpose : Compute u and v coriolis trends
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji ,jj                             ! dummy loop indices
+      REAL(wp) ::   zx1, zx2, zy1, zy2, z1_hu, z1_hv   !   -      -
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: hu_n, hv_n, un_b, vn_b, zhU, zhV
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) :: zu_trd, zv_trd
+      !!----------------------------------------------------------------------
+      SELECT CASE( nvor_scheme )
+      CASE( np_ENT )                ! enstrophy conserving scheme (f-point)
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               z1_hu = ssumask(ji,jj) / ( hu_n(ji,jj) + 1._wp - ssumask(ji,jj) )
+               z1_hv = ssvmask(ji,jj) / ( hv_n(ji,jj) + 1._wp - ssvmask(ji,jj) )
+               zu_trd(ji,jj) = + r1_4 * r1_e1e2u(ji,jj) * z1_hu                    &
+                  &               * (  e1e2t(ji+1,jj)*ht_n(ji+1,jj)*ff_t(ji+1,jj) * ( vn_b(ji+1,jj) + vn_b(ji+1,jj-1) )   &
+                  &                  + e1e2t(ji  ,jj)*ht_n(ji  ,jj)*ff_t(ji  ,jj) * ( vn_b(ji  ,jj) + vn_b(ji  ,jj-1) )   )
+                  !
+               zv_trd(ji,jj) = - r1_4 * r1_e1e2v(ji,jj) * z1_hv                    &
+                  &               * (  e1e2t(ji,jj+1)*ht_n(ji,jj+1)*ff_t(ji,jj+1) * ( un_b(ji,jj+1) + un_b(ji-1,jj+1) )   & 
+                  &                  + e1e2t(ji,jj  )*ht_n(ji,jj  )*ff_t(ji,jj  ) * ( un_b(ji,jj  ) + un_b(ji-1,jj  ) )   ) 
+            END DO  
+         END DO  
+         !         
+      CASE( np_ENE , np_MIX )        ! energy conserving scheme (t-point) ENE or MIX
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zy1 = ( zhV(ji,jj-1) + zhV(ji+1,jj-1) ) * r1_e1u(ji,jj)
+               zy2 = ( zhV(ji,jj  ) + zhV(ji+1,jj  ) ) * r1_e1u(ji,jj)
+               zx1 = ( zhU(ji-1,jj) + zhU(ji-1,jj+1) ) * r1_e2v(ji,jj)
+               zx2 = ( zhU(ji  ,jj) + zhU(ji  ,jj+1) ) * r1_e2v(ji,jj)
+               ! energy conserving formulation for planetary vorticity term
+               zu_trd(ji,jj) =   r1_4 * ( zwz(ji  ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
+               zv_trd(ji,jj) = - r1_4 * ( zwz(ji-1,jj  ) * zx1 + zwz(ji,jj) * zx2 )
+            END DO
+         END DO
+         !
+      CASE( np_ENS )                ! enstrophy conserving scheme (f-point)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zy1 =   r1_8 * ( zhV(ji  ,jj-1) + zhV(ji+1,jj-1) &
+                 &            + zhV(ji  ,jj  ) + zhV(ji+1,jj  ) ) * r1_e1u(ji,jj)
+               zx1 = - r1_8 * ( zhU(ji-1,jj  ) + zhU(ji-1,jj+1) &
+                 &            + zhU(ji  ,jj  ) + zhU(ji  ,jj+1) ) * r1_e2v(ji,jj)
+               zu_trd(ji,jj)  = zy1 * ( zwz(ji  ,jj-1) + zwz(ji,jj) )
+               zv_trd(ji,jj)  = zx1 * ( zwz(ji-1,jj  ) + zwz(ji,jj) )
+            END DO
+         END DO
+         !
+      CASE( np_EET , np_EEN )      ! energy & enstrophy scheme (using e3t or e3f)         
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zu_trd(ji,jj) = + r1_12 * r1_e1u(ji,jj) * (  ftne(ji,jj  ) * zhV(ji  ,jj  ) &
+                &                                         + ftnw(ji+1,jj) * zhV(ji+1,jj  ) &
+                &                                         + ftse(ji,jj  ) * zhV(ji  ,jj-1) &
+                &                                         + ftsw(ji+1,jj) * zhV(ji+1,jj-1) )
+               zv_trd(ji,jj) = - r1_12 * r1_e2v(ji,jj) * (  ftsw(ji,jj+1) * zhU(ji-1,jj+1) &
+                &                                         + ftse(ji,jj+1) * zhU(ji  ,jj+1) &
+                &                                         + ftnw(ji,jj  ) * zhU(ji-1,jj  ) &
+                &                                         + ftne(ji,jj  ) * zhU(ji  ,jj  ) )
+            END DO
+         END DO
+         !
+      END SELECT
+      !
+   END SUBROUTINE dyn_cor_2D
+
+
+   SUBROUTINE wad_tmsk( pssh, ptmsk )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE wad_lmt  ***
+      !!                    
+      !! ** Purpose :   set wetting & drying mask at tracer points 
+      !!              for the current barotropic sub-step 
+      !!
+      !! ** Method  :   ??? 
+      !!
+      !! ** Action  :  ptmsk : wetting & drying t-mask
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pssh    !
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   ptmsk   !
+      !
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      IF( ln_wd_dl_rmp ) THEN     
+         DO jj = 1, jpj
+            DO ji = 1, jpi                    
+               IF    ( pssh(ji,jj) + ht_0(ji,jj) >  2._wp * rn_wdmin1 ) THEN 
+                  !           IF    ( pssh(ji,jj) + ht_0(ji,jj) >          rn_wdmin2 ) THEN 
+                  ptmsk(ji,jj) = 1._wp
+               ELSEIF( pssh(ji,jj) + ht_0(ji,jj) >          rn_wdmin1 ) THEN
+                  ptmsk(ji,jj) = TANH( 50._wp*( ( pssh(ji,jj) + ht_0(ji,jj) -  rn_wdmin1 )*r_rn_wdmin1) )
+               ELSE 
+                  ptmsk(ji,jj) = 0._wp
+               ENDIF
+            END DO
+         END DO
+      ELSE  
+         DO jj = 1, jpj
+            DO ji = 1, jpi                              
+               IF ( pssh(ji,jj) + ht_0(ji,jj) >  rn_wdmin1 ) THEN   ;   ptmsk(ji,jj) = 1._wp
+               ELSE                                                 ;   ptmsk(ji,jj) = 0._wp
+               ENDIF
+            END DO
+         END DO
+      ENDIF
+      !
+   END SUBROUTINE wad_tmsk
+
+
+   SUBROUTINE wad_Umsk( pTmsk, phU, phV, pu, pv, pUmsk, pVmsk )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE wad_lmt  ***
+      !!                    
+      !! ** Purpose :   set wetting & drying mask at tracer points 
+      !!              for the current barotropic sub-step 
+      !!
+      !! ** Method  :   ??? 
+      !!
+      !! ** Action  :  ptmsk : wetting & drying t-mask
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) ::   pTmsk              ! W & D t-mask
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   phU, phV, pu, pv   ! ocean velocities and transports
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pUmsk, pVmsk       ! W & D u- and v-mask
+      !
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      DO jj = 1, jpj
+         DO ji = 1, jpim1   ! not jpi-column
+            IF ( phU(ji,jj) > 0._wp ) THEN   ;   pUmsk(ji,jj) = pTmsk(ji  ,jj) 
+            ELSE                             ;   pUmsk(ji,jj) = pTmsk(ji+1,jj)  
+            ENDIF
+            phU(ji,jj) = pUmsk(ji,jj)*phU(ji,jj)
+            pu (ji,jj) = pUmsk(ji,jj)*pu (ji,jj)
+         END DO
+      END DO
+      !
+      DO jj = 1, jpjm1   ! not jpj-row
+         DO ji = 1, jpi
+            IF ( phV(ji,jj) > 0._wp ) THEN   ;   pVmsk(ji,jj) = pTmsk(ji,jj  )
+            ELSE                             ;   pVmsk(ji,jj) = pTmsk(ji,jj+1)  
+            ENDIF
+            phV(ji,jj) = pVmsk(ji,jj)*phV(ji,jj) 
+            pv (ji,jj) = pVmsk(ji,jj)*pv (ji,jj)
+         END DO
+      END DO
+      !
+   END SUBROUTINE wad_Umsk
+
+
+   SUBROUTINE wad_spg( sshn, zcpx, zcpy )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE  wad_sp  ***
+      !!
+      !! ** Purpose : 
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji ,jj               ! dummy loop indices
+      LOGICAL  ::   ll_tmp1, ll_tmp2
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: sshn
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: zcpx, zcpy
+      !!----------------------------------------------------------------------
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1 
+            ll_tmp1 = MIN(  sshn(ji,jj)               ,  sshn(ji+1,jj) ) >                &
+                 &      MAX( -ht_0(ji,jj)               , -ht_0(ji+1,jj) ) .AND.            &
+                 &      MAX(  sshn(ji,jj) + ht_0(ji,jj) ,  sshn(ji+1,jj) + ht_0(ji+1,jj) )  &
+                 &                                                         > rn_wdmin1 + rn_wdmin2
+            ll_tmp2 = ( ABS( sshn(ji+1,jj)            -  sshn(ji  ,jj))  > 1.E-12 ).AND.( &
+                 &      MAX(   sshn(ji,jj)              ,  sshn(ji+1,jj) ) >                &
+                 &      MAX(  -ht_0(ji,jj)              , -ht_0(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2 )
+            IF(ll_tmp1) THEN
+               zcpx(ji,jj) = 1.0_wp
+            ELSEIF(ll_tmp2) THEN
+               ! no worries about  sshn(ji+1,jj) -  sshn(ji  ,jj) = 0, it won't happen ! here
+               zcpx(ji,jj) = ABS( (sshn(ji+1,jj) + ht_0(ji+1,jj) - sshn(ji,jj) - ht_0(ji,jj)) &
+                    &    / (sshn(ji+1,jj) - sshn(ji  ,jj)) )
+               zcpx(ji,jj) = max(min( zcpx(ji,jj) , 1.0_wp),0.0_wp)
+            ELSE
+               zcpx(ji,jj) = 0._wp
+            ENDIF
+            !
+            ll_tmp1 = MIN(  sshn(ji,jj)               ,  sshn(ji,jj+1) ) >                &
+                 &      MAX( -ht_0(ji,jj)               , -ht_0(ji,jj+1) ) .AND.            &
+                 &      MAX(  sshn(ji,jj) + ht_0(ji,jj) ,  sshn(ji,jj+1) + ht_0(ji,jj+1) )  &
+                 &                                                       > rn_wdmin1 + rn_wdmin2
+            ll_tmp2 = ( ABS( sshn(ji,jj)              -  sshn(ji,jj+1))  > 1.E-12 ).AND.( &
+                 &      MAX(   sshn(ji,jj)              ,  sshn(ji,jj+1) ) >                &
+                 &      MAX(  -ht_0(ji,jj)              , -ht_0(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2 )
+            
+            IF(ll_tmp1) THEN
+               zcpy(ji,jj) = 1.0_wp
+            ELSE IF(ll_tmp2) THEN
+               ! no worries about  sshn(ji,jj+1) -  sshn(ji,jj  ) = 0, it won't happen ! here
+               zcpy(ji,jj) = ABS( (sshn(ji,jj+1) + ht_0(ji,jj+1) - sshn(ji,jj) - ht_0(ji,jj)) &
+                    &             / (sshn(ji,jj+1) - sshn(ji,jj  )) )
+               zcpy(ji,jj) = MAX(  0._wp , MIN( zcpy(ji,jj) , 1.0_wp )  )
+            ELSE
+               zcpy(ji,jj) = 0._wp
+            ENDIF
+         END DO
+      END DO
+            
+   END SUBROUTINE wad_spg
+     
+
+
+   SUBROUTINE dyn_drg_init( pu_RHSi, pv_RHSi, pCdU_u, pCdU_v )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_drg_init  ***
+      !!                    
+      !! ** Purpose : - add the baroclinic top/bottom drag contribution to 
+      !!              the baroclinic part of the barotropic RHS
+      !!              - compute the barotropic drag coefficients
+      !!
+      !! ** Method  :   computation done over the INNER domain only 
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pu_RHSi, pv_RHSi   ! baroclinic part of the barotropic RHS
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) ::   pCdU_u , pCdU_v    ! barotropic drag coefficients
+      !
+      INTEGER  ::   ji, jj   ! dummy loop indices
+      INTEGER  ::   ikbu, ikbv, iktu, iktv
+      REAL(wp) ::   zztmp
+      REAL(wp), DIMENSION(jpi,jpj) ::   zu_i, zv_i
+      !!----------------------------------------------------------------------
+      !
+      !                    !==  Set the barotropic drag coef.  ==!
+      !
+      IF( ln_isfcav ) THEN          ! top+bottom friction (ocean cavities)
+         
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1     ! INNER domain
+               pCdU_u(ji,jj) = r1_2*( rCdU_bot(ji+1,jj)+rCdU_bot(ji,jj) + rCdU_top(ji+1,jj)+rCdU_top(ji,jj) )
+               pCdU_v(ji,jj) = r1_2*( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj) + rCdU_top(ji,jj+1)+rCdU_top(ji,jj) )
+            END DO
+         END DO
+      ELSE                          ! bottom friction only
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1  ! INNER domain
+               pCdU_u(ji,jj) = r1_2*( rCdU_bot(ji+1,jj)+rCdU_bot(ji,jj) )
+               pCdU_v(ji,jj) = r1_2*( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj) )
+            END DO
+         END DO
+      ENDIF
+      !
+      !                    !==  BOTTOM stress contribution from baroclinic velocities  ==!
+      !
+      IF( ln_bt_fw ) THEN                 ! FORWARD integration: use NOW bottom baroclinic velocities
+         
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1  ! INNER domain
+               ikbu = mbku(ji,jj)       
+               ikbv = mbkv(ji,jj)    
+               zu_i(ji,jj) = un(ji,jj,ikbu) - un_b(ji,jj)
+               zv_i(ji,jj) = vn(ji,jj,ikbv) - vn_b(ji,jj)
+            END DO
+         END DO
+      ELSE                                ! CENTRED integration: use BEFORE bottom baroclinic velocities
+         
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1   ! INNER domain
+               ikbu = mbku(ji,jj)       
+               ikbv = mbkv(ji,jj)    
+               zu_i(ji,jj) = ub(ji,jj,ikbu) - ub_b(ji,jj)
+               zv_i(ji,jj) = vb(ji,jj,ikbv) - vb_b(ji,jj)
+            END DO
+         END DO
+      ENDIF
+      !
+      IF( ln_wd_il ) THEN      ! W/D : use the "clipped" bottom friction   !!gm   explain WHY, please !
+         zztmp = -1._wp / rdtbt
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1    ! INNER domain
+               pu_RHSi(ji,jj) = pu_RHSi(ji,jj) + zu_i(ji,jj) *  wdrampu(ji,jj) * MAX(                                 & 
+                    &                              r1_hu_n(ji,jj) * r1_2*( rCdU_bot(ji+1,jj)+rCdU_bot(ji,jj) ) , zztmp  )
+               pv_RHSi(ji,jj) = pv_RHSi(ji,jj) + zv_i(ji,jj) *  wdrampv(ji,jj) * MAX(                                 & 
+                    &                              r1_hv_n(ji,jj) * r1_2*( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj) ) , zztmp  )
+            END DO
+         END DO
+      ELSE                    ! use "unclipped" drag (even if explicit friction is used in 3D calculation)
+         
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1    ! INNER domain
+               pu_RHSi(ji,jj) = pu_RHSi(ji,jj) + r1_hu_n(ji,jj) * r1_2*( rCdU_bot(ji+1,jj)+rCdU_bot(ji,jj) ) * zu_i(ji,jj)
+               pv_RHSi(ji,jj) = pv_RHSi(ji,jj) + r1_hv_n(ji,jj) * r1_2*( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj) ) * zv_i(ji,jj)
+            END DO
+         END DO
+      END IF
+      !
+      !                    !==  TOP stress contribution from baroclinic velocities  ==!   (no W/D case)
+      !
+      IF( ln_isfcav ) THEN
+         !
+         IF( ln_bt_fw ) THEN                ! FORWARD integration: use NOW top baroclinic velocity
+            
+            DO jj = 2, jpjm1
+               DO ji = 2, jpim1   ! INNER domain
+                  iktu = miku(ji,jj)
+                  iktv = mikv(ji,jj)
+                  zu_i(ji,jj) = un(ji,jj,iktu) - un_b(ji,jj)
+                  zv_i(ji,jj) = vn(ji,jj,iktv) - vn_b(ji,jj)
+               END DO
+            END DO
+         ELSE                                ! CENTRED integration: use BEFORE top baroclinic velocity
+            
+            DO jj = 2, jpjm1
+               DO ji = 2, jpim1      ! INNER domain
+                  iktu = miku(ji,jj)
+                  iktv = mikv(ji,jj)
+                  zu_i(ji,jj) = ub(ji,jj,iktu) - ub_b(ji,jj)
+                  zv_i(ji,jj) = vb(ji,jj,iktv) - vb_b(ji,jj)
+               END DO
+            END DO
+         ENDIF
+         !
+         !                    ! use "unclipped" top drag (even if explicit friction is used in 3D calculation)
+         
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1    ! INNER domain
+               pu_RHSi(ji,jj) = pu_RHSi(ji,jj) + r1_hu_n(ji,jj) * r1_2*( rCdU_top(ji+1,jj)+rCdU_top(ji,jj) ) * zu_i(ji,jj)
+               pv_RHSi(ji,jj) = pv_RHSi(ji,jj) + r1_hv_n(ji,jj) * r1_2*( rCdU_top(ji,jj+1)+rCdU_top(ji,jj) ) * zv_i(ji,jj)
+            END DO
+         END DO
+         !
+      ENDIF
+      !
+   END SUBROUTINE dyn_drg_init
+
+   SUBROUTINE ts_bck_interp( jn, ll_init,       &   ! <== in
+      &                      za0, za1, za2, za3 )   ! ==> out
+      !!----------------------------------------------------------------------
+      INTEGER ,INTENT(in   ) ::   jn                   ! index of sub time step
+      LOGICAL ,INTENT(in   ) ::   ll_init              !
+      REAL(wp),INTENT(  out) ::   za0, za1, za2, za3   ! Half-step back interpolation coefficient
+      !
+      REAL(wp) ::   zepsilon, zgamma                   !   -      -
+      !!----------------------------------------------------------------------
+      !                             ! set Half-step back interpolation coefficient
+      IF    ( jn==1 .AND. ll_init ) THEN   !* Forward-backward
+         za0 = 1._wp                        
+         za1 = 0._wp                           
+         za2 = 0._wp
+         za3 = 0._wp
+      ELSEIF( jn==2 .AND. ll_init ) THEN   !* AB2-AM3 Coefficients; bet=0 ; gam=-1/6 ; eps=1/12
+         za0 = 1.0833333333333_wp                 ! za0 = 1-gam-eps
+         za1 =-0.1666666666666_wp                 ! za1 = gam
+         za2 = 0.0833333333333_wp                 ! za2 = eps
+         za3 = 0._wp              
+      ELSE                                 !* AB3-AM4 Coefficients; bet=0.281105 ; eps=0.013 ; gam=0.0880 
+         IF( rn_bt_alpha == 0._wp ) THEN      ! Time diffusion  
+            za0 = 0.614_wp                        ! za0 = 1/2 +   gam + 2*eps
+            za1 = 0.285_wp                        ! za1 = 1/2 - 2*gam - 3*eps
+            za2 = 0.088_wp                        ! za2 = gam
+            za3 = 0.013_wp                        ! za3 = eps
+         ELSE                                 ! no time diffusion
+            zepsilon = 0.00976186_wp - 0.13451357_wp * rn_bt_alpha
+            zgamma   = 0.08344500_wp - 0.51358400_wp * rn_bt_alpha
+            za0 = 0.5_wp + zgamma + 2._wp * rn_bt_alpha + 2._wp * zepsilon
+            za1 = 1._wp - za0 - zgamma - zepsilon
+            za2 = zgamma
+            za3 = zepsilon
+         ENDIF 
+      ENDIF
+   END SUBROUTINE ts_bck_interp
+
+
    !!======================================================================
 END MODULE dynspg_ts
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynvor.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynvor.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/dynvor.F90	(revision 12143)
@@ -851,8 +851,8 @@
       REWIND( numnam_ref )              ! Namelist namdyn_vor in reference namelist : Vorticity scheme options
       READ  ( numnam_ref, namdyn_vor, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_vor in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_vor in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namdyn_vor in configuration namelist : Vorticity scheme options
       READ  ( numnam_cfg, namdyn_vor, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_vor in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_vor in configuration namelist' )
       IF(lwm) WRITE ( numond, namdyn_vor )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/sshwzv.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/sshwzv.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/sshwzv.F90	(revision 12143)
@@ -9,4 +9,5 @@
    !!             -   !  2010-09  (D.Storkey and E.O'Dea) bug fixes for BDY module
    !!            3.3  !  2011-10  (M. Leclair) split former ssh_wzv routine and remove all vvl related work
+   !!            4.0  !  2018-12  (A. Coward) add mixed implicit/explicit advection
    !!----------------------------------------------------------------------
 
@@ -286,5 +287,7 @@
       !!            :   wi      : now vertical velocity (for implicit treatment)
       !!
-      !! Reference  : Leclair, M., and G. Madec, 2009, Ocean Modelling.
+      !! Reference  : Shchepetkin, A. F. (2015): An adaptive, Courant-number-dependent
+      !!              implicit scheme for vertical advection in oceanic modeling. 
+      !!              Ocean Modelling, 91, 38-69.
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt   ! time step
@@ -293,5 +296,5 @@
       REAL(wp)             ::   zCu, zcff, z1_e3t                     ! local scalars
       REAL(wp) , PARAMETER ::   Cu_min = 0.15_wp                      ! local parameters
-      REAL(wp) , PARAMETER ::   Cu_max = 0.27                         ! local parameters
+      REAL(wp) , PARAMETER ::   Cu_max = 0.30_wp                      ! local parameters
       REAL(wp) , PARAMETER ::   Cu_cut = 2._wp*Cu_max - Cu_min        ! local parameters
       REAL(wp) , PARAMETER ::   Fcu    = 4._wp*Cu_max*(Cu_max-Cu_min) ! local parameters
@@ -307,20 +310,40 @@
       ENDIF
       !
-      !
-      DO jk = 1, jpkm1            ! calculate Courant numbers
-         DO jj = 2, jpjm1
-            DO ji = 2, fs_jpim1   ! vector opt.
-               z1_e3t = 1._wp / e3t_n(ji,jj,jk)
-               Cu_adv(ji,jj,jk) = 2._wp * rdt * ( ( MAX( wn(ji,jj,jk) , 0._wp ) - MIN( wn(ji,jj,jk+1) , 0._wp ) )   &  ! 2*rdt and not r2dt (for restartability)
-                  &                             + ( MAX( e2u(ji  ,jj)*e3u_n(ji  ,jj,jk)*un(ji  ,jj,jk), 0._wp ) -   &
-                  &                                 MIN( e2u(ji-1,jj)*e3u_n(ji-1,jj,jk)*un(ji-1,jj,jk), 0._wp ) )   &
-                  &                               * r1_e1e2t(ji,jj)                                                 &
-                  &                             + ( MAX( e1v(ji,jj  )*e3v_n(ji,jj  ,jk)*vn(ji,jj  ,jk), 0._wp ) -   &
-                  &                                 MIN( e1v(ji,jj-1)*e3v_n(ji,jj-1,jk)*vn(ji,jj-1,jk), 0._wp ) )   &
-                  &                               * r1_e1e2t(ji,jj)                                                 &
-                  &                             ) * z1_e3t
+      ! Calculate Courant numbers
+      IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = 2, fs_jpim1   ! vector opt.
+                  z1_e3t = 1._wp / e3t_n(ji,jj,jk)
+                  ! 2*rdt and not r2dt (for restartability)
+                  Cu_adv(ji,jj,jk) = 2._wp * rdt * ( ( MAX( wn(ji,jj,jk) , 0._wp ) - MIN( wn(ji,jj,jk+1) , 0._wp ) )                       &  
+                     &                             + ( MAX( e2u(ji  ,jj)*e3u_n(ji  ,jj,jk)*un(ji  ,jj,jk) + un_td(ji  ,jj,jk), 0._wp ) -   &
+                     &                                 MIN( e2u(ji-1,jj)*e3u_n(ji-1,jj,jk)*un(ji-1,jj,jk) + un_td(ji-1,jj,jk), 0._wp ) )   &
+                     &                               * r1_e1e2t(ji,jj)                                                                     &
+                     &                             + ( MAX( e1v(ji,jj  )*e3v_n(ji,jj  ,jk)*vn(ji,jj  ,jk) + vn_td(ji,jj  ,jk), 0._wp ) -   &
+                     &                                 MIN( e1v(ji,jj-1)*e3v_n(ji,jj-1,jk)*vn(ji,jj-1,jk) + vn_td(ji,jj-1,jk), 0._wp ) )   &
+                     &                               * r1_e1e2t(ji,jj)                                                                     &
+                     &                             ) * z1_e3t
+               END DO
             END DO
          END DO
-      END DO
+      ELSE
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = 2, fs_jpim1   ! vector opt.
+                  z1_e3t = 1._wp / e3t_n(ji,jj,jk)
+                  ! 2*rdt and not r2dt (for restartability)
+                  Cu_adv(ji,jj,jk) = 2._wp * rdt * ( ( MAX( wn(ji,jj,jk) , 0._wp ) - MIN( wn(ji,jj,jk+1) , 0._wp ) )   & 
+                     &                             + ( MAX( e2u(ji  ,jj)*e3u_n(ji  ,jj,jk)*un(ji  ,jj,jk), 0._wp ) -   &
+                     &                                 MIN( e2u(ji-1,jj)*e3u_n(ji-1,jj,jk)*un(ji-1,jj,jk), 0._wp ) )   &
+                     &                               * r1_e1e2t(ji,jj)                                                 &
+                     &                             + ( MAX( e1v(ji,jj  )*e3v_n(ji,jj  ,jk)*vn(ji,jj  ,jk), 0._wp ) -   &
+                     &                                 MIN( e1v(ji,jj-1)*e3v_n(ji,jj-1,jk)*vn(ji,jj-1,jk), 0._wp ) )   &
+                     &                               * r1_e1e2t(ji,jj)                                                 &
+                     &                             ) * z1_e3t
+               END DO
+            END DO
+         END DO
+      ENDIF
       CALL lbc_lnk( 'sshwzv', Cu_adv, 'T', 1. )
       !
@@ -353,5 +376,5 @@
                   wn(ji,jj,jk) = ( 1._wp - zcff ) * wn(ji,jj,jk)
                   !
-                  Cu_adv(ji,jj,jk) = zcff               ! Reuse array to output coefficient
+                  Cu_adv(ji,jj,jk) = zcff               ! Reuse array to output coefficient below and in stp_ctl
                END DO
             END DO
@@ -360,5 +383,5 @@
       ELSE
          ! Fully explicit everywhere
-         Cu_adv(:,:,:) = 0._wp                          ! Reuse array to output coefficient
+         Cu_adv(:,:,:) = 0._wp                          ! Reuse array to output coefficient below and in stp_ctl
          wi    (:,:,:) = 0._wp
       ENDIF
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/wet_dry.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/wet_dry.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/DYN/wet_dry.F90	(revision 12143)
@@ -81,8 +81,8 @@
       REWIND( numnam_ref )              ! Namelist namwad in reference namelist : Parameters for Wetting/Drying
       READ  ( numnam_ref, namwad, IOSTAT = ios, ERR = 905)
-905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namwad in reference namelist', .TRUE.) 
+905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namwad in reference namelist' ) 
       REWIND( numnam_cfg )              ! Namelist namwad in configuration namelist : Parameters for Wetting/Drying
       READ  ( numnam_cfg, namwad, IOSTAT = ios, ERR = 906)
-906   IF( ios >  0 )   CALL ctl_nam ( ios , 'namwad in configuration namelist', .TRUE. )
+906   IF( ios >  0 )   CALL ctl_nam ( ios , 'namwad in configuration namelist' )
       IF(lwm) WRITE ( numond, namwad )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flo4rk.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flo4rk.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flo4rk.F90	(revision 12143)
@@ -4,7 +4,5 @@
    !! Ocean floats :   trajectory computation using a 4th order Runge-Kutta
    !!======================================================================
-#if   defined key_floats
-   !!----------------------------------------------------------------------
-   !!   'key_floats'                                     float trajectories
+   !!
    !!----------------------------------------------------------------------
    !!   flo_4rk        : Compute the geographical position of floats
@@ -445,10 +443,4 @@
    END SUBROUTINE flo_interp
 
-#  else
-   !!----------------------------------------------------------------------
-   !!   No floats                                              Dummy module
-   !!----------------------------------------------------------------------
-#endif
-   
    !!======================================================================
 END MODULE flo4rk
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flo_oce.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flo_oce.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flo_oce.F90	(revision 12143)
@@ -6,8 +6,4 @@
    !! History :   OPA  ! 1999-10  (CLIPPER projet)
    !!   NEMO      1.0  ! 2002-11  (G. Madec, A. Bozec)  F90: Free form and module
-   !!----------------------------------------------------------------------
-#if   defined   key_floats
-   !!----------------------------------------------------------------------
-   !!   'key_floats'                                        drifting floats
    !!----------------------------------------------------------------------
    USE par_oce         ! ocean parameters
@@ -20,8 +16,7 @@
    PUBLIC   flo_oce_alloc   ! Routine called in floats.F90
 
-   LOGICAL, PUBLIC, PARAMETER ::   lk_floats = .TRUE.    !: float flag
-
    !! float parameters
    !! ----------------
+   LOGICAL, PUBLIC ::   ln_floats   !: Activate floats or not
    INTEGER, PUBLIC ::   jpnfl       !: total number of floats during the run
    INTEGER, PUBLIC ::   jpnnewflo   !: number of floats added in a new run
@@ -68,11 +63,4 @@
    END FUNCTION flo_oce_alloc
 
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option :                                 NO drifting floats
-   !!----------------------------------------------------------------------
-   LOGICAL, PUBLIC, PARAMETER ::   lk_floats = .FALSE.   !: float flag
-#endif
-
    !!======================================================================
 END MODULE flo_oce
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/floats.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/floats.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/floats.F90	(revision 12143)
@@ -7,7 +7,5 @@
    !!   NEMO     1.0  ! 2002-06  (A. Bozec)  F90, Free form and module
    !!----------------------------------------------------------------------
-#if   defined   key_floats
-   !!----------------------------------------------------------------------
-   !!   'key_floats'                                     float trajectories
+   !!
    !!----------------------------------------------------------------------
    !!   flo_stp   : float trajectories computation
@@ -30,5 +28,5 @@
 
    PUBLIC   flo_stp    ! routine called by step.F90
-   PUBLIC   flo_init   ! routine called by opa.F90
+   PUBLIC   flo_init   ! routine called by nemogcm.F90
 
    !!----------------------------------------------------------------------
@@ -81,5 +79,5 @@
       INTEGER ::   ios                 ! Local integer output status for namelist read
       !
-      NAMELIST/namflo/ jpnfl, jpnnewflo, ln_rstflo, nn_writefl, nn_stockfl, ln_argo, ln_flork4, ln_ariane, ln_flo_ascii
+      NAMELIST/namflo/ ln_floats, jpnfl, jpnnewflo, ln_rstflo, nn_writefl, nn_stockfl, ln_argo, ln_flork4, ln_ariane, ln_flo_ascii
       !!---------------------------------------------------------------------
       !
@@ -90,9 +88,9 @@
       REWIND( numnam_ref )              ! Namelist namflo in reference namelist : Floats
       READ  ( numnam_ref, namflo, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namflo in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namflo in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namflo in configuration namelist : Floats
       READ  ( numnam_cfg, namflo, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namflo in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namflo in configuration namelist' )
       IF(lwm) WRITE ( numond, namflo )
       !
@@ -100,55 +98,44 @@
          WRITE(numout,*)
          WRITE(numout,*) '         Namelist floats :'
-         WRITE(numout,*) '            number of floats                      jpnfl        = ', jpnfl
-         WRITE(numout,*) '            number of new floats                  jpnflnewflo  = ', jpnnewflo
-         WRITE(numout,*) '            restart                               ln_rstflo    = ', ln_rstflo
-         WRITE(numout,*) '            frequency of float output file        nn_writefl   = ', nn_writefl
-         WRITE(numout,*) '            frequency of float restart file       nn_stockfl   = ', nn_stockfl
-         WRITE(numout,*) '            Argo type floats                      ln_argo      = ', ln_argo
-         WRITE(numout,*) '            Computation of T trajectories         ln_flork4    = ', ln_flork4
-         WRITE(numout,*) '            Use of ariane convention              ln_ariane    = ', ln_ariane
-         WRITE(numout,*) '            ascii output (T) or netcdf output (F) ln_flo_ascii = ', ln_flo_ascii
+         WRITE(numout,*) '            Activate floats or not                   ln_floats    = ', ln_floats
+         WRITE(numout,*) '               number of floats                      jpnfl        = ', jpnfl
+         WRITE(numout,*) '               number of new floats                  jpnflnewflo  = ', jpnnewflo
+         WRITE(numout,*) '               restart                               ln_rstflo    = ', ln_rstflo
+         WRITE(numout,*) '               frequency of float output file        nn_writefl   = ', nn_writefl
+         WRITE(numout,*) '               frequency of float restart file       nn_stockfl   = ', nn_stockfl
+         WRITE(numout,*) '               Argo type floats                      ln_argo      = ', ln_argo
+         WRITE(numout,*) '               Computation of T trajectories         ln_flork4    = ', ln_flork4
+         WRITE(numout,*) '               Use of ariane convention              ln_ariane    = ', ln_ariane
+         WRITE(numout,*) '               ascii output (T) or netcdf output (F) ln_flo_ascii = ', ln_flo_ascii
 
       ENDIF
       !
-      !                             ! allocate floats arrays
-      IF( flo_oce_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'flo_init : unable to allocate arrays' )
-      !
-      !                             ! allocate flodom arrays
-      IF( flo_dom_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'flo_dom : unable to allocate arrays' )
-      !
-      !                             ! allocate flowri arrays
-      IF( flo_wri_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'flo_wri : unable to allocate arrays' )
-      !
-      !                             ! allocate florst arrays
-      IF( flo_rst_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'flo_rst : unable to allocate arrays' )
-      !
-      jpnrstflo = jpnfl-jpnnewflo   ! memory allocation 
-      !
-      DO jfl = 1, jpnfl             ! vertical axe for netcdf IOM ouput
-         nfloat(jfl) = jfl 
-      END DO
-      !
-      CALL flo_dom                  ! compute/read initial position of floats
-      !
-      wb(:,:,:) = wn(:,:,:)         ! set wb for computation of floats trajectories at the first time step
+      IF( ln_floats ) THEN
+         !                             ! allocate floats arrays
+         IF( flo_oce_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'flo_init : unable to allocate arrays' )
+         !
+         !                             ! allocate flodom arrays
+         IF( flo_dom_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'flo_dom : unable to allocate arrays' )
+         !
+         !                             ! allocate flowri arrays
+         IF( flo_wri_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'flo_wri : unable to allocate arrays' )
+         !
+         !                             ! allocate florst arrays
+         IF( flo_rst_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'flo_rst : unable to allocate arrays' )
+         !
+         jpnrstflo = jpnfl-jpnnewflo   ! memory allocation 
+         !
+         DO jfl = 1, jpnfl             ! vertical axe for netcdf IOM ouput
+            nfloat(jfl) = jfl 
+         END DO
+         !
+         CALL flo_dom                  ! compute/read initial position of floats
+         !
+         wb(:,:,:) = wn(:,:,:)         ! set wb for computation of floats trajectories at the first time step
+         !
+      ENDIF
       !
    END SUBROUTINE flo_init
 
-#  else
-   !!----------------------------------------------------------------------
-   !!   Default option :                                       Empty module
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE flo_stp( kt )          ! Empty routine
-      IMPLICIT NONE
-      INTEGER, INTENT( in ) :: kt
-      WRITE(*,*) 'flo_stp: You should not have seen this print! error?', kt
-   END SUBROUTINE flo_stp
-   SUBROUTINE flo_init          ! Empty routine
-      IMPLICIT NONE
-   END SUBROUTINE flo_init
-#endif
-
    !!======================================================================
  END MODULE floats
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/floblk.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/floblk.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/floblk.F90	(revision 12143)
@@ -4,7 +4,5 @@
    !! Ocean floats :   trajectory computation
    !!======================================================================
-#if   defined key_floats
-   !!----------------------------------------------------------------------
-   !!   'key_floats'                                     float trajectories
+   !!
    !!----------------------------------------------------------------------
    !!    flotblk     : compute float trajectories with Blanke algorithme
@@ -369,13 +367,4 @@
    END SUBROUTINE flo_blk
 
-#  else
-   !!----------------------------------------------------------------------
-   !!   Default option                                         Empty module
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE flo_blk                  ! Empty routine
-   END SUBROUTINE flo_blk 
-#endif
-   
    !!======================================================================
 END MODULE floblk 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flodom.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flodom.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flodom.F90	(revision 12143)
@@ -6,8 +6,4 @@
    !! History :  OPA  ! 1998-07 (Y.Drillet, CLIPPER)  Original code
    !!  NEMO      3.3  ! 2011-09 (C.Bricaud,S.Law-Chune Mercator-Ocean): add ARIANE convention + comsecitc changes
-   !!----------------------------------------------------------------------
-#if   defined key_floats
-   !!----------------------------------------------------------------------
-   !!   'key_floats'                                     float trajectories
    !!----------------------------------------------------------------------
    !!   flo_dom               : initialization of floats
@@ -437,5 +433,5 @@
       IF( ABS(dlx) > 1.0_wp ) dlx = 1.0_wp
       !
-      dld = ATAN(DSQRT( 1._wp * ( 1._wp-dlx )/( 1._wp+dlx ) )) * 222.24_wp / dls
+      dld = ATAN(SQRT( 1._wp * ( 1._wp-dlx )/( 1._wp+dlx ) )) * 222.24_wp / dls
       flo_dstnce = dld * 1000._wp
       !
@@ -455,15 +451,4 @@
    END FUNCTION flo_dom_alloc
 
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option                                         Empty module
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE flo_dom                 ! Empty routine
-         WRITE(*,*) 'flo_dom: : You should not have seen this print! error?'
-   END SUBROUTINE flo_dom
-#endif
-
    !!======================================================================
 END MODULE flodom
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/florst.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/florst.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/florst.F90	(revision 12143)
@@ -8,8 +8,4 @@
    !!   NEMO      1.0  !  2002-10  (A. Bozec)  F90 : Free form and module
    !!             3.2  !  2010-08  (slaw, cbricaud): netcdf outputs and others 
-   !!----------------------------------------------------------------------
-#if   defined key_floats
-   !!----------------------------------------------------------------------
-   !!   'key_floats'                                     float trajectories
    !!----------------------------------------------------------------------
    USE flo_oce         ! ocean drifting floats
@@ -125,13 +121,4 @@
    END SUBROUTINE flo_rst
 
-#  else
-   !!----------------------------------------------------------------------
-   !!   Default option                                         Empty module
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE flo_rst                 ! Empty routine
-   END SUBROUTINE flo_rst
-#endif
-
    !!=======================================================================
 END MODULE florst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flowri.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flowri.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/FLO/flowri.F90	(revision 12143)
@@ -10,8 +10,4 @@
    !!   NEMO      1.0  !  2002-10  (A. Bozec)  F90 : Free form and module
    !!             3.2  !  2010-08  (slaw, cbricaud): netcdf outputs and others 
-   !!----------------------------------------------------------------------
-#if   defined key_floats
-   !!----------------------------------------------------------------------
-   !!   'key_floats'                                     float trajectories
    !!----------------------------------------------------------------------
    USE flo_oce         ! ocean drifting floats
@@ -179,5 +175,5 @@
                CALL ctl_opn( numflo, 'trajec_float', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
                irecflo = NINT( (nitend-nn_it000) / FLOAT(nn_writefl) )
-               WRITE(numflo,*)cexper,no,irecflo,jpnfl,nn_writefl
+               WRITE(numflo,*) cexper, irecflo, jpnfl, nn_writefl
             ENDIF
 
@@ -225,5 +221,5 @@
                clname=TRIM(clname)//".nc"
 
-               CALL fliocrfd( clname , (/ 'ntraj' , 't' /), (/ jpnfl , -1  /) , numflo )
+               CALL fliocrfd( clname , (/'ntraj' , '    t' /), (/ jpnfl , -1/) , numflo )
    
                CALL fliodefv( numflo, 'traj_lon'    , (/1,2/), v_t=flio_r8, long_name="Longitude"           , units="degrees_east"  )
@@ -255,12 +251,11 @@
 
                istart = (/jfl,irec/)
-               icfl   = INT( tpkfl(jfl) )            ! K-index of the nearest point before
-
-               CALL flioputv( numflo , 'traj_lon'    , zlon(jfl)        , start=istart )
-               CALL flioputv( numflo , 'traj_lat'    , zlat(jfl)        , start=istart )  
-               CALL flioputv( numflo , 'traj_depth'  , zdep(jfl)        , start=istart )  
-               CALL flioputv( numflo , 'traj_temp'   , ztemp(icfl,jfl)  , start=istart )  
-               CALL flioputv( numflo , 'traj_salt'   , zsal(icfl,jfl)   , start=istart )  
-               CALL flioputv( numflo , 'traj_dens'   , zrho(icfl,jfl)   , start=istart )  
+
+               CALL flioputv( numflo , 'traj_lon'    , zlon(jfl), start=istart )
+               CALL flioputv( numflo , 'traj_lat'    , zlat(jfl), start=istart )  
+               CALL flioputv( numflo , 'traj_depth'  , zdep(jfl), start=istart )  
+               CALL flioputv( numflo , 'traj_temp'   , ztem(jfl), start=istart )  
+               CALL flioputv( numflo , 'traj_salt'   , zsal(jfl), start=istart )  
+               CALL flioputv( numflo , 'traj_dens'   , zrho(jfl), start=istart )  
 
             ENDDO
@@ -277,14 +272,4 @@
    END SUBROUTINE flo_wri
 
-
-#  else
-   !!----------------------------------------------------------------------
-   !!   Default option                                         Empty module
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE flo_wri                 ! Empty routine
-   END SUBROUTINE flo_wri
-#endif
-
    !!=======================================================================
 END MODULE flowri
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icbini.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icbini.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icbini.F90	(revision 12143)
@@ -406,8 +406,8 @@
       REWIND( numnam_ref )              ! Namelist namberg in reference namelist : Iceberg parameters
       READ  ( numnam_ref, namberg, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namberg in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namberg in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namberg in configuration namelist : Iceberg parameters
       READ  ( numnam_cfg, namberg, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namberg in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namberg in configuration namelist' )
       IF(lwm) WRITE ( numond, namberg )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icblbc.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icblbc.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icblbc.F90	(revision 12143)
@@ -278,5 +278,5 @@
          CALL mppsend( 12, zwebergs(1), 1, ipe_E, iml_req1)
          CALL mpprecv( 11, zewbergs(2), 1, ipe_E )
-         IF( l_isend ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
+         CALL mpi_wait( iml_req1, iml_stat, iml_err )
          ibergs_rcvd_from_e = INT( zewbergs(2) )
       CASE(  0 )
@@ -287,6 +287,6 @@
          CALL mpprecv( 11, zewbergs(2), 1, ipe_E )
          CALL mpprecv( 12, zwebergs(2), 1, ipe_W )
-         IF( l_isend ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
-         IF( l_isend ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
+         CALL mpi_wait( iml_req2, iml_stat, iml_err )
+         CALL mpi_wait( iml_req3, iml_stat, iml_err )
          ibergs_rcvd_from_e = INT( zewbergs(2) )
          ibergs_rcvd_from_w = INT( zwebergs(2) )
@@ -295,5 +295,5 @@
          CALL mppsend( 11, zewbergs(1), 1, ipe_W, iml_req4)
          CALL mpprecv( 12, zwebergs(2), 1, ipe_W )
-         IF( l_isend ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
+         CALL mpi_wait( iml_req4, iml_stat, iml_err )
          ibergs_rcvd_from_w = INT( zwebergs(2) )
       END SELECT
@@ -310,5 +310,5 @@
             CALL mpprecv( 13, ibuffer_e%data, ibergs_rcvd_from_e*jp_buffer_width )
          ENDIF
-         IF( ibergs_to_send_e > 0 .AND. l_isend ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
+         IF( ibergs_to_send_e > 0 ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
          DO i = 1, ibergs_rcvd_from_e
             IF( nn_verbose_level >= 4 ) THEN
@@ -329,6 +329,6 @@
             CALL mpprecv( 14, ibuffer_w%data, ibergs_rcvd_from_w*jp_buffer_width )
          ENDIF
-         IF( ibergs_to_send_w > 0 .AND. l_isend ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
-         IF( ibergs_to_send_e > 0 .AND. l_isend ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
+         IF( ibergs_to_send_w > 0 ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
+         IF( ibergs_to_send_e > 0 ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
          DO i = 1, ibergs_rcvd_from_e
             IF( nn_verbose_level >= 4 ) THEN
@@ -351,5 +351,5 @@
             CALL mpprecv( 14, ibuffer_w%data, ibergs_rcvd_from_w*jp_buffer_width )
          ENDIF
-         IF( ibergs_to_send_w > 0 .AND. l_isend ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
+         IF( ibergs_to_send_w > 0 ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
          DO i = 1, ibergs_rcvd_from_w
             IF( nn_verbose_level >= 4 ) THEN
@@ -409,5 +409,5 @@
          CALL mppsend( 16, zsnbergs(1), 1, ipe_N, iml_req1)
          CALL mpprecv( 15, znsbergs(2), 1, ipe_N )
-         IF( l_isend ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
+         CALL mpi_wait( iml_req1, iml_stat, iml_err )
          ibergs_rcvd_from_n = INT( znsbergs(2) )
       CASE(  0 )
@@ -418,6 +418,6 @@
          CALL mpprecv( 15, znsbergs(2), 1, ipe_N )
          CALL mpprecv( 16, zsnbergs(2), 1, ipe_S )
-         IF( l_isend ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
-         IF( l_isend ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
+         CALL mpi_wait( iml_req2, iml_stat, iml_err )
+         CALL mpi_wait( iml_req3, iml_stat, iml_err )
          ibergs_rcvd_from_n = INT( znsbergs(2) )
          ibergs_rcvd_from_s = INT( zsnbergs(2) )
@@ -426,5 +426,5 @@
          CALL mppsend( 15, znsbergs(1), 1, ipe_S, iml_req4)
          CALL mpprecv( 16, zsnbergs(2), 1, ipe_S )
-         IF( l_isend ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
+         CALL mpi_wait( iml_req4, iml_stat, iml_err )
          ibergs_rcvd_from_s = INT( zsnbergs(2) )
       END SELECT
@@ -441,5 +441,5 @@
             CALL mpprecv( 17, ibuffer_n%data, ibergs_rcvd_from_n*jp_buffer_width )
          ENDIF
-         IF( ibergs_to_send_n > 0 .AND. l_isend ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
+         IF( ibergs_to_send_n > 0 ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
          DO i = 1, ibergs_rcvd_from_n
             IF( nn_verbose_level >= 4 ) THEN
@@ -460,6 +460,6 @@
             CALL mpprecv( 18, ibuffer_s%data, ibergs_rcvd_from_s*jp_buffer_width )
          ENDIF
-         IF( ibergs_to_send_s > 0 .AND. l_isend ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
-         IF( ibergs_to_send_n > 0 .AND. l_isend ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
+         IF( ibergs_to_send_s > 0 ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
+         IF( ibergs_to_send_n > 0 ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
          DO i = 1, ibergs_rcvd_from_n
             IF( nn_verbose_level >= 4 ) THEN
@@ -482,5 +482,5 @@
             CALL mpprecv( 18, ibuffer_s%data, ibergs_rcvd_from_s*jp_buffer_width )
          ENDIF
-         IF( ibergs_to_send_s > 0 .AND. l_isend ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
+         IF( ibergs_to_send_s > 0 ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
          DO i = 1, ibergs_rcvd_from_s
             IF( nn_verbose_level >= 4 ) THEN
@@ -669,6 +669,5 @@
             ifldproc = nicbfldproc(jn)
             IF( ifldproc == narea ) CYCLE
-
-            IF( l_isend ) CALL mpi_wait( nicbfldreq(jn), iml_stat, iml_err )
+            CALL mpi_wait( nicbfldreq(jn), iml_stat, iml_err )
          ENDIF
          !
@@ -770,6 +769,5 @@
             ifldproc = nicbfldproc(jn)
             IF( ifldproc == narea ) CYCLE
-
-            IF( l_isend ) CALL mpi_wait( nicbfldreq(jn), iml_stat, iml_err )
+            CALL mpi_wait( nicbfldreq(jn), iml_stat, iml_err )
          ENDIF
          !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icbrst.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icbrst.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icbrst.F90	(revision 12143)
@@ -131,6 +131,4 @@
       CALL iom_get( ncid, jpdom_unknown, 'kount' , zdata(:) )
       num_bergs(:) = INT(zdata(:))
-      ! Close file
-      CALL iom_close( ncid )
       !
 
@@ -146,4 +144,6 @@
       IF( lwp )   WRITE(numout,'(a,i5,a,i5,a)') 'icebergs, icb_rst_read: there were',ibergs_in_file,   &
          &                                    ' bergs in the restart file and', jn,' bergs have been read'
+      ! Close file
+      CALL iom_close( ncid )
       !
       ! Confirm that all areas have a suitable base for assigning new iceberg
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icbstp.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icbstp.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ICB/icbstp.F90	(revision 12143)
@@ -86,5 +86,5 @@
       !                                   !* write out time
       ll_verbose = .FALSE.
-      IF( nn_verbose_write > 0 .AND. MOD( kt-1 , nn_verbose_write ) == 0 )   ll_verbose = ( nn_verbose_level >= 0 )
+      IF( nn_verbose_write > 0 .AND. MOD( kt-1 , nn_verbose_write ) == 0 )   ll_verbose = ( nn_verbose_level > 0 )
       !
       IF( ll_verbose )   WRITE(numicb,9100) nktberg, ndastp, nsec_day
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/in_out_manager.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/in_out_manager.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/in_out_manager.F90	(revision 12143)
@@ -80,7 +80,4 @@
    INTEGER       ::   nleapy                      !: Leap year calendar flag (0/1 or 30)
    INTEGER       ::   ninist                      !: initial state output flag (0/1)
-   INTEGER       ::   nwrite                      !: model standard output frequency
-   INTEGER       ::   nstock                      !: restart file frequency
-   INTEGER, DIMENSION(10) :: nstocklist           !: restart dump times
 
    !!----------------------------------------------------------------------
@@ -167,6 +164,4 @@
    CHARACTER(lc) ::   ctmp7, ctmp8, ctmp9   !: temporary characters 7 to 9
    CHARACTER(lc) ::   ctmp10                !: temporary character 10
-   CHARACTER(lc) ::   cform_err = "(/,' ===>>> : E R R O R',     /,'         ===========',/)"       !:
-   CHARACTER(lc) ::   cform_war = "(/,' ===>>> : W A R N I N G', /,'         ===============',/)"   !:
    LOGICAL       ::   lwm      = .FALSE.    !: boolean : true on the 1st processor only (always)
    LOGICAL       ::   lwp      = .FALSE.    !: boolean : true on the 1st processor only .OR. ln_ctl
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/iom.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/iom.F90	(revision 12143)
@@ -58,5 +58,5 @@
    PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get
    PUBLIC iom_chkatt, iom_getatt, iom_putatt, iom_getszuld, iom_rstput, iom_delay_rst, iom_put
-   PUBLIC iom_use, iom_context_finalize
+   PUBLIC iom_use, iom_context_finalize, iom_miss_val
 
    PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
@@ -212,8 +212,5 @@
           CALL iom_set_axis_attr( "depthv", bounds=zw_bnds )
           CALL iom_set_axis_attr( "depthw", bounds=zt_bnds )
-          !
-# if defined key_floats
           CALL iom_set_axis_attr( "nfloat", (/ (REAL(ji,wp), ji=1,jpnfl) /) )
-# endif
 # if defined key_si3
           CALL iom_set_axis_attr( "ncatice", (/ (REAL(ji,wp), ji=1,jpl) /) )
@@ -686,5 +683,6 @@
       clname   = trim(cdname)
       IF ( .NOT. Agrif_Root() .AND. .NOT. lliof ) THEN
-         iln    = INDEX(clname,'/') 
+!FUS         iln    = INDEX(clname,'/') 
+         iln    = INDEX(clname,'/',BACK=.true.)  ! FUS: to insert the nest index at the right location within the string, the last / has to be found (search from the right to left)
          cltmpn = clname(1:iln)
          clname = clname(iln+1:LEN_TRIM(clname))
@@ -824,5 +822,5 @@
 
 
-   FUNCTION iom_varid ( kiomid, cdvar, kdimsz, kndims, ldstop )  
+   FUNCTION iom_varid ( kiomid, cdvar, kdimsz, kndims, lduld, ldstop )  
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION  iom_varid  ***
@@ -833,5 +831,6 @@
       CHARACTER(len=*)     , INTENT(in   )           ::   cdvar    ! name of the variable
       INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of each dimension
-      INTEGER,               INTENT(  out), OPTIONAL ::   kndims   ! size of the dimensions
+      INTEGER              , INTENT(  out), OPTIONAL ::   kndims   ! number of dimensions
+      LOGICAL              , INTENT(  out), OPTIONAL ::   lduld    ! true if the last dimension is unlimited (time)
       LOGICAL              , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if looking for non-existing variable (default = .TRUE.)
       !
@@ -863,5 +862,5 @@
                iiv = iiv + 1
                IF( iiv <= jpmax_vars ) THEN
-                  iom_varid = iom_nf90_varid( kiomid, cdvar, iiv, kdimsz, kndims )
+                  iom_varid = iom_nf90_varid( kiomid, cdvar, iiv, kdimsz, kndims, lduld )
                ELSE
                   CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name,   &
@@ -881,4 +880,5 @@
                ENDIF
                IF( PRESENT(kndims) )  kndims = iom_file(kiomid)%ndims(iiv)
+               IF( PRESENT( lduld) )  lduld  = iom_file(kiomid)%luld( iiv)
             ENDIF
          ENDIF
@@ -1259,9 +1259,9 @@
                !--- overlap areas and extra hallows (mpp)
                IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN
-                  CALL lbc_lnk( 'iom', pv_r2d,'Z',-999.,'no0' )
+                  CALL lbc_lnk( 'iom', pv_r2d,'Z', -999., kfillmode = jpfillnothing )
                ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN
                   ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension
                   IF( icnt(3) == inlev ) THEN
-                     CALL lbc_lnk( 'iom', pv_r3d,'Z',-999.,'no0' )
+                     CALL lbc_lnk( 'iom', pv_r3d,'Z', -999., kfillmode = jpfillnothing )
                   ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...)
                      DO jj = nlcj+1, jpj   ;   pv_r3d(1:nlci, jj, :) = pv_r3d(1:nlci, nlej, :)   ;   END DO
@@ -1288,5 +1288,5 @@
             CALL xios_recv_field( trim(cdvar), pv_r3d)
             IF(idom /= jpdom_unknown ) then
-                CALL lbc_lnk( 'iom', pv_r3d,'Z',-999.,'no0' )
+                CALL lbc_lnk( 'iom', pv_r3d,'Z', -999., kfillmode = jpfillnothing)
             ENDIF
          ELSEIF( PRESENT(pv_r2d) ) THEN
@@ -1295,5 +1295,5 @@
             CALL xios_recv_field( trim(cdvar), pv_r2d)
             IF(idom /= jpdom_unknown ) THEN
-                CALL lbc_lnk('iom', pv_r2d,'Z',-999.,'no0')
+                CALL lbc_lnk('iom', pv_r2d,'Z',-999., kfillmode = jpfillnothing)
             ENDIF
          ELSEIF( PRESENT(pv_r1d) ) THEN
@@ -1658,9 +1658,9 @@
       CHARACTER(LEN=*), INTENT(in) ::   cdname
       REAL(wp)        , INTENT(in) ::   pfield0d
-      REAL(wp)        , DIMENSION(jpi,jpj) ::   zz     ! masson
+!!      REAL(wp)        , DIMENSION(jpi,jpj) ::   zz     ! masson
 #if defined key_iomput
-      zz(:,:)=pfield0d
-      CALL xios_send_field(cdname, zz)
-      !CALL xios_send_field(cdname, (/pfield0d/)) 
+!!clem      zz(:,:)=pfield0d
+!!clem      CALL xios_send_field(cdname, zz)
+      CALL xios_send_field(cdname, (/pfield0d/)) 
 #else
       IF( .FALSE. )   WRITE(numout,*) cdname, pfield0d   ! useless test to avoid compilation warnings
@@ -1968,6 +1968,6 @@
       ! Cell vertices on boundries
       DO jn = 1, 4
-         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,1), cdgrd, 1., pval=999._wp )
-         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp )
+         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,1), cdgrd, 1., pfillval=999._wp )
+         CALL lbc_lnk( 'iom', z_bnds(jn,:,:,2), cdgrd, 1., pfillval=999._wp )
       END DO
       !
@@ -2228,4 +2228,6 @@
       CHARACTER(LEN=20)  ::   clfreq
       CHARACTER(LEN=20)  ::   cldate
+      CHARACTER(LEN=256) ::   cltmpn                 !FUS needed for correct path with AGRIF
+      INTEGER            ::   iln                    !FUS needed for correct path with AGRIF
       INTEGER            ::   idx
       INTEGER            ::   jn
@@ -2310,5 +2312,13 @@
             END DO
             !
-            IF( jn == 1 .AND. TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname)
+!FUS            IF( jn == 1 .AND. TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname)
+!FUS see comment line 700 
+            IF( jn == 1 .AND. TRIM(Agrif_CFixed()) /= '0' ) THEN
+             iln    = INDEX(clname,'/',BACK=.true.)
+             cltmpn = clname(1:iln)
+             clname = clname(iln+1:LEN_TRIM(clname))
+             clname = TRIM(cltmpn)//TRIM(Agrif_CFixed())//'_'//TRIM(clname)
+            ENDIF
+!FUS 
             IF( jn == 1 )   CALL iom_set_file_attr( cdid, name        = clname )
             IF( jn == 2 )   CALL iom_set_file_attr( cdid, name_suffix = clname )
@@ -2378,5 +2388,4 @@
    !!   NOT 'key_iomput'                               a few dummy routines
    !!----------------------------------------------------------------------
-
    SUBROUTINE iom_setkt( kt, cdname )
       INTEGER         , INTENT(in)::   kt 
@@ -2393,8 +2402,5 @@
 
    LOGICAL FUNCTION iom_use( cdname )
-      !!----------------------------------------------------------------------
-      !!----------------------------------------------------------------------
       CHARACTER(LEN=*), INTENT(in) ::   cdname
-      !!----------------------------------------------------------------------
 #if defined key_iomput
       iom_use = xios_field_is_active( cdname )
@@ -2403,5 +2409,16 @@
 #endif
    END FUNCTION iom_use
-   
+
+   SUBROUTINE iom_miss_val( cdname, pmiss_val )
+      CHARACTER(LEN=*), INTENT(in ) ::   cdname
+      REAL(wp)        , INTENT(out) ::   pmiss_val   
+#if defined key_iomput
+      ! get missing value
+      CALL xios_get_field_attr( cdname, default_value = pmiss_val )
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pmiss_val   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_miss_val
+  
    !!======================================================================
 END MODULE iom
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/iom_nf90.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/iom_nf90.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/iom_nf90.F90	(revision 12143)
@@ -187,5 +187,5 @@
 
 
-   FUNCTION iom_nf90_varid ( kiomid, cdvar, kiv, kdimsz, kndims )  
+   FUNCTION iom_nf90_varid ( kiomid, cdvar, kiv, kdimsz, kndims, lduld )  
       !!-----------------------------------------------------------------------
       !!                  ***  FUNCTION  iom_varid  ***
@@ -198,4 +198,5 @@
       INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of the dimensions
       INTEGER,               INTENT(  out), OPTIONAL ::   kndims   ! size of the dimensions
+      LOGICAL              , INTENT(  out), OPTIONAL ::   lduld    ! true if the last dimension is unlimited (time)
       !
       INTEGER                        ::   iom_nf90_varid   ! iom variable Id
@@ -251,4 +252,5 @@
          ENDIF
          IF( PRESENT(kndims) )  kndims = iom_file(kiomid)%ndims(kiv)
+         IF( PRESENT( lduld) )  lduld  = iom_file(kiomid)%luld(kiv)
       ELSE  
          iom_nf90_varid = -1   !   variable not found, return error code: -1
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/restart.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/restart.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/IOM/restart.F90	(revision 12143)
@@ -70,14 +70,16 @@
          IF( ln_rst_list ) THEN
             nrst_lst = 1
-            nitrst = nstocklist( nrst_lst )
+            nitrst = nn_stocklist( nrst_lst )
          ELSE
             nitrst = nitend
          ENDIF
       ENDIF
+      
+      IF( .NOT. ln_rst_list .AND. nn_stock == -1 )   RETURN   ! we will never do any restart
 
       ! frequency-based restart dumping (nn_stock)
-      IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nstock ) == 0 ) THEN   
+      IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nn_stock ) == 0 ) THEN   
          ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment
-         nitrst = kt + nstock - 1                  ! define the next value of nitrst for restart writing
+         nitrst = kt + nn_stock - 1                  ! define the next value of nitrst for restart writing
          IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run
       ENDIF
@@ -85,5 +87,5 @@
       ! we open and define the ocean restart file one time step before writing the data (-> at nitrst - 1)
       ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1
-      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN
+      IF( kt == nitrst - 1 .OR. nn_stock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN
          IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 
             ! beware of the format used to write kt (default is i8.8, that should be large enough...)
@@ -173,6 +175,6 @@
          lrst_oce = .FALSE.
             IF( ln_rst_list ) THEN
-               nrst_lst = MIN(nrst_lst + 1, SIZE(nstocklist,1))
-               nitrst = nstocklist( nrst_lst )
+               nrst_lst = MIN(nrst_lst + 1, SIZE(nn_stocklist,1))
+               nitrst = nn_stocklist( nrst_lst )
             ENDIF
       ENDIF
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfstp.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfstp.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ISF/isfstp.F90	(revision 12143)
@@ -291,9 +291,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_rnf in reference namelist : Runoffs 
       READ  ( numnam_ref, namisf, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namisf in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namisf in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namsbc_rnf in configuration namelist : Runoffs
       READ  ( numnam_cfg, namisf, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namisf in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namisf in configuration namelist' )
       IF(lwm) WRITE ( numond, namisf )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbc_lnk_generic.h90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbc_lnk_generic.h90	(revision 12062)
+++ 	(revision )
@@ -1,117 +1,0 @@
-#if defined MULTI
-#   define NAT_IN(k)                cd_nat(k)   
-#   define SGN_IN(k)                psgn(k)
-#   define F_SIZE(ptab)             kfld
-#   define OPT_K(k)                 ,ipf
-#   if defined DIM_2d
-#      define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D)                , INTENT(inout) ::   ptab(f)
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt2d(i,j)
-#      define K_SIZE(ptab)             1
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D),INTENT(inout)::ptab(f)
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt3d(i,j,k)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt3d,3)
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D),INTENT(inout)::ptab(f)
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt4d(i,j,k,l)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt4d,3)
-#      define L_SIZE(ptab)             SIZE(ptab(1)%pt4d,4)
-#   endif
-#else
-#   define ARRAY_TYPE(i,j,k,l,f)    REAL(wp)                    , INTENT(inout) ::   ARRAY_IN(i,j,k,l,f)
-#   define NAT_IN(k)                cd_nat
-#   define SGN_IN(k)                psgn
-#   define F_SIZE(ptab)             1
-#   define OPT_K(k)                 
-#   if defined DIM_2d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
-#      define K_SIZE(ptab)          1
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k,l)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          SIZE(ptab,4)
-#   endif
-#endif
-
-#if defined MULTI
-   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn, kfld, cd_mpp, pval )
-      INTEGER                     , INTENT(in   ) ::   kfld        ! number of pt3d arrays
-#else
-   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn      , cd_mpp, pval )
-#endif
-      CHARACTER(len=*)            , INTENT(in   ) ::   cdname      ! name of the calling subroutine
-      ARRAY_TYPE(:,:,:,:,:)                                        ! array or pointer of arrays on which the boundary condition is applied
-      CHARACTER(len=1)            , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
-      REAL(wp)                    , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
-      CHARACTER(len=3), OPTIONAL  , INTENT(in   ) ::   cd_mpp      ! fill the overlap area only
-      REAL(wp)        , OPTIONAL  , INTENT(in   ) ::   pval        ! background value (used at closed boundaries)
-      !
-      INTEGER  ::    ji,  jj,  jk,  jl, jh, jf   ! dummy loop indices
-      INTEGER  ::   ipi, ipj, ipk, ipl, ipf      ! dimension of the input array
-      REAL(wp) ::   zland
-      LOGICAL  ::   ll_nfd
-      !!----------------------------------------------------------------------
-      !
-      ipk = K_SIZE(ptab)   ! 3rd dimension
-      ipl = L_SIZE(ptab)   ! 4th    -
-      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
-      !
-      ll_nfd    = jperio==3 .OR. jperio==4 .OR. jperio==5 .OR. jperio==6
-      !
-      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value
-      ELSE                         ;   zland = 0._wp     ! zero by default
-      ENDIF
-
-      ! ------------------------------- !
-      !   standard boundary treatment   !    ! CAUTION: semi-column notation is often impossible
-      ! ------------------------------- !
-      !
-      IF( .NOT. PRESENT( cd_mpp ) ) THEN  !==  standard close or cyclic treatment  ==!
-         !
-         DO jf = 1, ipf                   ! number of arrays to be treated
-            !
-            !                                ! East-West boundaries
-            IF( l_Iperio ) THEN                   !* cyclic
-               ARRAY_IN( 1 ,:,:,:,jf) = ARRAY_IN(jpim1,:,:,:,jf)
-               ARRAY_IN(jpi,:,:,:,jf) = ARRAY_IN(  2  ,:,:,:,jf)
-            ELSE                                   !* closed
-               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN( 1 ,:,:,:,jf) = zland    ! east except F-point
-                                               ARRAY_IN(jpi,:,:,:,jf) = zland    ! west
-            ENDIF
-            !                                ! North-South boundaries
-            IF( l_Jperio ) THEN                   !* cyclic
-               ARRAY_IN(:, 1 ,:,:,jf) = ARRAY_IN(:, jpjm1,:,:,jf)
-               ARRAY_IN(:,jpj,:,:,jf) = ARRAY_IN(:,   2  ,:,:,jf)
-            ELSEIF( ll_nfd ) THEN                  !* north fold
-               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(:, 1 ,:,:,jf) = zland    ! south except F-point
-               CALL lbc_nfd( ptab, NAT_IN(:), SGN_IN(:) OPT_K(:) )                       ! north fold treatment         
-            ELSE                                   !* closed
-               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(:, 1 ,:,:,jf) = zland    ! south except F-point
-                                               ARRAY_IN(:,jpj,:,:,jf) = zland    ! north
-            ENDIF
-            !
-         END DO
-         !
-      ENDIF
-      !
-   END SUBROUTINE ROUTINE_LNK
-
-#undef ARRAY_TYPE
-#undef NAT_IN
-#undef SGN_IN
-#undef ARRAY_IN
-#undef K_SIZE
-#undef L_SIZE
-#undef F_SIZE
-#undef OPT_K
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbc_lnk_multi_generic.h90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbc_lnk_multi_generic.h90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbc_lnk_multi_generic.h90	(revision 12143)
@@ -14,23 +14,27 @@
 #   define PTR_ptab              pt4d
 #endif
-   SUBROUTINE ROUTINE_MULTI( cdname                                                    &
-      &                    , pt1, cdna1, psgn1, pt2, cdna2, psgn2, pt3, cdna3, psgn3   &
-      &                    , pt4, cdna4, psgn4, pt5, cdna5, psgn5, pt6, cdna6, psgn6   &
-      &                    , pt7, cdna7, psgn7, pt8, cdna8, psgn8, pt9, cdna9, psgn9, cd_mpp, pval)
+
+   SUBROUTINE ROUTINE_MULTI( cdname                                                                             &
+      &                    , pt1, cdna1, psgn1, pt2 , cdna2 , psgn2 , pt3 , cdna3 , psgn3 , pt4, cdna4, psgn4   &
+      &                    , pt5, cdna5, psgn5, pt6 , cdna6 , psgn6 , pt7 , cdna7 , psgn7 , pt8, cdna8, psgn8   &
+      &                    , pt9, cdna9, psgn9, pt10, cdna10, psgn10, pt11, cdna11, psgn11                      &
+      &                    , kfillmode, pfillval, lsend, lrecv, ihlcom )
       !!---------------------------------------------------------------------
-      CHARACTER(len=*)   ,                   INTENT(in   ) ::   cdname  ! name of the calling subroutine
-      ARRAY_TYPE(:,:,:,:)          , TARGET, INTENT(inout) ::   pt1     ! arrays on which the lbc is applied
-      ARRAY_TYPE(:,:,:,:), OPTIONAL, TARGET, INTENT(inout) ::   pt2  ,  pt3  , pt4  , pt5  , pt6  , pt7  , pt8  , pt9
-      CHARACTER(len=1)                     , INTENT(in   ) ::   cdna1   ! nature of pt2D. array grid-points
-      CHARACTER(len=1)   , OPTIONAL        , INTENT(in   ) ::   cdna2,  cdna3, cdna4, cdna5, cdna6, cdna7, cdna8, cdna9
-      REAL(wp)                             , INTENT(in   ) ::   psgn1   ! sign used across the north fold
-      REAL(wp)           , OPTIONAL        , INTENT(in   ) ::   psgn2,  psgn3, psgn4, psgn5, psgn6, psgn7, psgn8, psgn9   
-      CHARACTER(len=3)   , OPTIONAL        , INTENT(in   ) ::   cd_mpp  ! fill the overlap area only
-      REAL(wp)           , OPTIONAL        , INTENT(in   ) ::   pval    ! background value (used at closed boundaries)
+      CHARACTER(len=*)   ,                   INTENT(in   ) :: cdname  ! name of the calling subroutine
+      ARRAY_TYPE(:,:,:,:)          , TARGET, INTENT(inout) :: pt1     ! arrays on which the lbc is applied
+      ARRAY_TYPE(:,:,:,:), OPTIONAL, TARGET, INTENT(inout) :: pt2  , pt3  , pt4  , pt5  , pt6  , pt7  , pt8  , pt9  , pt10  , pt11
+      CHARACTER(len=1)                     , INTENT(in   ) :: cdna1   ! nature of pt2D. array grid-points
+      CHARACTER(len=1)   , OPTIONAL        , INTENT(in   ) :: cdna2, cdna3, cdna4, cdna5, cdna6, cdna7, cdna8, cdna9, cdna10, cdna11
+      REAL(wp)                             , INTENT(in   ) :: psgn1   ! sign used across the north fold
+      REAL(wp)           , OPTIONAL        , INTENT(in   ) :: psgn2, psgn3, psgn4, psgn5, psgn6, psgn7, psgn8, psgn9, psgn10, psgn11
+      INTEGER            , OPTIONAL        , INTENT(in   ) :: kfillmode   ! filling method for halo over land (default = constant)
+      REAL(wp)           , OPTIONAL        , INTENT(in   ) :: pfillval    ! background value (used at closed boundaries)
+      LOGICAL, DIMENSION(4), OPTIONAL      , INTENT(in   ) :: lsend, lrecv   ! indicate how communications are to be carried out
+      INTEGER            , OPTIONAL        , INTENT(in   ) :: ihlcom         ! number of ranks and rows to be communicated
       !!
-      INTEGER                         ::   kfld        ! number of elements that will be attributed
-      PTR_TYPE         , DIMENSION(9) ::   ptab_ptr    ! pointer array
-      CHARACTER(len=1) , DIMENSION(9) ::   cdna_ptr    ! nature of ptab_ptr grid-points
-      REAL(wp)         , DIMENSION(9) ::   psgn_ptr    ! sign used across the north fold boundary
+      INTEGER                          ::   kfld        ! number of elements that will be attributed
+      PTR_TYPE         , DIMENSION(11) ::   ptab_ptr    ! pointer array
+      CHARACTER(len=1) , DIMENSION(11) ::   cdna_ptr    ! nature of ptab_ptr grid-points
+      REAL(wp)         , DIMENSION(11) ::   psgn_ptr    ! sign used across the north fold boundary
       !!---------------------------------------------------------------------
       !
@@ -41,14 +45,16 @@
       !
       !                 ! Look if more arrays are added
-      IF( PRESENT(psgn2) )   CALL ROUTINE_LOAD( pt2, cdna2, psgn2, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn3) )   CALL ROUTINE_LOAD( pt3, cdna3, psgn3, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn4) )   CALL ROUTINE_LOAD( pt4, cdna4, psgn4, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn5) )   CALL ROUTINE_LOAD( pt5, cdna5, psgn5, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn6) )   CALL ROUTINE_LOAD( pt6, cdna6, psgn6, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn7) )   CALL ROUTINE_LOAD( pt7, cdna7, psgn7, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn8) )   CALL ROUTINE_LOAD( pt8, cdna8, psgn8, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn9) )   CALL ROUTINE_LOAD( pt9, cdna9, psgn9, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn2 ) )   CALL ROUTINE_LOAD( pt2 , cdna2 , psgn2 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn3 ) )   CALL ROUTINE_LOAD( pt3 , cdna3 , psgn3 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn4 ) )   CALL ROUTINE_LOAD( pt4 , cdna4 , psgn4 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn5 ) )   CALL ROUTINE_LOAD( pt5 , cdna5 , psgn5 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn6 ) )   CALL ROUTINE_LOAD( pt6 , cdna6 , psgn6 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn7 ) )   CALL ROUTINE_LOAD( pt7 , cdna7 , psgn7 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn8 ) )   CALL ROUTINE_LOAD( pt8 , cdna8 , psgn8 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn9 ) )   CALL ROUTINE_LOAD( pt9 , cdna9 , psgn9 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn10) )   CALL ROUTINE_LOAD( pt10, cdna10, psgn10, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn11) )   CALL ROUTINE_LOAD( pt11, cdna11, psgn11, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
       !
-      CALL lbc_lnk_ptr( cdname, ptab_ptr, cdna_ptr, psgn_ptr, kfld, cd_mpp, pval )
+      CALL lbc_lnk_ptr    ( cdname,               ptab_ptr, cdna_ptr, psgn_ptr, kfld, kfillmode, pfillval, lsend, lrecv, ihlcom )
       !
    END SUBROUTINE ROUTINE_MULTI
@@ -72,4 +78,5 @@
       !
    END SUBROUTINE ROUTINE_LOAD
+
 #undef ARRAY_TYPE
 #undef PTR_TYPE
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbc_nfd_nogather_generic.h90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbc_nfd_nogather_generic.h90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbc_nfd_nogather_generic.h90	(revision 12143)
@@ -74,9 +74,5 @@
       !
       ! Security check for further developments
-      IF ( ipf > 1 ) THEN
-        write(6,*) 'lbc_nfd_nogather: multiple fields not allowed. Revise implementation' 
-        write(6,*) 'You should not be there...' 
-        STOP
-      ENDIF
+      IF ( ipf > 1 ) CALL ctl_stop( 'STOP', 'lbc_nfd_nogather: multiple fields not allowed. Revise implementation...' )
       !
       ijpj   = 1    ! index of first modified line 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbclnk.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbclnk.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbclnk.F90	(revision 12143)
@@ -14,8 +14,4 @@
    !!             -   ! 2017-05  (G. Madec) create generic.h90 files to generate all lbc and north fold routines
    !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
-   !!----------------------------------------------------------------------
-   !!   'key_mpp_mpi'             MPI massively parallel processing library
-   !!----------------------------------------------------------------------
    !!           define the generic interfaces of lib_mpp routines
    !!----------------------------------------------------------------------
@@ -23,7 +19,11 @@
    !!   lbc_bdy_lnk   : generic interface for mpp_lnk_bdy_2d and mpp_lnk_bdy_3d routines defined in lib_mpp
    !!----------------------------------------------------------------------
-   USE par_oce        ! ocean dynamics and tracers   
+   USE dom_oce        ! ocean space and time domain
    USE lib_mpp        ! distributed memory computing library
    USE lbcnfd         ! north fold
+   USE in_out_manager ! I/O manager
+
+   IMPLICIT NONE
+   PRIVATE
 
    INTERFACE lbc_lnk
@@ -37,16 +37,28 @@
    END INTERFACE
    !
-   INTERFACE lbc_bdy_lnk
-      MODULE PROCEDURE mpp_lnk_bdy_2d, mpp_lnk_bdy_3d, mpp_lnk_bdy_4d
-   END INTERFACE
-   !
    INTERFACE lbc_lnk_icb
       MODULE PROCEDURE mpp_lnk_2d_icb
    END INTERFACE
 
+   INTERFACE mpp_nfd
+      MODULE PROCEDURE   mpp_nfd_2d    , mpp_nfd_3d    , mpp_nfd_4d
+      MODULE PROCEDURE   mpp_nfd_2d_ptr, mpp_nfd_3d_ptr, mpp_nfd_4d_ptr
+   END INTERFACE
+
    PUBLIC   lbc_lnk       ! ocean/ice lateral boundary conditions
    PUBLIC   lbc_lnk_multi ! modified ocean/ice lateral boundary conditions
-   PUBLIC   lbc_bdy_lnk   ! ocean lateral BDY boundary conditions
    PUBLIC   lbc_lnk_icb   ! iceberg lateral boundary conditions
+
+#if   defined key_mpp_mpi
+!$AGRIF_DO_NOT_TREAT
+   INCLUDE 'mpif.h'
+!$AGRIF_END_DO_NOT_TREAT
+#endif
+
+   INTEGER, PUBLIC, PARAMETER ::   jpfillnothing = 1
+   INTEGER, PUBLIC, PARAMETER ::   jpfillcst     = 2
+   INTEGER, PUBLIC, PARAMETER ::   jpfillcopy    = 3
+   INTEGER, PUBLIC, PARAMETER ::   jpfillperio   = 4
+   INTEGER, PUBLIC, PARAMETER ::   jpfillmpi     = 5
 
    !!----------------------------------------------------------------------
@@ -56,181 +68,4 @@
    !!----------------------------------------------------------------------
 CONTAINS
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option                              shared memory computing
-   !!----------------------------------------------------------------------
-   !!                routines setting the appropriate values
-   !!         on first and last row and column of the global domain
-   !!----------------------------------------------------------------------
-   !!   lbc_lnk_sum_3d: compute sum over the halos on a 3D variable on ocean mesh
-   !!   lbc_lnk_sum_3d: compute sum over the halos on a 2D variable on ocean mesh
-   !!   lbc_lnk       : generic interface for lbc_lnk_3d and lbc_lnk_2d
-   !!   lbc_lnk_3d    : set the lateral boundary condition on a 3D variable on ocean mesh
-   !!   lbc_lnk_2d    : set the lateral boundary condition on a 2D variable on ocean mesh
-   !!   lbc_bdy_lnk   : set the lateral BDY boundary condition
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers   
-   USE dom_oce        ! ocean space and time domain 
-   USE in_out_manager ! I/O manager
-   USE lbcnfd         ! north fold
-
-   IMPLICIT NONE
-   PRIVATE
-
-   INTERFACE lbc_lnk
-      MODULE PROCEDURE   lbc_lnk_2d      , lbc_lnk_3d      , lbc_lnk_4d
-   END INTERFACE
-   INTERFACE lbc_lnk_ptr
-      MODULE PROCEDURE   lbc_lnk_2d_ptr  , lbc_lnk_3d_ptr  , lbc_lnk_4d_ptr
-   END INTERFACE
-   INTERFACE lbc_lnk_multi
-      MODULE PROCEDURE   lbc_lnk_2d_multi, lbc_lnk_3d_multi, lbc_lnk_4d_multi
-   END INTERFACE
-   !
-   INTERFACE lbc_bdy_lnk
-      MODULE PROCEDURE lbc_bdy_lnk_2d, lbc_bdy_lnk_3d, lbc_bdy_lnk_4d
-   END INTERFACE
-   !
-   INTERFACE lbc_lnk_icb
-      MODULE PROCEDURE lbc_lnk_2d_icb
-   END INTERFACE
-   
-   PUBLIC   lbc_lnk       ! ocean/ice  lateral boundary conditions
-   PUBLIC   lbc_lnk_multi ! modified ocean/ice lateral boundary conditions
-   PUBLIC   lbc_bdy_lnk   ! ocean lateral BDY boundary conditions
-   PUBLIC   lbc_lnk_icb   ! iceberg lateral boundary conditions
-   
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   !!======================================================================
-   !!   Default option                           3D shared memory computing
-   !!======================================================================
-   !!          routines setting land point, or east-west cyclic,
-   !!             or north-south cyclic, or north fold values
-   !!         on first and last row and column of the global domain
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!                   ***  routine lbc_lnk_(2,3,4)d  ***
-   !!
-   !!   * Argument : dummy argument use in lbc_lnk_... routines
-   !!                ptab   :   array or pointer of arrays on which the boundary condition is applied
-   !!                cd_nat :   nature of array grid-points
-   !!                psgn   :   sign used across the north fold boundary
-   !!                kfld   :   optional, number of pt3d arrays
-   !!                cd_mpp :   optional, fill the overlap area only
-   !!                pval   :   optional, background value (used at closed boundaries)
-   !!----------------------------------------------------------------------
-   !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
-#  define DIM_2d
-#     define ROUTINE_LNK           lbc_lnk_2d
-#     include "lbc_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           lbc_lnk_2d_ptr
-#     include "lbc_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_LNK           lbc_lnk_3d
-#     include "lbc_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           lbc_lnk_3d_ptr
-#     include "lbc_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_LNK           lbc_lnk_4d
-#     include "lbc_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           lbc_lnk_4d_ptr
-#     include "lbc_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_4d
-   
-   !!======================================================================
-   !!   identical routines in both C1D and shared memory computing
-   !!======================================================================
-
-   !!----------------------------------------------------------------------
-   !!                   ***  routine lbc_bdy_lnk_(2,3,4)d  ***
-   !!
-   !!   wrapper rountine to 'lbc_lnk_3d'. This wrapper is used
-   !!   to maintain the same interface with regards to the mpp case
-   !!----------------------------------------------------------------------
-   
-   SUBROUTINE lbc_bdy_lnk_4d( cdname, pt4d, cd_type, psgn, ib_bdy )
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*)          , INTENT(in   ) ::   cdname      ! name of the calling subroutine
-      REAL(wp), DIMENSION(:,:,:,:), INTENT(inout) ::   pt4d      ! 3D array on which the lbc is applied
-      CHARACTER(len=1)          , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
-      REAL(wp)                  , INTENT(in   ) ::   psgn      ! sign used across north fold 
-      INTEGER                   , INTENT(in   ) ::   ib_bdy    ! BDY boundary set
-      !!----------------------------------------------------------------------
-      CALL lbc_lnk_4d( cdname, pt4d, cd_type, psgn)
-   END SUBROUTINE lbc_bdy_lnk_4d
-
-   SUBROUTINE lbc_bdy_lnk_3d( cdname, pt3d, cd_type, psgn, ib_bdy )
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*)          , INTENT(in   ) ::   cdname      ! name of the calling subroutine
-      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pt3d      ! 3D array on which the lbc is applied
-      CHARACTER(len=1)          , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
-      REAL(wp)                  , INTENT(in   ) ::   psgn      ! sign used across north fold 
-      INTEGER                   , INTENT(in   ) ::   ib_bdy    ! BDY boundary set
-      !!----------------------------------------------------------------------
-      CALL lbc_lnk_3d( cdname, pt3d, cd_type, psgn)
-   END SUBROUTINE lbc_bdy_lnk_3d
-
-
-   SUBROUTINE lbc_bdy_lnk_2d( cdname, pt2d, cd_type, psgn, ib_bdy )
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*)        , INTENT(in   ) ::   cdname      ! name of the calling subroutine
-      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pt2d      ! 3D array on which the lbc is applied
-      CHARACTER(len=1)        , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
-      REAL(wp)                , INTENT(in   ) ::   psgn      ! sign used across north fold 
-      INTEGER                 , INTENT(in   ) ::   ib_bdy    ! BDY boundary set
-      !!----------------------------------------------------------------------
-      CALL lbc_lnk_2d( cdname, pt2d, cd_type, psgn)
-   END SUBROUTINE lbc_bdy_lnk_2d
-
-
-!!gm  This routine should be removed with an optional halos size added in argument of generic routines
-
-   SUBROUTINE lbc_lnk_2d_icb( cdname, pt2d, cd_type, psgn, ki, kj )
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*)        , INTENT(in   ) ::   cdname      ! name of the calling subroutine
-      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pt2d      ! 2D array on which the lbc is applied
-      CHARACTER(len=1)        , INTENT(in   ) ::   cd_type   ! nature of pt3d grid-points
-      REAL(wp)                , INTENT(in   ) ::   psgn      ! sign used across north fold 
-      INTEGER                 , INTENT(in   ) ::   ki, kj    ! sizes of extra halo (not needed in non-mpp)
-      !!----------------------------------------------------------------------
-      CALL lbc_lnk_2d( cdname, pt2d, cd_type, psgn )
-   END SUBROUTINE lbc_lnk_2d_icb
-!!gm end
-
-#endif
-
-   !!======================================================================
-   !!   identical routines in both distributed and shared memory computing
-   !!======================================================================
 
    !!----------------------------------------------------------------------
@@ -256,6 +91,6 @@
 
 #  define DIM_2d
+#     define ROUTINE_LOAD           load_ptr_2d
 #     define ROUTINE_MULTI          lbc_lnk_2d_multi
-#     define ROUTINE_LOAD           load_ptr_2d
 #     include "lbc_lnk_multi_generic.h90"
 #     undef ROUTINE_MULTI
@@ -263,8 +98,7 @@
 #  undef DIM_2d
 
-
 #  define DIM_3d
+#     define ROUTINE_LOAD           load_ptr_3d
 #     define ROUTINE_MULTI          lbc_lnk_3d_multi
-#     define ROUTINE_LOAD           load_ptr_3d
 #     include "lbc_lnk_multi_generic.h90"
 #     undef ROUTINE_MULTI
@@ -272,8 +106,7 @@
 #  undef DIM_3d
 
-
 #  define DIM_4d
+#     define ROUTINE_LOAD           load_ptr_4d
 #     define ROUTINE_MULTI          lbc_lnk_4d_multi
-#     define ROUTINE_LOAD           load_ptr_4d
 #     include "lbc_lnk_multi_generic.h90"
 #     undef ROUTINE_MULTI
@@ -281,5 +114,394 @@
 #  undef DIM_4d
 
+   !!----------------------------------------------------------------------
+   !!                   ***  routine mpp_lnk_(2,3,4)d  ***
+   !!
+   !!   * Argument : dummy argument use in mpp_lnk_... routines
+   !!                ptab      :   array or pointer of arrays on which the boundary condition is applied
+   !!                cd_nat    :   nature of array grid-points
+   !!                psgn      :   sign used across the north fold boundary
+   !!                kfld      :   optional, number of pt3d arrays
+   !!                kfillmode :   optional, method to be use to fill the halos (see jpfill* variables)
+   !!                pfillval  :   optional, background value (used with jpfillcopy)
+   !!----------------------------------------------------------------------
+   !
+   !                       !==  2D array and array of 2D pointer  ==!
+   !
+#  define DIM_2d
+#     define ROUTINE_LNK           mpp_lnk_2d
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     define MULTI
+#     define ROUTINE_LNK           mpp_lnk_2d_ptr
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     undef MULTI
+#  undef DIM_2d
+   !
+   !                       !==  3D array and array of 3D pointer  ==!
+   !
+#  define DIM_3d
+#     define ROUTINE_LNK           mpp_lnk_3d
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     define MULTI
+#     define ROUTINE_LNK           mpp_lnk_3d_ptr
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     undef MULTI
+#  undef DIM_3d
+   !
+   !                       !==  4D array and array of 4D pointer  ==!
+   !
+#  define DIM_4d
+#     define ROUTINE_LNK           mpp_lnk_4d
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     define MULTI
+#     define ROUTINE_LNK           mpp_lnk_4d_ptr
+#     include "mpp_lnk_generic.h90"
+#     undef ROUTINE_LNK
+#     undef MULTI
+#  undef DIM_4d
+
+   !!----------------------------------------------------------------------
+   !!                   ***  routine mpp_nfd_(2,3,4)d  ***
+   !!
+   !!   * Argument : dummy argument use in mpp_nfd_... routines
+   !!                ptab      :   array or pointer of arrays on which the boundary condition is applied
+   !!                cd_nat    :   nature of array grid-points
+   !!                psgn      :   sign used across the north fold boundary
+   !!                kfld      :   optional, number of pt3d arrays
+   !!                kfillmode :   optional, method to be use to fill the halos (see jpfill* variables)
+   !!                pfillval  :   optional, background value (used with jpfillcopy)
+   !!----------------------------------------------------------------------
+   !
+   !                       !==  2D array and array of 2D pointer  ==!
+   !
+#  define DIM_2d
+#     define ROUTINE_NFD           mpp_nfd_2d
+#     include "mpp_nfd_generic.h90"
+#     undef ROUTINE_NFD
+#     define MULTI
+#     define ROUTINE_NFD           mpp_nfd_2d_ptr
+#     include "mpp_nfd_generic.h90"
+#     undef ROUTINE_NFD
+#     undef MULTI
+#  undef DIM_2d
+   !
+   !                       !==  3D array and array of 3D pointer  ==!
+   !
+#  define DIM_3d
+#     define ROUTINE_NFD           mpp_nfd_3d
+#     include "mpp_nfd_generic.h90"
+#     undef ROUTINE_NFD
+#     define MULTI
+#     define ROUTINE_NFD           mpp_nfd_3d_ptr
+#     include "mpp_nfd_generic.h90"
+#     undef ROUTINE_NFD
+#     undef MULTI
+#  undef DIM_3d
+   !
+   !                       !==  4D array and array of 4D pointer  ==!
+   !
+#  define DIM_4d
+#     define ROUTINE_NFD           mpp_nfd_4d
+#     include "mpp_nfd_generic.h90"
+#     undef ROUTINE_NFD
+#     define MULTI
+#     define ROUTINE_NFD           mpp_nfd_4d_ptr
+#     include "mpp_nfd_generic.h90"
+#     undef ROUTINE_NFD
+#     undef MULTI
+#  undef DIM_4d
+
+
    !!======================================================================
+
+
+
+   SUBROUTINE mpp_lbc_north_icb( pt2d, cd_type, psgn, kextj)
+      !!---------------------------------------------------------------------
+      !!                   ***  routine mpp_lbc_north_icb  ***
+      !!
+      !! ** Purpose :   Ensure proper north fold horizontal bondary condition
+      !!              in mpp configuration in case of jpn1 > 1 and for 2d
+      !!              array with outer extra halo
+      !!
+      !! ** Method  :   North fold condition and mpp with more than one proc
+      !!              in i-direction require a specific treatment. We gather
+      !!              the 4+kextj northern lines of the global domain on 1
+      !!              processor and apply lbc north-fold on this sub array.
+      !!              Then we scatter the north fold array back to the processors.
+      !!              This routine accounts for an extra halo with icebergs
+      !!              and assumes ghost rows and columns have been suppressed.
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pt2d     ! 2D array with extra halo
+      CHARACTER(len=1)        , INTENT(in   ) ::   cd_type  ! nature of pt3d grid-points
+      !                                                     !   = T ,  U , V , F or W -points
+      REAL(wp)                , INTENT(in   ) ::   psgn     ! = -1. the sign change across the
+      !!                                                    ! north fold, =  1. otherwise
+      INTEGER                 , INTENT(in   ) ::   kextj    ! Extra halo width at north fold
+      !
+      INTEGER ::   ji, jj, jr
+      INTEGER ::   ierr, itaille, ildi, ilei, iilb
+      INTEGER ::   ipj, ij, iproc
+      !
+      REAL(wp), DIMENSION(:,:)  , ALLOCATABLE  ::  ztab_e, znorthloc_e
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE  ::  znorthgloio_e
+      !!----------------------------------------------------------------------
+#if defined key_mpp_mpi
+      !
+      ipj=4
+      ALLOCATE(        ztab_e(jpiglo, 1-kextj:ipj+kextj)       ,       &
+     &            znorthloc_e(jpimax, 1-kextj:ipj+kextj)       ,       &
+     &          znorthgloio_e(jpimax, 1-kextj:ipj+kextj,jpni)    )
+      !
+      ztab_e(:,:)      = 0._wp
+      znorthloc_e(:,:) = 0._wp
+      !
+      ij = 1 - kextj
+      ! put the last ipj+2*kextj lines of pt2d into znorthloc_e 
+      DO jj = jpj - ipj + 1 - kextj , jpj + kextj
+         znorthloc_e(1:jpi,ij)=pt2d(1:jpi,jj)
+         ij = ij + 1
+      END DO
+      !
+      itaille = jpimax * ( ipj + 2*kextj )
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
+      CALL MPI_ALLGATHER( znorthloc_e(1,1-kextj)    , itaille, MPI_DOUBLE_PRECISION,    &
+         &                znorthgloio_e(1,1-kextj,1), itaille, MPI_DOUBLE_PRECISION,    &
+         &                ncomm_north, ierr )
+      !
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
+      !
+      DO jr = 1, ndim_rank_north            ! recover the global north array
+         iproc = nrank_north(jr) + 1
+         ildi = nldit (iproc)
+         ilei = nleit (iproc)
+         iilb = nimppt(iproc)
+         DO jj = 1-kextj, ipj+kextj
+            DO ji = ildi, ilei
+               ztab_e(ji+iilb-1,jj) = znorthgloio_e(ji,jj,jr)
+            END DO
+         END DO
+      END DO
+
+      ! 2. North-Fold boundary conditions
+      ! ----------------------------------
+      CALL lbc_nfd( ztab_e(:,1-kextj:ipj+kextj), cd_type, psgn, kextj )
+
+      ij = 1 - kextj
+      !! Scatter back to pt2d
+      DO jj = jpj - ipj + 1 - kextj , jpj + kextj
+         DO ji= 1, jpi
+            pt2d(ji,jj) = ztab_e(ji+nimpp-1,ij)
+         END DO
+         ij  = ij +1
+      END DO
+      !
+      DEALLOCATE( ztab_e, znorthloc_e, znorthgloio_e )
+      !
+#endif
+   END SUBROUTINE mpp_lbc_north_icb
+
+
+   SUBROUTINE mpp_lnk_2d_icb( cdname, pt2d, cd_type, psgn, kexti, kextj )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_lnk_2d_icb  ***
+      !!
+      !! ** Purpose :   Message passing management for 2d array (with extra halo for icebergs)
+      !!                This routine receives a (1-kexti:jpi+kexti,1-kexti:jpj+kextj)
+      !!                array (usually (0:jpi+1, 0:jpj+1)) from lbc_lnk_icb calls.
+      !!
+      !! ** Method  :   Use mppsend and mpprecv function for passing mask
+      !!      between processors following neighboring subdomains.
+      !!            domain parameters
+      !!                    jpi    : first dimension of the local subdomain
+      !!                    jpj    : second dimension of the local subdomain
+      !!                    kexti  : number of columns for extra outer halo
+      !!                    kextj  : number of rows for extra outer halo
+      !!                    nbondi : mark for "east-west local boundary"
+      !!                    nbondj : mark for "north-south local boundary"
+      !!                    noea   : number for local neighboring processors
+      !!                    nowe   : number for local neighboring processors
+      !!                    noso   : number for local neighboring processors
+      !!                    nono   : number for local neighboring processors
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*)                                        , INTENT(in   ) ::   cdname      ! name of the calling subroutine
+      REAL(wp), DIMENSION(1-kexti:jpi+kexti,1-kextj:jpj+kextj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
+      CHARACTER(len=1)                                        , INTENT(in   ) ::   cd_type  ! nature of ptab array grid-points
+      REAL(wp)                                                , INTENT(in   ) ::   psgn     ! sign used across the north fold
+      INTEGER                                                 , INTENT(in   ) ::   kexti    ! extra i-halo width
+      INTEGER                                                 , INTENT(in   ) ::   kextj    ! extra j-halo width
+      !
+      INTEGER  ::   jl   ! dummy loop indices
+      INTEGER  ::   imigr, iihom, ijhom        ! local integers
+      INTEGER  ::   ipreci, iprecj             !   -       -
+      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
+      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
+      !!
+      REAL(wp), DIMENSION(1-kexti:jpi+kexti,nn_hls+kextj,2) ::   r2dns, r2dsn
+      REAL(wp), DIMENSION(1-kextj:jpj+kextj,nn_hls+kexti,2) ::   r2dwe, r2dew
+      !!----------------------------------------------------------------------
+
+      ipreci = nn_hls + kexti      ! take into account outer extra 2D overlap area
+      iprecj = nn_hls + kextj
+
+      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, 1, 1, 1, ld_lbc = .TRUE. )
+
+      ! 1. standard boundary treatment
+      ! ------------------------------
+      ! Order matters Here !!!!
+      !
+      !                                      ! East-West boundaries
+      !                                           !* Cyclic east-west
+      IF( l_Iperio ) THEN
+         pt2d(1-kexti:     1   ,:) = pt2d(jpim1-kexti: jpim1 ,:)       ! east
+         pt2d(  jpi  :jpi+kexti,:) = pt2d(     2     :2+kexti,:)       ! west
+         !
+      ELSE                                        !* closed
+         IF( .NOT. cd_type == 'F' )   pt2d(  1-kexti   :nn_hls   ,:) = 0._wp    ! east except at F-point
+                                      pt2d(jpi-nn_hls+1:jpi+kexti,:) = 0._wp    ! west
+      ENDIF
+      !                                      ! North-South boundaries
+      IF( l_Jperio ) THEN                         !* cyclic (only with no mpp j-split)
+         pt2d(:,1-kextj:     1   ) = pt2d(:,jpjm1-kextj:  jpjm1)       ! north
+         pt2d(:,  jpj  :jpj+kextj) = pt2d(:,     2     :2+kextj)       ! south
+      ELSE                                        !* closed
+         IF( .NOT. cd_type == 'F' )   pt2d(:,  1-kextj   :nn_hls   ) = 0._wp    ! north except at F-point
+                                      pt2d(:,jpj-nn_hls+1:jpj+kextj) = 0._wp    ! south
+      ENDIF
+      !
+
+      ! north fold treatment
+      ! -----------------------
+      IF( npolj /= 0 ) THEN
+         !
+         SELECT CASE ( jpni )
+                   CASE ( 1 )     ;   CALL lbc_nfd          ( pt2d(1:jpi,1:jpj+kextj), cd_type, psgn, kextj )
+                   CASE DEFAULT   ;   CALL mpp_lbc_north_icb( pt2d(1:jpi,1:jpj+kextj), cd_type, psgn, kextj )
+         END SELECT
+         !
+      ENDIF
+
+      ! 2. East and west directions exchange
+      ! ------------------------------------
+      ! we play with the neigbours AND the row number because of the periodicity
+      !
+      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
+      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
+         iihom = jpi-nreci-kexti
+         DO jl = 1, ipreci
+            r2dew(:,jl,1) = pt2d(nn_hls+jl,:)
+            r2dwe(:,jl,1) = pt2d(iihom +jl,:)
+         END DO
+      END SELECT
+      !
+      !                           ! Migrations
+      imigr = ipreci * ( jpj + 2*kextj )
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
+      !
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         CALL mppsend( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req1 )
+         CALL mpprecv( 1, r2dew(1-kextj,1,2), imigr, noea )
+         CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      CASE ( 0 )
+         CALL mppsend( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
+         CALL mppsend( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req2 )
+         CALL mpprecv( 1, r2dew(1-kextj,1,2), imigr, noea )
+         CALL mpprecv( 2, r2dwe(1-kextj,1,2), imigr, nowe )
+         CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         CALL mpi_wait(ml_req2,ml_stat,ml_err)
+      CASE ( 1 )
+         CALL mppsend( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
+         CALL mpprecv( 2, r2dwe(1-kextj,1,2), imigr, nowe )
+         CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      END SELECT
+      !
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
+      !
+      !                           ! Write Dirichlet lateral conditions
+      iihom = jpi - nn_hls
+      !
+      SELECT CASE ( nbondi )
+      CASE ( -1 )
+         DO jl = 1, ipreci
+            pt2d(iihom+jl,:) = r2dew(:,jl,2)
+         END DO
+      CASE ( 0 )
+         DO jl = 1, ipreci
+            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
+            pt2d(iihom+jl,:) = r2dew(:,jl,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, ipreci
+            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
+         END DO
+      END SELECT
+
+
+      ! 3. North and south directions
+      ! -----------------------------
+      ! always closed : we play only with the neigbours
+      !
+      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+         ijhom = jpj-nrecj-kextj
+         DO jl = 1, iprecj
+            r2dsn(:,jl,1) = pt2d(:,ijhom +jl)
+            r2dns(:,jl,1) = pt2d(:,nn_hls+jl)
+         END DO
+      ENDIF
+      !
+      !                           ! Migrations
+      imigr = iprecj * ( jpi + 2*kexti )
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         CALL mppsend( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req1 )
+         CALL mpprecv( 3, r2dns(1-kexti,1,2), imigr, nono )
+         CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      CASE ( 0 )
+         CALL mppsend( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
+         CALL mppsend( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req2 )
+         CALL mpprecv( 3, r2dns(1-kexti,1,2), imigr, nono )
+         CALL mpprecv( 4, r2dsn(1-kexti,1,2), imigr, noso )
+         CALL mpi_wait(ml_req1,ml_stat,ml_err)
+         CALL mpi_wait(ml_req2,ml_stat,ml_err)
+      CASE ( 1 )
+         CALL mppsend( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
+         CALL mpprecv( 4, r2dsn(1-kexti,1,2), imigr, noso )
+         CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      END SELECT
+      !
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
+      !
+      !                           ! Write Dirichlet lateral conditions
+      ijhom = jpj - nn_hls
+      !
+      SELECT CASE ( nbondj )
+      CASE ( -1 )
+         DO jl = 1, iprecj
+            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
+         END DO
+      CASE ( 0 )
+         DO jl = 1, iprecj
+            pt2d(:,jl-kextj) = r2dsn(:,jl,2)
+            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
+         END DO
+      CASE ( 1 )
+         DO jl = 1, iprecj
+            pt2d(:,jl-kextj) = r2dsn(:,jl,2)
+         END DO
+      END SELECT
+      !
+   END SUBROUTINE mpp_lnk_2d_icb
+   
 END MODULE lbclnk
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbcnfd.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbcnfd.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lbcnfd.F90	(revision 12143)
@@ -20,4 +20,5 @@
    USE dom_oce        ! ocean space and time domain 
    USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
 
    IMPLICIT NONE
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lib_mpp.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lib_mpp.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/lib_mpp.F90	(revision 12143)
@@ -32,12 +32,7 @@
    !!   ctl_opn       : Open file and check if required file is available.
    !!   ctl_nam       : Prints informations when an error occurs while reading a namelist
-   !!   get_unit      : give the index of an unused logical unit
-   !!----------------------------------------------------------------------
-#if   defined key_mpp_mpi
-   !!----------------------------------------------------------------------
-   !!   'key_mpp_mpi'             MPI massively parallel processing library
-   !!----------------------------------------------------------------------
-   !!   lib_mpp_alloc : allocate mpp arrays
-   !!   mynode        : indentify the processor unit
+   !!----------------------------------------------------------------------
+   !!----------------------------------------------------------------------
+   !!   mpp_start     : get local communicator its size and rank
    !!   mpp_lnk       : interface (defined in lbclnk) for message passing of 2d or 3d arrays (mpp_lnk_2d, mpp_lnk_3d)
    !!   mpp_lnk_icb   : interface for message passing of 2d arrays with extra halo for icebergs (mpp_lnk_2d_icb)
@@ -57,29 +52,12 @@
    !!----------------------------------------------------------------------
    USE dom_oce        ! ocean space and time domain
-   USE lbcnfd         ! north fold treatment
    USE in_out_manager ! I/O manager
 
    IMPLICIT NONE
    PRIVATE
-
-   INTERFACE mpp_nfd
-      MODULE PROCEDURE   mpp_nfd_2d    , mpp_nfd_3d    , mpp_nfd_4d
-      MODULE PROCEDURE   mpp_nfd_2d_ptr, mpp_nfd_3d_ptr, mpp_nfd_4d_ptr
-   END INTERFACE
-
-   ! Interface associated to the mpp_lnk_... routines is defined in lbclnk
-   PUBLIC   mpp_lnk_2d    , mpp_lnk_3d    , mpp_lnk_4d
-   PUBLIC   mpp_lnk_2d_ptr, mpp_lnk_3d_ptr, mpp_lnk_4d_ptr
    !
-!!gm  this should be useless
-   PUBLIC   mpp_nfd_2d    , mpp_nfd_3d    , mpp_nfd_4d
-   PUBLIC   mpp_nfd_2d_ptr, mpp_nfd_3d_ptr, mpp_nfd_4d_ptr
-!!gm end
-   !
-   PUBLIC   ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam
-   PUBLIC   mynode, mppstop, mppsync, mpp_comm_free
+   PUBLIC   ctl_stop, ctl_warn, ctl_opn, ctl_nam
+   PUBLIC   mpp_start, mppstop, mppsync, mpp_comm_free
    PUBLIC   mpp_ini_north
-   PUBLIC   mpp_lnk_2d_icb
-   PUBLIC   mpp_lbc_north_icb
    PUBLIC   mpp_min, mpp_max, mpp_sum, mpp_minloc, mpp_maxloc
    PUBLIC   mpp_delay_max, mpp_delay_sum, mpp_delay_rcv
@@ -87,5 +65,9 @@
    PUBLIC   mpp_ini_znl
    PUBLIC   mppsend, mpprecv                          ! needed by TAM and ICB routines
-   PUBLIC   mpp_lnk_bdy_2d, mpp_lnk_bdy_3d, mpp_lnk_bdy_4d
+   PUBLIC   mpp_report
+   PUBLIC   tic_tac
+#if ! defined key_mpp_mpi
+   PUBLIC MPI_Wtime
+#endif
    
    !! * Interfaces
@@ -113,9 +95,14 @@
    !!  MPI  variable definition !!
    !! ========================= !!
+#if   defined key_mpp_mpi
 !$AGRIF_DO_NOT_TREAT
    INCLUDE 'mpif.h'
 !$AGRIF_END_DO_NOT_TREAT
-
    LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .TRUE.    !: mpp flag
+#else   
+   INTEGER, PUBLIC, PARAMETER ::   MPI_STATUS_SIZE = 1
+   INTEGER, PUBLIC, PARAMETER ::   MPI_DOUBLE_PRECISION = 8
+   LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .FALSE.    !: mpp flag
+#endif
 
    INTEGER, PARAMETER         ::   nprocmax = 2**10   ! maximun dimension (required to be a power of 2)
@@ -145,9 +132,4 @@
    INTEGER, PUBLIC ::   north_root        !: number (in the comm_opa) of proc 0 in the northern comm
    INTEGER, PUBLIC, DIMENSION(:), ALLOCATABLE, SAVE ::   nrank_north   !: dimension ndim_rank_north
-
-   ! Type of send : standard, buffered, immediate
-   CHARACTER(len=1), PUBLIC ::   cn_mpi_send        !: type od mpi send/recieve (S=standard, B=bsend, I=isend)
-   LOGICAL         , PUBLIC ::   l_isend = .FALSE.  !: isend use indicator (T if cn_mpi_send='I')
-   INTEGER         , PUBLIC ::   nn_buffer          !: size of the buffer in case of mpi_bsend
 
    ! Communications summary report
@@ -187,5 +169,5 @@
    LOGICAL, PUBLIC ::   ln_nnogather                !: namelist control of northfold comms
    LOGICAL, PUBLIC ::   l_north_nogather = .FALSE.  !: internal control of northfold comms
-
+   
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -195,103 +177,30 @@
 CONTAINS
 
-   FUNCTION mynode( ldtxt, ldname, kumnam_ref, kumnam_cfg, kumond, kstop, localComm )
-      !!----------------------------------------------------------------------
-      !!                  ***  routine mynode  ***
-      !!
-      !! ** Purpose :   Find processor unit
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt        !
-      CHARACTER(len=*)             , INTENT(in   ) ::   ldname       !
-      INTEGER                      , INTENT(in   ) ::   kumnam_ref   ! logical unit for reference namelist
-      INTEGER                      , INTENT(in   ) ::   kumnam_cfg   ! logical unit for configuration namelist
-      INTEGER                      , INTENT(inout) ::   kumond       ! logical unit for namelist output
-      INTEGER                      , INTENT(inout) ::   kstop        ! stop indicator
+   SUBROUTINE mpp_start( localComm )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine mpp_start  ***
+      !!
+      !! ** Purpose :   get mpi_comm_oce, mpprank and mppsize
+      !!----------------------------------------------------------------------
       INTEGER         , OPTIONAL   , INTENT(in   ) ::   localComm    !
       !
-      INTEGER ::   mynode, ierr, code, ji, ii, ios
-      LOGICAL ::   mpi_was_called
-      !
-      NAMELIST/nammpp/ cn_mpi_send, nn_buffer, jpni, jpnj, ln_nnogather
-      !!----------------------------------------------------------------------
-      !
-      ii = 1
-      WRITE(ldtxt(ii),*)                                                                  ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'mynode : mpi initialisation'                                    ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~ '                                                        ;   ii = ii + 1
-      !
-      REWIND( kumnam_ref )              ! Namelist nammpp in reference namelist: mpi variables
-      READ  ( kumnam_ref, nammpp, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nammpp in reference namelist', lwp )
-      !
-      REWIND( kumnam_cfg )              ! Namelist nammpp in configuration namelist: mpi variables
-      READ  ( kumnam_cfg, nammpp, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nammpp in configuration namelist', lwp )
-      !
-      !                              ! control print
-      WRITE(ldtxt(ii),*) '   Namelist nammpp'                                             ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      mpi send type          cn_mpi_send = ', cn_mpi_send       ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      size exported buffer   nn_buffer   = ', nn_buffer,' bytes';   ii = ii + 1
-      !
-      IF( jpni < 1 .OR. jpnj < 1  ) THEN
-         WRITE(ldtxt(ii),*) '      jpni and jpnj will be calculated automatically' ;   ii = ii + 1
-      ELSE
-         WRITE(ldtxt(ii),*) '      processor grid extent in i         jpni = ',jpni       ;   ii = ii + 1
-         WRITE(ldtxt(ii),*) '      processor grid extent in j         jpnj = ',jpnj       ;   ii = ii + 1
-      ENDIF
-
-      WRITE(ldtxt(ii),*) '      avoid use of mpi_allgather at the north fold  ln_nnogather = ', ln_nnogather  ; ii = ii + 1
-
-      CALL mpi_initialized ( mpi_was_called, code )
-      IF( code /= MPI_SUCCESS ) THEN
-         DO ji = 1, SIZE(ldtxt)
-            IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode
-         END DO
-         WRITE(*, cform_err)
-         WRITE(*, *) 'lib_mpp: Error in routine mpi_initialized'
-         CALL mpi_abort( mpi_comm_world, code, ierr )
-      ENDIF
-
-      IF( mpi_was_called ) THEN
-         !
-         SELECT CASE ( cn_mpi_send )
-         CASE ( 'S' )                ! Standard mpi send (blocking)
-            WRITE(ldtxt(ii),*) '           Standard blocking mpi send (send)'             ;   ii = ii + 1
-         CASE ( 'B' )                ! Buffer mpi send (blocking)
-            WRITE(ldtxt(ii),*) '           Buffer blocking mpi send (bsend)'              ;   ii = ii + 1
-            IF( Agrif_Root() )   CALL mpi_init_oce( ldtxt, ii, ierr )
-         CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
-            WRITE(ldtxt(ii),*) '           Immediate non-blocking send (isend)'           ;   ii = ii + 1
-            l_isend = .TRUE.
-         CASE DEFAULT
-            WRITE(ldtxt(ii),cform_err)                                                    ;   ii = ii + 1
-            WRITE(ldtxt(ii),*) '           bad value for cn_mpi_send = ', cn_mpi_send     ;   ii = ii + 1
-            kstop = kstop + 1
-         END SELECT
-         !
-      ELSEIF ( PRESENT(localComm) .AND. .NOT. mpi_was_called ) THEN
-         WRITE(ldtxt(ii),cform_err)                                                    ;   ii = ii + 1
-         WRITE(ldtxt(ii),*) ' lib_mpp: You cannot provide a local communicator '          ;   ii = ii + 1
-         WRITE(ldtxt(ii),*) '          without calling MPI_Init before ! '                ;   ii = ii + 1
-         kstop = kstop + 1
-      ELSE
-         SELECT CASE ( cn_mpi_send )
-         CASE ( 'S' )                ! Standard mpi send (blocking)
-            WRITE(ldtxt(ii),*) '           Standard blocking mpi send (send)'             ;   ii = ii + 1
-            CALL mpi_init( ierr )
-         CASE ( 'B' )                ! Buffer mpi send (blocking)
-            WRITE(ldtxt(ii),*) '           Buffer blocking mpi send (bsend)'              ;   ii = ii + 1
-            IF( Agrif_Root() )   CALL mpi_init_oce( ldtxt, ii, ierr )
-         CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
-            WRITE(ldtxt(ii),*) '           Immediate non-blocking send (isend)'           ;   ii = ii + 1
-            l_isend = .TRUE.
-            CALL mpi_init( ierr )
-         CASE DEFAULT
-            WRITE(ldtxt(ii),cform_err)                                                    ;   ii = ii + 1
-            WRITE(ldtxt(ii),*) '           bad value for cn_mpi_send = ', cn_mpi_send     ;   ii = ii + 1
-            kstop = kstop + 1
-         END SELECT
-         !
-      ENDIF
-
+      INTEGER ::   ierr
+      LOGICAL ::   llmpi_init
+      !!----------------------------------------------------------------------
+#if defined key_mpp_mpi
+      !
+      CALL mpi_initialized ( llmpi_init, ierr )
+      IF( ierr /= MPI_SUCCESS ) CALL ctl_stop( 'STOP', ' lib_mpp: Error in routine mpi_initialized' )
+
+      IF( .NOT. llmpi_init ) THEN
+         IF( PRESENT(localComm) ) THEN
+            WRITE(ctmp1,*) ' lib_mpp: You cannot provide a local communicator '
+            WRITE(ctmp2,*) '          without calling MPI_Init before ! '
+            CALL ctl_stop( 'STOP', ctmp1, ctmp2 )
+         ENDIF
+         CALL mpi_init( ierr )
+         IF( ierr /= MPI_SUCCESS ) CALL ctl_stop( 'STOP', ' lib_mpp: Error in routine mpi_init' )
+      ENDIF
+       
       IF( PRESENT(localComm) ) THEN
          IF( Agrif_Root() ) THEN
@@ -299,16 +208,9 @@
          ENDIF
       ELSE
-         CALL mpi_comm_dup( mpi_comm_world, mpi_comm_oce, code)
-         IF( code /= MPI_SUCCESS ) THEN
-            DO ji = 1, SIZE(ldtxt)
-               IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode
-            END DO
-            WRITE(*, cform_err)
-            WRITE(*, *) ' lib_mpp: Error in routine mpi_comm_dup'
-            CALL mpi_abort( mpi_comm_world, code, ierr )
-         ENDIF
-      ENDIF
-
-#if defined key_agrif
+         CALL mpi_comm_dup( mpi_comm_world, mpi_comm_oce, ierr)
+         IF( ierr /= MPI_SUCCESS ) CALL ctl_stop( 'STOP', ' lib_mpp: Error in routine mpi_comm_dup' )
+      ENDIF
+
+# if defined key_agrif
       IF( Agrif_Root() ) THEN
          CALL Agrif_MPI_Init(mpi_comm_oce)
@@ -316,167 +218,17 @@
          CALL Agrif_MPI_set_grid_comm(mpi_comm_oce)
       ENDIF
-#endif
+# endif
 
       CALL mpi_comm_rank( mpi_comm_oce, mpprank, ierr )
       CALL mpi_comm_size( mpi_comm_oce, mppsize, ierr )
-      mynode = mpprank
-
-      IF( mynode == 0 ) THEN
-         CALL ctl_opn( kumond, TRIM(ldname), 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. , 1 )
-         WRITE(kumond, nammpp)      
-      ENDIF
       !
       CALL MPI_OP_CREATE(DDPDD_MPI, .TRUE., MPI_SUMDD, ierr)
       !
-   END FUNCTION mynode
-
-   !!----------------------------------------------------------------------
-   !!                   ***  routine mpp_lnk_(2,3,4)d  ***
-   !!
-   !!   * Argument : dummy argument use in mpp_lnk_... routines
-   !!                ptab   :   array or pointer of arrays on which the boundary condition is applied
-   !!                cd_nat :   nature of array grid-points
-   !!                psgn   :   sign used across the north fold boundary
-   !!                kfld   :   optional, number of pt3d arrays
-   !!                cd_mpp :   optional, fill the overlap area only
-   !!                pval   :   optional, background value (used at closed boundaries)
-   !!----------------------------------------------------------------------
-   !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
-#  define DIM_2d
-#     define ROUTINE_LNK           mpp_lnk_2d
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           mpp_lnk_2d_ptr
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_LNK           mpp_lnk_3d
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           mpp_lnk_3d_ptr
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_LNK           mpp_lnk_4d
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           mpp_lnk_4d_ptr
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_4d
-
-   !!----------------------------------------------------------------------
-   !!                   ***  routine mpp_nfd_(2,3,4)d  ***
-   !!
-   !!   * Argument : dummy argument use in mpp_nfd_... routines
-   !!                ptab   :   array or pointer of arrays on which the boundary condition is applied
-   !!                cd_nat :   nature of array grid-points
-   !!                psgn   :   sign used across the north fold boundary
-   !!                kfld   :   optional, number of pt3d arrays
-   !!                cd_mpp :   optional, fill the overlap area only
-   !!                pval   :   optional, background value (used at closed boundaries)
-   !!----------------------------------------------------------------------
-   !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
-#  define DIM_2d
-#     define ROUTINE_NFD           mpp_nfd_2d
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           mpp_nfd_2d_ptr
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_NFD           mpp_nfd_3d
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           mpp_nfd_3d_ptr
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_NFD           mpp_nfd_4d
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           mpp_nfd_4d_ptr
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_4d
-
-
-   !!----------------------------------------------------------------------
-   !!                   ***  routine mpp_lnk_bdy_(2,3,4)d  ***
-   !!
-   !!   * Argument : dummy argument use in mpp_lnk_... routines
-   !!                ptab   :   array or pointer of arrays on which the boundary condition is applied
-   !!                cd_nat :   nature of array grid-points
-   !!                psgn   :   sign used across the north fold boundary
-   !!                kb_bdy :   BDY boundary set
-   !!                kfld   :   optional, number of pt3d arrays
-   !!----------------------------------------------------------------------
-   !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
-#  define DIM_2d
-#     define ROUTINE_BDY           mpp_lnk_bdy_2d
-#     include "mpp_bdy_generic.h90"
-#     undef ROUTINE_BDY
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_BDY           mpp_lnk_bdy_3d
-#     include "mpp_bdy_generic.h90"
-#     undef ROUTINE_BDY
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_BDY           mpp_lnk_bdy_4d
-#     include "mpp_bdy_generic.h90"
-#     undef ROUTINE_BDY
-#  undef DIM_4d
-
-   !!----------------------------------------------------------------------
-   !!
-   !!   load_array  &   mpp_lnk_2d_9    à generaliser a 3D et 4D
-   
-   
-   !!    mpp_lnk_sum_2d et 3D   ====>>>>>>   à virer du code !!!!
-   
-   
-   !!----------------------------------------------------------------------
-
+#else
+      IF( PRESENT( localComm ) ) mpi_comm_oce = localComm
+      mppsize = 1
+      mpprank = 0
+#endif
+   END SUBROUTINE mpp_start
 
 
@@ -497,13 +249,7 @@
       !!----------------------------------------------------------------------
       !
-      SELECT CASE ( cn_mpi_send )
-      CASE ( 'S' )                ! Standard mpi send (blocking)
-         CALL mpi_send ( pmess, kbytes, mpi_double_precision, kdest , ktyp, mpi_comm_oce        , iflag )
-      CASE ( 'B' )                ! Buffer mpi send (blocking)
-         CALL mpi_bsend( pmess, kbytes, mpi_double_precision, kdest , ktyp, mpi_comm_oce        , iflag )
-      CASE ( 'I' )                ! Immediate mpi send (non-blocking send)
-         ! be carefull, one more argument here : the mpi request identifier..
-         CALL mpi_isend( pmess, kbytes, mpi_double_precision, kdest , ktyp, mpi_comm_oce, md_req, iflag )
-      END SELECT
+#if defined key_mpp_mpi
+      CALL mpi_isend( pmess, kbytes, mpi_double_precision, kdest , ktyp, mpi_comm_oce, md_req, iflag )
+#endif
       !
    END SUBROUTINE mppsend
@@ -527,4 +273,5 @@
       !!----------------------------------------------------------------------
       !
+#if defined key_mpp_mpi
       ! If a specific process number has been passed to the receive call,
       ! use that one. Default is to use mpi_any_source
@@ -533,4 +280,5 @@
       !
       CALL mpi_recv( pmess, kbytes, mpi_double_precision, use_source, ktyp, mpi_comm_oce, istatus, iflag )
+#endif
       !
    END SUBROUTINE mpprecv
@@ -553,6 +301,10 @@
       !
       itaille = jpi * jpj
+#if defined key_mpp_mpi
       CALL mpi_gather( ptab, itaille, mpi_double_precision, pio, itaille     ,   &
          &                            mpi_double_precision, kp , mpi_comm_oce, ierror )
+#else
+      pio(:,:,1) = ptab(:,:)
+#endif
       !
    END SUBROUTINE mppgather
@@ -576,6 +328,10 @@
       itaille = jpi * jpj
       !
+#if defined key_mpp_mpi
       CALL mpi_scatter( pio, itaille, mpi_double_precision, ptab, itaille     ,   &
          &                            mpi_double_precision, kp  , mpi_comm_oce, ierror )
+#else
+      ptab(:,:) = pio(:,:,1)
+#endif
       !
    END SUBROUTINE mppscatter
@@ -601,4 +357,5 @@
       COMPLEX(wp), ALLOCATABLE, DIMENSION(:) ::   ytmp
       !!----------------------------------------------------------------------
+#if defined key_mpp_mpi
       ilocalcomm = mpi_comm_oce
       IF( PRESENT(kcom) )   ilocalcomm = kcom
@@ -639,10 +396,13 @@
 
       ! send y_in into todelay(idvar)%y1d with a non-blocking communication
-#if defined key_mpi2
+# if defined key_mpi2
       IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.)
       CALL  mpi_allreduce( y_in(:), todelay(idvar)%y1d(:), isz, MPI_DOUBLE_COMPLEX, mpi_sumdd, ilocalcomm, ndelayid(idvar), ierr )
       IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.)
+# else
+      CALL mpi_iallreduce( y_in(:), todelay(idvar)%y1d(:), isz, MPI_DOUBLE_COMPLEX, mpi_sumdd, ilocalcomm, ndelayid(idvar), ierr )
+# endif
 #else
-      CALL mpi_iallreduce( y_in(:), todelay(idvar)%y1d(:), isz, MPI_DOUBLE_COMPLEX, mpi_sumdd, ilocalcomm, ndelayid(idvar), ierr )
+      pout(:) = REAL(y_in(:), wp)
 #endif
 
@@ -668,4 +428,5 @@
       INTEGER ::   ierr, ilocalcomm
       !!----------------------------------------------------------------------
+#if defined key_mpp_mpi
       ilocalcomm = mpi_comm_oce
       IF( PRESENT(kcom) )   ilocalcomm = kcom
@@ -702,10 +463,13 @@
 
       ! send p_in into todelay(idvar)%z1d with a non-blocking communication
-#if defined key_mpi2
+# if defined key_mpi2
       IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.)
       CALL  mpi_allreduce( p_in(:), todelay(idvar)%z1d(:), isz, MPI_DOUBLE_PRECISION, mpi_max, ilocalcomm, ndelayid(idvar), ierr )
       IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.)
+# else
+      CALL mpi_iallreduce( p_in(:), todelay(idvar)%z1d(:), isz, MPI_DOUBLE_PRECISION, mpi_max, ilocalcomm, ndelayid(idvar), ierr )
+# endif
 #else
-      CALL mpi_iallreduce( p_in(:), todelay(idvar)%z1d(:), isz, MPI_DOUBLE_PRECISION, mpi_max, ilocalcomm, ndelayid(idvar), ierr )
+      pout(:) = p_in(:)
 #endif
 
@@ -723,4 +487,5 @@
       INTEGER ::   ierr
       !!----------------------------------------------------------------------
+#if defined key_mpp_mpi
       IF( ndelayid(kid) /= -2 ) THEN  
 #if ! defined key_mpi2
@@ -732,4 +497,5 @@
          ndelayid(kid) = -2   ! add flag to know that mpi_wait was already called on kid
       ENDIF
+#endif
    END SUBROUTINE mpp_delay_rcv
 
@@ -890,10 +656,12 @@
       !!-----------------------------------------------------------------------
       !
+#if defined key_mpp_mpi
       CALL mpi_barrier( mpi_comm_oce, ierror )
+#endif
       !
    END SUBROUTINE mppsync
 
 
-   SUBROUTINE mppstop( ldfinal, ld_force_abort ) 
+   SUBROUTINE mppstop( ld_abort ) 
       !!----------------------------------------------------------------------
       !!                  ***  routine mppstop  ***
@@ -902,15 +670,13 @@
       !!
       !!----------------------------------------------------------------------
-      LOGICAL, OPTIONAL, INTENT(in) :: ldfinal    ! source process number
-      LOGICAL, OPTIONAL, INTENT(in) :: ld_force_abort    ! source process number
-      LOGICAL ::   llfinal, ll_force_abort
+      LOGICAL, OPTIONAL, INTENT(in) :: ld_abort    ! source process number
+      LOGICAL ::   ll_abort
       INTEGER ::   info
       !!----------------------------------------------------------------------
-      llfinal = .FALSE.
-      IF( PRESENT(ldfinal) ) llfinal = ldfinal
-      ll_force_abort = .FALSE.
-      IF( PRESENT(ld_force_abort) ) ll_force_abort = ld_force_abort
-      !
-      IF(ll_force_abort) THEN
+      ll_abort = .FALSE.
+      IF( PRESENT(ld_abort) ) ll_abort = ld_abort
+      !
+#if defined key_mpp_mpi
+      IF(ll_abort) THEN
          CALL mpi_abort( MPI_COMM_WORLD )
       ELSE
@@ -918,5 +684,6 @@
          CALL mpi_finalize( info )
       ENDIF
-      IF( .NOT. llfinal ) STOP 123
+#endif
+      IF( ll_abort ) STOP 123
       !
    END SUBROUTINE mppstop
@@ -930,5 +697,7 @@
       !!----------------------------------------------------------------------
       !
+#if defined key_mpp_mpi
       CALL MPI_COMM_FREE(kcom, ierr)
+#endif
       !
    END SUBROUTINE mpp_comm_free
@@ -960,4 +729,5 @@
       INTEGER, ALLOCATABLE, DIMENSION(:) ::   kwork
       !!----------------------------------------------------------------------
+#if defined key_mpp_mpi
       !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ngrp_world     : ', ngrp_world
       !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - mpi_comm_world : ', mpi_comm_world
@@ -965,9 +735,5 @@
       !
       ALLOCATE( kwork(jpnij), STAT=ierr )
-      IF( ierr /= 0 ) THEN
-         WRITE(kumout, cform_err)
-         WRITE(kumout,*) 'mpp_ini_znl : failed to allocate 1D array of length jpnij'
-         CALL mppstop
-      ENDIF
+      IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'mpp_ini_znl : failed to allocate 1D array of length jpnij')
 
       IF( jpnj == 1 ) THEN
@@ -1031,4 +797,5 @@
 
       DEALLOCATE(kwork)
+#endif
 
    END SUBROUTINE mpp_ini_znl
@@ -1062,4 +829,5 @@
       !!----------------------------------------------------------------------
       !
+#if defined key_mpp_mpi
       njmppmax = MAXVAL( njmppt )
       !
@@ -1093,65 +861,6 @@
       CALL MPI_COMM_CREATE( mpi_comm_oce, ngrp_north, ncomm_north, ierr )
       !
+#endif
    END SUBROUTINE mpp_ini_north
-
-
-   SUBROUTINE mpi_init_oce( ldtxt, ksft, code )
-      !!---------------------------------------------------------------------
-      !!                   ***  routine mpp_init.opa  ***
-      !!
-      !! ** Purpose :: export and attach a MPI buffer for bsend
-      !!
-      !! ** Method  :: define buffer size in namelist, if 0 no buffer attachment
-      !!            but classical mpi_init
-      !!
-      !! History :: 01/11 :: IDRIS initial version for IBM only
-      !!            08/04 :: R. Benshila, generalisation
-      !!---------------------------------------------------------------------
-      CHARACTER(len=*),DIMENSION(:), INTENT(  out) ::   ldtxt
-      INTEGER                      , INTENT(inout) ::   ksft
-      INTEGER                      , INTENT(  out) ::   code
-      INTEGER                                      ::   ierr, ji
-      LOGICAL                                      ::   mpi_was_called
-      !!---------------------------------------------------------------------
-      !
-      CALL mpi_initialized( mpi_was_called, code )      ! MPI initialization
-      IF ( code /= MPI_SUCCESS ) THEN
-         DO ji = 1, SIZE(ldtxt)
-            IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode
-         END DO
-         WRITE(*, cform_err)
-         WRITE(*, *) ' lib_mpp: Error in routine mpi_initialized'
-         CALL mpi_abort( mpi_comm_world, code, ierr )
-      ENDIF
-      !
-      IF( .NOT. mpi_was_called ) THEN
-         CALL mpi_init( code )
-         CALL mpi_comm_dup( mpi_comm_world, mpi_comm_oce, code )
-         IF ( code /= MPI_SUCCESS ) THEN
-            DO ji = 1, SIZE(ldtxt)
-               IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode
-            END DO
-            WRITE(*, cform_err)
-            WRITE(*, *) ' lib_mpp: Error in routine mpi_comm_dup'
-            CALL mpi_abort( mpi_comm_world, code, ierr )
-         ENDIF
-      ENDIF
-      !
-      IF( nn_buffer > 0 ) THEN
-         WRITE(ldtxt(ksft),*) 'mpi_bsend, buffer allocation of  : ', nn_buffer   ;   ksft = ksft + 1
-         ! Buffer allocation and attachment
-         ALLOCATE( tampon(nn_buffer), stat = ierr )
-         IF( ierr /= 0 ) THEN
-            DO ji = 1, SIZE(ldtxt)
-               IF( TRIM(ldtxt(ji)) /= '' )   WRITE(*,*) ldtxt(ji)      ! control print of mynode
-            END DO
-            WRITE(*, cform_err)
-            WRITE(*, *) ' lib_mpp: Error in ALLOCATE', ierr
-            CALL mpi_abort( mpi_comm_world, code, ierr )
-         END IF
-         CALL mpi_buffer_attach( tampon, nn_buffer, code )
-      ENDIF
-      !
-   END SUBROUTINE mpi_init_oce
 
 
@@ -1187,286 +896,4 @@
 
 
-   SUBROUTINE mpp_lbc_north_icb( pt2d, cd_type, psgn, kextj)
-      !!---------------------------------------------------------------------
-      !!                   ***  routine mpp_lbc_north_icb  ***
-      !!
-      !! ** Purpose :   Ensure proper north fold horizontal bondary condition
-      !!              in mpp configuration in case of jpn1 > 1 and for 2d
-      !!              array with outer extra halo
-      !!
-      !! ** Method  :   North fold condition and mpp with more than one proc
-      !!              in i-direction require a specific treatment. We gather
-      !!              the 4+kextj northern lines of the global domain on 1
-      !!              processor and apply lbc north-fold on this sub array.
-      !!              Then we scatter the north fold array back to the processors.
-      !!              This routine accounts for an extra halo with icebergs
-      !!              and assumes ghost rows and columns have been suppressed.
-      !!
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   pt2d     ! 2D array with extra halo
-      CHARACTER(len=1)        , INTENT(in   ) ::   cd_type  ! nature of pt3d grid-points
-      !                                                     !   = T ,  U , V , F or W -points
-      REAL(wp)                , INTENT(in   ) ::   psgn     ! = -1. the sign change across the
-      !!                                                    ! north fold, =  1. otherwise
-      INTEGER                 , INTENT(in   ) ::   kextj    ! Extra halo width at north fold
-      !
-      INTEGER ::   ji, jj, jr
-      INTEGER ::   ierr, itaille, ildi, ilei, iilb
-      INTEGER ::   ipj, ij, iproc
-      !
-      REAL(wp), DIMENSION(:,:)  , ALLOCATABLE  ::  ztab_e, znorthloc_e
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE  ::  znorthgloio_e
-      !!----------------------------------------------------------------------
-      !
-      ipj=4
-      ALLOCATE(        ztab_e(jpiglo, 1-kextj:ipj+kextj)       ,       &
-     &            znorthloc_e(jpimax, 1-kextj:ipj+kextj)       ,       &
-     &          znorthgloio_e(jpimax, 1-kextj:ipj+kextj,jpni)    )
-      !
-      ztab_e(:,:)      = 0._wp
-      znorthloc_e(:,:) = 0._wp
-      !
-      ij = 1 - kextj
-      ! put the last ipj+2*kextj lines of pt2d into znorthloc_e 
-      DO jj = jpj - ipj + 1 - kextj , jpj + kextj
-         znorthloc_e(1:jpi,ij)=pt2d(1:jpi,jj)
-         ij = ij + 1
-      END DO
-      !
-      itaille = jpimax * ( ipj + 2*kextj )
-      !
-      IF( ln_timing ) CALL tic_tac(.TRUE.)
-      CALL MPI_ALLGATHER( znorthloc_e(1,1-kextj)    , itaille, MPI_DOUBLE_PRECISION,    &
-         &                znorthgloio_e(1,1-kextj,1), itaille, MPI_DOUBLE_PRECISION,    &
-         &                ncomm_north, ierr )
-      !
-      IF( ln_timing ) CALL tic_tac(.FALSE.)
-      !
-      DO jr = 1, ndim_rank_north            ! recover the global north array
-         iproc = nrank_north(jr) + 1
-         ildi = nldit (iproc)
-         ilei = nleit (iproc)
-         iilb = nimppt(iproc)
-         DO jj = 1-kextj, ipj+kextj
-            DO ji = ildi, ilei
-               ztab_e(ji+iilb-1,jj) = znorthgloio_e(ji,jj,jr)
-            END DO
-         END DO
-      END DO
-
-      ! 2. North-Fold boundary conditions
-      ! ----------------------------------
-      CALL lbc_nfd( ztab_e(:,1-kextj:ipj+kextj), cd_type, psgn, kextj )
-
-      ij = 1 - kextj
-      !! Scatter back to pt2d
-      DO jj = jpj - ipj + 1 - kextj , jpj + kextj
-         DO ji= 1, jpi
-            pt2d(ji,jj) = ztab_e(ji+nimpp-1,ij)
-         END DO
-         ij  = ij +1
-      END DO
-      !
-      DEALLOCATE( ztab_e, znorthloc_e, znorthgloio_e )
-      !
-   END SUBROUTINE mpp_lbc_north_icb
-
-
-   SUBROUTINE mpp_lnk_2d_icb( cdname, pt2d, cd_type, psgn, kexti, kextj )
-      !!----------------------------------------------------------------------
-      !!                  ***  routine mpp_lnk_2d_icb  ***
-      !!
-      !! ** Purpose :   Message passing management for 2d array (with extra halo for icebergs)
-      !!                This routine receives a (1-kexti:jpi+kexti,1-kexti:jpj+kextj)
-      !!                array (usually (0:jpi+1, 0:jpj+1)) from lbc_lnk_icb calls.
-      !!
-      !! ** Method  :   Use mppsend and mpprecv function for passing mask
-      !!      between processors following neighboring subdomains.
-      !!            domain parameters
-      !!                    jpi    : first dimension of the local subdomain
-      !!                    jpj    : second dimension of the local subdomain
-      !!                    kexti  : number of columns for extra outer halo
-      !!                    kextj  : number of rows for extra outer halo
-      !!                    nbondi : mark for "east-west local boundary"
-      !!                    nbondj : mark for "north-south local boundary"
-      !!                    noea   : number for local neighboring processors
-      !!                    nowe   : number for local neighboring processors
-      !!                    noso   : number for local neighboring processors
-      !!                    nono   : number for local neighboring processors
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*)                                        , INTENT(in   ) ::   cdname      ! name of the calling subroutine
-      REAL(wp), DIMENSION(1-kexti:jpi+kexti,1-kextj:jpj+kextj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
-      CHARACTER(len=1)                                        , INTENT(in   ) ::   cd_type  ! nature of ptab array grid-points
-      REAL(wp)                                                , INTENT(in   ) ::   psgn     ! sign used across the north fold
-      INTEGER                                                 , INTENT(in   ) ::   kexti    ! extra i-halo width
-      INTEGER                                                 , INTENT(in   ) ::   kextj    ! extra j-halo width
-      !
-      INTEGER  ::   jl   ! dummy loop indices
-      INTEGER  ::   imigr, iihom, ijhom        ! local integers
-      INTEGER  ::   ipreci, iprecj             !   -       -
-      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
-      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
-      !!
-      REAL(wp), DIMENSION(1-kexti:jpi+kexti,nn_hls+kextj,2) ::   r2dns, r2dsn
-      REAL(wp), DIMENSION(1-kextj:jpj+kextj,nn_hls+kexti,2) ::   r2dwe, r2dew
-      !!----------------------------------------------------------------------
-
-      ipreci = nn_hls + kexti      ! take into account outer extra 2D overlap area
-      iprecj = nn_hls + kextj
-
-      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, 1, 1, 1, ld_lbc = .TRUE. )
-
-      ! 1. standard boundary treatment
-      ! ------------------------------
-      ! Order matters Here !!!!
-      !
-      !                                      ! East-West boundaries
-      !                                           !* Cyclic east-west
-      IF( l_Iperio ) THEN
-         pt2d(1-kexti:     1   ,:) = pt2d(jpim1-kexti: jpim1 ,:)       ! east
-         pt2d(  jpi  :jpi+kexti,:) = pt2d(     2     :2+kexti,:)       ! west
-         !
-      ELSE                                        !* closed
-         IF( .NOT. cd_type == 'F' )   pt2d(  1-kexti   :nn_hls   ,:) = 0._wp    ! east except at F-point
-                                      pt2d(jpi-nn_hls+1:jpi+kexti,:) = 0._wp    ! west
-      ENDIF
-      !                                      ! North-South boundaries
-      IF( l_Jperio ) THEN                         !* cyclic (only with no mpp j-split)
-         pt2d(:,1-kextj:     1   ) = pt2d(:,jpjm1-kextj:  jpjm1)       ! north
-         pt2d(:,  jpj  :jpj+kextj) = pt2d(:,     2     :2+kextj)       ! south
-      ELSE                                        !* closed
-         IF( .NOT. cd_type == 'F' )   pt2d(:,  1-kextj   :nn_hls   ) = 0._wp    ! north except at F-point
-                                      pt2d(:,jpj-nn_hls+1:jpj+kextj) = 0._wp    ! south
-      ENDIF
-      !
-
-      ! north fold treatment
-      ! -----------------------
-      IF( npolj /= 0 ) THEN
-         !
-         SELECT CASE ( jpni )
-                   CASE ( 1 )     ;   CALL lbc_nfd          ( pt2d(1:jpi,1:jpj+kextj), cd_type, psgn, kextj )
-                   CASE DEFAULT   ;   CALL mpp_lbc_north_icb( pt2d(1:jpi,1:jpj+kextj), cd_type, psgn, kextj )
-         END SELECT
-         !
-      ENDIF
-
-      ! 2. East and west directions exchange
-      ! ------------------------------------
-      ! we play with the neigbours AND the row number because of the periodicity
-      !
-      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
-      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
-         iihom = jpi-nreci-kexti
-         DO jl = 1, ipreci
-            r2dew(:,jl,1) = pt2d(nn_hls+jl,:)
-            r2dwe(:,jl,1) = pt2d(iihom +jl,:)
-         END DO
-      END SELECT
-      !
-      !                           ! Migrations
-      imigr = ipreci * ( jpj + 2*kextj )
-      !
-      IF( ln_timing ) CALL tic_tac(.TRUE.)
-      !
-      SELECT CASE ( nbondi )
-      CASE ( -1 )
-         CALL mppsend( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req1 )
-         CALL mpprecv( 1, r2dew(1-kextj,1,2), imigr, noea )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      CASE ( 0 )
-         CALL mppsend( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
-         CALL mppsend( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req2 )
-         CALL mpprecv( 1, r2dew(1-kextj,1,2), imigr, noea )
-         CALL mpprecv( 2, r2dwe(1-kextj,1,2), imigr, nowe )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
-      CASE ( 1 )
-         CALL mppsend( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
-         CALL mpprecv( 2, r2dwe(1-kextj,1,2), imigr, nowe )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      END SELECT
-      !
-      IF( ln_timing ) CALL tic_tac(.FALSE.)
-      !
-      !                           ! Write Dirichlet lateral conditions
-      iihom = jpi - nn_hls
-      !
-      SELECT CASE ( nbondi )
-      CASE ( -1 )
-         DO jl = 1, ipreci
-            pt2d(iihom+jl,:) = r2dew(:,jl,2)
-         END DO
-      CASE ( 0 )
-         DO jl = 1, ipreci
-            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
-            pt2d(iihom+jl,:) = r2dew(:,jl,2)
-         END DO
-      CASE ( 1 )
-         DO jl = 1, ipreci
-            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
-         END DO
-      END SELECT
-
-
-      ! 3. North and south directions
-      ! -----------------------------
-      ! always closed : we play only with the neigbours
-      !
-      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
-         ijhom = jpj-nrecj-kextj
-         DO jl = 1, iprecj
-            r2dsn(:,jl,1) = pt2d(:,ijhom +jl)
-            r2dns(:,jl,1) = pt2d(:,nn_hls+jl)
-         END DO
-      ENDIF
-      !
-      !                           ! Migrations
-      imigr = iprecj * ( jpi + 2*kexti )
-      !
-      IF( ln_timing ) CALL tic_tac(.TRUE.)
-      !
-      SELECT CASE ( nbondj )
-      CASE ( -1 )
-         CALL mppsend( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req1 )
-         CALL mpprecv( 3, r2dns(1-kexti,1,2), imigr, nono )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      CASE ( 0 )
-         CALL mppsend( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
-         CALL mppsend( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req2 )
-         CALL mpprecv( 3, r2dns(1-kexti,1,2), imigr, nono )
-         CALL mpprecv( 4, r2dsn(1-kexti,1,2), imigr, noso )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-         IF(l_isend) CALL mpi_wait(ml_req2,ml_stat,ml_err)
-      CASE ( 1 )
-         CALL mppsend( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
-         CALL mpprecv( 4, r2dsn(1-kexti,1,2), imigr, noso )
-         IF(l_isend) CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      END SELECT
-      !
-      IF( ln_timing ) CALL tic_tac(.FALSE.)
-      !
-      !                           ! Write Dirichlet lateral conditions
-      ijhom = jpj - nn_hls
-      !
-      SELECT CASE ( nbondj )
-      CASE ( -1 )
-         DO jl = 1, iprecj
-            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
-         END DO
-      CASE ( 0 )
-         DO jl = 1, iprecj
-            pt2d(:,jl-kextj) = r2dsn(:,jl,2)
-            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
-         END DO
-      CASE ( 1 )
-         DO jl = 1, iprecj
-            pt2d(:,jl-kextj) = r2dsn(:,jl,2)
-         END DO
-      END SELECT
-      !
-   END SUBROUTINE mpp_lnk_2d_icb
-
-
    SUBROUTINE mpp_report( cdname, kpk, kpl, kpf, ld_lbc, ld_glb, ld_dlg )
       !!----------------------------------------------------------------------
@@ -1484,4 +911,5 @@
       INTEGER ::    ji,  jj,  jk,  jh, jf, jcount   ! dummy loop indices
       !!----------------------------------------------------------------------
+#if defined key_mpp_mpi
       !
       ll_lbc = .FALSE.
@@ -1594,4 +1022,5 @@
          DEALLOCATE(crname_lbc)
       ENDIF
+#endif
    END SUBROUTINE mpp_report
 
@@ -1604,4 +1033,5 @@
     REAL(wp),               SAVE :: tic_ct = 0._wp
     INTEGER :: ii
+#if defined key_mpp_mpi
 
     IF( ncom_stp <= nit000 ) RETURN
@@ -1619,258 +1049,24 @@
        tic_ct = MPI_Wtime()                                                        ! start count tac->tic (waiting time)
     ENDIF
+#endif
     
    END SUBROUTINE tic_tac
 
+#if ! defined key_mpp_mpi
+   SUBROUTINE mpi_wait(request, status, ierror)
+      INTEGER                            , INTENT(in   ) ::   request
+      INTEGER, DIMENSION(MPI_STATUS_SIZE), INTENT(  out) ::   status
+      INTEGER                            , INTENT(  out) ::   ierror
+   END SUBROUTINE mpi_wait
+
    
-#else
-   !!----------------------------------------------------------------------
-   !!   Default case:            Dummy module        share memory computing
-   !!----------------------------------------------------------------------
-   USE in_out_manager
-
-   INTERFACE mpp_sum
-      MODULE PROCEDURE mppsum_int, mppsum_a_int, mppsum_real, mppsum_a_real, mppsum_realdd, mppsum_a_realdd
-   END INTERFACE
-   INTERFACE mpp_max
-      MODULE PROCEDURE mppmax_a_int, mppmax_int, mppmax_a_real, mppmax_real
-   END INTERFACE
-   INTERFACE mpp_min
-      MODULE PROCEDURE mppmin_a_int, mppmin_int, mppmin_a_real, mppmin_real
-   END INTERFACE
-   INTERFACE mpp_minloc
-      MODULE PROCEDURE mpp_minloc2d ,mpp_minloc3d
-   END INTERFACE
-   INTERFACE mpp_maxloc
-      MODULE PROCEDURE mpp_maxloc2d ,mpp_maxloc3d
-   END INTERFACE
-
-   LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .FALSE.      !: mpp flag
-   LOGICAL, PUBLIC            ::   ln_nnogather          !: namelist control of northfold comms (needed here in case "key_mpp_mpi" is not used)
-   INTEGER, PUBLIC            ::   mpi_comm_oce          ! opa local communicator
-
-   INTEGER, PARAMETER, PUBLIC               ::   nbdelay = 0   ! make sure we don't enter loops: DO ji = 1, nbdelay
-   CHARACTER(len=32), DIMENSION(1), PUBLIC  ::   c_delaylist = 'empty'
-   CHARACTER(len=32), DIMENSION(1), PUBLIC  ::   c_delaycpnt = 'empty'
-   LOGICAL, PUBLIC                          ::   l_full_nf_update = .TRUE.
-   TYPE ::   DELAYARR
-      REAL(   wp), POINTER, DIMENSION(:) ::  z1d => NULL()
-      COMPLEX(wp), POINTER, DIMENSION(:) ::  y1d => NULL()
-   END TYPE DELAYARR
-   TYPE( DELAYARR ), DIMENSION(1), PUBLIC  ::   todelay              
-   INTEGER,  PUBLIC, DIMENSION(1)           ::   ndelayid = -1
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   INTEGER FUNCTION lib_mpp_alloc(kumout)          ! Dummy function
-      INTEGER, INTENT(in) ::   kumout
-      lib_mpp_alloc = 0
-   END FUNCTION lib_mpp_alloc
-
-   FUNCTION mynode( ldtxt, ldname, kumnam_ref, knumnam_cfg,  kumond , kstop, localComm ) RESULT (function_value)
-      INTEGER, OPTIONAL            , INTENT(in   ) ::   localComm
-      CHARACTER(len=*),DIMENSION(:) ::   ldtxt
-      CHARACTER(len=*) ::   ldname
-      INTEGER ::   kumnam_ref, knumnam_cfg , kumond , kstop
-      IF( PRESENT( localComm ) ) mpi_comm_oce = localComm
-      function_value = 0
-      IF( .FALSE. )   ldtxt(:) = 'never done'
-      CALL ctl_opn( kumond, TRIM(ldname), 'UNKNOWN', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. , 1 )
-   END FUNCTION mynode
-
-   SUBROUTINE mppsync                       ! Dummy routine
-   END SUBROUTINE mppsync
-
-   !!----------------------------------------------------------------------
-   !!    ***  mppmax_a_int, mppmax_int, mppmax_a_real, mppmax_real  ***
-   !!   
-   !!----------------------------------------------------------------------
-   !!
-#  define OPERATION_MAX
-#  define INTEGER_TYPE
-#  define DIM_0d
-#     define ROUTINE_ALLREDUCE           mppmax_int
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_0d
-#  define DIM_1d
-#     define ROUTINE_ALLREDUCE           mppmax_a_int
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_1d
-#  undef INTEGER_TYPE
-!
-#  define REAL_TYPE
-#  define DIM_0d
-#     define ROUTINE_ALLREDUCE           mppmax_real
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_0d
-#  define DIM_1d
-#     define ROUTINE_ALLREDUCE           mppmax_a_real
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_1d
-#  undef REAL_TYPE
-#  undef OPERATION_MAX
-   !!----------------------------------------------------------------------
-   !!    ***  mppmin_a_int, mppmin_int, mppmin_a_real, mppmin_real  ***
-   !!   
-   !!----------------------------------------------------------------------
-   !!
-#  define OPERATION_MIN
-#  define INTEGER_TYPE
-#  define DIM_0d
-#     define ROUTINE_ALLREDUCE           mppmin_int
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_0d
-#  define DIM_1d
-#     define ROUTINE_ALLREDUCE           mppmin_a_int
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_1d
-#  undef INTEGER_TYPE
-!
-#  define REAL_TYPE
-#  define DIM_0d
-#     define ROUTINE_ALLREDUCE           mppmin_real
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_0d
-#  define DIM_1d
-#     define ROUTINE_ALLREDUCE           mppmin_a_real
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_1d
-#  undef REAL_TYPE
-#  undef OPERATION_MIN
-
-   !!----------------------------------------------------------------------
-   !!    ***  mppsum_a_int, mppsum_int, mppsum_a_real, mppsum_real  ***
-   !!   
-   !!   Global sum of 1D array or a variable (integer, real or complex)
-   !!----------------------------------------------------------------------
-   !!
-#  define OPERATION_SUM
-#  define INTEGER_TYPE
-#  define DIM_0d
-#     define ROUTINE_ALLREDUCE           mppsum_int
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_0d
-#  define DIM_1d
-#     define ROUTINE_ALLREDUCE           mppsum_a_int
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_1d
-#  undef INTEGER_TYPE
-!
-#  define REAL_TYPE
-#  define DIM_0d
-#     define ROUTINE_ALLREDUCE           mppsum_real
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_0d
-#  define DIM_1d
-#     define ROUTINE_ALLREDUCE           mppsum_a_real
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_1d
-#  undef REAL_TYPE
-#  undef OPERATION_SUM
-
-#  define OPERATION_SUM_DD
-#  define COMPLEX_TYPE
-#  define DIM_0d
-#     define ROUTINE_ALLREDUCE           mppsum_realdd
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_0d
-#  define DIM_1d
-#     define ROUTINE_ALLREDUCE           mppsum_a_realdd
-#     include "mpp_allreduce_generic.h90"
-#     undef ROUTINE_ALLREDUCE
-#  undef DIM_1d
-#  undef COMPLEX_TYPE
-#  undef OPERATION_SUM_DD
-
-   !!----------------------------------------------------------------------
-   !!    ***  mpp_minloc2d, mpp_minloc3d, mpp_maxloc2d, mpp_maxloc3d
-   !!   
-   !!----------------------------------------------------------------------
-   !!
-#  define OPERATION_MINLOC
-#  define DIM_2d
-#     define ROUTINE_LOC           mpp_minloc2d
-#     include "mpp_loc_generic.h90"
-#     undef ROUTINE_LOC
-#  undef DIM_2d
-#  define DIM_3d
-#     define ROUTINE_LOC           mpp_minloc3d
-#     include "mpp_loc_generic.h90"
-#     undef ROUTINE_LOC
-#  undef DIM_3d
-#  undef OPERATION_MINLOC
-
-#  define OPERATION_MAXLOC
-#  define DIM_2d
-#     define ROUTINE_LOC           mpp_maxloc2d
-#     include "mpp_loc_generic.h90"
-#     undef ROUTINE_LOC
-#  undef DIM_2d
-#  define DIM_3d
-#     define ROUTINE_LOC           mpp_maxloc3d
-#     include "mpp_loc_generic.h90"
-#     undef ROUTINE_LOC
-#  undef DIM_3d
-#  undef OPERATION_MAXLOC
-
-   SUBROUTINE mpp_delay_sum( cdname, cdelay, y_in, pout, ldlast, kcom )
-      CHARACTER(len=*), INTENT(in   )               ::   cdname  ! name of the calling subroutine
-      CHARACTER(len=*), INTENT(in   )               ::   cdelay  ! name (used as id) of the delayed operation
-      COMPLEX(wp),      INTENT(in   ), DIMENSION(:) ::   y_in
-      REAL(wp),         INTENT(  out), DIMENSION(:) ::   pout
-      LOGICAL,          INTENT(in   )               ::   ldlast  ! true if this is the last time we call this routine
-      INTEGER,          INTENT(in   ), OPTIONAL     ::   kcom
-      !
-      pout(:) = REAL(y_in(:), wp)
-   END SUBROUTINE mpp_delay_sum
-
-   SUBROUTINE mpp_delay_max( cdname, cdelay, p_in, pout, ldlast, kcom )
-      CHARACTER(len=*), INTENT(in   )               ::   cdname  ! name of the calling subroutine
-      CHARACTER(len=*), INTENT(in   )               ::   cdelay  ! name (used as id) of the delayed operation
-      REAL(wp),         INTENT(in   ), DIMENSION(:) ::   p_in
-      REAL(wp),         INTENT(  out), DIMENSION(:) ::   pout
-      LOGICAL,          INTENT(in   )               ::   ldlast  ! true if this is the last time we call this routine
-      INTEGER,          INTENT(in   ), OPTIONAL     ::   kcom
-      !
-      pout(:) = p_in(:)
-   END SUBROUTINE mpp_delay_max
-
-   SUBROUTINE mpp_delay_rcv( kid )
-      INTEGER,INTENT(in   )      ::  kid 
-      WRITE(*,*) 'mpp_delay_rcv: You should not have seen this print! error?', kid
-   END SUBROUTINE mpp_delay_rcv
-   
-   SUBROUTINE mppstop( ldfinal, ld_force_abort )
-      LOGICAL, OPTIONAL, INTENT(in) :: ldfinal    ! source process number
-      LOGICAL, OPTIONAL, INTENT(in) :: ld_force_abort    ! source process number
-      STOP      ! non MPP case, just stop the run
-   END SUBROUTINE mppstop
-
-   SUBROUTINE mpp_ini_znl( knum )
-      INTEGER :: knum
-      WRITE(*,*) 'mpp_ini_znl: You should not have seen this print! error?', knum
-   END SUBROUTINE mpp_ini_znl
-
-   SUBROUTINE mpp_comm_free( kcom )
-      INTEGER :: kcom
-      WRITE(*,*) 'mpp_comm_free: You should not have seen this print! error?', kcom
-   END SUBROUTINE mpp_comm_free
-   
-#endif
-
-   !!----------------------------------------------------------------------
-   !!   All cases:         ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam   routines
+   FUNCTION MPI_Wtime()
+      REAL(wp) ::  MPI_Wtime
+      MPI_Wtime = -1.
+   END FUNCTION MPI_Wtime
+#endif
+
+   !!----------------------------------------------------------------------
+   !!   ctl_stop, ctl_warn, get_unit, ctl_opn, ctl_nam   routines
    !!----------------------------------------------------------------------
 
@@ -1883,15 +1079,20 @@
       !!                increment the error number (nstop) by one.
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
-      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
+      CHARACTER(len=*), INTENT(in   )           ::   cd1
+      CHARACTER(len=*), INTENT(in   ), OPTIONAL ::        cd2, cd3, cd4, cd5
+      CHARACTER(len=*), INTENT(in   ), OPTIONAL ::   cd6, cd7, cd8, cd9, cd10
       !!----------------------------------------------------------------------
       !
       nstop = nstop + 1
-
-      ! force to open ocean.output file
+      !
+      ! force to open ocean.output file if not already opened
       IF( numout == 6 ) CALL ctl_opn( numout, 'ocean.output', 'APPEND', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-       
-      WRITE(numout,cform_err)
-      IF( PRESENT(cd1 ) )   WRITE(numout,*) TRIM(cd1)
+      !
+                            WRITE(numout,*)
+                            WRITE(numout,*) ' ===>>> : E R R O R'
+                            WRITE(numout,*)
+                            WRITE(numout,*) '         ==========='
+                            WRITE(numout,*)
+                            WRITE(numout,*) TRIM(cd1)
       IF( PRESENT(cd2 ) )   WRITE(numout,*) TRIM(cd2)
       IF( PRESENT(cd3 ) )   WRITE(numout,*) TRIM(cd3)
@@ -1903,5 +1104,6 @@
       IF( PRESENT(cd9 ) )   WRITE(numout,*) TRIM(cd9)
       IF( PRESENT(cd10) )   WRITE(numout,*) TRIM(cd10)
-
+                            WRITE(numout,*)
+      !
                                CALL FLUSH(numout    )
       IF( numstp     /= -1 )   CALL FLUSH(numstp    )
@@ -1910,6 +1112,8 @@
       !
       IF( cd1 == 'STOP' ) THEN
+         WRITE(numout,*)  
          WRITE(numout,*)  'huge E-R-R-O-R : immediate stop'
-         CALL mppstop(ld_force_abort = .true.)
+         WRITE(numout,*)  
+         CALL mppstop( ld_abort = .true. )
       ENDIF
       !
@@ -1930,16 +1134,22 @@
       !
       nwarn = nwarn + 1
+      !
       IF(lwp) THEN
-         WRITE(numout,cform_war)
-         IF( PRESENT(cd1 ) ) WRITE(numout,*) TRIM(cd1)
-         IF( PRESENT(cd2 ) ) WRITE(numout,*) TRIM(cd2)
-         IF( PRESENT(cd3 ) ) WRITE(numout,*) TRIM(cd3)
-         IF( PRESENT(cd4 ) ) WRITE(numout,*) TRIM(cd4)
-         IF( PRESENT(cd5 ) ) WRITE(numout,*) TRIM(cd5)
-         IF( PRESENT(cd6 ) ) WRITE(numout,*) TRIM(cd6)
-         IF( PRESENT(cd7 ) ) WRITE(numout,*) TRIM(cd7)
-         IF( PRESENT(cd8 ) ) WRITE(numout,*) TRIM(cd8)
-         IF( PRESENT(cd9 ) ) WRITE(numout,*) TRIM(cd9)
-         IF( PRESENT(cd10) ) WRITE(numout,*) TRIM(cd10)
+                               WRITE(numout,*)
+                               WRITE(numout,*) ' ===>>> : W A R N I N G'
+                               WRITE(numout,*)
+                               WRITE(numout,*) '         ==============='
+                               WRITE(numout,*)
+         IF( PRESENT(cd1 ) )   WRITE(numout,*) TRIM(cd1)
+         IF( PRESENT(cd2 ) )   WRITE(numout,*) TRIM(cd2)
+         IF( PRESENT(cd3 ) )   WRITE(numout,*) TRIM(cd3)
+         IF( PRESENT(cd4 ) )   WRITE(numout,*) TRIM(cd4)
+         IF( PRESENT(cd5 ) )   WRITE(numout,*) TRIM(cd5)
+         IF( PRESENT(cd6 ) )   WRITE(numout,*) TRIM(cd6)
+         IF( PRESENT(cd7 ) )   WRITE(numout,*) TRIM(cd7)
+         IF( PRESENT(cd8 ) )   WRITE(numout,*) TRIM(cd8)
+         IF( PRESENT(cd9 ) )   WRITE(numout,*) TRIM(cd9)
+         IF( PRESENT(cd10) )   WRITE(numout,*) TRIM(cd10)
+                               WRITE(numout,*)
       ENDIF
       CALL FLUSH(numout)
@@ -1984,6 +1194,5 @@
       IF( TRIM(cdfile) == '/dev/null' )   clfile = TRIM(cdfile)   ! force the use of /dev/null
       !
-      iost=0
-      IF( cdacce(1:6) == 'DIRECT' )  THEN         ! cdacce has always more than 6 characters
+      IF(       cdacce(1:6) == 'DIRECT' )  THEN   ! cdacce has always more than 6 characters
          OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh         , ERR=100, IOSTAT=iost )
       ELSE IF( TRIM(cdstat) == 'APPEND' )  THEN   ! cdstat can have less than 6 characters
@@ -2006,29 +1215,13 @@
 100   CONTINUE
       IF( iost /= 0 ) THEN
-         IF(ldwp) THEN
-            WRITE(kout,*)
-            WRITE(kout,*) ' ===>>>> : bad opening file: ', TRIM(clfile)
-            WRITE(kout,*) ' =======   ===  '
-            WRITE(kout,*) '           unit   = ', knum
-            WRITE(kout,*) '           status = ', cdstat
-            WRITE(kout,*) '           form   = ', cdform
-            WRITE(kout,*) '           access = ', cdacce
-            WRITE(kout,*) '           iostat = ', iost
-            WRITE(kout,*) '           we stop. verify the file '
-            WRITE(kout,*)
-         ELSE  !!! Force writing to make sure we get the information - at least once - in this violent STOP!!
-            WRITE(*,*)
-            WRITE(*,*) ' ===>>>> : bad opening file: ', TRIM(clfile)
-            WRITE(*,*) ' =======   ===  '
-            WRITE(*,*) '           unit   = ', knum
-            WRITE(*,*) '           status = ', cdstat
-            WRITE(*,*) '           form   = ', cdform
-            WRITE(*,*) '           access = ', cdacce
-            WRITE(*,*) '           iostat = ', iost
-            WRITE(*,*) '           we stop. verify the file '
-            WRITE(*,*)
-         ENDIF
-         CALL FLUSH( kout ) 
-         STOP 'ctl_opn bad opening'
+         WRITE(ctmp1,*) ' ===>>>> : bad opening file: ', TRIM(clfile)
+         WRITE(ctmp2,*) ' =======   ===  '
+         WRITE(ctmp3,*) '           unit   = ', knum
+         WRITE(ctmp4,*) '           status = ', cdstat
+         WRITE(ctmp5,*) '           form   = ', cdform
+         WRITE(ctmp6,*) '           access = ', cdacce
+         WRITE(ctmp7,*) '           iostat = ', iost
+         WRITE(ctmp8,*) '           we stop. verify the file '
+         CALL ctl_stop( 'STOP', ctmp1, ctmp2, ctmp3, ctmp4, ctmp5, ctmp6, ctmp7, ctmp8 )
       ENDIF
       !
@@ -2036,5 +1229,5 @@
 
 
-   SUBROUTINE ctl_nam ( kios, cdnam, ldwp )
+   SUBROUTINE ctl_nam ( kios, cdnam )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE ctl_nam  ***
@@ -2044,8 +1237,8 @@
       !! ** Method  :   Fortan open
       !!----------------------------------------------------------------------
-      INTEGER         , INTENT(inout) ::   kios    ! IO status after reading the namelist
-      CHARACTER(len=*), INTENT(in   ) ::   cdnam   ! group name of namelist for which error occurs
-      CHARACTER(len=5)                ::   clios   ! string to convert iostat in character for print
-      LOGICAL         , INTENT(in   ) ::   ldwp    ! boolean term for print
+      INTEGER                                , INTENT(inout) ::   kios    ! IO status after reading the namelist
+      CHARACTER(len=*)                       , INTENT(in   ) ::   cdnam   ! group name of namelist for which error occurs
+      !
+      CHARACTER(len=5) ::   clios   ! string to convert iostat in character for print
       !!----------------------------------------------------------------------
       !
@@ -2061,5 +1254,4 @@
       ENDIF
       kios = 0
-      RETURN
       !
    END SUBROUTINE ctl_nam
@@ -2082,6 +1274,5 @@
       END DO
       IF( (get_unit == 999) .AND. llopn ) THEN
-         CALL ctl_stop( 'get_unit: All logical units until 999 are used...' )
-         get_unit = -1
+         CALL ctl_stop( 'STOP', 'get_unit: All logical units until 999 are used...' )
       ENDIF
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mpp_bdy_generic.h90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mpp_bdy_generic.h90	(revision 12062)
+++ 	(revision )
@@ -1,317 +1,0 @@
-#   define ARRAY_TYPE(i,j,k,l,f)    REAL(wp)                    , INTENT(inout) ::   ARRAY_IN(i,j,k,l,f)
-#   define NAT_IN(k)                cd_nat
-#   define SGN_IN(k)                psgn
-#   define IBD_IN(k)                kb_bdy
-#   define F_SIZE(ptab)             1
-#   define OPT_K(k)                 
-#   if defined DIM_2d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
-#      define K_SIZE(ptab)          1
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k,l)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          SIZE(ptab,4)
-#   endif
-
-   SUBROUTINE ROUTINE_BDY( cdname, ptab, cd_nat, psgn      , kb_bdy )
-      !!----------------------------------------------------------------------
-      !!                  ***  routine mpp_lnk_bdy_3d  ***
-      !!
-      !! ** Purpose :   Message passing management
-      !!
-      !! ** Method  :   Use mppsend and mpprecv function for passing BDY boundaries 
-      !!      between processors following neighboring subdomains.
-      !!            domain parameters
-      !!                    nlci   : first dimension of the local subdomain
-      !!                    nlcj   : second dimension of the local subdomain
-      !!                    nbondi_bdy : mark for "east-west local boundary"
-      !!                    nbondj_bdy : mark for "north-south local boundary"
-      !!                    noea   : number for local neighboring processors 
-      !!                    nowe   : number for local neighboring processors
-      !!                    noso   : number for local neighboring processors
-      !!                    nono   : number for local neighboring processors
-      !!
-      !! ** Action  :   ptab with update value at its periphery
-      !!
-      !!----------------------------------------------------------------------
-      CHARACTER(len=*)            , INTENT(in   ) ::   cdname      ! name of the calling subroutine
-      ARRAY_TYPE(:,:,:,:,:)   ! array or pointer of arrays on which the boundary condition is applied
-      CHARACTER(len=1)            , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
-      REAL(wp)                    , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
-      INTEGER                     , INTENT(in   ) ::   IBD_IN(:)   ! BDY boundary set
-      !
-      INTEGER  ::   ji, jj, jk, jl, jh, jf     ! dummy loop indices
-      INTEGER  ::   ipk, ipl, ipf              ! 3dimension of the input array
-      INTEGER  ::   imigr, iihom, ijhom        ! local integers
-      INTEGER  ::   ml_req1, ml_req2, ml_err   ! for key_mpi_isend
-      REAL(wp) ::   zland                      ! local scalar
-      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat   ! for key_mpi_isend
-      !
-      REAL(wp), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   zt3ns, zt3sn   ! 3d for north-south & south-north
-      REAL(wp), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   zt3ew, zt3we   ! 3d for east-west & west-east
-      !!----------------------------------------------------------------------
-      !
-      ipk = K_SIZE(ptab)   ! 3rd dimension
-      ipl = L_SIZE(ptab)   ! 4th    -
-      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
-      !
-      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. )
-      !      
-      ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,2), zt3sn(jpi,nn_hls,ipk,ipl,ipf,2),   &
-         &      zt3ew(jpj,nn_hls,ipk,ipl,ipf,2), zt3we(jpj,nn_hls,ipk,ipl,ipf,2)  )
-
-      zland = 0._wp
-
-      ! 1. standard boundary treatment
-      ! ------------------------------
-      !
-      DO jf = 1, ipf                   ! number of arrays to be treated
-         !
-         !                                ! East-West boundaries
-         !                    
-         IF( nbondi == 2) THEN                  ! neither subdomain to the east nor to the west
-            !                                      !* Cyclic
-            IF( l_Iperio ) THEN
-               ARRAY_IN( 1 ,:,:,:,jf) = ARRAY_IN(jpim1,:,:,:,jf)
-               ARRAY_IN(jpi,:,:,:,jf) = ARRAY_IN(  2  ,:,:,:,jf)
-            ELSE                                   !* Closed
-               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(     1       :nn_hls,:,:,:,jf) = zland  ! east except F-point
-                                               ARRAY_IN(nlci-nn_hls+1:jpi   ,:,:,:,jf) = zland  ! west
-            ENDIF
-         ELSEIF(nbondi == -1) THEN              ! subdomain to the east only
-            IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(1:nn_hls,:,:,:,jf) = zland     ! south except F-point
-            !
-         ELSEIF(nbondi ==  1) THEN              ! subdomain to the west only
-            ARRAY_IN(nlci-nn_hls+1:jpi,:,:,:,jf) = zland    ! north
-         ENDIF
-         !                                ! North-South boundaries
-         !
-         IF( nbondj == 2) THEN                  ! neither subdomain to the north nor to the south
-            !                                      !* Cyclic
-            IF( l_Jperio ) THEN
-               ARRAY_IN(:, 1 ,:,:,jf) = ARRAY_IN(:,jpjm1,:,:,jf)
-               ARRAY_IN(:,jpj,:,:,jf) = ARRAY_IN(:,  2  ,:,:,jf)
-            ELSE                                   !* Closed
-               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(:,     1       :nn_hls,:,:,jf) = zland  ! east except F-point
-                                               ARRAY_IN(:,nlcj-nn_hls+1:jpj   ,:,:,jf) = zland  ! west
-            ENDIF
-         ELSEIF(nbondj == -1) THEN              ! subdomain to the east only
-            IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(:,1:nn_hls,:,:,jf) = zland     ! south except F-point
-            !
-         ELSEIF(nbondj ==  1) THEN              ! subdomain to the west only
-            ARRAY_IN(:,nlcj-nn_hls+1:jpj,:,:,jf) = zland    ! north
-         ENDIF
-         !
-      END DO
-
-      ! 2. East and west directions exchange
-      ! ------------------------------------
-      ! we play with the neigbours AND the row number because of the periodicity 
-      !
-      !
-      DO jf = 1, ipf
-         SELECT CASE ( nbondi_bdy(IBD_IN(jf)) )      ! Read Dirichlet lateral conditions
-         CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
-            iihom = nlci-nreci
-               DO jl = 1, ipl
-                  DO jk = 1, ipk
-                     DO jh = 1, nn_hls
-                        zt3ew(:,jh,jk,jl,jf,1) = ARRAY_IN(nn_hls+jh,:,jk,jl,jf)
-                        zt3we(:,jh,jk,jl,jf,1) = ARRAY_IN(iihom +jh,:,jk,jl,jf)
-                     END DO
-                  END DO
-               END DO
-         END SELECT
-         !
-         !                           ! Migrations
-!!gm      imigr = nn_hls * jpj * ipk * ipl * ipf
-         imigr = nn_hls * jpj * ipk * ipl
-         !
-         IF( ln_timing ) CALL tic_tac(.TRUE.)
-         !
-         SELECT CASE ( nbondi_bdy(IBD_IN(jf)) )
-         CASE ( -1 )
-            CALL mppsend( 2, zt3we(1,1,1,1,1,1), imigr, noea, ml_req1 )
-         CASE ( 0 )
-            CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
-            CALL mppsend( 2, zt3we(1,1,1,1,1,1), imigr, noea, ml_req2 )
-         CASE ( 1 )
-            CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
-         END SELECT
-         !
-         SELECT CASE ( nbondi_bdy_b(IBD_IN(jf)) )
-         CASE ( -1 )
-            CALL mpprecv( 1, zt3ew(1,1,1,1,1,2), imigr, noea )
-         CASE ( 0 )
-            CALL mpprecv( 1, zt3ew(1,1,1,1,1,2), imigr, noea )
-            CALL mpprecv( 2, zt3we(1,1,1,1,1,2), imigr, nowe )
-         CASE ( 1 )
-            CALL mpprecv( 2, zt3we(1,1,1,1,1,2), imigr, nowe )
-         END SELECT
-         !
-         SELECT CASE ( nbondi_bdy(IBD_IN(jf)) )
-         CASE ( -1 )
-            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
-         CASE ( 0 )
-            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
-            IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
-         CASE ( 1 )
-            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
-         END SELECT
-         !
-         IF( ln_timing ) CALL tic_tac(.FALSE.)
-         !
-         !                           ! Write Dirichlet lateral conditions
-         iihom = nlci-nn_hls
-         !
-         !
-         SELECT CASE ( nbondi_bdy_b(IBD_IN(jf)) )
-         CASE ( -1 )
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,2)
-                  END DO
-               END DO
-            END DO
-         CASE ( 0 )
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,2)
-                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,2)
-                  END DO
-               END DO
-            END DO
-         CASE ( 1 )
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,2)
-                  END DO
-               END DO
-            END DO
-         END SELECT
-         !
-      END DO
-
-      ! 3. north fold treatment
-      ! -----------------------
-      !
-      ! do it before south directions so concerned processes can do it without waiting for the comm with the sourthern neighbor
-      IF( npolj /= 0) THEN
-         !
-         SELECT CASE ( jpni )
-         CASE ( 1 )     ;   CALL lbc_nfd( ptab, NAT_IN(:), SGN_IN(:) OPT_K(:) )   ! only 1 northern proc, no mpp
-         CASE DEFAULT   ;   CALL mpp_nfd( ptab, NAT_IN(:), SGN_IN(:) OPT_K(:) )   ! for all northern procs.
-         END SELECT
-         !
-      ENDIF
-
-      ! 4. North and south directions
-      ! -----------------------------
-      ! always closed : we play only with the neigbours
-      !
-      DO jf = 1, ipf
-         IF( nbondj_bdy(IBD_IN(jf)) /= 2 ) THEN      ! Read Dirichlet lateral conditions
-            ijhom = nlcj-nrecj
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     zt3sn(:,jh,jk,jl,jf,1) = ARRAY_IN(:,ijhom +jh,jk,jl,jf)
-                     zt3ns(:,jh,jk,jl,jf,1) = ARRAY_IN(:,nn_hls+jh,jk,jl,jf)
-                  END DO
-               END DO
-            END DO
-         ENDIF
-         !
-         !                           ! Migrations
-!!gm      imigr = nn_hls * jpi * ipk * ipl * ipf
-         imigr = nn_hls * jpi * ipk * ipl
-         !
-         IF( ln_timing ) CALL tic_tac(.TRUE.)
-         ! 
-         SELECT CASE ( nbondj_bdy(IBD_IN(jf)) )
-         CASE ( -1 )
-            CALL mppsend( 4, zt3sn(1,1,1,1,1,1), imigr, nono, ml_req1 )
-         CASE ( 0 )
-            CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
-            CALL mppsend( 4, zt3sn(1,1,1,1,1,1), imigr, nono, ml_req2 )
-         CASE ( 1 )
-            CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
-         END SELECT
-         ! 
-         SELECT CASE ( nbondj_bdy_b(IBD_IN(jf)) )
-         CASE ( -1 )
-            CALL mpprecv( 3, zt3ns(1,1,1,1,1,2), imigr, nono )
-         CASE ( 0 )
-            CALL mpprecv( 3, zt3ns(1,1,1,1,1,2), imigr, nono )
-            CALL mpprecv( 4, zt3sn(1,1,1,1,1,2), imigr, noso )
-         CASE ( 1 )
-            CALL mpprecv( 4, zt3sn(1,1,1,1,1,2), imigr, noso )
-         END SELECT
-         ! 
-         SELECT CASE ( nbondj_bdy(IBD_IN(jf)) )
-         CASE ( -1 )
-            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
-         CASE ( 0 )
-            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
-            IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
-         CASE ( 1 )
-            IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
-         END SELECT
-         !
-         IF( ln_timing ) CALL tic_tac(.FALSE.)
-         !
-         !                           ! Write Dirichlet lateral conditions
-         ijhom = nlcj-nn_hls
-         !
-         SELECT CASE ( nbondj_bdy_b(IBD_IN(jf)) )
-         CASE ( -1 )
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,2)
-                  END DO
-               END DO
-            END DO
-         CASE ( 0 )
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(:,      jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,2)
-                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,2)
-                  END DO
-               END DO
-            END DO
-         CASE ( 1 )
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(:,jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,2)
-                  END DO
-               END DO
-            END DO
-         END SELECT
-      END DO
-      !
-      DEALLOCATE( zt3ns, zt3sn, zt3ew, zt3we  )
-      !
-   END SUBROUTINE ROUTINE_BDY
-
-#undef ARRAY_TYPE
-#undef NAT_IN
-#undef SGN_IN
-#undef IBD_IN
-#undef ARRAY_IN
-#undef K_SIZE
-#undef L_SIZE
-#undef F_SIZE
-#undef OPT_K
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mpp_lnk_generic.h90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mpp_lnk_generic.h90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mpp_lnk_generic.h90	(revision 12143)
@@ -46,26 +46,37 @@
 
 #if defined MULTI
-   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn, kfld, cd_mpp, pval )
-      INTEGER                     , INTENT(in   ) ::   kfld        ! number of pt3d arrays
+   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, lsend, lrecv, ihlcom )
+      INTEGER             , INTENT(in   ) ::   kfld        ! number of pt3d arrays
 #else
-   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn      , cd_mpp, pval )
+   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn      , kfillmode, pfillval, lsend, lrecv, ihlcom )
 #endif
       ARRAY_TYPE(:,:,:,:,:)                                        ! array or pointer of arrays on which the boundary condition is applied
-      CHARACTER(len=*)            , INTENT(in   ) ::   cdname      ! name of the calling subroutine
-      CHARACTER(len=1)            , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
-      REAL(wp)                    , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
-      CHARACTER(len=3), OPTIONAL  , INTENT(in   ) ::   cd_mpp      ! fill the overlap area only
-      REAL(wp)        , OPTIONAL  , INTENT(in   ) ::   pval        ! background value (used at closed boundaries)
-      !
-      INTEGER  ::    ji,  jj,  jk,  jl, jh, jf   ! dummy loop indices
+      CHARACTER(len=*)              , INTENT(in   ) ::   cdname      ! name of the calling subroutine
+      CHARACTER(len=1)              , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
+      REAL(wp)                      , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
+      INTEGER ,             OPTIONAL, INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
+      REAL(wp),             OPTIONAL, INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
+      LOGICAL, DIMENSION(4),OPTIONAL, INTENT(in   ) ::   lsend, lrecv  ! communication with other 4 proc
+      INTEGER              ,OPTIONAL, INTENT(in   ) ::   ihlcom        ! number of ranks and rows to be communicated
+      !
+      INTEGER  ::    ji,  jj,  jk,  jl,  jf      ! dummy loop indices
       INTEGER  ::   ipi, ipj, ipk, ipl, ipf      ! dimension of the input array
-      INTEGER  ::   imigr, iihom, ijhom          ! local integers
-      INTEGER  ::   ml_req1, ml_req2, ml_err     ! for key_mpi_isend
+      INTEGER  ::   isize, ishift, ishift2       ! local integers
+      INTEGER  ::   ireq_we, ireq_ea, ireq_so, ireq_no     ! mpi_request id
       INTEGER  ::   ierr
+      INTEGER  ::   ifill_we, ifill_ea, ifill_so, ifill_no
+      INTEGER  ::   ihl                          ! number of ranks and rows to be communicated 
       REAL(wp) ::   zland
-      INTEGER , DIMENSION(MPI_STATUS_SIZE)      ::   ml_stat        ! for key_mpi_isend
-      REAL(wp), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   zt3ns, zt3sn   ! north-south & south-north  halos
-      REAL(wp), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   zt3ew, zt3we   ! east -west  & west - east  halos
+      INTEGER , DIMENSION(MPI_STATUS_SIZE)        ::   istat          ! for mpi_isend
+      REAL(wp), DIMENSION(:,:,:,:,:), ALLOCATABLE ::   zsnd_we, zrcv_we, zsnd_ea, zrcv_ea   ! east -west  & west - east  halos
+      REAL(wp), DIMENSION(:,:,:,:,:), ALLOCATABLE ::   zsnd_so, zrcv_so, zsnd_no, zrcv_no   ! north-south & south-north  halos
+      LOGICAL  ::   llsend_we, llsend_ea, llsend_no, llsend_so       ! communication send
+      LOGICAL  ::   llrecv_we, llrecv_ea, llrecv_no, llrecv_so       ! communication receive 
+      LOGICAL  ::   lldo_nfd                                     ! do north pole folding
       !!----------------------------------------------------------------------
+      !
+      ! ----------------------------------------- !
+      !     0. local variables initialization     !
+      ! ----------------------------------------- !
       !
       ipk = K_SIZE(ptab)   ! 3rd dimension
@@ -73,151 +84,170 @@
       ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
       !
+      IF( PRESENT(ihlcom) ) THEN   ;   ihl = ihlcom
+      ELSE                         ;   ihl = 1
+      END IF
+      !
       IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. )
       !
-      IF( PRESENT( pval ) ) THEN   ;   zland = pval      ! set land value
-      ELSE                         ;   zland = 0._wp     ! zero by default
-      ENDIF
-
-      ! ------------------------------- !
-      !   standard boundary treatment   !    ! CAUTION: semi-column notation is often impossible
-      ! ------------------------------- !
-      !
-      IF( .NOT. PRESENT( cd_mpp ) ) THEN     !==  standard close or cyclic treatment  ==!
-         !
-         DO jf = 1, ipf                      ! number of arrays to be treated
-            !
-            !                                ! East-West boundaries
-            IF( l_Iperio ) THEN                    !* cyclic
-               ARRAY_IN( 1 ,:,:,:,jf) = ARRAY_IN(jpim1,:,:,:,jf)
-               ARRAY_IN(jpi,:,:,:,jf) = ARRAY_IN(  2  ,:,:,:,jf)
-            ELSE                                   !* closed
-               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(     1       :nn_hls,:,:,:,jf) = zland    ! east except F-point
-                                               ARRAY_IN(nlci-nn_hls+1:jpi   ,:,:,:,jf) = zland    ! west
-            ENDIF
-            !                                ! North-South boundaries
-            IF( l_Jperio ) THEN                    !* cyclic (only with no mpp j-split)
-               ARRAY_IN(:, 1 ,:,:,jf) = ARRAY_IN(:, jpjm1,:,:,jf)
-               ARRAY_IN(:,jpj,:,:,jf) = ARRAY_IN(:,   2  ,:,:,jf)
-            ELSE                                   !* closed
-               IF( .NOT. NAT_IN(jf) == 'F' )   ARRAY_IN(:,     1       :nn_hls,:,:,jf) = zland    ! south except F-point
-                                               ARRAY_IN(:,nlcj-nn_hls+1:jpj   ,:,:,jf) = zland    ! north
+      IF     ( PRESENT(lsend) .AND. PRESENT(lrecv) ) THEN
+         llsend_we = lsend(1)   ;   llsend_ea = lsend(2)   ;   llsend_so = lsend(3)   ;   llsend_no = lsend(4)
+         llrecv_we = lrecv(1)   ;   llrecv_ea = lrecv(2)   ;   llrecv_so = lrecv(3)   ;   llrecv_no = lrecv(4)
+      ELSE IF( PRESENT(lsend) .OR.  PRESENT(lrecv) ) THEN
+         WRITE(ctmp1,*) ' E R R O R : Routine ', cdname, '  is calling lbc_lnk with only one of the two arguments lsend or lrecv'
+         WRITE(ctmp2,*) ' ========== '
+         CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
+      ELSE   ! send and receive with every neighbour
+         llsend_we = nbondi ==  1 .OR. nbondi == 0   ! keep for compatibility, should be defined in mppini
+         llsend_ea = nbondi == -1 .OR. nbondi == 0   ! keep for compatibility, should be defined in mppini
+         llsend_so = nbondj ==  1 .OR. nbondj == 0   ! keep for compatibility, should be defined in mppini
+         llsend_no = nbondj == -1 .OR. nbondj == 0   ! keep for compatibility, should be defined in mppini
+         llrecv_we = llsend_we   ;   llrecv_ea = llsend_ea   ;   llrecv_so = llsend_so   ;   llrecv_no = llsend_no
+      END IF
+         
+         
+      lldo_nfd = npolj /= 0                      ! keep for compatibility, should be defined in mppini
+
+      zland = 0._wp                                     ! land filling value: zero by default
+      IF( PRESENT( pfillval ) )   zland = pfillval      ! set land value
+
+      ! define the method we will use to fill the halos in each direction
+      IF(              llrecv_we ) THEN   ;   ifill_we = jpfillmpi
+      ELSEIF(           l_Iperio ) THEN   ;   ifill_we = jpfillperio
+      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_we = kfillmode
+      ELSE                                ;   ifill_we = jpfillcst
+      END IF
+      !
+      IF(              llrecv_ea ) THEN   ;   ifill_ea = jpfillmpi
+      ELSEIF(           l_Iperio ) THEN   ;   ifill_ea = jpfillperio
+      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_ea = kfillmode
+      ELSE                                ;   ifill_ea = jpfillcst
+      END IF
+      !
+      IF(              llrecv_so ) THEN   ;   ifill_so = jpfillmpi
+      ELSEIF(           l_Jperio ) THEN   ;   ifill_so = jpfillperio
+      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_so = kfillmode
+      ELSE                                ;   ifill_so = jpfillcst
+      END IF
+      !
+      IF(              llrecv_no ) THEN   ;   ifill_no = jpfillmpi
+      ELSEIF(           l_Jperio ) THEN   ;   ifill_no = jpfillperio
+      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_no = kfillmode
+      ELSE                                ;   ifill_no = jpfillcst
+      END IF
+      !
+#if defined PRINT_CAUTION
+      !
+      ! ================================================================================== !
+      ! CAUTION: semi-column notation is often impossible because of the cpp preprocessing !
+      ! ================================================================================== !
+      !
+#endif
+      !
+      ! -------------------------------------------------- !
+      !     1. Do east and west MPI exchange if needed     !
+      ! -------------------------------------------------- !
+      !
+      ! Must exchange the whole column (from 1 to jpj) to get the corners if we have no south/north neighbourg
+      isize = ihl * jpj * ipk * ipl * ipf      
+      !
+      ! Allocate local temporary arrays to be sent/received. Fill arrays to be sent
+      IF( llsend_we )   ALLOCATE( zsnd_we(ihl,jpj,ipk,ipl,ipf) )
+      IF( llsend_ea )   ALLOCATE( zsnd_ea(ihl,jpj,ipk,ipl,ipf) )
+      IF( llrecv_we )   ALLOCATE( zrcv_we(ihl,jpj,ipk,ipl,ipf) )
+      IF( llrecv_ea )   ALLOCATE( zrcv_ea(ihl,jpj,ipk,ipl,ipf) )
+      !
+      IF( llsend_we ) THEN   ! copy western side of the inner mpi domain in local temporary array to be sent by MPI
+         ishift = ihl
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, ihl
+            zsnd_we(ji,jj,jk,jl,jf) = ARRAY_IN(ishift+ji,jj,jk,jl,jf)   ! ihl + 1 -> 2*ihl
+         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+      ENDIF
+      !
+      IF(llsend_ea  ) THEN   ! copy eastern side of the inner mpi domain in local temporary array to be sent by MPI
+         ishift = jpi - 2 * ihl
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, ihl
+            zsnd_ea(ji,jj,jk,jl,jf) = ARRAY_IN(ishift+ji,jj,jk,jl,jf)   ! jpi - 2*ihl + 1 -> jpi - ihl
+         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+      ENDIF
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
+      !
+      ! non-blocking send of the western/eastern side using local temporary arrays
+      IF( llsend_we )   CALL mppsend( 1, zsnd_we(1,1,1,1,1), isize, nowe, ireq_we )
+      IF( llsend_ea )   CALL mppsend( 2, zsnd_ea(1,1,1,1,1), isize, noea, ireq_ea )
+      ! blocking receive of the western/eastern halo in local temporary arrays
+      IF( llrecv_we )   CALL mpprecv( 2, zrcv_we(1,1,1,1,1), isize, nowe )
+      IF( llrecv_ea )   CALL mpprecv( 1, zrcv_ea(1,1,1,1,1), isize, noea )
+      !
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
+      !
+      !
+      ! ----------------------------------- !
+      !     2. Fill east and west halos     !
+      ! ----------------------------------- !
+      !
+      ! 2.1 fill weastern halo
+      ! ----------------------
+      ! ishift = 0                         ! fill halo from ji = 1 to ihl
+      SELECT CASE ( ifill_we )
+      CASE ( jpfillnothing )               ! no filling 
+      CASE ( jpfillmpi   )                 ! use data received by MPI 
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, ihl
+            ARRAY_IN(ji,jj,jk,jl,jf) = zrcv_we(ji,jj,jk,jl,jf)   ! 1 -> ihl
+         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+      CASE ( jpfillperio )                 ! use east-weast periodicity
+         ishift2 = jpi - 2 * ihl
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, ihl
+            ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
+         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+      CASE ( jpfillcopy  )                 ! filling with inner domain values
+         DO jf = 1, ipf                               ! number of arrays to be treated
+            IF( .NOT. NAT_IN(jf) == 'F' ) THEN        ! do nothing for F point
+               DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, ihl
+                  ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ihl+1,jj,jk,jl,jf)
+               END DO   ;   END DO   ;   END DO   ;   END DO
             ENDIF
          END DO
-         !
-      ENDIF
-
-      ! ------------------------------- !
-      !      East and west exchange     !
-      ! ------------------------------- !
-      ! we play with the neigbours AND the row number because of the periodicity
-      !
-      IF( ABS(nbondi) == 1 ) ALLOCATE( zt3ew(jpj,nn_hls,ipk,ipl,ipf,1), zt3we(jpj,nn_hls,ipk,ipl,ipf,1) )
-      IF(     nbondi  == 0 ) ALLOCATE( zt3ew(jpj,nn_hls,ipk,ipl,ipf,2), zt3we(jpj,nn_hls,ipk,ipl,ipf,2) )
-      !
-      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
-      CASE ( -1 )
-         iihom = nlci-nreci
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     zt3we(:,jh,jk,jl,jf,1) = ARRAY_IN(iihom +jh,:,jk,jl,jf)
-                  END DO
-               END DO
-            END DO
-         END DO
-      CASE ( 0 )
-         iihom = nlci-nreci
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     zt3ew(:,jh,jk,jl,jf,1) = ARRAY_IN(nn_hls+jh,:,jk,jl,jf)
-                     zt3we(:,jh,jk,jl,jf,1) = ARRAY_IN(iihom +jh,:,jk,jl,jf)
-                  END DO
-               END DO
-            END DO
-         END DO
-      CASE ( 1 )
-         iihom = nlci-nreci
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     zt3ew(:,jh,jk,jl,jf,1) = ARRAY_IN(nn_hls+jh,:,jk,jl,jf)
-                  END DO
-               END DO
-            END DO
+      CASE ( jpfillcst   )                 ! filling with constant value
+         DO jf = 1, ipf                               ! number of arrays to be treated
+            IF( .NOT. NAT_IN(jf) == 'F' ) THEN        ! do nothing for F point
+               DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, ihl
+                  ARRAY_IN(ji,jj,jk,jl,jf) = zland
+               END DO;   END DO   ;   END DO   ;   END DO
+            ENDIF
          END DO
       END SELECT
-      !                           ! Migrations
-      imigr = nn_hls * jpj * ipk * ipl * ipf      
-      !
-      IF( ln_timing ) CALL tic_tac(.TRUE.)
-      !
-      SELECT CASE ( nbondi )
-      CASE ( -1 )
-         CALL mppsend( 2, zt3we(1,1,1,1,1,1), imigr, noea, ml_req1 )
-         CALL mpprecv( 1, zt3ew(1,1,1,1,1,1), imigr, noea )
-         IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err)
-      CASE ( 0 )
-         CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
-         CALL mppsend( 2, zt3we(1,1,1,1,1,1), imigr, noea, ml_req2 )
-         CALL mpprecv( 1, zt3ew(1,1,1,1,1,2), imigr, noea )
-         CALL mpprecv( 2, zt3we(1,1,1,1,1,2), imigr, nowe )
-         IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err)
-         IF(l_isend)   CALL mpi_wait(ml_req2, ml_stat, ml_err)
-      CASE ( 1 )
-         CALL mppsend( 1, zt3ew(1,1,1,1,1,1), imigr, nowe, ml_req1 )
-         CALL mpprecv( 2, zt3we(1,1,1,1,1,1), imigr, nowe )
-         IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err )
+      !
+      ! 2.2 fill eastern halo
+      ! ---------------------
+      ishift = jpi - ihl                ! fill halo from ji = jpi-ihl+1 to jpi 
+      SELECT CASE ( ifill_ea )
+      CASE ( jpfillnothing )               ! no filling 
+      CASE ( jpfillmpi   )                 ! use data received by MPI 
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, ihl
+            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zrcv_ea(ji,jj,jk,jl,jf)   ! jpi - ihl + 1 -> jpi
+         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+      CASE ( jpfillperio )                 ! use east-weast periodicity
+         ishift2 = ihl
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, ihl
+            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
+         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+      CASE ( jpfillcopy  )                 ! filling with inner domain values
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, ihl
+            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
+         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+      CASE ( jpfillcst   )                 ! filling with constant value
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, ihl
+            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
+         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
       END SELECT
-      !
-      IF( ln_timing ) CALL tic_tac(.FALSE.)
-      !
-      !                           ! Write Dirichlet lateral conditions
-      iihom = nlci-nn_hls
-      !
-      SELECT CASE ( nbondi )
-      CASE ( -1 )
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,1)
-                  END DO
-               END DO
-            END DO
-         END DO
-      CASE ( 0 )
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,2)
-                     ARRAY_IN(iihom+jh,:,jk,jl,jf) = zt3ew(:,jh,jk,jl,jf,2)
-                  END DO
-               END DO
-            END DO
-         END DO
-      CASE ( 1 )
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(jh      ,:,jk,jl,jf) = zt3we(:,jh,jk,jl,jf,1)
-                  END DO
-               END DO
-            END DO
-         END DO
-      END SELECT
-      !
-      IF( nbondi /= 2 ) DEALLOCATE( zt3ew, zt3we )
       !
       ! ------------------------------- !
       !     3. north fold treatment     !
       ! ------------------------------- !
+      !
       ! do it before south directions so concerned processes can do it without waiting for the comm with the sourthern neighbor
-      IF( npolj /= 0 .AND. .NOT. PRESENT(cd_mpp) ) THEN
+      !
+      IF( lldo_nfd .AND. ifill_no /= jpfillnothing ) THEN
          !
          SELECT CASE ( jpni )
@@ -226,113 +256,130 @@
          END SELECT
          !
-      ENDIF
-      !
-      ! ------------------------------- !
-      !  4. North and south directions  !
-      ! ------------------------------- !
-      ! always closed : we play only with the neigbours
-      !
-      IF( ABS(nbondj) == 1 ) ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,1), zt3sn(jpi,nn_hls,ipk,ipl,ipf,1) )
-      IF(     nbondj  == 0 ) ALLOCATE( zt3ns(jpi,nn_hls,ipk,ipl,ipf,2), zt3sn(jpi,nn_hls,ipk,ipl,ipf,2) )
-      !
-      SELECT CASE ( nbondj )
-      CASE ( -1 )
-         ijhom = nlcj-nrecj
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     zt3sn(:,jh,jk,jl,jf,1) = ARRAY_IN(:,ijhom +jh,jk,jl,jf)
-                  END DO
-               END DO
-            END DO
+         ifill_no = jpfillnothing  ! force to do nothing for the northern halo as we just done the north pole folding
+         !
+      ENDIF
+      !
+      ! ---------------------------------------------------- !
+      !     4. Do north and south MPI exchange if needed     !
+      ! ---------------------------------------------------- !
+      !
+      IF( llsend_so )   ALLOCATE( zsnd_so(jpi,ihl,ipk,ipl,ipf) )
+      IF( llsend_no )   ALLOCATE( zsnd_no(jpi,ihl,ipk,ipl,ipf) )
+      IF( llrecv_so )   ALLOCATE( zrcv_so(jpi,ihl,ipk,ipl,ipf) )
+      IF( llrecv_no )   ALLOCATE( zrcv_no(jpi,ihl,ipk,ipl,ipf) )
+      !
+      isize = jpi * ihl * ipk * ipl * ipf      
+
+      ! allocate local temporary arrays to be sent/received. Fill arrays to be sent
+      IF( llsend_so ) THEN   ! copy sourhern side of the inner mpi domain in local temporary array to be sent by MPI
+         ishift = ihl
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, ihl   ;   DO ji = 1, jpi
+            zsnd_so(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift+jj,jk,jl,jf)   ! ihl+1 -> 2*ihl
+         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+      ENDIF
+      !
+      IF( llsend_no ) THEN   ! copy eastern side of the inner mpi domain in local temporary array to be sent by MPI
+         ishift = jpj - 2 * ihl
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, ihl   ;   DO ji = 1, jpi
+            zsnd_no(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift+jj,jk,jl,jf)   ! jpj-2*ihl+1 -> jpj-ihl
+         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+      ENDIF
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
+      !
+      ! non-blocking send of the southern/northern side
+      IF( llsend_so )   CALL mppsend( 3, zsnd_so(1,1,1,1,1), isize, noso, ireq_so )
+      IF( llsend_no )   CALL mppsend( 4, zsnd_no(1,1,1,1,1), isize, nono, ireq_no )
+      ! blocking receive of the southern/northern halo
+      IF( llrecv_so )   CALL mpprecv( 4, zrcv_so(1,1,1,1,1), isize, noso )
+      IF( llrecv_no )   CALL mpprecv( 3, zrcv_no(1,1,1,1,1), isize, nono )
+      !
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
+      !
+      ! ------------------------------------- !
+      !     5. Fill south and north halos     !
+      ! ------------------------------------- !
+      !
+      ! 5.1 fill southern halo
+      ! ----------------------
+      ! ishift = 0                         ! fill halo from jj = 1 to ihl
+      SELECT CASE ( ifill_so )
+      CASE ( jpfillnothing )               ! no filling 
+      CASE ( jpfillmpi   )                 ! use data received by MPI 
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, ihl   ;   DO ji = 1, jpi
+            ARRAY_IN(ji,jj,jk,jl,jf) = zrcv_so(ji,jj,jk,jl,jf)   ! 1 -> ihl
+         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+      CASE ( jpfillperio )                 ! use north-south periodicity
+         ishift2 = jpj - 2 * ihl
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, ihl   ;   DO ji = 1, jpi
+            ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf)
+         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+      CASE ( jpfillcopy  )                 ! filling with inner domain values
+         DO jf = 1, ipf                               ! number of arrays to be treated
+            IF( .NOT. NAT_IN(jf) == 'F' ) THEN        ! do nothing for F point
+               DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, ihl   ;   DO ji = 1, jpi
+                  ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ihl+1,jk,jl,jf)
+               END DO   ;   END DO   ;   END DO   ;   END DO
+            ENDIF
          END DO
-      CASE ( 0 )
-         ijhom = nlcj-nrecj
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     zt3sn(:,jh,jk,jl,jf,1) = ARRAY_IN(:,ijhom +jh,jk,jl,jf)
-                     zt3ns(:,jh,jk,jl,jf,1) = ARRAY_IN(:,nn_hls+jh,jk,jl,jf)
-                  END DO
-               END DO
-            END DO
-         END DO
-      CASE ( 1 )
-         ijhom = nlcj-nrecj
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     zt3ns(:,jh,jk,jl,jf,1) = ARRAY_IN(:,nn_hls+jh,jk,jl,jf)
-                  END DO
-               END DO
-            END DO
+      CASE ( jpfillcst   )                 ! filling with constant value
+         DO jf = 1, ipf                               ! number of arrays to be treated
+            IF( .NOT. NAT_IN(jf) == 'F' ) THEN        ! do nothing for F point
+               DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, ihl   ;   DO ji = 1, jpi 
+                  ARRAY_IN(ji,jj,jk,jl,jf) = zland
+               END DO;   END DO   ;   END DO   ;   END DO
+            ENDIF
          END DO
       END SELECT
       !
-      !                           ! Migrations
-      imigr = nn_hls * jpi * ipk * ipl * ipf
-      !
-      IF( ln_timing ) CALL tic_tac(.TRUE.)
-      ! 
-      SELECT CASE ( nbondj )
-      CASE ( -1 )
-         CALL mppsend( 4, zt3sn(1,1,1,1,1,1), imigr, nono, ml_req1 )
-         CALL mpprecv( 3, zt3ns(1,1,1,1,1,1), imigr, nono )
-         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err )
-      CASE ( 0 )
-         CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
-         CALL mppsend( 4, zt3sn(1,1,1,1,1,1), imigr, nono, ml_req2 )
-         CALL mpprecv( 3, zt3ns(1,1,1,1,1,2), imigr, nono )
-         CALL mpprecv( 4, zt3sn(1,1,1,1,1,2), imigr, noso )
-         IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err )
-         IF(l_isend)   CALL mpi_wait(ml_req2, ml_stat, ml_err )
-      CASE ( 1 )
-         CALL mppsend( 3, zt3ns(1,1,1,1,1,1), imigr, noso, ml_req1 )
-         CALL mpprecv( 4, zt3sn(1,1,1,1,1,1), imigr, noso )
-         IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err )
+      ! 5.2 fill northern halo
+      ! ----------------------
+      ishift = jpj - ihl                ! fill halo from jj = jpj-ihl+1 to jpj 
+      SELECT CASE ( ifill_no )
+      CASE ( jpfillnothing )               ! no filling 
+      CASE ( jpfillmpi   )                 ! use data received by MPI 
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, ihl   ;   DO ji = 1, jpi
+            ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zrcv_no(ji,jj,jk,jl,jf)   ! jpj-ihl+1 -> jpj
+         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+      CASE ( jpfillperio )                 ! use north-south periodicity
+         ishift2 = ihl
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, ihl   ;   DO ji = 1, jpi
+            ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf)
+         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+      CASE ( jpfillcopy  )                 ! filling with inner domain values
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, ihl   ;   DO ji = 1, jpi
+            ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift,jk,jl,jf)
+         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
+      CASE ( jpfillcst   )                 ! filling with constant value
+         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, ihl   ;   DO ji = 1, jpi
+            ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zland
+         END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
       END SELECT
       !
-      IF( ln_timing ) CALL tic_tac(.FALSE.)
-      !                           ! Write Dirichlet lateral conditions
-      ijhom = nlcj-nn_hls
-      !
-      SELECT CASE ( nbondj )
-      CASE ( -1 )
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,1)
-                  END DO
-               END DO
-            END DO
-         END DO
-      CASE ( 0 )
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(:,      jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,2)
-                     ARRAY_IN(:,ijhom+jh,jk,jl,jf) = zt3ns(:,jh,jk,jl,jf,2)
-                  END DO
-               END DO
-            END DO
-         END DO
-      CASE ( 1 )
-         DO jf = 1, ipf
-            DO jl = 1, ipl
-               DO jk = 1, ipk
-                  DO jh = 1, nn_hls
-                     ARRAY_IN(:,jh,jk,jl,jf) = zt3sn(:,jh,jk,jl,jf,1)
-                  END DO
-               END DO
-            END DO
-         END DO
-      END SELECT
-      !
-      IF( nbondj /= 2 ) DEALLOCATE( zt3ns, zt3sn )
+      ! -------------------------------------------- !
+      !     6. deallocate local temporary arrays     !
+      ! -------------------------------------------- !
+      !
+      IF( llsend_we ) THEN
+         CALL mpi_wait(ireq_we, istat, ierr )
+         DEALLOCATE( zsnd_we )
+      ENDIF
+      IF( llsend_ea )  THEN
+         CALL mpi_wait(ireq_ea, istat, ierr )
+         DEALLOCATE( zsnd_ea )
+      ENDIF
+      IF( llsend_so ) THEN
+         CALL mpi_wait(ireq_so, istat, ierr )
+         DEALLOCATE( zsnd_so )
+      ENDIF
+      IF( llsend_no ) THEN
+         CALL mpi_wait(ireq_no, istat, ierr )
+         DEALLOCATE( zsnd_no )
+      ENDIF
+      !
+      IF( llrecv_we )   DEALLOCATE( zrcv_we )
+      IF( llrecv_ea )   DEALLOCATE( zrcv_ea )
+      IF( llrecv_so )   DEALLOCATE( zrcv_so )
+      IF( llrecv_no )   DEALLOCATE( zrcv_no )
       !
    END SUBROUTINE ROUTINE_LNK
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mpp_nfd_generic.h90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mpp_nfd_generic.h90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mpp_nfd_generic.h90	(revision 12143)
@@ -76,5 +76,5 @@
       ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
       !
-      IF( l_north_nogather ) THEN      !==  ????  ==!
+      IF( l_north_nogather ) THEN      !==  no allgather exchanges  ==!
 
          ALLOCATE(ipj_s(ipf))
@@ -200,11 +200,9 @@
             ENDIF
          END DO
-         IF( l_isend ) THEN
-            DO jr = 1,nsndto
-               IF( nfipproc(isendto(jr),jpnj) /= narea-1 .AND. nfipproc(isendto(jr),jpnj) /= -1 ) THEN
-                  CALL mpi_wait( ml_req_nf(jr), ml_stat, ml_err )
-               ENDIF
-            END DO
-         ENDIF
+         DO jr = 1,nsndto
+            IF( nfipproc(isendto(jr),jpnj) /= narea-1 .AND. nfipproc(isendto(jr),jpnj) /= -1 ) THEN
+               CALL mpi_wait( ml_req_nf(jr), ml_stat, ml_err )
+            ENDIF
+         END DO
          !
          IF( ln_timing ) CALL tic_tac(.FALSE.)
@@ -213,12 +211,10 @@
          !
          DO jf = 1, ipf
-            CALL lbc_nfd_nogather(ARRAY_IN(:,:,:,:,jf), ztabr(:,1:ipj_s(jf),:,:,jf), cd_nat LBC_ARG, psgn LBC_ARG )
-         END DO
-         !
-         DEALLOCATE( zfoldwk )
-         DEALLOCATE( ztabr ) 
-         DEALLOCATE( jj_s ) 
-         DEALLOCATE( ipj_s ) 
-      ELSE                             !==  ????  ==!
+            CALL lbc_nfd_nogather( ARRAY_IN(:,:,:,:,jf), ztabr(:,1:ipj_s(jf),:,:,jf), cd_nat LBC_ARG, psgn LBC_ARG )
+         END DO
+         !
+         DEALLOCATE( zfoldwk, ztabr, jj_s, ipj_s )
+         !
+      ELSE                             !==  allgather exchanges  ==!
          !
          ipj   = 4            ! 2nd dimension of message transfers (last j-lines)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mppini.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mppini.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LBC/mppini.F90	(revision 12143)
@@ -84,5 +84,7 @@
       nbondj = 2
       nidom  = FLIO_DOM_NONE
-      npolj = jperio
+      npolj = 0
+      IF( jperio == 3 .OR. jperio == 4 )   npolj = 3
+      IF( jperio == 5 .OR. jperio == 6 )   npolj = 5
       l_Iperio = jpni == 1 .AND. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6 .OR. jperio == 7)
       l_Jperio = jpnj == 1 .AND. (jperio == 2 .OR. jperio == 7)
@@ -152,4 +154,5 @@
       LOGICAL ::   llbest, llauto
       LOGICAL ::   llwrtlay
+      LOGICAL ::   ln_listonly
       INTEGER, ALLOCATABLE, DIMENSION(:)     ::   iin, ii_nono, ii_noea          ! 1D workspace
       INTEGER, ALLOCATABLE, DIMENSION(:)     ::   ijn, ii_noso, ii_nowe          !  -     -
@@ -164,19 +167,45 @@
            &             ln_tra_dmp, ln_dyn3d_dmp, rn_time_dmp, rn_time_dmp_out, &
            &             cn_ice, nn_ice_dta,                                     &
-           &             rn_ice_tem, rn_ice_sal, rn_ice_age,                     &
-           &             ln_vol, nn_volctl, nn_rimwidth, nb_jpk_bdy
-      !!----------------------------------------------------------------------
-
+           &             ln_vol, nn_volctl, nn_rimwidth
+      NAMELIST/nammpp/ jpni, jpnj, ln_nnogather, ln_listonly
+      !!----------------------------------------------------------------------
+      !
       llwrtlay = lwp .OR. ln_ctl .OR. sn_cfctl%l_layout
+      !
+      !  0. read namelists parameters
+      ! -----------------------------------
+      !
+      REWIND( numnam_ref )              ! Namelist nammpp in reference namelist
+      READ  ( numnam_ref, nammpp, IOSTAT = ios, ERR = 901 )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nammpp in reference namelist' )
+      REWIND( numnam_cfg )              ! Namelist nammpp in confguration namelist
+      READ  ( numnam_cfg, nammpp, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nammpp in configuration namelist' )   
+      !
+      IF(lwp) THEN
+            WRITE(numout,*) '   Namelist nammpp'
+         IF( jpni < 1 .OR. jpnj < 1  ) THEN
+            WRITE(numout,*) '      jpni and jpnj will be calculated automatically'
+         ELSE
+            WRITE(numout,*) '      processor grid extent in i                            jpni = ', jpni
+            WRITE(numout,*) '      processor grid extent in j                            jpnj = ', jpnj
+         ENDIF
+            WRITE(numout,*) '      avoid use of mpi_allgather at the north fold  ln_nnogather = ', ln_nnogather
+      ENDIF
+      !
+      IF(lwm)   WRITE( numond, nammpp )
+
       ! do we need to take into account bdy_msk?
       REWIND( numnam_ref )              ! Namelist nambdy in reference namelist : BDY
       READ  ( numnam_ref, nambdy, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist (mppini)', lwp )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist (mppini)' )
       REWIND( numnam_cfg )              ! Namelist nambdy in configuration namelist : BDY
       READ  ( numnam_cfg, nambdy, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist (mppini)', lwp )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist (mppini)' )
       !
       IF(               ln_read_cfg ) CALL iom_open( cn_domcfg,    numbot )
       IF( ln_bdy .AND. ln_mask_file ) CALL iom_open( cn_mask_file, numbdy )
+      !
+      IF( ln_listonly )   CALL mpp_init_bestpartition( MAX(mppsize,jpni*jpnj), ldlist = .TRUE. )   ! must be done by all core
       !
       !  1. Dimension arrays for subdomains
@@ -241,5 +270,4 @@
          CALL ctl_stop( ctmp1, ctmp2, ctmp3, ' ', ctmp4, ' ' )
          CALL mpp_init_bestpartition( mppsize, ldlist = .TRUE. )   ! must be done by all core
-         CALL ctl_stop( 'STOP' )
       ENDIF
 
@@ -266,5 +294,4 @@
          ENDIF
          CALL mpp_init_bestpartition( mppsize, ldlist = .TRUE. )   ! must be done by all core
-         CALL ctl_stop( 'STOP' )
       ENDIF
 
@@ -511,5 +538,5 @@
  9401    FORMAT('              '   ,20('   ',i3,'          ') )
  9402    FORMAT('       ',i3,' *  ',20(i3,'  x',i3,'   *   ') )
- 9404    FORMAT('           *  '   ,20('      ',i3,'   *   ') )
+ 9404    FORMAT('           *  '   ,20('     ' ,i4,'   *   ') )
       ENDIF
          
@@ -816,5 +843,5 @@
       INTEGER :: isziref, iszjref
       INTEGER :: inbij, iszij
-      INTEGER :: inbimax, inbjmax, inbijmax
+      INTEGER :: inbimax, inbjmax, inbijmax, inbijold
       INTEGER :: isz0, isz1
       INTEGER, DIMENSION(  :), ALLOCATABLE :: indexok
@@ -941,25 +968,37 @@
       DEALLOCATE( indexok, inbi1, inbj1, iszi1, iszj1 )
 
-      IF( llist ) THEN  ! we print about 21 best partitions
+      IF( llist ) THEN
          IF(lwp) THEN
             WRITE(numout,*)
-            WRITE(numout,         *) '                  For your information:'
-            WRITE(numout,'(a,i5,a)') '  list of the best partitions around ',   knbij, ' mpi processes'
-            WRITE(numout,         *) '  --------------------------------------', '-----', '--------------'
+            WRITE(numout,*) '                  For your information:'
+            WRITE(numout,*) '  list of the best partitions including land supression'
+            WRITE(numout,*) '  -----------------------------------------------------'
             WRITE(numout,*)
          END IF
-         iitarget = MINLOC( inbi0(:)*inbj0(:), mask = inbi0(:)*inbj0(:) >= knbij, dim = 1 )
-         DO ji = MAX(1,iitarget-10), MIN(isz0,iitarget+10)
+         ji = isz0   ! initialization with the largest value
+         ALLOCATE( llisoce(inbi0(ji), inbj0(ji)) )
+         CALL mpp_init_isoce( inbi0(ji), inbj0(ji), llisoce ) ! Warning: must be call by all cores (call mpp_sum)
+         inbijold = COUNT(llisoce)
+         DEALLOCATE( llisoce )
+         DO ji =isz0-1,1,-1
             ALLOCATE( llisoce(inbi0(ji), inbj0(ji)) )
             CALL mpp_init_isoce( inbi0(ji), inbj0(ji), llisoce ) ! Warning: must be call by all cores (call mpp_sum)
             inbij = COUNT(llisoce)
             DEALLOCATE( llisoce )
-            IF(lwp) WRITE(numout,'(a, i5, a, i5, a, i4, a, i4, a, i9, a, i5, a, i5, a)')    &
-               &     'nb_cores ' , inbij,' oce + ', inbi0(ji)*inbj0(ji) - inbij             &
-               &                                , ' land ( ', inbi0(ji),' x ', inbj0(ji),   &
-               & ' ), nb_points ', iszi0(ji)*iszj0(ji),' ( ', iszi0(ji),' x ', iszj0(ji),' )'
+            IF(lwp .AND. inbij < inbijold) THEN
+               WRITE(numout,'(a, i6, a, i6, a, f4.1, a, i9, a, i6, a, i6, a)')                                 &
+                  &   'nb_cores oce: ', inbij, ', land domains excluded: ', inbi0(ji)*inbj0(ji) - inbij,       &
+                  &   ' (', REAL(inbi0(ji)*inbj0(ji) - inbij,wp) / REAL(inbi0(ji)*inbj0(ji),wp) *100.,         &
+                  &   '%), largest oce domain: ', iszi0(ji)*iszj0(ji), ' ( ', iszi0(ji),' x ', iszj0(ji), ' )'
+               inbijold = inbij
+            END IF
          END DO
          DEALLOCATE( inbi0, inbj0, iszi0, iszj0 )
-         RETURN
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*)  '  -----------------------------------------------------------'
+         ENDIF
+         CALL mppsync
+         CALL mppstop( ld_abort = .TRUE. )
       ENDIF
       
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LDF/ldfdyn.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LDF/ldfdyn.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LDF/ldfdyn.F90	(revision 12143)
@@ -117,9 +117,9 @@
       REWIND( numnam_ref )              ! Namelist namdyn_ldf in reference namelist : Lateral physics
       READ  ( numnam_ref, namdyn_ldf, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_ldf in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_ldf in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namdyn_ldf in configuration namelist : Lateral physics
       READ  ( numnam_cfg, namdyn_ldf, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_ldf in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdyn_ldf in configuration namelist' )
       IF(lwm) WRITE ( numond, namdyn_ldf )
 
@@ -315,6 +315,6 @@
             DO jj = 1, jpj             ! Set local gridscale values
                DO ji = 1, jpi
-                  esqt(ji,jj) = ( e1e2t(ji,jj) / ( e1t(ji,jj) + e2t(ji,jj) ) )**2 
-                  esqf(ji,jj) = ( e1e2f(ji,jj) / ( e1f(ji,jj) + e2f(ji,jj) ) )**2 
+                  esqt(ji,jj) = ( 2._wp * e1e2t(ji,jj) / ( e1t(ji,jj) + e2t(ji,jj) ) )**2 
+                  esqf(ji,jj) = ( 2._wp * e1e2f(ji,jj) / ( e1f(ji,jj) + e2f(ji,jj) ) )**2 
                END DO
             END DO
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LDF/ldftra.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LDF/ldftra.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/LDF/ldftra.F90	(revision 12143)
@@ -154,8 +154,8 @@
       REWIND( numnam_ref )              ! Namelist namtra_ldf in reference namelist : Lateral physics on tracers
       READ  ( numnam_ref, namtra_ldf, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_ldf in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_ldf in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namtra_ldf in configuration namelist : Lateral physics on tracers
       READ  ( numnam_cfg, namtra_ldf, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_ldf in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_ldf in configuration namelist' )
       IF(lwm) WRITE( numond, namtra_ldf )
       !
@@ -512,9 +512,9 @@
       REWIND( numnam_ref )              ! Namelist namtra_eiv in reference namelist : eddy induced velocity param.
       READ  ( numnam_ref, namtra_eiv, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_eiv in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_eiv in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namtra_eiv in configuration namelist : eddy induced velocity param.
       READ  ( numnam_cfg, namtra_eiv, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_eiv in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_eiv in configuration namelist' )
       IF(lwm)  WRITE ( numond, namtra_eiv )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/OBS/diaobs.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/OBS/diaobs.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/OBS/diaobs.F90	(revision 12143)
@@ -203,8 +203,8 @@
       REWIND( numnam_ref )   ! Namelist namobs in reference namelist
       READ  ( numnam_ref, namobs, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namobs in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namobs in reference namelist' )
       REWIND( numnam_cfg )   ! Namelist namobs in configuration namelist
       READ  ( numnam_cfg, namobs, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namobs in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namobs in configuration namelist' )
       IF(lwm) WRITE ( numond, namobs )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/fldread.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/fldread.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/fldread.F90	(revision 12143)
@@ -48,5 +48,5 @@
    TYPE, PUBLIC ::   FLD_N      !: Namelist field informations
       CHARACTER(len = 256) ::   clname      ! generic name of the NetCDF flux file
-      REAL(wp)             ::   nfreqh      ! frequency of each flux file
+      REAL(wp)             ::   freqh       ! frequency of each flux file
       CHARACTER(len = 34)  ::   clvar       ! generic name of the variable in the NetCDF flux file
       LOGICAL              ::   ln_tint     ! time interpolation or not (T/F)
@@ -64,5 +64,5 @@
       CHARACTER(len = 256)            ::   clrootname   ! generic name of the NetCDF file
       CHARACTER(len = 256)            ::   clname       ! current name of the NetCDF file
-      REAL(wp)                        ::   nfreqh       ! frequency of each flux file
+      REAL(wp)                        ::   freqh        ! frequency of each flux file
       CHARACTER(len = 34)             ::   clvar        ! generic name of the variable in the NetCDF flux file
       LOGICAL                         ::   ln_tint      ! time interpolation or not (T/F)
@@ -80,12 +80,12 @@
       INTEGER                         ::   nreclast     ! last record to be read in the current file
       CHARACTER(len = 256)            ::   lsmname      ! current name of the NetCDF mask file acting as a key
-      INTEGER                         ::   igrd         ! grid type for bdy data
-      INTEGER                         ::   ibdy         ! bdy set id number
+      !                                                 ! 
+      !                                                 ! Variables related to BDY
+      INTEGER                         ::   igrd         !   grid type for bdy data
+      INTEGER                         ::   ibdy         !   bdy set id number
+      INTEGER, POINTER, DIMENSION(:)  ::   imap         !   Array of integer pointers to 1D arrays
+      LOGICAL                         ::   ltotvel      !   total velocity or not (T/F)
+      LOGICAL                         ::   lzint        !   T if it requires a vertical interpolation
    END TYPE FLD
-
-   TYPE, PUBLIC ::   MAP_POINTER      !: Map from input data file to local domain
-      INTEGER, POINTER, DIMENSION(:)  ::  ptr           ! Array of integer pointers to 1D arrays
-      LOGICAL                         ::  ll_unstruc    ! Unstructured (T) or structured (F) boundary data file
-   END TYPE MAP_POINTER
 
 !$AGRIF_DO_NOT_TREAT
@@ -129,5 +129,5 @@
 CONTAINS
 
-   SUBROUTINE fld_read( kt, kn_fsbc, sd, map, kit, kt_offset, jpk_bdy, fvl )
+   SUBROUTINE fld_read( kt, kn_fsbc, sd, kit, kt_offset )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_read  ***
@@ -144,5 +144,4 @@
       INTEGER  , INTENT(in   )               ::   kn_fsbc   ! sbc computation period (in time step) 
       TYPE(FLD), INTENT(inout), DIMENSION(:) ::   sd        ! input field related variables
-      TYPE(MAP_POINTER),INTENT(in), OPTIONAL, DIMENSION(:) ::   map   ! global-to-local mapping indices
       INTEGER  , INTENT(in   ), OPTIONAL     ::   kit       ! subcycle timestep for timesplitting option
       INTEGER  , INTENT(in   ), OPTIONAL     ::   kt_offset ! provide fields at time other than "now"
@@ -150,6 +149,4 @@
       !                                                     !   kt_offset = +1 => fields at "after"  time level
       !                                                     !   etc.
-      INTEGER  , INTENT(in   ), OPTIONAL     ::   jpk_bdy   ! number of vertical levels in the BDY data
-      LOGICAL  , INTENT(in   ), OPTIONAL     ::   fvl   ! number of vertical levels in the BDY data
       !!
       INTEGER  ::   itmp         ! local variable
@@ -166,5 +163,4 @@
       REAL(wp) ::   ztintb       ! ratio applied to before records when doing time interpolation
       CHARACTER(LEN=1000) ::   clfmt  ! write format
-      TYPE(MAP_POINTER)   ::   imap   ! global-to-local mapping indices
       !!---------------------------------------------------------------------
       ll_firstcall = kt == nit000
@@ -175,6 +171,4 @@
       ENDIF
       IF( PRESENT(kt_offset) )   it_offset = kt_offset
-
-      imap%ptr => NULL()
 
       ! Note that shifting time to be centrered in the middle of sbc time step impacts only nsec_* variables of the calendar 
@@ -188,10 +182,6 @@
       IF( ll_firstcall ) THEN                      ! initialization
          DO jf = 1, imf 
-            IF( PRESENT(map) ) imap = map(jf)
-               IF( PRESENT(jpk_bdy) ) THEN
-                  CALL fld_init( kn_fsbc, sd(jf), imap, jpk_bdy, fvl )  ! read each before field (put them in after as they will be swapped)
-               ELSE
-                  CALL fld_init( kn_fsbc, sd(jf), imap )  ! read each before field (put them in after as they will be swapped)
-               ENDIF
+            IF( TRIM(sd(jf)%clrootname) == 'NOT USED' )   CYCLE
+            CALL fld_init( kn_fsbc, sd(jf) )       ! read each before field (put them in after as they will be swapped)
          END DO
          IF( lwp ) CALL wgt_print()                ! control print
@@ -202,8 +192,8 @@
          !
          DO jf = 1, imf                            ! ---   loop over field   --- !
-            
+
+            IF( TRIM(sd(jf)%clrootname) == 'NOT USED' )   CYCLE
+                      
             IF( isecsbc > sd(jf)%nrec_a(2) .OR. ll_firstcall ) THEN    ! read/update the after data?
-
-               IF( PRESENT(map) )   imap = map(jf)   ! temporary definition of map
 
                sd(jf)%nrec_b(:) = sd(jf)%nrec_a(:)                                  ! swap before record informations
@@ -213,5 +203,5 @@
                CALL fld_rec( kn_fsbc, sd(jf), kt_offset = it_offset, kit = kit )    ! update after record informations
 
-               ! if kn_fsbc*rdt is larger than nfreqh (which is kind of odd),
+               ! if kn_fsbc*rdt is larger than freqh (which is kind of odd),
                ! it is possible that the before value is no more the good one... we have to re-read it
                ! if before is not the last record of the file currently opened and after is the first record to be read
@@ -222,8 +212,8 @@
                   itmp = sd(jf)%nrec_a(1)                       ! temporary storage
                   sd(jf)%nrec_a(1) = sd(jf)%nreclast            ! read the last record of the file currently opened
-                  CALL fld_get( sd(jf), imap )                  ! read after data
+                  CALL fld_get( sd(jf) )                        ! read after data
                   sd(jf)%fdta(:,:,:,1) = sd(jf)%fdta(:,:,:,2)   ! re-swap before record field
                   sd(jf)%nrec_b(1) = sd(jf)%nrec_a(1)           ! update before record informations
-                  sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%nfreqh * 3600 )  ! assume freq to be in hours in this case
+                  sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%freqh * 3600. )  ! assume freq to be in hours in this case
                   sd(jf)%rotn(1)   = sd(jf)%rotn(2)             ! update before rotate informations
                   sd(jf)%nrec_a(1) = itmp                       ! move back to after record 
@@ -234,5 +224,5 @@
                IF( sd(jf)%ln_tint ) THEN
                   
-                  ! if kn_fsbc*rdt is larger than nfreqh (which is kind of odd),
+                  ! if kn_fsbc*rdt is larger than freqh (which is kind of odd),
                   ! it is possible that the before value is no more the good one... we have to re-read it
                   ! if before record is not just just before the after record...
@@ -240,8 +230,8 @@
                      &                   .AND. sd(jf)%nrec_b(1) /= sd(jf)%nrec_a(1) - 1 ) THEN   
                      sd(jf)%nrec_a(1) = sd(jf)%nrec_a(1) - 1       ! move back to before record
-                     CALL fld_get( sd(jf), imap )                  ! read after data
+                     CALL fld_get( sd(jf) )                        ! read after data
                      sd(jf)%fdta(:,:,:,1) = sd(jf)%fdta(:,:,:,2)   ! re-swap before record field
                      sd(jf)%nrec_b(1) = sd(jf)%nrec_a(1)           ! update before record informations
-                     sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%nfreqh * 3600 )  ! assume freq to be in hours in this case
+                     sd(jf)%nrec_b(2) = sd(jf)%nrec_a(2) - NINT( sd(jf)%freqh * 3600. )  ! assume freq to be in hours in this case
                      sd(jf)%rotn(1)   = sd(jf)%rotn(2)             ! update before rotate informations
                      sd(jf)%nrec_a(1) = sd(jf)%nrec_a(1) + 1       ! move back to after record
@@ -268,5 +258,5 @@
                      ! year/month/week/day, next year/month/week/day file must exist
                      isecend = nsec_year + nsec1jan000 + (nitend - kt) * NINT(rdt)   ! second at the end of the run
-                     llstop = isecend > sd(jf)%nrec_a(2)                                   ! read more than 1 record of next year
+                     llstop = isecend > sd(jf)%nrec_a(2)                             ! read more than 1 record of next year
                      ! we suppose that the date of next file is next day (should be ok even for weekly files...)
                      CALL fld_clopn( sd(jf), nyear  + COUNT((/llnxtyr /))                                           ,         &
@@ -277,5 +267,5 @@
                         CALL ctl_warn('next year/month/week/day file: '//TRIM(sd(jf)%clname)//     &
                            &     ' not present -> back to current year/month/day')
-                        CALL fld_clopn( sd(jf) )       ! back to the current year/month/day
+                        CALL fld_clopn( sd(jf) )               ! back to the current year/month/day
                         sd(jf)%nrec_a(1) = sd(jf)%nreclast     ! force to read the last record in the current year file
                      ENDIF
@@ -285,9 +275,6 @@
                   
                ! read after data
-               IF( PRESENT(jpk_bdy) ) THEN
-                  CALL fld_get( sd(jf), imap, jpk_bdy, fvl)
-               ELSE
-                  CALL fld_get( sd(jf), imap )
-               ENDIF
+               CALL fld_get( sd(jf) )
+               
             ENDIF   ! read new data?
          END DO                                    ! --- end loop over field --- !
@@ -296,4 +283,6 @@
 
          DO jf = 1, imf                            ! ---   loop over field   --- !
+            !
+            IF( TRIM(sd(jf)%clrootname) == 'NOT USED' )   CYCLE
             !
             IF( sd(jf)%ln_tint ) THEN              ! temporal interpolation
@@ -327,5 +316,5 @@
 
 
-   SUBROUTINE fld_init( kn_fsbc, sdjf, map , jpk_bdy, fvl)
+   SUBROUTINE fld_init( kn_fsbc, sdjf )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_init  ***
@@ -336,7 +325,4 @@
       INTEGER  , INTENT(in   ) ::   kn_fsbc      ! sbc computation period (in time step) 
       TYPE(FLD), INTENT(inout) ::   sdjf         ! input field related variables
-      TYPE(MAP_POINTER),INTENT(in) ::   map      ! global-to-local mapping indices
-      INTEGER  , INTENT(in), OPTIONAL :: jpk_bdy ! number of vertical levels in the BDY data
-      LOGICAL  , INTENT(in), OPTIONAL :: fvl     ! number of vertical levels in the BDY data
       !!
       LOGICAL :: llprevyr              ! are we reading previous year  file?
@@ -351,4 +337,5 @@
       CHARACTER(LEN=1000) ::   clfmt   ! write format
       !!---------------------------------------------------------------------
+      !
       llprevyr   = .FALSE.
       llprevmth  = .FALSE.
@@ -365,5 +352,5 @@
          !
          IF( sdjf%nrec_a(1) == 0  ) THEN   ! we redefine record sdjf%nrec_a(1) with the last record of previous year file
-            IF    ( sdjf%nfreqh == -12 ) THEN   ! yearly mean
+            IF    ( NINT(sdjf%freqh) == -12 ) THEN   ! yearly mean
                IF( sdjf%cltype == 'yearly' ) THEN             ! yearly file
                   sdjf%nrec_a(1) = 1                                                       ! force to read the unique record
@@ -372,5 +359,5 @@
                   CALL ctl_stop( "fld_init: yearly mean file must be in a yearly type of file: "//TRIM(sdjf%clrootname) )
                ENDIF
-            ELSEIF( sdjf%nfreqh ==  -1 ) THEN   ! monthly mean
+            ELSEIF( NINT(sdjf%freqh) ==  -1 ) THEN   ! monthly mean
                IF( sdjf%cltype == 'monthly' ) THEN            ! monthly file
                   sdjf%nrec_a(1) = 1                                                       ! force to read the unique record
@@ -381,20 +368,20 @@
                   llprevyr = .NOT. sdjf%ln_clim                                            ! use previous year  file?
                ENDIF
-            ELSE                                ! higher frequency mean (in hours) 
+            ELSE                                     ! higher frequency mean (in hours) 
                IF    ( sdjf%cltype      == 'monthly' ) THEN   ! monthly file
-                  sdjf%nrec_a(1) = NINT( 24 * nmonth_len(nmonth-1) / sdjf%nfreqh )         ! last record of previous month
+                  sdjf%nrec_a(1) = NINT( 24. * REAL(nmonth_len(nmonth-1),wp) / sdjf%freqh )! last record of previous month
                   llprevmth = .TRUE.                                                       ! use previous month file?
                   llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file?
                ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ! weekly file
                   llprevweek = .TRUE.                                                      ! use previous week  file?
-                  sdjf%nrec_a(1) = NINT( 24 * 7 / sdjf%nfreqh )                            ! last record of previous week
+                  sdjf%nrec_a(1) = NINT( 24. * 7. / sdjf%freqh )                           ! last record of previous week
                   isec_week = NINT(rday) * 7                                               ! add a shift toward previous week
                ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ! daily file
-                  sdjf%nrec_a(1) = NINT( 24 / sdjf%nfreqh )                                ! last record of previous day
+                  sdjf%nrec_a(1) = NINT( 24. / sdjf%freqh )                                ! last record of previous day
                   llprevday = .TRUE.                                                       ! use previous day   file?
                   llprevmth = llprevday .AND. nday   == 1                                  ! use previous month file?
                   llprevyr  = llprevmth .AND. nmonth == 1                                  ! use previous year  file?
                ELSE                                           ! yearly file
-                  sdjf%nrec_a(1) = NINT( 24 * nyear_len(0) / sdjf%nfreqh )                 ! last record of previous year 
+                  sdjf%nrec_a(1) = NINT( 24. * REAL(nyear_len(0),wp) / sdjf%freqh )        ! last record of previous year 
                   llprevyr = .NOT. sdjf%ln_clim                                            ! use previous year  file?
                ENDIF
@@ -433,9 +420,5 @@
          !
          ! read before data in after arrays(as we will swap it later)
-         IF( PRESENT(jpk_bdy) ) THEN
-            CALL fld_get( sdjf, map, jpk_bdy, fvl )
-         ELSE
-            CALL fld_get( sdjf, map )
-         ENDIF
+         CALL fld_get( sdjf )
          !
          clfmt = "('   fld_init : time-interpolation for ', a, ' read previous record = ', i6, ' at time = ', f7.2, ' days')"
@@ -456,5 +439,5 @@
       !!              if sdjf%ln_tint = .FALSE.
       !!                  nrec_a(1): record number
-      !!                  nrec_b(2) and nrec_a(2): time of the beginning and end of the record (for print only)
+      !!                  nrec_b(2) and nrec_a(2): time of the beginning and end of the record
       !!----------------------------------------------------------------------
       INTEGER  , INTENT(in   )           ::   kn_fsbc   ! sbc computation period (in time step) 
@@ -484,14 +467,14 @@
       ELSE                                      ;   it_offset = 0
       ENDIF
-      IF( PRESENT(kt_offset) )   it_offset = kt_offset
+      IF( PRESENT(kt_offset) )      it_offset = kt_offset
       IF( PRESENT(kit) ) THEN   ;   it_offset = ( kit + it_offset ) * NINT( rdt/REAL(nn_baro,wp) )
       ELSE                      ;   it_offset =         it_offset   * NINT(       rdt            )
       ENDIF
       !
-      !                                      ! =========== !
-      IF    ( sdjf%nfreqh == -12 ) THEN      ! yearly mean
-         !                                   ! =========== !
-         !
-         IF( sdjf%ln_tint ) THEN                 ! time interpolation, shift by 1/2 record
+      !                                           ! =========== !
+      IF    ( NINT(sdjf%freqh) == -12 ) THEN      ! yearly mean
+         !                                        ! =========== !
+         !
+         IF( sdjf%ln_tint ) THEN                  ! time interpolation, shift by 1/2 record
             !
             !                  INT( ztmp )
@@ -505,6 +488,6 @@
             !       forcing record :    1 
             !                            
-            ztmp = REAL( nsec_year, wp ) / ( REAL( nyear_len(1), wp ) * rday ) + 0.5 &
-           &       + REAL( it_offset, wp ) / ( REAL( nyear_len(1), wp ) * rday )
+            ztmp =  REAL( nsec_year, wp ) / ( REAL( nyear_len(1), wp ) * rday ) + 0.5 &
+               &  + REAL( it_offset, wp ) / ( REAL( nyear_len(1), wp ) * rday )
             sdjf%nrec_a(1) = 1 + INT( ztmp ) - COUNT((/llbefore/))
             ! swap at the middle of the year
@@ -514,5 +497,5 @@
                                     & INT(ztmp) * INT(rday) * nyear_len(1) + INT(ztmp) * NINT( 0.5 * rday) * nyear_len(2) 
             ENDIF
-         ELSE                                    ! no time interpolation
+         ELSE                                     ! no time interpolation
             sdjf%nrec_a(1) = 1
             sdjf%nrec_a(2) = NINT(rday) * nyear_len(1) + nsec1jan000   ! swap at the end    of the year
@@ -520,9 +503,9 @@
          ENDIF
          !
-         !                                   ! ============ !
-      ELSEIF( sdjf%nfreqh ==  -1 ) THEN      ! monthly mean !
-         !                                   ! ============ !
-         !
-         IF( sdjf%ln_tint ) THEN                 ! time interpolation, shift by 1/2 record
+         !                                        ! ============ !
+      ELSEIF( NINT(sdjf%freqh) ==  -1 ) THEN      ! monthly mean !
+         !                                        ! ============ !
+         !
+         IF( sdjf%ln_tint ) THEN                  ! time interpolation, shift by 1/2 record
             !
             !                  INT( ztmp )
@@ -536,6 +519,6 @@
             !       forcing record :  nmonth 
             !                            
-            ztmp = REAL( nsec_month, wp ) / ( REAL( nmonth_len(nmonth), wp ) * rday ) + 0.5 &
-           &       + REAL( it_offset, wp ) / ( REAL( nmonth_len(nmonth), wp ) * rday )
+            ztmp =  REAL( nsec_month, wp ) / ( REAL( nmonth_len(nmonth), wp ) * rday ) + 0.5 &
+           &      + REAL(  it_offset, wp ) / ( REAL( nmonth_len(nmonth), wp ) * rday )
             imth = nmonth + INT( ztmp ) - COUNT((/llbefore/))
             IF( sdjf%cltype == 'monthly' ) THEN   ;   sdjf%nrec_a(1) = 1 + INT( ztmp ) - COUNT((/llbefore/))
@@ -551,9 +534,9 @@
          ENDIF
          !
-         !                                   ! ================================ !
-      ELSE                                   ! higher frequency mean (in hours)
-         !                                   ! ================================ !
-         !
-         ifreq_sec = NINT( sdjf%nfreqh * 3600 )                                         ! frequency mean (in seconds)
+         !                                        ! ================================ !
+      ELSE                                        ! higher frequency mean (in hours)
+         !                                        ! ================================ !
+         !
+         ifreq_sec = NINT( sdjf%freqh * 3600. )                                         ! frequency mean (in seconds)
          IF( sdjf%cltype(1:4) == 'week' )   isec_week = ksec_week( sdjf%cltype(6:8) )   ! since the first day of the current week
          ! number of second since the beginning of the file
@@ -565,5 +548,5 @@
          ztmp = ztmp + 0.5 * REAL(kn_fsbc - 1, wp) * rdt + REAL( it_offset, wp )        ! centrered in the middle of sbc time step
          ztmp = ztmp + 0.01 * rdt                                                       ! avoid truncation error 
-         IF( sdjf%ln_tint ) THEN                ! time interpolation, shift by 1/2 record
+         IF( sdjf%ln_tint ) THEN                 ! time interpolation, shift by 1/2 record
             !
             !          INT( ztmp/ifreq_sec + 0.5 )
@@ -579,5 +562,5 @@
             !                   
             ztmp= ztmp / REAL(ifreq_sec, wp) + 0.5
-         ELSE                                   ! no time interpolation
+         ELSE                                    ! no time interpolation
             !
             !           INT( ztmp/ifreq_sec )
@@ -610,8 +593,10 @@
       ENDIF
       !
+      IF( .NOT. sdjf%ln_tint ) sdjf%nrec_a(2) = sdjf%nrec_a(2) - 1   ! last second belongs to bext record : *----(
+      !
    END SUBROUTINE fld_rec
 
 
-   SUBROUTINE fld_get( sdjf, map, jpk_bdy, fvl )
+   SUBROUTINE fld_get( sdjf )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_get  ***
@@ -620,7 +605,4 @@
       !!----------------------------------------------------------------------
       TYPE(FLD)        , INTENT(inout) ::   sdjf   ! input field related variables
-      TYPE(MAP_POINTER), INTENT(in   ) ::   map    ! global-to-local mapping indices
-      INTEGER  , INTENT(in), OPTIONAL  ::   jpk_bdy ! number of vertical levels in the bdy data
-      LOGICAL  , INTENT(in), OPTIONAL  ::   fvl     ! number of vertical levels in the bdy data
       !
       INTEGER ::   ipk      ! number of vertical levels of sdjf%fdta ( 2D: ipk=1 ; 3D: ipk=jpk )
@@ -634,16 +616,10 @@
       ipk = SIZE( sdjf%fnow, 3 )
       !
-      IF( ASSOCIATED(map%ptr) ) THEN
-         IF( PRESENT(jpk_bdy) ) THEN
-            IF( sdjf%ln_tint ) THEN   ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fdta(:,:,:,2),                &
-                                                        sdjf%nrec_a(1), map, sdjf%igrd, sdjf%ibdy, jpk_bdy, fvl )
-            ELSE                      ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fnow(:,:,:  ),                &
-                                                        sdjf%nrec_a(1), map, sdjf%igrd, sdjf%ibdy, jpk_bdy, fvl )
-            ENDIF
-         ELSE
-            IF( sdjf%ln_tint ) THEN   ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fdta(:,:,:,2), sdjf%nrec_a(1), map )
-            ELSE                      ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fnow(:,:,:  ), sdjf%nrec_a(1), map )
-            ENDIF
-         ENDIF        
+      IF( ASSOCIATED(sdjf%imap) ) THEN
+         IF( sdjf%ln_tint ) THEN   ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fdta(:,:,:,2), sdjf%nrec_a(1),   &
+            &                                        sdjf%imap, sdjf%igrd, sdjf%ibdy, sdjf%ltotvel, sdjf%lzint )
+         ELSE                      ;   CALL fld_map( sdjf%num, sdjf%clvar, sdjf%fnow(:,:,:  ), sdjf%nrec_a(1),   &
+            &                                        sdjf%imap, sdjf%igrd, sdjf%ibdy, sdjf%ltotvel, sdjf%lzint )
+         ENDIF
       ELSE IF( LEN(TRIM(sdjf%wgtname)) > 0 ) THEN
          CALL wgt_list( sdjf, iw )
@@ -700,5 +676,6 @@
    END SUBROUTINE fld_get
 
-   SUBROUTINE fld_map( num, clvar, dta, nrec, map, igrd, ibdy, jpk_bdy, fvl )
+   
+   SUBROUTINE fld_map( knum, cdvar, pdta, krec, kmap, kgrd, kbdy, ldtotvel, ldzint )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_map  ***
@@ -707,136 +684,144 @@
       !!                using a general mapping (for open boundaries)
       !!----------------------------------------------------------------------
-
-      USE bdy_oce, ONLY: ln_bdy, idx_bdy, dta_global, dta_global_z, dta_global_dz, dta_global2, dta_global2_z, dta_global2_dz                 ! workspace to read in global data arrays
-
-      INTEGER                   , INTENT(in ) ::   num     ! stream number
-      CHARACTER(LEN=*)          , INTENT(in ) ::   clvar   ! variable name
-      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   dta     ! output field on model grid (2 dimensional)
-      INTEGER                   , INTENT(in ) ::   nrec    ! record number to read (ie time slice)
-      TYPE(MAP_POINTER)         , INTENT(in ) ::   map     ! global-to-local mapping indices
-      INTEGER  , INTENT(in), OPTIONAL         ::   igrd, ibdy, jpk_bdy  ! grid type, set number and number of vertical levels in the bdy data
-      LOGICAL  , INTENT(in), OPTIONAL         ::   fvl     ! grid type, set number and number of vertical levels in the bdy data
-      INTEGER                                 ::   jpkm1_bdy! number of vertical levels in the bdy data minus 1
-      !!
-      INTEGER                                 ::   ipi      ! length of boundary data on local process
-      INTEGER                                 ::   ipj      ! length of dummy dimension ( = 1 )
-      INTEGER                                 ::   ipk      ! number of vertical levels of dta ( 2D: ipk=1 ; 3D: ipk=jpk )
-      INTEGER                                 ::   ilendta  ! length of data in file
-      INTEGER                                 ::   idvar    ! variable ID
-      INTEGER                                 ::   ib, ik, ji, jj   ! loop counters
-      INTEGER                                 ::   ierr
-      REAL(wp)                                ::   fv          ! fillvalue 
-      REAL(wp), POINTER, DIMENSION(:,:,:)     ::   dta_read    ! work space for global data
-      REAL(wp), POINTER, DIMENSION(:,:,:)     ::   dta_read_z  ! work space for global data
-      REAL(wp), POINTER, DIMENSION(:,:,:)     ::   dta_read_dz ! work space for global data
-      !!---------------------------------------------------------------------
-      !
-      ipi = SIZE( dta, 1 )
-      ipj = 1
-      ipk = SIZE( dta, 3 )
-      !
-      idvar   = iom_varid( num, clvar )
-      ilendta = iom_file(num)%dimsz(1,idvar)
-
-      IF ( ln_bdy ) THEN
-         ipj = iom_file(num)%dimsz(2,idvar)
-         IF( map%ll_unstruc) THEN   ! unstructured open boundary data file
-            dta_read => dta_global
-            IF( PRESENT(jpk_bdy) ) THEN
-               IF( jpk_bdy>0 ) THEN
-                  dta_read_z => dta_global_z
-                  dta_read_dz => dta_global_dz
-                  jpkm1_bdy = jpk_bdy-1
-               ENDIF
-            ENDIF
-         ELSE                       ! structured open boundary file
-            dta_read => dta_global2
-            IF( PRESENT(jpk_bdy) ) THEN
-               IF( jpk_bdy>0 ) THEN
-                  dta_read_z => dta_global2_z
-                  dta_read_dz => dta_global2_dz
-                  jpkm1_bdy = jpk_bdy-1
-               ENDIF
-            ENDIF
-         ENDIF
-      ENDIF
-
-      IF(lwp) WRITE(numout,*) 'Dim size for ',        TRIM(clvar),' is ', ilendta
-      IF(lwp) WRITE(numout,*) 'Number of levels for ',TRIM(clvar),' is ', ipk
-      !
-      SELECT CASE( ipk )
-      CASE(1)        ;   
-      CALL iom_get ( num, jpdom_unknown, clvar, dta_read(1:ilendta,1:ipj,1    ), nrec )
-         IF ( map%ll_unstruc) THEN ! unstructured open boundary data file
-            DO ib = 1, ipi
-              DO ik = 1, ipk
-                dta(ib,1,ik) =  dta_read(map%ptr(ib),1,ik)
-              END DO
-            END DO
-         ELSE ! we assume that this is a structured open boundary file
-            DO ib = 1, ipi
-               jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-               ji=map%ptr(ib)-(jj-1)*ilendta
-               DO ik = 1, ipk
-                  dta(ib,1,ik) =  dta_read(ji,jj,ik)
-               END DO
-            END DO
-         ENDIF
+      INTEGER                   , INTENT(in   ) ::   knum         ! stream number
+      CHARACTER(LEN=*)          , INTENT(in   ) ::   cdvar        ! variable name
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdta         ! bdy output field on model grid
+      INTEGER                   , INTENT(in   ) ::   krec         ! record number to read (ie time slice)
+      INTEGER , DIMENSION(:)    , INTENT(in   ) ::   kmap         ! global-to-local bdy mapping indices
+      ! optional variables used for vertical interpolation:
+      INTEGER, OPTIONAL         , INTENT(in   ) ::   kgrd         ! grid type (t, u, v)
+      INTEGER, OPTIONAL         , INTENT(in   ) ::   kbdy         ! bdy number
+      LOGICAL, OPTIONAL         , INTENT(in   ) ::   ldtotvel     ! true if total ( = barotrop + barocline) velocity
+      LOGICAL, OPTIONAL         , INTENT(in   ) ::   ldzint       ! true if 3D variable requires a vertical interpolation
+      !!
+      INTEGER                                   ::   ipi          ! length of boundary data on local process
+      INTEGER                                   ::   ipj          ! length of dummy dimension ( = 1 )
+      INTEGER                                   ::   ipk          ! number of vertical levels of pdta ( 2D: ipk=1 ; 3D: ipk=jpk )
+      INTEGER                                   ::   ipkb         ! number of vertical levels in boundary data file
+      INTEGER                                   ::   idvar        ! variable ID
+      INTEGER                                   ::   indims       ! number of dimensions of the variable
+      INTEGER, DIMENSION(4)                     ::   idimsz       ! size of variable dimensions 
+      REAL(wp)                                  ::   zfv          ! fillvalue 
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   zz_read      ! work space for global boundary data
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   zdta_read    ! work space local data requiring vertical interpolation
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   zdta_read_z  ! work space local data requiring vertical interpolation
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   zdta_read_dz ! work space local data requiring vertical interpolation
+      CHARACTER(LEN=1),DIMENSION(3)             ::   clgrid
+      LOGICAL                                   ::   lluld        ! is the variable using the unlimited dimension
+      LOGICAL                                   ::   llzint       ! local value of ldzint
+      !!---------------------------------------------------------------------
+      !
+      clgrid = (/'t','u','v'/)
+      !
+      ipi = SIZE( pdta, 1 )
+      ipj = SIZE( pdta, 2 )   ! must be equal to 1
+      ipk = SIZE( pdta, 3 )
+      !
+      llzint = .FALSE.
+      IF( PRESENT(ldzint) )   llzint = ldzint
+      !
+      idvar = iom_varid( knum, cdvar, kndims = indims, kdimsz = idimsz, lduld = lluld  )
+      IF( indims == 4 .OR. ( indims == 3 .AND. .NOT. lluld ) ) THEN   ;   ipkb = idimsz(3)   ! xy(zl)t or xy(zl)
+      ELSE                                                            ;   ipkb = 1           ! xy or xyt
+      ENDIF
+      !
+      ALLOCATE( zz_read( idimsz(1), idimsz(2), ipkb ) )  ! ++++++++ !!! this can be very big...         
+      !
+      IF( ipk == 1 ) THEN
+
+         IF( ipkb /= 1 ) CALL ctl_stop( 'fld_map : we must have ipkb = 1 to read surface data' )
+         CALL iom_get ( knum, jpdom_unknown, cdvar, zz_read(:,:,1), krec )   ! call iom_get with a 2D file
+         CALL fld_map_core( zz_read, kmap, pdta )
 
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       ! Do we include something here to adjust barotropic velocities !
       ! in case of a depth difference between bdy files and          !
-      ! bathymetry in the case ln_full_vel = .false. and jpk_bdy>0?  !
+      ! bathymetry in the case ln_totvel = .false. and ipkb>0?       !
       ! [as the enveloping and parital cells could change H]         !
       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-      CASE DEFAULT   ;
-
-      IF( PRESENT(jpk_bdy) .AND. jpk_bdy>0 ) THEN       ! boundary data not on model grid: vertical interpolation
-         CALL iom_getatt(num, '_FillValue', fv, cdvar=clvar )
-         dta_read(:,:,:) = -ABS(fv)
-         dta_read_z(:,:,:) = 0._wp
-         dta_read_dz(:,:,:) = 0._wp
-         CALL iom_get ( num, jpdom_unknown, clvar, dta_read(1:ilendta,1:ipj,1:jpk_bdy), nrec )
-         SELECT CASE( igrd )                  
-            CASE(1)
-               CALL iom_get ( num, jpdom_unknown, 'gdept', dta_read_z(1:ilendta,1:ipj,1:jpk_bdy) )
-               CALL iom_get ( num, jpdom_unknown, 'e3t',  dta_read_dz(1:ilendta,1:ipj,1:jpk_bdy) )
-            CASE(2)  
-               CALL iom_get ( num, jpdom_unknown, 'gdepu', dta_read_z(1:ilendta,1:ipj,1:jpk_bdy) )
-               CALL iom_get ( num, jpdom_unknown, 'e3u',  dta_read_dz(1:ilendta,1:ipj,1:jpk_bdy) )
-            CASE(3)
-               CALL iom_get ( num, jpdom_unknown, 'gdepv', dta_read_z(1:ilendta,1:ipj,1:jpk_bdy) )
-               CALL iom_get ( num, jpdom_unknown, 'e3v',  dta_read_dz(1:ilendta,1:ipj,1:jpk_bdy) )
-         END SELECT
-
-      IF ( ln_bdy ) & 
-         CALL fld_bdy_interp(dta_read, dta_read_z, dta_read_dz, map, jpk_bdy, igrd, ibdy, fv, dta, fvl, ilendta)
-
-      ELSE ! boundary data assumed to be on model grid
-         
-         CALL iom_get ( num, jpdom_unknown, clvar, dta_read(1:ilendta,1:ipj,1:ipk), nrec )                    
-         IF ( map%ll_unstruc) THEN ! unstructured open boundary data file
-            DO ib = 1, ipi
-              DO ik = 1, ipk
-                dta(ib,1,ik) =  dta_read(map%ptr(ib),1,ik)
-              END DO
+      ELSE
+         !
+         CALL iom_get ( knum, jpdom_unknown, cdvar, zz_read(:,:,:), krec )   ! call iom_get with a 3D file
+         !
+         IF( ipkb /= ipk .OR. llzint ) THEN   ! boundary data not on model vertical grid : vertical interpolation
+            !
+            IF( ipk == jpk .AND. iom_varid(knum,'gdep'//clgrid(kgrd)) /= -1 .AND. iom_varid(knum,'e3'//clgrid(kgrd)) /= -1 ) THEN
+               
+               ALLOCATE( zdta_read(ipi,ipj,ipkb), zdta_read_z(ipi,ipj,ipkb), zdta_read_dz(ipi,ipj,ipkb) )
+                
+               CALL fld_map_core( zz_read, kmap, zdta_read )
+               CALL iom_get ( knum, jpdom_unknown, 'gdep'//clgrid(kgrd), zz_read )   ! read only once? Potential temporal evolution?
+               CALL fld_map_core( zz_read, kmap, zdta_read_z )
+               CALL iom_get ( knum, jpdom_unknown,   'e3'//clgrid(kgrd), zz_read )   ! read only once? Potential temporal evolution?
+               CALL fld_map_core( zz_read, kmap, zdta_read_dz )
+               
+               CALL iom_getatt(knum, '_FillValue', zfv, cdvar=cdvar )
+               CALL fld_bdy_interp(zdta_read, zdta_read_z, zdta_read_dz, pdta, kgrd, kbdy, zfv, ldtotvel)
+               DEALLOCATE( zdta_read, zdta_read_z, zdta_read_dz )
+               
+            ELSE
+               IF( ipk /= jpk ) CALL ctl_stop( 'fld_map : this should be an impossible case...' )
+               WRITE(ctmp1,*) 'fld_map : vertical interpolation for bdy variable '//TRIM(cdvar)//' requires ' 
+               IF( iom_varid(knum, 'gdep'//clgrid(kgrd)) == -1 ) CALL ctl_stop( ctmp1//'gdep'//clgrid(kgrd)//' variable' )
+               IF( iom_varid(knum,   'e3'//clgrid(kgrd)) == -1 ) CALL ctl_stop( ctmp1//  'e3'//clgrid(kgrd)//' variable' )
+
+            ENDIF
+            !
+         ELSE                            ! bdy data assumed to be the same levels as bdy variables
+            !
+            CALL fld_map_core( zz_read, kmap, pdta )
+            !
+         ENDIF   ! ipkb /= ipk
+      ENDIF   ! ipk == 1
+      
+      DEALLOCATE( zz_read )
+
+   END SUBROUTINE fld_map
+
+     
+   SUBROUTINE fld_map_core( pdta_read, kmap, pdta_bdy )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE fld_map_core  ***
+      !!
+      !! ** Purpose :  inner core of fld_map
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pdta_read    ! global boundary data
+      INTEGER,  DIMENSION(:    ), INTENT(in   ) ::   kmap         ! global-to-local bdy mapping indices
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdta_bdy     ! bdy output field on model grid
+      !!
+      INTEGER,  DIMENSION(3) ::   idim_read,  idim_bdy            ! arrays dimensions
+      INTEGER                ::   ji, jj, jk, jb                  ! loop counters
+      INTEGER                ::   im1
+      !!---------------------------------------------------------------------
+      !
+      idim_read = SHAPE( pdta_read )
+      idim_bdy  = SHAPE( pdta_bdy  )
+      !
+      ! in all cases: idim_bdy(2) == 1 .AND. idim_read(1) * idim_read(2) == idim_bdy(1)
+      ! structured BDY with rimwidth > 1                     : idim_read(2) == rimwidth /= 1
+      ! structured BDY with rimwidth == 1 or unstructured BDY: idim_read(2) == 1
+      !
+      IF( idim_read(2) > 1 ) THEN    ! structured BDY with rimwidth > 1  
+         DO jk = 1, idim_bdy(3)
+            DO jb = 1, idim_bdy(1)
+               im1 = kmap(jb) - 1
+               jj = im1 / idim_read(1) + 1
+               ji = MOD( im1, idim_read(1) ) + 1
+               pdta_bdy(jb,1,jk) =  pdta_read(ji,jj,jk)
             END DO
-         ELSE ! we assume that this is a structured open boundary file
-            DO ib = 1, ipi
-               jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-               ji=map%ptr(ib)-(jj-1)*ilendta
-               DO ik = 1, ipk
-                  dta(ib,1,ik) =  dta_read(ji,jj,ik)
-               END DO
+         END DO
+      ELSE
+         DO jk = 1, idim_bdy(3)
+            DO jb = 1, idim_bdy(1)   ! horizontal remap of bdy data on the local bdy 
+               pdta_bdy(jb,1,jk) = pdta_read(kmap(jb),1,jk)
             END DO
-         ENDIF
-      ENDIF ! PRESENT(jpk_bdy)
-      END SELECT
-
-   END SUBROUTINE fld_map
+         END DO
+      ENDIF
+      
+   END SUBROUTINE fld_map_core
    
-   SUBROUTINE fld_bdy_interp(dta_read, dta_read_z, dta_read_dz, map, jpk_bdy, igrd, ibdy, fv, dta, fvl, ilendta)
-
+   
+   SUBROUTINE fld_bdy_interp(pdta_read, pdta_read_z, pdta_read_dz, pdta, kgrd, kbdy, pfv, ldtotvel)
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE fld_bdy_interp  ***
@@ -847,284 +832,159 @@
       USE bdy_oce, ONLY:  idx_bdy         ! indexing for map <-> ij transformation
 
-      REAL(wp), POINTER, DIMENSION(:,:,:), INTENT(in )     ::   dta_read      ! work space for global data
-      REAL(wp), POINTER, DIMENSION(:,:,:), INTENT(in )     ::   dta_read_z    ! work space for global data
-      REAL(wp), POINTER, DIMENSION(:,:,:), INTENT(in )     ::   dta_read_dz   ! work space for global data
-      REAL(wp) , INTENT(in)                                ::   fv            ! fillvalue and alternative -ABS(fv)
-      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   dta                        ! output field on model grid (2 dimensional)
-      TYPE(MAP_POINTER)         , INTENT(in ) ::   map                        ! global-to-local mapping indices
-      LOGICAL  , INTENT(in), OPTIONAL         ::   fvl                        ! grid type, set number and number of vertical levels in the bdy data
-      INTEGER  , INTENT(in)                   ::   igrd, ibdy, jpk_bdy        ! number of levels in bdy data
-      INTEGER  , INTENT(in)                   ::   ilendta                    ! length of data in file
-      !!
-      INTEGER                                 ::   ipi                        ! length of boundary data on local process
-      INTEGER                                 ::   ipj                        ! length of dummy dimension ( = 1 )
-      INTEGER                                 ::   ipk                        ! number of vertical levels of dta ( 2D: ipk=1 ; 3D: ipk=jpk )
-      INTEGER                                 ::   jpkm1_bdy                  ! number of levels in bdy data minus 1
-      INTEGER                                 ::   ib, ik, ikk                ! loop counters
-      INTEGER                                 ::   ji, jj, zij, zjj           ! temporary indices
-      REAL(wp)                                ::   zl, zi, zh                 ! tmp variable for current depth and interpolation factor
-      REAL(wp)                                ::   fv_alt, ztrans, ztrans_new ! fillvalue and alternative -ABS(fv)
-      CHARACTER (LEN=10)                      ::   ibstr
+      REAL(wp), DIMENSION(:,:,:), INTENT(in   ) ::   pdta_read       ! data read in bdy file
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pdta_read_z     ! depth of the data read in bdy file
+      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   pdta_read_dz    ! thickness of the levels in bdy file
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdta            ! output field on model grid (2 dimensional)
+      REAL(wp)                  , INTENT(in   ) ::   pfv             ! fillvalue of the data read in bdy file
+      LOGICAL                   , INTENT(in   ) ::   ldtotvel        ! true if toal ( = barotrop + barocline) velocity
+      INTEGER                   , INTENT(in   ) ::   kgrd            ! grid type (t, u, v)
+      INTEGER                   , INTENT(in   ) ::   kbdy            ! bdy number
+      !!
+      INTEGER                                   ::   ipi             ! length of boundary data on local process
+      INTEGER                                   ::   ipkb            ! number of vertical levels in boundary data file
+      INTEGER                                   ::   jb, ji, jj, jk, jkb   ! loop counters
+      REAL(wp)                                  ::   zcoef
+      REAL(wp)                                  ::   zl, zi, zh      ! tmp variable for current depth and interpolation factor
+      REAL(wp)                                  ::   zfv_alt, ztrans, ztrans_new ! fillvalue and alternative -ABS(pfv)
+      REAL(wp), DIMENSION(jpk)                  ::   zdepth, zdhalf  ! level and half-level depth
       !!---------------------------------------------------------------------
      
-
-      ipi       = SIZE( dta, 1 )
-      ipj       = SIZE( dta_read, 2 )
-      ipk       = SIZE( dta, 3 )
-      jpkm1_bdy = jpk_bdy-1
+      ipi  = SIZE( pdta, 1 )
+      ipkb = SIZE( pdta_read, 3 )
       
-      fv_alt = -ABS(fv)  ! set _FillValue < 0 as we make use of MAXVAL and MAXLOC later
-      DO ib = 1, ipi
-            zij = idx_bdy(ibdy)%nbi(ib,igrd)
-            zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-         IF(narea==2) WRITE(*,*) 'MAPI', ib, igrd, map%ptr(ib), narea-1, zij, zjj
-      ENDDO
-      !
-      IF ( map%ll_unstruc ) THEN                            ! unstructured open boundary data file
-
-         DO ib = 1, ipi
-            DO ik = 1, jpk_bdy
-               IF( ( dta_read(map%ptr(ib),1,ik) == fv ) ) THEN
-                  dta_read_z(map%ptr(ib),1,ik)  = fv_alt ! safety: put fillvalue into external depth field so consistent with data
-                  dta_read_dz(map%ptr(ib),1,ik) = 0._wp  ! safety: put 0._wp into external thickness factors to ensure transport is correct
+      zfv_alt = -ABS(pfv)  ! set _FillValue < 0 as we make use of MAXVAL and MAXLOC later
+      !
+      WHERE( pdta_read == pfv )
+         pdta_read_z  = zfv_alt ! safety: put fillvalue into external depth field so consistent with data
+         pdta_read_dz = 0._wp   ! safety: put 0._wp into external thickness factors to ensure transport is correct
+      ENDWHERE
+      
+      DO jb = 1, ipi
+         ji = idx_bdy(kbdy)%nbi(jb,kgrd)
+         jj = idx_bdy(kbdy)%nbj(jb,kgrd)
+         zh  = SUM(pdta_read_dz(jb,1,:) )
+         !
+         ! Warnings to flag differences in the input and model topgraphy - is this useful/necessary?
+         SELECT CASE( kgrd )                         
+         CASE(1)
+            IF( ABS( (zh - ht_n(ji,jj)) / ht_n(ji,jj)) * tmask(ji,jj,1) > 0.01_wp ) THEN
+               WRITE(ctmp1,"(I10.10)") jb 
+               CALL ctl_warn('fld_bdy_interp: T depths differ between grids at BDY point '//TRIM(ctmp1)//' by more than 1%')
+               !   IF(lwp) WRITE(numout,*) 'DEPTHT', zh, sum(e3t_n(ji,jj,:), mask=tmask(ji,jj,:)==1),  ht_n(ji,jj), jb, jb, ji, jj
+            ENDIF
+         CASE(2)
+            IF( ABS( (zh - hu_n(ji,jj)) * r1_hu_n(ji,jj)) * umask(ji,jj,1) > 0.01_wp ) THEN
+               WRITE(ctmp1,"(I10.10)") jb 
+               CALL ctl_warn('fld_bdy_interp: U depths differ between grids at BDY point '//TRIM(ctmp1)//' by more than 1%')
+               !   IF(lwp) WRITE(numout,*) 'DEPTHU', zh, SUM(e3u_n(ji,jj,:), mask=umask(ji,jj,:)==1),  SUM(umask(ji,jj,:)), &
+               !      &                hu_n(ji,jj), jb, jb, ji, jj, narea-1, pdta_read(jb,1,:)
+            ENDIF
+         CASE(3)
+            IF( ABS( (zh - hv_n(ji,jj)) * r1_hv_n(ji,jj)) * vmask(ji,jj,1) > 0.01_wp ) THEN
+               WRITE(ctmp1,"(I10.10)") jb
+               CALL ctl_warn('fld_bdy_interp: V depths differ between grids at BDY point '//TRIM(ctmp1)//' by more than 1%')
+            ENDIF
+         END SELECT
+         !
+         SELECT CASE( kgrd )                         
+         CASE(1)
+            ! depth of T points:
+            zdepth(:) = gdept_n(ji,jj,:)
+         CASE(2)
+            ! depth of U points: we must not use gdept_n as we don't want to do a communication
+            !   --> copy what is done for gdept_n in domvvl...
+            zdhalf(1) = 0.0_wp
+            zdepth(1) = 0.5_wp * e3uw_n(ji,jj,1)
+            DO jk = 2, jpk                               ! vertical sum
+               !    zcoef = umask - wumask    ! 0 everywhere tmask = wmask, ie everywhere expect at jk = mikt
+               !                              ! 1 everywhere from mbkt to mikt + 1 or 1 (if no isf)
+               !                              ! 0.5 where jk = mikt     
+               !!gm ???????   BUG ?  gdept_n as well as gde3w_n  does not include the thickness of ISF ??
+               zcoef = ( umask(ji,jj,jk) - wumask(ji,jj,jk) )
+               zdhalf(jk) = zdhalf(jk-1) + e3u_n(ji,jj,jk-1)
+               zdepth(jk) =      zcoef  * ( zdhalf(jk  ) + 0.5 * e3uw_n(ji,jj,jk))  &
+                  &         + (1-zcoef) * ( zdepth(jk-1) +       e3uw_n(ji,jj,jk))
+            END DO
+         CASE(3)
+            ! depth of V points: we must not use gdept_n as we don't want to do a communication
+            !   --> copy what is done for gdept_n in domvvl...
+            zdhalf(1) = 0.0_wp
+            zdepth(1) = 0.5_wp * e3vw_n(ji,jj,1)
+            DO jk = 2, jpk                               ! vertical sum
+               !    zcoef = vmask - wvmask    ! 0 everywhere tmask = wmask, ie everywhere expect at jk = mikt
+               !                              ! 1 everywhere from mbkt to mikt + 1 or 1 (if no isf)
+               !                              ! 0.5 where jk = mikt     
+               !!gm ???????   BUG ?  gdept_n as well as gde3w_n  does not include the thickness of ISF ??
+               zcoef = ( vmask(ji,jj,jk) - wvmask(ji,jj,jk) )
+               zdhalf(jk) = zdhalf(jk-1) + e3v_n(ji,jj,jk-1)
+               zdepth(jk) =      zcoef  * ( zdhalf(jk  ) + 0.5 * e3vw_n(ji,jj,jk))  &
+                  &         + (1-zcoef) * ( zdepth(jk-1) +       e3vw_n(ji,jj,jk))
+            END DO
+         END SELECT
+         !
+         DO jk = 1, jpk                      
+            IF(     zdepth(jk) < pdta_read_z(jb,1,          1) ) THEN                ! above the first level of external data
+               pdta(jb,1,jk) =  pdta_read(jb,1,1)
+            ELSEIF( zdepth(jk) > pdta_read_z(jb,1,ipkb) ) THEN                       ! below the last level of external data 
+               pdta(jb,1,jk) =  pdta_read(jb,1,MAXLOC(pdta_read_z(jb,1,:),1))
+            ELSE                                                             ! inbetween: vertical interpolation between jkb & jkb+1
+               DO jkb = 1, ipkb-1                                            ! when  gdept_n(jkb) < zdepth(jk) < gdept_n(jkb+1)
+                  IF( ( ( zdepth(jk) - pdta_read_z(jb,1,jkb) ) * ( zdepth(jk) - pdta_read_z(jb,1,jkb+1) ) <= 0._wp ) &
+                     &    .AND. ( pdta_read_z(jb,1,jkb+1) /= zfv_alt) ) THEN   ! linear interpolation between 2 levels
+                     zi = ( zdepth(jk) - pdta_read_z(jb,1,jkb) ) / ( pdta_read_z(jb,1,jkb+1) - pdta_read_z(jb,1,jkb) )
+                     pdta(jb,1,jk) = pdta_read(jb,1,jkb) + ( pdta_read  (jb,1,jkb+1) - pdta_read  (jb,1,jkb) ) * zi
+                  ENDIF
+               END DO
+            ENDIF
+         END DO   ! jpk
+         !
+      END DO   ! ipi
+      
+      IF(kgrd == 2) THEN                                  ! do we need to adjust the transport term?
+         DO jb = 1, ipi
+            ji = idx_bdy(kbdy)%nbi(jb,kgrd)
+            jj = idx_bdy(kbdy)%nbj(jb,kgrd)
+            zh  = SUM(pdta_read_dz(jb,1,:) )
+            ztrans = 0._wp
+            ztrans_new = 0._wp
+            DO jkb = 1, ipkb                              ! calculate transport on input grid
+               ztrans     = ztrans     + pdta_read(jb,1,jkb) * pdta_read_dz(jb, 1,jkb)
+            ENDDO
+            DO jk = 1, jpk                                ! calculate transport on model grid
+               ztrans_new = ztrans_new +      pdta(jb,1,jk ) *        e3u_n(ji,jj,jk ) * umask(ji,jj,jk)
+            ENDDO
+            DO jk = 1, jpk                                ! make transport correction
+               IF(ldtotvel) THEN ! bdy data are total velocity so adjust bt transport term to match input data
+                  pdta(jb,1,jk) = ( pdta(jb,1,jk) + ( ztrans - ztrans_new ) * r1_hu_n(ji,jj) ) * umask(ji,jj,jk)
+               ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
+                  pdta(jb,1,jk) =   pdta(jb,1,jk) + (  0._wp - ztrans_new ) * r1_hu_n(ji,jj)   * umask(ji,jj,jk)
                ENDIF
             ENDDO
-         ENDDO 
-
-         DO ib = 1, ipi
-            zij = idx_bdy(ibdy)%nbi(ib,igrd)
-            zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-            zh  = SUM(dta_read_dz(map%ptr(ib),1,:) )
-            ! Warnings to flag differences in the input and model topgraphy - is this useful/necessary?
-            SELECT CASE( igrd )                         
-               CASE(1)
-                  IF( ABS( (zh - ht_n(zij,zjj)) / ht_n(zij,zjj)) * tmask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: T depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                 !   IF(lwp) WRITE(*,*) 'DEPTHT', zh, sum(e3t_n(zij,zjj,:), mask=tmask(zij,zjj,:)==1),  ht_n(zij,zjj), map%ptr(ib), ib, zij, zjj
-                  ENDIF
-               CASE(2)
-                  IF( ABS( (zh - hu_n(zij,zjj)) * r1_hu_n(zij,zjj)) * umask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: U depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                     IF(lwp) WRITE(*,*) 'DEPTHU', zh, sum(e3u_n(zij,zjj,:), mask=umask(zij,zjj,:)==1),  sum(umask(zij,zjj,:)), &
-                       &                hu_n(zij,zjj), map%ptr(ib), ib, zij, zjj, narea-1  , &
-                        &                dta_read(map%ptr(ib),1,:)
-                  ENDIF
-               CASE(3)
-                  IF( ABS( (zh - hv_n(zij,zjj)) * r1_hv_n(zij,zjj)) * vmask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: V depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                  ENDIF
-            END SELECT
-            DO ik = 1, ipk                      
-               SELECT CASE( igrd )                       
-                  CASE(1)
-                     zl =  gdept_n(zij,zjj,ik)                                          ! if using in step could use fsdept instead of gdept_n?
-                  CASE(2)
-                     IF(ln_sco) THEN
-                        zl =  ( gdept_n(zij,zjj,ik) + gdept_n(zij+1,zjj,ik) ) * 0.5_wp  ! if using in step could use fsdept instead of gdept_n?
-                     ELSE
-                        zl =  MIN( gdept_n(zij,zjj,ik), gdept_n(zij+1,zjj,ik) ) 
-                     ENDIF
-                  CASE(3)
-                     IF(ln_sco) THEN
-                        zl =  ( gdept_n(zij,zjj,ik) + gdept_n(zij,zjj+1,ik) ) * 0.5_wp  ! if using in step could use fsdept instead of gdept_n?
-                     ELSE
-                        zl =  MIN( gdept_n(zij,zjj,ik), gdept_n(zij,zjj+1,ik) )
-                     ENDIF
-               END SELECT
-               IF( zl < dta_read_z(map%ptr(ib),1,1) ) THEN                                         ! above the first level of external data
-                  dta(ib,1,ik) =  dta_read(map%ptr(ib),1,1)
-               ELSEIF( zl > MAXVAL(dta_read_z(map%ptr(ib),1,:),1) ) THEN                           ! below the last level of external data 
-                  dta(ib,1,ik) =  dta_read(map%ptr(ib),1,MAXLOC(dta_read_z(map%ptr(ib),1,:),1))
-               ELSE                                                                                ! inbetween : vertical interpolation between ikk & ikk+1
-                  DO ikk = 1, jpkm1_bdy                                                            ! when  gdept_n(ikk) < zl < gdept_n(ikk+1)
-                     IF( ( (zl-dta_read_z(map%ptr(ib),1,ikk)) * (zl-dta_read_z(map%ptr(ib),1,ikk+1)) <= 0._wp) &
-                    &    .AND. (dta_read_z(map%ptr(ib),1,ikk+1) /= fv_alt)) THEN
-                        zi           = ( zl - dta_read_z(map%ptr(ib),1,ikk) ) / &
-                       &               ( dta_read_z(map%ptr(ib),1,ikk+1) - dta_read_z(map%ptr(ib),1,ikk) )
-                        dta(ib,1,ik) = dta_read(map%ptr(ib),1,ikk) + &
-                       &               ( dta_read(map%ptr(ib),1,ikk+1) - dta_read(map%ptr(ib),1,ikk) ) * zi
-                     ENDIF
-                  END DO
-               ENDIF
-            END DO
-         END DO
-
-         IF(igrd == 2) THEN                                 ! do we need to adjust the transport term?
-            DO ib = 1, ipi
-              zij = idx_bdy(ibdy)%nbi(ib,igrd)
-              zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-              zh  = SUM(dta_read_dz(map%ptr(ib),1,:) )
-              ztrans = 0._wp
-              ztrans_new = 0._wp
-              DO ik = 1, jpk_bdy                            ! calculate transport on input grid
-                  ztrans     = ztrans     + dta_read(map%ptr(ib),1,ik) * dta_read_dz(map%ptr(ib),1,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! calculate transport on model grid
-                  ztrans_new = ztrans_new + dta(ib,1,ik) * e3u_n(zij,zjj,ik) * umask(zij,zjj,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! make transport correction
-                 IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
-                    dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * r1_hu_n(zij,zjj) ) * umask(zij,zjj,ik)
-                 ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
-                    IF( ABS(ztrans * r1_hu_n(zij,zjj)) > 0.01_wp ) &
-                   &   CALL ctl_warn('fld_bdy_interp: barotropic component of > 0.01 ms-1 found in baroclinic velocities at')
-                    dta(ib,1,ik) = dta(ib,1,ik) + ( 0._wp - ztrans_new ) * r1_hu_n(zij,zjj) * umask(zij,zjj,ik)
-                 ENDIF
-              ENDDO
+         ENDDO
+      ENDIF
+      
+      IF(kgrd == 3) THEN                                  ! do we need to adjust the transport term?
+         DO jb = 1, ipi
+            ji = idx_bdy(kbdy)%nbi(jb,kgrd)
+            jj = idx_bdy(kbdy)%nbj(jb,kgrd)
+            zh  = SUM(pdta_read_dz(jb,1,:) )
+            ztrans = 0._wp
+            ztrans_new = 0._wp
+            DO jkb = 1, ipkb                              ! calculate transport on input grid
+               ztrans     = ztrans     + pdta_read(jb,1,jkb) * pdta_read_dz(jb, 1,jkb)
             ENDDO
-         ENDIF
-
-         IF(igrd == 3) THEN                                 ! do we need to adjust the transport term?
-            DO ib = 1, ipi
-              zij = idx_bdy(ibdy)%nbi(ib,igrd)
-              zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-              zh  = SUM(dta_read_dz(map%ptr(ib),1,:) )
-              ztrans = 0._wp
-              ztrans_new = 0._wp
-              DO ik = 1, jpk_bdy                            ! calculate transport on input grid
-                  ztrans     = ztrans     + dta_read(map%ptr(ib),1,ik) * dta_read_dz(map%ptr(ib),1,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! calculate transport on model grid
-                  ztrans_new = ztrans_new + dta(ib,1,ik) * e3v_n(zij,zjj,ik) * vmask(zij,zjj,ik)
-              ENDDO
-              DO ik = 1, ipk                                ! make transport correction
-                 IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
-                    dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * r1_hv_n(zij,zjj) ) * vmask(zij,zjj,ik)
-                 ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
-                    dta(ib,1,ik) = dta(ib,1,ik) + ( 0._wp - ztrans_new ) * r1_hv_n(zij,zjj) * vmask(zij,zjj,ik)
-                 ENDIF
-              ENDDO
+            DO jk = 1, jpk                                ! calculate transport on model grid
+               ztrans_new = ztrans_new +      pdta(jb,1,jk ) *        e3v_n(ji,jj,jk ) * vmask(ji,jj,jk)
             ENDDO
-         ENDIF
-  
-      ELSE ! structured open boundary file
-
-         DO ib = 1, ipi
-            jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-            ji=map%ptr(ib)-(jj-1)*ilendta
-            DO ik = 1, jpk_bdy                      
-               IF( ( dta_read(ji,jj,ik) == fv ) ) THEN
-                  dta_read_z(ji,jj,ik)  = fv_alt ! safety: put fillvalue into external depth field so consistent with data
-                  dta_read_dz(ji,jj,ik) = 0._wp  ! safety: put 0._wp into external thickness factors to ensure transport is correct
+            DO jk = 1, jpk                                ! make transport correction
+               IF(ldtotvel) THEN ! bdy data are total velocity so adjust bt transport term to match input data
+                  pdta(jb,1,jk) = ( pdta(jb,1,jk) + ( ztrans - ztrans_new ) * r1_hv_n(ji,jj) ) * vmask(ji,jj,jk)
+               ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
+                  pdta(jb,1,jk) =   pdta(jb,1,jk) + (  0._wp - ztrans_new ) * r1_hv_n(ji,jj)   * vmask(ji,jj,jk)
                ENDIF
             ENDDO
-         ENDDO 
-       
-
-         DO ib = 1, ipi
-            jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-            ji=map%ptr(ib)-(jj-1)*ilendta
-            zij = idx_bdy(ibdy)%nbi(ib,igrd)
-            zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-            zh  = SUM(dta_read_dz(ji,jj,:) )
-            ! Warnings to flag differences in the input and model topgraphy - is this useful/necessary?
-            SELECT CASE( igrd )                         
-               CASE(1)
-                  IF( ABS( (zh - ht_n(zij,zjj)) / ht_n(zij,zjj)) * tmask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: T depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                 !   IF(lwp) WRITE(*,*) 'DEPTHT', zh, sum(e3t_n(zij,zjj,:), mask=tmask(zij,zjj,:)==1),  ht_n(zij,zjj), map%ptr(ib), ib, zij, zjj
-                  ENDIF
-               CASE(2)
-                  IF( ABS( (zh - hu_n(zij,zjj)) * r1_hu_n(zij,zjj)) * umask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: U depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                  ENDIF
-               CASE(3)
-                  IF( ABS( (zh - hv_n(zij,zjj)) * r1_hv_n(zij,zjj)) * vmask(zij,zjj,1) > 0.01_wp ) THEN
-                     WRITE(ibstr,"(I10.10)") map%ptr(ib) 
-                     CALL ctl_warn('fld_bdy_interp: V depths differ between grids at BDY point '//TRIM(ibstr)//' by more than 1%')
-                  ENDIF
-            END SELECT
-            DO ik = 1, ipk                      
-               SELECT CASE( igrd )                          ! coded for sco - need zco and zps option using min
-                  CASE(1)
-                     zl =  gdept_n(zij,zjj,ik)              ! if using in step could use fsdept instead of gdept_n?
-                  CASE(2)
-                     IF(ln_sco) THEN
-                        zl =  ( gdept_n(zij,zjj,ik) + gdept_n(zij+1,zjj,ik) ) * 0.5_wp  ! if using in step could use fsdept instead of gdept_n?
-                     ELSE
-                        zl =  MIN( gdept_n(zij,zjj,ik), gdept_n(zij+1,zjj,ik) )
-                     ENDIF
-                  CASE(3)
-                     IF(ln_sco) THEN
-                        zl =  ( gdept_n(zij,zjj,ik) + gdept_n(zij,zjj+1,ik) ) * 0.5_wp  ! if using in step could use fsdept instead of gdept_n?
-                     ELSE
-                        zl =  MIN( gdept_n(zij,zjj,ik), gdept_n(zij,zjj+1,ik) )
-                     ENDIF
-               END SELECT
-               IF( zl < dta_read_z(ji,jj,1) ) THEN                                      ! above the first level of external data
-                  dta(ib,1,ik) =  dta_read(ji,jj,1)
-               ELSEIF( zl > MAXVAL(dta_read_z(ji,jj,:),1) ) THEN                        ! below the last level of external data 
-                  dta(ib,1,ik) =  dta_read(ji,jj,MAXLOC(dta_read_z(ji,jj,:),1))
-               ELSE                                                                     ! inbetween : vertical interpolation between ikk & ikk+1
-                  DO ikk = 1, jpkm1_bdy                                                 ! when  gdept_n(ikk) < zl < gdept_n(ikk+1)
-                     IF( ( (zl-dta_read_z(ji,jj,ikk)) * (zl-dta_read_z(ji,jj,ikk+1)) <= 0._wp) &
-                    &    .AND. (dta_read_z(ji,jj,ikk+1) /= fv_alt)) THEN
-                        zi           = ( zl - dta_read_z(ji,jj,ikk) ) / &
-                       &               ( dta_read_z(ji,jj,ikk+1) - dta_read_z(ji,jj,ikk) )
-                        dta(ib,1,ik) = dta_read(ji,jj,ikk) + &
-                       &               ( dta_read(ji,jj,ikk+1) - dta_read(ji,jj,ikk) ) * zi
-                     ENDIF
-                  END DO
-               ENDIF
-            END DO
-         END DO
-
-         IF(igrd == 2) THEN                                 ! do we need to adjust the transport term?
-            DO ib = 1, ipi
-               jj=1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-               ji=map%ptr(ib)-(jj-1)*ilendta
-               zij = idx_bdy(ibdy)%nbi(ib,igrd)
-               zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-               zh = SUM(dta_read_dz(ji,jj,:) )
-               ztrans = 0._wp
-               ztrans_new = 0._wp
-               DO ik = 1, jpk_bdy                            ! calculate transport on input grid
-                  ztrans = ztrans + dta_read(ji,jj,ik) * dta_read_dz(ji,jj,ik)
-               ENDDO
-               DO ik = 1, ipk                                ! calculate transport on model grid
-                  ztrans_new = ztrans_new + dta(ib,1,ik) * e3u_n(zij,zjj,ik) * umask(zij,zjj,ik)
-               ENDDO
-               DO ik = 1, ipk                                ! make transport correction
-                  IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
-                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * r1_hu_n(zij,zjj) ) * umask(zij,zjj,ik)
-                  ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
-                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( 0._wp  - ztrans_new ) * r1_hu_n(zij,zjj) ) * umask(zij,zjj,ik)
-                  ENDIF
-               ENDDO
-            ENDDO
-         ENDIF
-
-         IF(igrd == 3) THEN                                 ! do we need to adjust the transport term?
-            DO ib = 1, ipi
-               jj  = 1+floor(REAL(map%ptr(ib)-1)/REAL(ilendta))
-               ji  = map%ptr(ib)-(jj-1)*ilendta
-               zij = idx_bdy(ibdy)%nbi(ib,igrd)
-               zjj = idx_bdy(ibdy)%nbj(ib,igrd)
-               zh  = SUM(dta_read_dz(ji,jj,:) )
-               ztrans = 0._wp
-               ztrans_new = 0._wp
-               DO ik = 1, jpk_bdy                            ! calculate transport on input grid
-                  ztrans     = ztrans     + dta_read(ji,jj,ik) * dta_read_dz(ji,jj,ik)
-               ENDDO
-               DO ik = 1, ipk                                ! calculate transport on model grid
-                  ztrans_new = ztrans_new + dta(ib,1,ik) * e3v_n(zij,zjj,ik) * vmask(zij,zjj,ik)
-               ENDDO
-               DO ik = 1, ipk                                ! make transport correction
-                  IF(fvl) THEN ! bdy data are total velocity so adjust bt transport term to match input data
-                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( ztrans - ztrans_new ) * r1_hv_n(zij,zjj) ) * vmask(zij,zjj,ik)
-                  ELSE ! we're just dealing with bc velocity so bt transport term should sum to zero
-                     dta(ib,1,ik) = ( dta(ib,1,ik) + ( 0._wp  - ztrans_new ) * r1_hv_n(zij,zjj) ) * vmask(zij,zjj,ik)
-                  ENDIF
-               ENDDO
-            ENDDO
-         ENDIF
-
-      ENDIF ! endif unstructured or structured
-
+         ENDDO
+      ENDIF
+      
    END SUBROUTINE fld_bdy_interp
 
@@ -1151,4 +1011,5 @@
       imf = SIZE( sd )
       DO ju = 1, imf
+         IF( TRIM(sd(ju)%clrootname) == 'NOT USED' )   CYCLE
          ill = LEN_TRIM( sd(ju)%vcomp )
          DO jn = 2-COUNT((/sd(ju)%ln_tint/)), 2
@@ -1159,4 +1020,5 @@
                   iv = -1
                   DO jv = 1, imf
+                     IF( TRIM(sd(jv)%clrootname) == 'NOT USED' )   CYCLE
                      IF( TRIM(sd(jv)%vcomp) == TRIM(clcomp) )   iv = jv
                   END DO
@@ -1197,11 +1059,11 @@
       LOGICAL, OPTIONAL, INTENT(in   ) ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
       !
-      LOGICAL :: llprevyr              ! are we reading previous year  file?
-      LOGICAL :: llprevmth             ! are we reading previous month file?
-      INTEGER :: iyear, imonth, iday   ! first day of the current file in yyyy mm dd
-      INTEGER :: isec_week             ! number of seconds since start of the weekly file
-      INTEGER :: indexyr               ! year undex (O/1/2: previous/current/next)
-      INTEGER :: iyear_len, imonth_len ! length (days) of iyear and imonth             ! 
-      CHARACTER(len = 256)::   clname  ! temporary file name
+      LOGICAL  :: llprevyr              ! are we reading previous year  file?
+      LOGICAL  :: llprevmth             ! are we reading previous month file?
+      INTEGER  :: iyear, imonth, iday   ! first day of the current file in yyyy mm dd
+      INTEGER  :: isec_week             ! number of seconds since start of the weekly file
+      INTEGER  :: indexyr               ! year undex (O/1/2: previous/current/next)
+      REAL(wp) :: zyear_len, zmonth_len ! length (days) of iyear and imonth             ! 
+      CHARACTER(len = 256) ::   clname  ! temporary file name
       !!----------------------------------------------------------------------
       IF( PRESENT(kyear) ) THEN                             ! use given values 
@@ -1254,22 +1116,22 @@
          ! find the last record to be read -> update sdjf%nreclast
          indexyr = iyear - nyear + 1
-         iyear_len = nyear_len( indexyr )
+         zyear_len = REAL(nyear_len( indexyr ), wp)
          SELECT CASE ( indexyr )
-         CASE ( 0 )   ;   imonth_len = 31   ! previous year -> imonth = 12
-         CASE ( 1 )   ;   imonth_len = nmonth_len(imonth) 
-         CASE ( 2 )   ;   imonth_len = 31   ! next     year -> imonth = 1
+         CASE ( 0 )   ;   zmonth_len = 31.   ! previous year -> imonth = 12
+         CASE ( 1 )   ;   zmonth_len = REAL(nmonth_len(imonth), wp)
+         CASE ( 2 )   ;   zmonth_len = 31.   ! next     year -> imonth = 1
          END SELECT
          !
          ! last record to be read in the current file
-         IF    ( sdjf%nfreqh == -12 ) THEN                 ;   sdjf%nreclast = 1    !  yearly mean
-         ELSEIF( sdjf%nfreqh ==  -1 ) THEN                                          ! monthly mean
+         IF    ( sdjf%freqh == -12. ) THEN                 ;   sdjf%nreclast = 1    !  yearly mean
+         ELSEIF( sdjf%freqh ==  -1. ) THEN                                          ! monthly mean
             IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = 1
             ELSE                                           ;   sdjf%nreclast = 12
             ENDIF
          ELSE                                                                       ! higher frequency mean (in hours)
-            IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = NINT( 24 * imonth_len / sdjf%nfreqh )
-            ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ;   sdjf%nreclast = NINT( 24 * 7          / sdjf%nfreqh )
-            ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ;   sdjf%nreclast = NINT( 24              / sdjf%nfreqh )
-            ELSE                                           ;   sdjf%nreclast = NINT( 24 * iyear_len  / sdjf%nfreqh )
+            IF(     sdjf%cltype      == 'monthly' ) THEN   ;   sdjf%nreclast = NINT( 24. * zmonth_len / sdjf%freqh )
+            ELSEIF( sdjf%cltype(1:4) == 'week'    ) THEN   ;   sdjf%nreclast = NINT( 24. * 7.         / sdjf%freqh )
+            ELSEIF( sdjf%cltype      == 'daily'   ) THEN   ;   sdjf%nreclast = NINT( 24.              / sdjf%freqh )
+            ELSE                                           ;   sdjf%nreclast = NINT( 24. * zyear_len  / sdjf%freqh )
             ENDIF
          ENDIF
@@ -1299,7 +1161,8 @@
       !
       DO jf = 1, SIZE(sdf)
-         sdf(jf)%clrootname = TRIM( cdir )//TRIM( sdf_n(jf)%clname )
+         sdf(jf)%clrootname = sdf_n(jf)%clname
+         IF( TRIM(sdf_n(jf)%clname) /= 'NOT USED' )   sdf(jf)%clrootname = TRIM( cdir )//sdf(jf)%clrootname
          sdf(jf)%clname     = "not yet defined"
-         sdf(jf)%nfreqh     = sdf_n(jf)%nfreqh
+         sdf(jf)%freqh      = sdf_n(jf)%freqh
          sdf(jf)%clvar      = sdf_n(jf)%clvar
          sdf(jf)%ln_tint    = sdf_n(jf)%ln_tint
@@ -1308,7 +1171,7 @@
          sdf(jf)%num        = -1
          sdf(jf)%wgtname    = " "
-         IF( LEN( TRIM(sdf_n(jf)%wname) ) > 0 )   sdf(jf)%wgtname = TRIM( cdir )//TRIM( sdf_n(jf)%wname )
+         IF( LEN( TRIM(sdf_n(jf)%wname) ) > 0 )   sdf(jf)%wgtname = TRIM( cdir )//sdf_n(jf)%wname
          sdf(jf)%lsmname = " "
-         IF( LEN( TRIM(sdf_n(jf)%lname) ) > 0 )   sdf(jf)%lsmname = TRIM( cdir )//TRIM( sdf_n(jf)%lname )
+         IF( LEN( TRIM(sdf_n(jf)%lname) ) > 0 )   sdf(jf)%lsmname = TRIM( cdir )//sdf_n(jf)%lname
          sdf(jf)%vcomp      = sdf_n(jf)%vcomp
          sdf(jf)%rotn(:)    = .TRUE.   ! pretend to be rotated -> won't try to rotate data before the first call to fld_get
@@ -1317,5 +1180,10 @@
          IF( sdf(jf)%cltype(1:4) == 'week' .AND. sdf(jf)%ln_clim )   &
             &   CALL ctl_stop('fld_clopn: weekly file ('//TRIM(sdf(jf)%clrootname)//') needs ln_clim = .FALSE.')
-         sdf(jf)%nreclast = -1 ! Set to non zero default value to avoid errors, is updated to meaningful value during fld_clopn
+         sdf(jf)%nreclast   = -1 ! Set to non zero default value to avoid errors, is updated to meaningful value during fld_clopn
+         sdf(jf)%igrd       = 0
+         sdf(jf)%ibdy       = 0
+         sdf(jf)%imap       => NULL()
+         sdf(jf)%ltotvel    = .FALSE.
+         sdf(jf)%lzint      = .FALSE.
       END DO
       !
@@ -1331,5 +1199,5 @@
          DO jf = 1, SIZE(sdf)
             WRITE(numout,*) '      root filename: '  , TRIM( sdf(jf)%clrootname ), '   variable name: ', TRIM( sdf(jf)%clvar )
-            WRITE(numout,*) '         frequency: '      ,       sdf(jf)%nfreqh      ,   &
+            WRITE(numout,*) '         frequency: '      ,       sdf(jf)%freqh       ,   &
                &                  '   time interp: '    ,       sdf(jf)%ln_tint     ,   &
                &                  '   climatology: '    ,       sdf(jf)%ln_clim
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcapr.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcapr.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcapr.F90	(revision 12143)
@@ -71,9 +71,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_apr in reference namelist : File for atmospheric pressure forcing
       READ  ( numnam_ref, namsbc_apr, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_apr in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_apr in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namsbc_apr in configuration namelist : File for atmospheric pressure forcing
       READ  ( numnam_cfg, namsbc_apr, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_apr in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_apr in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_apr )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcblk.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcblk.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcblk.F90	(revision 12143)
@@ -182,9 +182,9 @@
       REWIND( numnam_ref )                !* Namelist namsbc_blk in reference namelist : bulk parameters
       READ  ( numnam_ref, namsbc_blk, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_blk in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_blk in reference namelist' )
       !
       REWIND( numnam_cfg )                !* Namelist namsbc_blk in configuration namelist : bulk parameters
       READ  ( numnam_cfg, namsbc_blk, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_blk in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_blk in configuration namelist' )
       !
       IF(lwm) WRITE( numond, namsbc_blk )
@@ -201,5 +201,5 @@
       !
       IF( ln_dm2dc ) THEN                 !* check: diurnal cycle on Qsr
-         IF( sn_qsr%nfreqh /= 24 )   CALL ctl_stop( 'sbc_blk_init: ln_dm2dc=T only with daily short-wave input' )
+         IF( sn_qsr%freqh /= 24. )   CALL ctl_stop( 'sbc_blk_init: ln_dm2dc=T only with daily short-wave input' )
          IF( sn_qsr%ln_tint ) THEN 
             CALL ctl_warn( 'sbc_blk_init: ln_dm2dc=T daily qsr time interpolation done by sbcdcy module',   &
@@ -225,5 +225,5 @@
          ALLOCATE( sf(ifpr)%fnow(jpi,jpj,1) )
          IF( slf_i(ifpr)%ln_tint )   ALLOCATE( sf(ifpr)%fdta(jpi,jpj,1,2) )
-         IF( slf_i(ifpr)%nfreqh > 0. .AND. MOD( 3600. * slf_i(ifpr)%nfreqh , REAL(nn_fsbc) * rdt) /= 0. )   &
+         IF( slf_i(ifpr)%freqh > 0. .AND. MOD( NINT(3600. * slf_i(ifpr)%freqh), nn_fsbc * NINT(rdt) ) /= 0 )   &
             &  CALL ctl_warn( 'sbc_blk_init: sbcmod timestep rdt*nn_fsbc is NOT a submultiple of atmospheric forcing frequency.',   &
             &                 '               This is not ideal. You should consider changing either rdt or nn_fsbc value...' )
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbccpl.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbccpl.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbccpl.F90	(revision 12143)
@@ -266,9 +266,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_cpl in reference namelist : Variables for OASIS coupling
       READ  ( numnam_ref, namsbc_cpl, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_cpl in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_cpl in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namsbc_cpl in configuration namelist : Variables for OASIS coupling
       READ  ( numnam_cfg, namsbc_cpl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_cpl in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_cpl in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_cpl )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcflx.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcflx.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcflx.F90	(revision 12143)
@@ -93,13 +93,13 @@
          REWIND( numnam_ref )              ! Namelist namsbc_flx in reference namelist : Files for fluxes
          READ  ( numnam_ref, namsbc_flx, IOSTAT = ios, ERR = 901)
-901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_flx in reference namelist', lwp )
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_flx in reference namelist' )
 
          REWIND( numnam_cfg )              ! Namelist namsbc_flx in configuration namelist : Files for fluxes
          READ  ( numnam_cfg, namsbc_flx, IOSTAT = ios, ERR = 902 )
-902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_flx in configuration namelist', lwp )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_flx in configuration namelist' )
          IF(lwm) WRITE ( numond, namsbc_flx ) 
          !
          !                                         ! check: do we plan to use ln_dm2dc with non-daily forcing?
-         IF( ln_dm2dc .AND. sn_qsr%nfreqh /= 24 )   &
+         IF( ln_dm2dc .AND. sn_qsr%freqh /= 24. )   &
             &   CALL ctl_stop( 'sbc_blk_core: ln_dm2dc can be activated only with daily short-wave forcing' ) 
          !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcice_cice.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcice_cice.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcice_cice.F90	(revision 12143)
@@ -764,9 +764,9 @@
          REWIND( numnam_ref )              ! Namelist namsbc_cice in reference namelist : 
          READ  ( numnam_ref, namsbc_cice, IOSTAT = ios, ERR = 901)
-901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_cice in reference namelist', lwp )
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_cice in reference namelist' )
 
          REWIND( numnam_cfg )              ! Namelist namsbc_cice in configuration namelist : Parameters of the run
          READ  ( numnam_cfg, namsbc_cice, IOSTAT = ios, ERR = 902 )
-902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_cice in configuration namelist', lwp )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_cice in configuration namelist' )
          IF(lwm) WRITE ( numond, namsbc_cice )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcice_if.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcice_if.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcice_if.F90	(revision 12143)
@@ -76,9 +76,9 @@
          REWIND( numnam_ref )              ! Namelist namsbc_iif in reference namelist : Ice if file
          READ  ( numnam_ref, namsbc_iif, IOSTAT = ios, ERR = 901)
-901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_iif in reference namelist', lwp )
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_iif in reference namelist' )
 
          REWIND( numnam_cfg )              ! Namelist Namelist namsbc_iif in configuration namelist : Ice if file
          READ  ( numnam_cfg, namsbc_iif, IOSTAT = ios, ERR = 902 )
-902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_iif in configuration namelist', lwp )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_iif in configuration namelist' )
          IF(lwm) WRITE ( numond, namsbc_iif )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcmod.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcmod.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcmod.F90	(revision 12143)
@@ -108,8 +108,8 @@
       REWIND( numnam_ref )          !* Namelist namsbc in reference namelist : Surface boundary
       READ  ( numnam_ref, namsbc, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc in reference namelist' )
       REWIND( numnam_cfg )          !* Namelist namsbc in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, namsbc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc in configuration namelist' )
       IF(lwm) WRITE( numond, namsbc )
       !
@@ -299,9 +299,13 @@
       !
       !                             !* check consistency between model timeline and nn_fsbc
-      IF( MOD( nitend - nit000 + 1, nn_fsbc) /= 0 .OR.   &
-          MOD( nstock             , nn_fsbc) /= 0 ) THEN
-         WRITE(ctmp1,*) 'sbc_init : experiment length (', nitend - nit000 + 1, ') or nstock (', nstock,   &
-            &           ' is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
-         CALL ctl_stop( ctmp1, 'Impossible to properly do model restart' )
+      IF( ln_rst_list .OR. nn_stock /= -1 ) THEN   ! we will do restart files
+         IF( MOD( nitend - nit000 + 1, nn_fsbc) /= 0 ) THEN
+            WRITE(ctmp1,*) 'sbc_init : experiment length (', nitend - nit000 + 1, ') is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
+            CALL ctl_stop( ctmp1, 'Impossible to properly do model restart' )
+         ENDIF
+         IF( .NOT. ln_rst_list .AND. MOD( nn_stock, nn_fsbc) /= 0 ) THEN   ! we don't use nn_stock if ln_rst_list
+            WRITE(ctmp1,*) 'sbc_init : nn_stock (', nn_stock, ') is NOT a multiple of nn_fsbc (', nn_fsbc, ')'
+            CALL ctl_stop( ctmp1, 'Impossible to properly do model restart' )
+         ENDIF
       ENDIF
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcrnf.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcrnf.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcrnf.F90	(revision 12143)
@@ -263,9 +263,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_rnf in reference namelist : Runoffs 
       READ  ( numnam_ref, namsbc_rnf, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_rnf in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_rnf in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namsbc_rnf in configuration namelist : Runoffs
       READ  ( numnam_cfg, namsbc_rnf, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_rnf in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_rnf in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_rnf )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcssr.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcssr.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcssr.F90	(revision 12143)
@@ -166,9 +166,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_ssr in reference namelist : 
       READ  ( numnam_ref, namsbc_ssr, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_ssr in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_ssr in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namsbc_ssr in configuration namelist :
       READ  ( numnam_cfg, namsbc_ssr, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_ssr in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_ssr in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_ssr )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcwave.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcwave.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/sbcwave.F90	(revision 12143)
@@ -397,9 +397,9 @@
       REWIND( numnam_ref )              ! Namelist namsbc_wave in reference namelist : File for drag coeff. from wave model
       READ  ( numnam_ref, namsbc_wave, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_wave in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_wave in reference namelist' )
          
       REWIND( numnam_cfg )              ! Namelist namsbc_wave in configuration namelist : File for drag coeff. from wave model
       READ  ( numnam_cfg, namsbc_wave, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_wave in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_wave in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_wave )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/tideini.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/tideini.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/tideini.F90	(revision 12143)
@@ -60,9 +60,9 @@
       REWIND( numnam_ref )              ! Namelist nam_tide in reference namelist : Tides
       READ  ( numnam_ref, nam_tide, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_tide in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_tide in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist nam_tide in configuration namelist : Tides
       READ  ( numnam_cfg, nam_tide, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_tide in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nam_tide in configuration namelist' )
       IF(lwm) WRITE ( numond, nam_tide )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/updtide.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/updtide.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/SBC/updtide.F90	(revision 12143)
@@ -27,5 +27,5 @@
 CONTAINS
 
-   SUBROUTINE upd_tide( kt, kit, time_offset )
+   SUBROUTINE upd_tide( kt, kit, kt_offset )
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE upd_tide  ***
@@ -39,9 +39,9 @@
       INTEGER, INTENT(in)           ::   kt      ! ocean time-step index
       INTEGER, INTENT(in), OPTIONAL ::   kit     ! external mode sub-time-step index (lk_dynspg_ts=T)
-      INTEGER, INTENT(in), OPTIONAL ::   time_offset ! time offset in number 
+      INTEGER, INTENT(in), OPTIONAL ::   kt_offset ! time offset in number 
                                                      ! of internal steps             (lk_dynspg_ts=F)
                                                      ! of external steps             (lk_dynspg_ts=T)
       !
-      INTEGER  ::   joffset      ! local integer
+      INTEGER  ::   ioffset      ! local integer
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       REAL(wp) ::   zt, zramp    ! local scalar
@@ -52,11 +52,11 @@
       zt = ( kt - kt_tide ) * rdt
       !
-      joffset = 0
-      IF( PRESENT( time_offset ) )   joffset = time_offset
+      ioffset = 0
+      IF( PRESENT( kt_offset ) )   ioffset = kt_offset
       !
       IF( PRESENT( kit ) )   THEN
-         zt = zt + ( kit +  joffset - 1 ) * rdt / REAL( nn_baro, wp )
+         zt = zt + ( kit +  ioffset - 1 ) * rdt / REAL( nn_baro, wp )
       ELSE
-         zt = zt + joffset * rdt
+         zt = zt + ioffset * rdt
       ENDIF
       !
@@ -70,5 +70,5 @@
       IF( ln_tide_ramp ) THEN         ! linear increase if asked
          zt = ( kt - nit000 ) * rdt
-         IF( PRESENT( kit ) )   zt = zt + ( kit + joffset -1) * rdt / REAL( nn_baro, wp )
+         IF( PRESENT( kit ) )   zt = zt + ( kit + ioffset -1) * rdt / REAL( nn_baro, wp )
          zramp = MIN(  MAX( zt / (rdttideramp*rday) , 0._wp ) , 1._wp  )
          pot_astro(:,:) = zramp * pot_astro(:,:)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/STO/stopar.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/STO/stopar.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/STO/stopar.F90	(revision 12143)
@@ -263,12 +263,12 @@
       REWIND( numnam_ref )              ! Namelist namdyn_adv in reference namelist : Momentum advection scheme
       READ  ( numnam_ref, namsto, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsto in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsto in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namdyn_adv in configuration namelist : Momentum advection scheme
       READ  ( numnam_cfg, namsto, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namsto in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namsto in configuration namelist' )
       IF(lwm) WRITE ( numond, namsto )
 
-      IF( .NOT.ln_rststo ) THEN   ! no use of stochastic parameterization
+      IF( .NOT.ln_sto_eos ) THEN   ! no use of stochastic parameterization
          IF(lwp) THEN
             WRITE(numout,*)
@@ -750,5 +750,8 @@
       CHARACTER(LEN=9)    ::   clsto3d='sto3d_000' ! stochastic parameter variable name
       CHARACTER(LEN=10)   ::   clseed='seed0_0000' ! seed variable name
-
+      !!----------------------------------------------------------------------
+
+      IF( .NOT. ln_rst_list .AND. nn_stock == -1 ) RETURN   ! we will never do any restart
+      
       IF ( jpsto2d > 0 .OR. jpsto3d > 0 ) THEN
 
@@ -790,5 +793,5 @@
          ! Open the restart file one timestep before writing restart
          IF( kt < nitend) THEN
-         IF( kt == nitrst - 1 .OR. nstock == 1 .OR. kt == nitend-1 ) THEN
+         IF( kt == nitrst - 1 .OR. nn_stock == 1 .OR. kt == nitend-1 ) THEN
             ! create the filename
             IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/eosbn2.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/eosbn2.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/eosbn2.F90	(revision 12143)
@@ -30,4 +30,6 @@
    !!   eos_insitu_2d : Compute the in situ density for 2d fields
    !!   bn2           : Compute the Brunt-Vaisala frequency
+   !!   bn2           : compute the Brunt-Vaisala frequency
+   !!   eos_pt_from_ct: compute the potential temperature from the Conservative Temperature
    !!   eos_rab       : generic interface of in situ thermal/haline expansion ratio 
    !!   eos_rab_3d    : compute in situ thermal/haline expansion ratio
@@ -74,7 +76,7 @@
 
    !                               !!** Namelist nameos **
-   LOGICAL , PUBLIC ::   ln_TEOS10   ! determine if eos_pt_from_ct is used to compute sst_m
-   LOGICAL , PUBLIC ::   ln_EOS80   ! determine if eos_pt_from_ct is used to compute sst_m
-   LOGICAL , PUBLIC ::   ln_SEOS   ! determine if eos_pt_from_ct is used to compute sst_m
+   LOGICAL , PUBLIC ::   ln_TEOS10
+   LOGICAL , PUBLIC ::   ln_EOS80
+   LOGICAL , PUBLIC ::   ln_SEOS
 
    ! Parameters
@@ -1235,9 +1237,9 @@
       REWIND( numnam_ref )              ! Namelist nameos in reference namelist : equation of state
       READ  ( numnam_ref, nameos, IOSTAT = ios, ERR = 901 )
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nameos in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nameos in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist nameos in configuration namelist : equation of state
       READ  ( numnam_cfg, nameos, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nameos in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nameos in configuration namelist' )
       IF(lwm) WRITE( numond, nameos )
       !
@@ -1647,4 +1649,7 @@
          !
       CASE( np_seos )                        !==  Simplified EOS     ==!
+
+         r1_S0  = 0.875_wp/35.16504_wp   ! Used to convert CT in potential temperature when using bulk formulae (eos_pt_from_ct)
+         
          IF(lwp) THEN
             WRITE(numout,*)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traadv.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traadv.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traadv.F90	(revision 12143)
@@ -196,9 +196,9 @@
       REWIND( numnam_ref )                   ! Namelist namtra_adv in reference namelist : Tracer advection scheme
       READ  ( numnam_ref, namtra_adv, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_adv in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_adv in reference namelist' )
       !
       REWIND( numnam_cfg )                   ! Namelist namtra_adv in configuration namelist : Tracer advection scheme
       READ  ( numnam_cfg, namtra_adv, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_adv in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_adv in configuration namelist' )
       IF(lwm) WRITE( numond, namtra_adv )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traadv_fct.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traadv_fct.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traadv_fct.F90	(revision 12143)
@@ -21,4 +21,5 @@
    USE diaar5         ! AR5 diagnostics
    USE phycst  , ONLY : rau0_rcp
+   USE zdf_oce , ONLY : ln_zad_Aimp
    !
    USE in_out_manager ! I/O manager
@@ -86,4 +87,6 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk)        ::   zwi, zwx, zwy, zwz, ztu, ztv, zltu, zltv, ztw
       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrdx, ztrdy, ztrdz, zptry
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   zwinf, zwdia, zwsup
+      LOGICAL  ::   ll_zAimp                                 ! flag to apply adaptive implicit vertical advection
       !!----------------------------------------------------------------------
       !
@@ -97,4 +100,5 @@
       l_hst = .FALSE.
       l_ptr = .FALSE.
+      ll_zAimp = .FALSE.
       IF( ( cdtype =='TRA' .AND. l_trdtra  ) .OR. ( cdtype =='TRC' .AND. l_trdtrc ) )       l_trd = .TRUE.
       IF(   cdtype =='TRA' .AND. ln_diaptr )                                                l_ptr = .TRUE. 
@@ -116,4 +120,22 @@
       !
       zwi(:,:,:) = 0._wp        
+      !
+      ! If adaptive vertical advection, check if it is needed on this PE at this time
+      IF( ln_zad_Aimp ) THEN
+         IF( MAXVAL( ABS( wi(:,:,:) ) ) > 0._wp ) ll_zAimp = .TRUE.
+      END IF
+      ! If active adaptive vertical advection, build tridiagonal matrix
+      IF( ll_zAimp ) THEN
+         ALLOCATE(zwdia(jpi,jpj,jpk), zwinf(jpi,jpj,jpk),zwsup(jpi,jpj,jpk))
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt. (ensure same order of calculation as below if wi=0.)
+                  zwdia(ji,jj,jk) =  1._wp + p2dt * ( MAX( wi(ji,jj,jk  ) , 0._wp ) - MIN( wi(ji,jj,jk+1) , 0._wp ) ) / e3t_a(ji,jj,jk)
+                  zwinf(ji,jj,jk) =  p2dt * MIN( wi(ji,jj,jk  ) , 0._wp ) / e3t_a(ji,jj,jk)
+                  zwsup(ji,jj,jk) = -p2dt * MAX( wi(ji,jj,jk+1) , 0._wp ) / e3t_a(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+      END IF
       !
       DO jn = 1, kjpt            !==  loop over the tracers  ==!
@@ -169,4 +191,29 @@
             END DO
          END DO
+         
+         IF ( ll_zAimp ) THEN
+            CALL tridia_solver( zwdia, zwsup, zwinf, zwi, zwi , 0 )
+            !
+            ztw(:,:,1) = 0._wp ; ztw(:,:,jpk) = 0._wp ;
+            DO jk = 2, jpkm1        ! Interior value ( multiplied by wmask)
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.  
+                     zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) )
+                     zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) )
+                     ztw(ji,jj,jk) =  0.5 * e1e2t(ji,jj) * ( zfp_wk * zwi(ji,jj,jk) + zfm_wk * zwi(ji,jj,jk-1) ) * wmask(ji,jj,jk)
+                     zwz(ji,jj,jk) = zwz(ji,jj,jk) + ztw(ji,jj,jk) ! update vertical fluxes
+                  END DO
+               END DO
+            END DO
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.  
+                     pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) - ( ztw(ji,jj,jk) - ztw(ji  ,jj  ,jk+1) ) &
+                        &                                  * r1_e1e2t(ji,jj) / e3t_n(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !
+         END IF
          !                
          IF( l_trd .OR. l_hst )  THEN             ! trend diagnostics (contribution of upstream fluxes)
@@ -277,4 +324,30 @@
             zwz(:,:,1) = 0._wp   ! only ocean surface as interior zwz values have been w-masked
          ENDIF
+         !         
+         IF ( ll_zAimp ) THEN
+            DO jk = 1, jpkm1     !* trend and after field with monotonic scheme
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     !                             ! total intermediate advective trends
+                     ztra = - (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
+                        &      + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
+                        &      + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) ) * r1_e1e2t(ji,jj)
+                     ztw(ji,jj,jk)  = zwi(ji,jj,jk) + p2dt * ztra / e3t_a(ji,jj,jk) * tmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !
+            CALL tridia_solver( zwdia, zwsup, zwinf, ztw, ztw , 0 )
+            !
+            DO jk = 2, jpkm1        ! Interior value ( multiplied by wmask)
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) )
+                     zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) )
+                     zwz(ji,jj,jk) =  zwz(ji,jj,jk) + 0.5 * e1e2t(ji,jj) * ( zfp_wk * ztw(ji,jj,jk) + zfm_wk * ztw(ji,jj,jk-1) ) * wmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         END IF
          !
          CALL lbc_lnk_multi( 'traadv_fct', zwi, 'T', 1., zwx, 'U', -1. , zwy, 'V', -1.,  zwz, 'W',  1. )
@@ -289,11 +362,35 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.  
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) - (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
-                     &                                   + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
-                     &                                   + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) ) &
-                     &                                * r1_e1e2t(ji,jj) / e3t_n(ji,jj,jk)
-               END DO
-            END DO
-         END DO
+                  ztra = - (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
+                     &      + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
+                     &      + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) ) * r1_e1e2t(ji,jj)
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra / e3t_n(ji,jj,jk)
+                  zwi(ji,jj,jk) = zwi(ji,jj,jk) + p2dt * ztra / e3t_a(ji,jj,jk) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !
+         IF ( ll_zAimp ) THEN
+            !
+            ztw(:,:,1) = 0._wp ; ztw(:,:,jpk) = 0._wp
+            DO jk = 2, jpkm1        ! Interior value ( multiplied by wmask)
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) )
+                     zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) )
+                     ztw(ji,jj,jk) = - 0.5 * e1e2t(ji,jj) * ( zfp_wk * zwi(ji,jj,jk) + zfm_wk * zwi(ji,jj,jk-1) ) * wmask(ji,jj,jk)
+                     zwz(ji,jj,jk) = zwz(ji,jj,jk) + ztw(ji,jj,jk) ! Update vertical fluxes for trend diagnostic
+                  END DO
+               END DO
+            END DO
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.  
+                     pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) - ( ztw(ji,jj,jk) - ztw(ji  ,jj  ,jk+1) ) &
+                        &                                * r1_e1e2t(ji,jj) / e3t_n(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         END IF         
          !
          IF( l_trd .OR. l_hst ) THEN   ! trend diagnostics // heat/salt transport
@@ -318,4 +415,7 @@
       END DO                     ! end of tracer loop
       !
+      IF ( ll_zAimp ) THEN
+         DEALLOCATE( zwdia, zwinf, zwsup )
+      ENDIF
       IF( l_trd .OR. l_hst ) THEN 
          DEALLOCATE( ztrdx, ztrdy, ztrdz )
@@ -559,5 +659,5 @@
          DO ji = fs_2, fs_jpim1
             ikt = mikt(ji,jj) + 1            ! w-point below the 1st  wet point
-            ikb = mbkt(ji,jj)                !     -   above the last wet point
+            ikb = MAX(mbkt(ji,jj), 2)        !     -   above the last wet point
             !
             zwd (ji,jj,ikt) = 1._wp          ! top
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/trabbc.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/trabbc.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/trabbc.F90	(revision 12143)
@@ -135,9 +135,9 @@
       REWIND( numnam_ref )              ! Namelist nambbc in reference namelist : Bottom momentum boundary condition
       READ  ( numnam_ref, nambbc, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambbc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambbc in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist nambbc in configuration namelist : Bottom momentum boundary condition
       READ  ( numnam_cfg, nambbc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambbc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambbc in configuration namelist' )
       IF(lwm) WRITE ( numond, nambbc )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/trabbl.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/trabbl.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/trabbl.F90	(revision 12143)
@@ -485,9 +485,9 @@
       REWIND( numnam_ref )              ! Namelist nambbl in reference namelist : Bottom boundary layer scheme
       READ  ( numnam_ref, nambbl, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambbl in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambbl in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist nambbl in configuration namelist : Bottom boundary layer scheme
       READ  ( numnam_cfg, nambbl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambbl in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambbl in configuration namelist' )
       IF(lwm) WRITE ( numond, nambbl )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/tradmp.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/tradmp.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/tradmp.F90	(revision 12143)
@@ -179,9 +179,9 @@
       REWIND( numnam_ref )   ! Namelist namtra_dmp in reference namelist : T & S relaxation
       READ  ( numnam_ref, namtra_dmp, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_dmp in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_dmp in reference namelist' )
       !
       REWIND( numnam_cfg )   ! Namelist namtra_dmp in configuration namelist : T & S relaxation
       READ  ( numnam_cfg, namtra_dmp, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_dmp in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_dmp in configuration namelist' )
       IF(lwm) WRITE ( numond, namtra_dmp )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traldf_iso.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traldf_iso.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traldf_iso.F90	(revision 12143)
@@ -289,5 +289,5 @@
          !!----------------------------------------------------------------------
          !
-         ztfw(1,:,:) = 0._wp     ;     ztfw(jpi,:,:) = 0._wp
+         ztfw(fs_2:1,:,:) = 0._wp     ;     ztfw(jpi:fs_jpim1,:,:) = 0._wp   ! avoid to potentially manipulate NaN values
          !
          ! Vertical fluxes
@@ -323,5 +323,5 @@
          IF( ln_traldf_lap ) THEN               ! laplacian case: eddy coef = ah_wslp2 - akz
             DO jk = 2, jpkm1       
-               DO jj = 1, jpjm1
+               DO jj = 2, jpjm1
                   DO ji = fs_2, fs_jpim1
                      ztfw(ji,jj,jk) = ztfw(ji,jj,jk) + e1e2t(ji,jj) / e3w_n(ji,jj,jk) * wmask(ji,jj,jk)   &
@@ -336,5 +336,5 @@
             CASE(  1  )                            ! 1st pass : eddy coef = ah_wslp2
                DO jk = 2, jpkm1 
-                  DO jj = 1, jpjm1
+                  DO jj = 2, jpjm1
                      DO ji = fs_2, fs_jpim1
                         ztfw(ji,jj,jk) = ztfw(ji,jj,jk)    &
@@ -346,5 +346,5 @@
             CASE(  2  )                         ! 2nd pass : eddy flux = ah_wslp2 and akz applied on ptb  and ptbb gradients, resp.
                DO jk = 2, jpkm1 
-                  DO jj = 1, jpjm1
+                  DO jj = 2, jpjm1
                      DO ji = fs_2, fs_jpim1
                         ztfw(ji,jj,jk) = ztfw(ji,jj,jk) + e1e2t(ji,jj) / e3w_n(ji,jj,jk) * wmask(ji,jj,jk)                      &
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/tramle.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/tramle.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/tramle.F90	(revision 12143)
@@ -268,9 +268,9 @@
       REWIND( numnam_ref )              ! Namelist namtra_mle in reference namelist : Tracer advection scheme
       READ  ( numnam_ref, namtra_mle, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_mle in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_mle in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namtra_mle in configuration namelist : Tracer advection scheme
       READ  ( numnam_cfg, namtra_mle, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_mle in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_mle in configuration namelist' )
       IF(lwm) WRITE ( numond, namtra_mle )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traqsr.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traqsr.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRA/traqsr.F90	(revision 12143)
@@ -168,5 +168,5 @@
                DO jj = 2, jpjm1                       ! Separation in R-G-B depending of the surface Chl
                   DO ji = fs_2, fs_jpim1
-                     zchl    = sf_chl(1)%fnow(ji,jj,1)
+                     zchl    = MIN( 10. , MAX( 0.03, sf_chl(1)%fnow(ji,jj,1) ) )
                      zCtot   = 40.6  * zchl**0.459
                      zze     = 568.2 * zCtot**(-0.746)
@@ -338,9 +338,9 @@
       REWIND( numnam_ref )              ! Namelist namtra_qsr in reference     namelist
       READ  ( numnam_ref, namtra_qsr, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_qsr in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtra_qsr in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namtra_qsr in configuration namelist
       READ  ( numnam_cfg, namtra_qsr, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_qsr in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtra_qsr in configuration namelist' )
       IF(lwm) WRITE ( numond, namtra_qsr )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdini.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdini.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdini.F90	(revision 12143)
@@ -48,9 +48,9 @@
       REWIND( numnam_ref )              ! Namelist namtrd in reference namelist : trends diagnostic
       READ  ( numnam_ref, namtrd, IOSTAT = ios, ERR = 901 )
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrd in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrd in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namtrd in configuration namelist : trends diagnostic
       READ  ( numnam_cfg, namtrd, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrd in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrd in configuration namelist' )
       IF(lwm) WRITE( numond, namtrd )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdmxl.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdmxl.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdmxl.F90	(revision 12143)
@@ -734,9 +734,9 @@
       REWIND( numnam_ref )              ! Namelist namtrd_mxl in reference namelist : mixed layer trends diagnostic
       READ  ( numnam_ref, namtrd_mxl, IOSTAT = ios, ERR = 901 )
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrd_mxl in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrd_mxl in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namtrd_mxl in configuration namelist : mixed layer trends diagnostic
       READ  ( numnam_cfg, namtrd_mxl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrd_mxl in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrd_mxl in configuration namelist' )
       IF(lwm) WRITE( numond, namtrd_mxl )
       !
@@ -764,14 +764,13 @@
 
       IF( MOD( nitend, nn_trd ) /= 0 ) THEN
-         WRITE(numout,cform_err)
-         WRITE(numout,*) '                Your nitend parameter, nitend = ', nitend
-         WRITE(numout,*) '                is no multiple of the trends diagnostics frequency        '
-         WRITE(numout,*) '                          you defined, nn_trd   = ', nn_trd
-         WRITE(numout,*) '                This will not allow you to restart from this simulation.  '
-         WRITE(numout,*) '                You should reconsider this choice.                        ' 
-         WRITE(numout,*) 
-         WRITE(numout,*) '                N.B. the nitend parameter is also constrained to be a     '
-         WRITE(numout,*) '                     multiple of the nn_fsbc parameter '
-         CALL ctl_stop( 'trd_mxl_init: see comment just above' )
+         WRITE(ctmp1,*) '                Your nitend parameter, nitend = ', nitend
+         WRITE(ctmp2,*) '                is no multiple of the trends diagnostics frequency        '
+         WRITE(ctmp3,*) '                          you defined, nn_trd   = ', nn_trd
+         WRITE(ctmp4,*) '                This will not allow you to restart from this simulation.  '
+         WRITE(ctmp5,*) '                You should reconsider this choice.                        ' 
+         WRITE(ctmp6,*) 
+         WRITE(ctmp7,*) '                N.B. the nitend parameter is also constrained to be a     '
+         WRITE(ctmp8,*) '                     multiple of the nn_fsbc parameter '
+         CALL ctl_stop( ctmp1, ctmp2, ctmp3, ctmp4, ctmp5, ctmp6, ctmp7, ctmp8 )
       END IF
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdmxl_rst.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdmxl_rst.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdmxl_rst.F90	(revision 12143)
@@ -47,8 +47,10 @@
       !!--------------------------------------------------------------------------------
 
+      IF( .NOT. ln_rst_list .AND. nn_stock == -1 )   RETURN   ! we will never do any restart
+
       ! to get better performances with NetCDF format:
       ! we open and define the ocean restart_mxl file one time step before writing the data (-> at nitrst - 1)
       ! except if we write ocean restart_mxl files every time step or if an ocean restart_mxl file was writen at nitend - 1
-      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. MOD( nitend - 1, nstock ) == 0 ) ) THEN
+      IF( kt == nitrst - 1 .OR. nn_stock == 1 .OR. ( kt == nitend .AND. MOD( nitend - 1, nn_stock ) == 0 ) ) THEN
          ! beware of the format used to write kt (default is i8.8, that should be large enough...)
          IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdvor.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdvor.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/TRD/trdvor.F90	(revision 12143)
@@ -46,7 +46,7 @@
    REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avr      ! average
    REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrb     ! before vorticity (kt-1)
-   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrbb    ! vorticity at begining of the nwrite-1 timestep averaging period
+   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrbb    ! vorticity at begining of the nn_write-1 timestep averaging period
    REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrbn    ! after vorticity at time step after the
-   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   rotot        ! begining of the NWRITE-1 timesteps
+   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   rotot        ! begining of the NN_WRITE-1 timesteps
    REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrtot   !
    REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrres   !
@@ -129,5 +129,5 @@
       !!              from ocean surface down to control surface (NetCDF output)
       !!
-      !! ** Method/usage :   integration done over nwrite-1 time steps
+      !! ** Method/usage :   integration done over nn_write-1 time steps
       !!
       !! ** Action :   trends :
@@ -143,5 +143,5 @@
       !!                  vortrd (,,10) = forcing term
       !!		              vortrd (,,11) = bottom friction term
-      !!                  rotot(,) : total cumulative trends over nwrite-1 time steps
+      !!                  rotot(,) : total cumulative trends over nn_write-1 time steps
       !!                  vor_avrtot(,) : first membre of vrticity equation
       !!                  vor_avrres(,) : residual = dh/dt entrainment
@@ -214,5 +214,5 @@
       !!              from ocean surface down to control surface (NetCDF output)
       !!
-      !! ** Method/usage :   integration done over nwrite-1 time steps
+      !! ** Method/usage :   integration done over nn_write-1 time steps
       !!
       !! ** Action :     trends :
@@ -228,5 +228,5 @@
       !!                  vortrd (,,10) = forcing term
       !!		  vortrd (,,11) = bottom friction term
-      !!                  rotot(,) : total cumulative trends over nwrite-1 time steps
+      !!                  rotot(,) : total cumulative trends over nn_write-1 time steps
       !!                  vor_avrtot(,) : first membre of vrticity equation
       !!                  vor_avrres(,) : residual = dh/dt entrainment
@@ -360,7 +360,7 @@
       ENDIF
 
-      ! II.2 cumulated trends over analysis period (kt=2 to nwrite)
+      ! II.2 cumulated trends over analysis period (kt=2 to nn_write)
       ! ----------------------
-      ! trends cumulated over nwrite-2 time steps
+      ! trends cumulated over nn_write-2 time steps
 
       IF( kt >= nit000+2 ) THEN
@@ -376,5 +376,5 @@
       !   III. Output in netCDF + residual computation
       !  =============================================
-
+      
       ! define time axis
       it    = kt
@@ -504,5 +504,5 @@
       ENDIF
 #if defined key_diainstant
-      zsto = nwrite*rdt
+      zsto = nn_write*rdt
       clop = "inst("//TRIM(clop)//")"
 #else
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/USR/README-setup-configs
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/USR/README-setup-configs	(revision 12062)
+++ 	(revision )
@@ -1,53 +1,0 @@
-==============================================================
-== HOW TO set up user’s configuration in NEMO version 4.0 : ==
-==============================================================
-This document describes how a configuration is set up in NEMO.
-
-In NEMO 4.0 two types of configurations can be build: global/regional and idealized.
-
-- create ./cfgs/your_config
-- case 1: regional or global 
-    => ln_read_cfg = .true. in ./cfgs/your_config/EXP00/namelist_cfg (i.e. read domain_cfg.nc)
-- case 2: idealized 
-    =>in ./cfgs/your_config/EXP00/namelist_cfg :
-      ln_read_cfg = .false. (need to define usrdef_hgr.F90 and usrdef_zgr.F90) 
-      ln_usr = .true.       (need to define usrdef_sbc.F90)    
-    => copy ./src/OCE/USR in ./cfgs/your_config/MY_SRC routines nedeed to set up domain, forcing fields and initial state
-    
-  Routines in NEMOGCM/NEMO/OCE/USR define analytically the domain, the initial state and the surface boundary conditions for the reference configuration GYRE.
-	  •	usrdef_hgr.F90 and usrdef_zgr.F90 : define horizontal and vertical grid
-	  •	usrdef_sbc.F90    : provides at each time-step the surface boundary condition, i.e. the momentum, heat and freshwater fluxes
-	  •	usrdef_istate.F90 : defines initialization of the dynamics and tracers
-	  •	usrdef_fmask.F90  : used just in ORCA CONFIGURATIONS for alteration of f-point land/ocean mask in some straits 
-	  •	usrdef_closea.F90 : used just in ORCA CONFIGURATIONS for specific treatments associated with closed seas
-	  •	usrdef_nam.F90    : set the domain characteristics of a user configuration
-
-  Other analytical examples are given in ./tests.
-
-===========================================
-== The domain_cfg.nc file must contain : ==
-===========================================
-   int ORCA  , ORCA_index            : configuration name, configuration resolution
-   int jpiglo, jpjglo , jpkglo       : global domain sizes 
-   int jperio                        : lateral global domain b.c. 
-   int ln_zco, ln_zps, ln_sco        : flags for z-coordinate, z-coordinate with partial steps and s-coordinate 
-   int ln_isfcav                     : flag  for ice shelf cavities 
-   double glamt, glamu, glamv, glamf : geographic position 
-   double gphit, gphiu, gphiv, gphif : geographic position
-   double iff, ff_f, ff_t            : Coriolis parameter (if not on the sphere)
-   double e1t, e1u, e1v, e1f         : horizontal scale factors
-   double e2t, e2u, e2v, e2f         : horizontal scale factors
-   double ie1e2u_v, e1e2u, e1e2v     : U and V surfaces (if grid size reduction in some straits)
-   double e3t_1d, e3w_1d             : reference vertical scale factors at T and W points
-   double e3t_0, e3u_0, e3v_0, e3f_0, e3w_0 : vertical scale factors 3D coordinate at T,U,V,F and W points
-   double e3uw_0,e3vw_0              : vertical scale factors 3D coordinate at UW and VW points
-   int bottom_level, top_level       : last wet T-points, 1st wet T-points (for ice shelf cavities)
-
-=======================================
-= HOW TO CREATE domain_cfg.nc file : ==
-=======================================
-Two options are possible :
-
- - users can create with his own tool the domain_cfg.nc with all mandatory fields.  
-
- - tool is available in ./tools/DOMAINcfg based on NEMO 3.6 version. See ./tools/DOMAINcfg/README.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/USR/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/USR/README.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/USR/README.rst	(revision 12143)
@@ -0,0 +1,280 @@
+******************************
+Setting up a new configuration
+******************************
+
+.. todo::
+
+
+
+.. contents::
+   :local:
+
+Starting from an existing configuration
+=======================================
+
+There are three options to build a new configuration from an existing one.
+
+Option 1: Duplicate an existing configuration
+---------------------------------------------
+
+The NEMO so-called Reference Configurations cover a number of major features for NEMO setup
+(global, regional, 1D, using embedded zoom with AGRIF...)
+
+One can create a new configuration by duplicating one of the reference configurations
+(``ORCA2_ICE_PISCES`` in the following example)
+
+.. code-block:: console
+
+   $ ./makenemo –n 'ORCA2_ICE_PISCES_MINE' -r 'ORCA2_ICE_PISCES' -m 'my_arch'
+
+Option 2: Duplicate with differences
+------------------------------------
+
+Create and compile a new configuration based on a reference configuration
+(``ORCA2_ICE_PISCES`` in the following example) but with different pre-processor options.
+For this either add ``add_key`` or ``del_key`` keys as required; e.g.
+
+.. code-block:: console
+
+   $ ./makenemo –n 'ORCA2_ICE_PISCES_MINE' -r 'ORCA2_ICE_PISCES' -m 'my_arch' del_key 'key_iomput' add_key 'key_diahth'
+
+Option 3: Use the SIREN tools to subset an existing model
+---------------------------------------------------------
+
+Define a regional configuration which is a {sub,super}-set of an existing configuration.
+
+This last option employs the SIREN software tools that are included in the standard distribution.
+The software is written in Fortran 95 and available in the :file:`./tools/SIREN` directory.
+SIREN allows you to create your own regional configuration embedded in a wider one.
+
+SIREN is a set of programs to create all the input files you need to
+run a NEMO regional configuration.
+
+:Demo:     Set of GLORYS files (GLObal ReanalYSis on the ORCA025 grid),
+           as well as examples of namelists are available `here`_.
+:Doc:      :forge:`chrome/site/doc/SIREN/html/index.html`
+:Support:  Any questions or comments regarding the use of SIREN should be posted in
+  :forge:`the corresponding forum <discussion/forum/2>`.
+
+.. _here: https://prodn.idris.fr/thredds/catalog/ipsl_public/rron463/catalog.html
+
+Creating a completely new configuration
+=======================================
+
+From NEMO version 4.0 there are two ways to build configurations from scratch.
+The appropriate method to use depends largely on the target configuration.
+Method 1 is for more complex/realistic global or regional configurations and
+method 2 is intended for simpler, idealised configurations whose
+domains and characteristics can be described in simple geometries and formulae.
+
+Option 1: Create and use a domain configuration file
+----------------------------------------------------
+
+This method is used by each of the reference configurations,
+so that downloading their input files linked to their description can help.
+Although starting from scratch,
+it is advisable to create the directory structure to house your new configuration by
+duplicating the closest reference configuration to your target application.
+For example, if your application requires both ocean ice and passive tracers,
+then use the ``ORCA2_ICE_PISCES`` as template,
+and execute following command to build your ``MY_NEW_CONFIG`` configuration:
+
+.. code-block:: sh
+
+   $ ./makenemo –n 'MY_NEW_CONFIG' -r 'ORCA2_ICE_PISCES' -m 'my_arch'
+
+where ``MY_NEW_CONFIG`` can be substituted with
+a suitably descriptive name for your new configuration.
+
+The purpose of this step is simply to create and populate the appropriate :file:`WORK`,
+:file:`MY_SRC` and :file:`EXP00` subdirectories for your new configuration.
+Other choices for the base reference configuration might be
+
+:GYRE:  If your target application is ocean-only
+:AMM12: If your target application is regional with open boundaries
+
+All the domain information for your new configuration will be contained within
+a netcdf file called :file:`domain_cfg.nc` which you will need to create and
+place in the :file:`./cfgs/MY_NEW_CONFIG/EXP00` sub-directory.
+Firstly though, ensure that your configuration is set to use such a file by checking that
+
+.. code-block:: fortran
+
+   ln_read_cfg = .true.
+
+in :file:`./cfgs/MY_NEW_CONFIG/EXP00/namelist_cfg`
+
+Create the :file:`domain_cfg.nc` file which must contain the following fields
+
+.. code-block:: c
+
+   /* configuration name, configuration resolution                 */
+   int    ORCA, ORCA_index
+   /* global domain sizes                                          */
+   int    jpiglo, jpjglo, jpkglo
+   /* lateral global domain b.c.                                   */
+   int    jperio
+   /* flags for z-coord, z-coord with partial steps and s-coord    */
+   int    ln_zco, ln_zps, ln_sco
+   /* flag  for ice shelf cavities                                 */
+   int    ln_isfcav
+   /* geographic position                                          */
+   double glamt, glamu, glamv, glamf
+   /* geographic position                                          */
+   double gphit, gphiu, gphiv, gphif
+   /* Coriolis parameter (if not on the sphere)                    */
+   double iff, ff_f, ff_t
+   /* horizontal scale factors                                     */
+   double e1t, e1u, e1v, e1f
+   /* horizontal scale factors                                     */
+   double e2t, e2u, e2v, e2f
+   /* U and V surfaces (if grid size reduction in some straits)    */
+   double ie1e2u_v, e1e2u, e1e2v
+   /* reference vertical scale factors at T and W points           */
+   double e3t_1d, e3w_1d
+   /* vertical scale factors 3D coordinate at T,U,V,F and W points */
+   double e3t_0, e3u_0, e3v_0, e3f_0, e3w_0
+   /* vertical scale factors 3D coordinate at UW and VW points     */
+   double e3uw_0, e3vw_0
+   /* last wet T-points, 1st wet T-points (for ice shelf cavities) */
+   int    bottom_level, top_level
+
+There are two options for creating a :file:`domain_cfg.nc` file:
+
+- Users can use tools of their own choice to build a :file:`domain_cfg.nc` with all mandatory fields.
+- Users can adapt and apply the supplied tool available in :file:`./tools/DOMAINcfg`.
+  This tool is based on code extracted from NEMO version 3.6 and will allow similar choices for
+  the horizontal and vertical grids that were available internally to that version.
+  See :ref:`tools <DOMAINcfg>` for details.
+
+Option 2: Adapt the usr_def configuration module of NEMO for you own purposes
+-----------------------------------------------------------------------------
+
+This method is intended for configuring easily simple/idealised configurations which
+are often used as demonstrators or for process evaluation and comparison.
+This method can be used whenever the domain geometry has a simple mathematical description and
+the ocean initial state and boundary forcing is described analytically.
+As a start, consider the case of starting a completely new ocean-only test case based on
+the ``LOCK_EXCHANGE`` example.
+
+.. note::
+
+   We probably need an even more basic example than this with only one namelist and
+   minimal changes to the usrdef modules
+
+Firstly, construct the directory structure, starting in the :file:`cfgs` directory:
+
+.. code-block:: console
+
+   $ ./makenemo -n 'MY_NEW_TEST' -t 'LOCK_EXCHANGE' -m 'my_arch'
+
+where the ``-t`` option has been used to locate the new configuration in
+the :file:`tests` subdirectory
+(it is recommended practice to keep full configurations and idealised cases clearly distinguishable).
+This command will create (amongst others) the following files and directories::
+
+   ./tests/MY_NEW_TEST:
+   BLD  EXP00  MY_SRC WORK  cpp_MY_NEW_TEST.fcm
+
+   ./tests/MY_NEW_TEST/EXP00:
+   context_nemo.xml  domain_def_nemo.xml  field_def_nemo-oce.xml  file_def_nemo-oce.xml  iodef.xml
+   namelist_cfg      namelist_ref
+
+   ./tests/MY_NEW_TEST/MY_SRC:
+   usrdef_hgr.F90  usrdef_nam.F90  usrdef_zgr.F90  usrdef_istate.F90  usrdef_sbc.F90  zdfini.F90
+
+The key to setting up an idealised configuration lies in
+adapting a small set of short Fortran 90 modules which
+should be dropped into the :file:`MY_SRC` directory.
+Here the ``LOCK_EXCHANGE`` example is using 5 such routines but the full set that is available in
+the :file:`src/OCE/USR` directory is::
+
+   ./src/OCE/USR:
+   usrdef_closea.F90  usrdef_fmask.F90  usrdef_hgr.F90  usrdef_istate.F90
+   usrdef_nam.F90     usrdef_sbc.F90    usrdef_zgr.F90
+
+Before discussing these in more detail it is worth noting the various namelist controls that
+engage the different user-defined aspects.
+These controls are set using two new logical switches or are implied by the settings of existing ones.
+For example, the mandatory requirement for an idealised configuration is to provide routines which
+define the horizontal and vertical domains.
+Templates for these are provided in the :file:`usrdef_hgr.F90` and :file:`usrdef_zgr.F90` modules.
+The application of these modules is activated whenever:
+
+.. code-block:: fortran
+
+   ln_read_cfg = .false.
+
+in any configuration's :file:`namelist_cfg` file.
+This setting also activates the reading of an optional ``&nam_usrdef`` namelist which can be used to
+supply configuration specific settings.
+These need to be declared and read in the :file:`usrdef_nam.F90` module.
+
+Another explicit control is available in the ``&namsbc`` namelist which
+activates the use of analytical forcing.
+With
+
+.. code-block:: fortran
+
+   ln_usr = .true.
+
+Other usrdef modules are activated by less explicit means.
+For example, code in :file:`usrdef_istate.F90` is used to
+define initial temperature and salinity fields if
+
+.. code-block:: fortran
+
+   ln_tsd_init   = .false.
+
+in the ``&namtsd`` namelist.
+The remaining modules, namely :file:`usrdef_closea.F90` :file:`usrdef_fmask.F90` are specific to
+ORCA configurations and set local variations of some specific fields for
+the various resolutions of the global models.
+They do not need to be considered here in the context of idealised cases but
+it is worth noting that all configuration specific code has now been isolated in the usrdef modules.
+In the case of these last two modules, they are activated only if an ORCA configuration is detected.
+Currently,
+this requires a specific integer variable named ``ORCA`` to be set in a :file:`domain_cfg.nc` file.
+
+.. note::
+
+   This would be less confusing if the ``cn_cfg`` string is read directly as
+   a character attribue from the :file:`domain_cfg.nc`.
+
+So, in most cases, the set up of idealised model configurations can be completed by
+copying the template routines from :file:`./src/OCE/USR` into
+your new :file:`./cfgs/MY_NEW_TEST/MY_SRC` directory and
+editing the appropriate modules as needed.
+The default set are those used for the GYRE reference configuration.
+The contents of :file:`MY_SRC` directories from other idealised configurations may provide
+more convenient templates if they share common characteristics with your target application.
+
+Whatever the starting point,
+it should not require too many changes or additional lines of code to produce routines in
+:file:`./src/OCE/USR` that define analytically the domain,
+the initial state and the surface boundary conditions for your new configuration.
+
+To summarize, the base set of modules is:
+
+:usrdef_hgr.F90:    Define horizontal grid
+:usrdef_zgr.F90:    Define vertical grid
+:usrdef_sbc.F90:    Provides at each time-step the surface boundary condition,
+   i.e. the momentum, heat and freshwater fluxes
+:usrdef_istate.F90: Defines initialization of the dynamics and tracers
+:usrdef_nam.F90:    Configuration-specific namelist processing to
+   set any associated run-time parameters
+
+with two specialised ORCA modules
+(not related to idealised configurations but used to isolate configuration specific code that
+is used in ORCA2 reference configurations and established global configurations using
+the ORCA tripolar grid):
+
+:usrdef_fmask.F90:  only used in ORCA configurations for
+   alteration of f-point land/ocean mask in some straits
+:usrdef_closea.F90: only used in ORCA configurations for
+   specific treatments associated with closed seas
+
+From version 4.0, the NEMO release includes a :file:`tests` subdirectory containing available and
+up to date :doc:`test cases <tests>` build by the community.
+These will not be fully supported as are NEMO reference configurations,
+but should provide a source of raw material.
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/USR/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/USR/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/USR/usrdef_nam.F90	(revision 12143)
@@ -37,5 +37,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -49,22 +49,19 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg          ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg          ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
+      INTEGER         , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii   ! Local integer
+      INTEGER ::   ios   ! Local integer
       !!
       NAMELIST/namusr_def/ nn_GYRE, ln_bench, jpkglo
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       cd_cfg = 'GYRE'               ! name & resolution (not used)
@@ -83,27 +80,27 @@
 #endif
       kpk = jpkglo
-      !
-      !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                            ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'     ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : GYRE case'                                             ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      GYRE used as Benchmark (=T)                      ln_bench  = ', ln_bench  ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      inverse resolution & implied domain size         nn_GYRE   = ', nn_GYRE   ;   ii = ii + 1
-#if defined key_agrif
-      IF( Agrif_Root() ) THEN
-#endif
-      WRITE(ldtxt(ii),*) '         jpiglo = 30*nn_GYRE+2                            jpiglo = ', kpi       ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         jpjglo = 20*nn_GYRE+2                            jpjglo = ', kpj       ;   ii = ii + 1
-#if defined key_agrif
-      ENDIF
-#endif
-      WRITE(ldtxt(ii),*) '      number of model levels                              jpkglo = ', kpk       ;   ii = ii + 1
-      !
       !                             ! Set the lateral boundary condition of the global domain
       kperio = 0                    ! GYRE configuration : closed domain
       !
-      WRITE(ldtxt(ii),*) '   '                                                                            ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Lateral b.c. of the global domain set to closed     jperio = ', kperio       ;   ii = ii + 1
+      !                             ! control print
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : GYRE case'
+         WRITE(numout,*) '      GYRE used as Benchmark (=T)                      ln_bench  = ', ln_bench
+         WRITE(numout,*) '      inverse resolution & implied domain size         nn_GYRE   = ', nn_GYRE
+#if defined key_agrif
+         IF( Agrif_Root() ) THEN
+#endif
+         WRITE(numout,*) '         jpiglo = 30*nn_GYRE+2                            jpiglo = ', kpi
+         WRITE(numout,*) '         jpjglo = 20*nn_GYRE+2                            jpjglo = ', kpj
+#if defined key_agrif
+         ENDIF
+#endif
+         WRITE(numout,*) '      number of model levels                              jpkglo = ', kpk
+         WRITE(numout,*) '   '
+         WRITE(numout,*) '   Lateral b.c. of the global domain set to closed        jperio = ', kperio
+      ENDIF
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfdrg.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfdrg.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfdrg.F90	(revision 12143)
@@ -238,8 +238,8 @@
       REWIND( numnam_ref )                   ! Namelist namdrg in reference namelist
       READ  ( numnam_ref, namdrg, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam( ios , 'namdrg in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam( ios , 'namdrg in reference namelist' )
       REWIND( numnam_cfg )                   ! Namelist namdrg in configuration namelist
       READ  ( numnam_cfg, namdrg, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam( ios , 'namdrg in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam( ios , 'namdrg in configuration namelist' )
       IF(lwm) WRITE ( numond, namdrg )
       !
@@ -338,9 +338,9 @@
       IF(ll_top)   READ  ( numnam_ref, namdrg_top, IOSTAT = ios, ERR = 901)
       IF(ll_bot)   READ  ( numnam_ref, namdrg_bot, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam( ios , TRIM(cl_namref), lwp )
+901   IF( ios /= 0 )   CALL ctl_nam( ios , TRIM(cl_namref) )
       REWIND( numnam_cfg )                   ! Namelist cd_namdrg in configuration namelist
       IF(ll_top)   READ  ( numnam_cfg, namdrg_top, IOSTAT = ios, ERR = 902 )
       IF(ll_bot)   READ  ( numnam_cfg, namdrg_bot, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam( ios , TRIM(cl_namcfg), lwp )
+902   IF( ios >  0 )   CALL ctl_nam( ios , TRIM(cl_namcfg) )
       IF(lwm .AND. ll_top)   WRITE ( numond, namdrg_top )
       IF(lwm .AND. ll_bot)   WRITE ( numond, namdrg_bot )
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfgls.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfgls.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfgls.F90	(revision 12143)
@@ -859,9 +859,9 @@
       REWIND( numnam_ref )              ! Namelist namzdf_gls in reference namelist : Vertical eddy diffivity and viscosity using gls turbulent closure scheme
       READ  ( numnam_ref, namzdf_gls, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf_gls in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf_gls in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namzdf_gls in configuration namelist : Vertical eddy diffivity and viscosity using gls turbulent closure scheme
       READ  ( numnam_cfg, namzdf_gls, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf_gls in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf_gls in configuration namelist' )
       IF(lwm) WRITE ( numond, namzdf_gls )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfiwm.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfiwm.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfiwm.F90	(revision 12143)
@@ -424,9 +424,9 @@
       REWIND( numnam_ref )              ! Namelist namzdf_iwm in reference namelist : Wave-driven mixing
       READ  ( numnam_ref, namzdf_iwm, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf_iwm in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf_iwm in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namzdf_iwm in configuration namelist : Wave-driven mixing
       READ  ( numnam_cfg, namzdf_iwm, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf_iwm in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf_iwm in configuration namelist' )
       IF(lwm) WRITE ( numond, namzdf_iwm )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfosm.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfosm.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfosm.F90	(revision 12143)
@@ -1386,9 +1386,9 @@
      REWIND( numnam_ref )              ! Namelist namzdf_osm in reference namelist : Osmosis ML model
      READ  ( numnam_ref, namzdf_osm, IOSTAT = ios, ERR = 901)
-901  IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_osm in reference namelist', lwp )
+901  IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_osm in reference namelist' )
 
      REWIND( numnam_cfg )              ! Namelist namzdf_tke in configuration namelist : Turbulent Kinetic Energy
      READ  ( numnam_cfg, namzdf_osm, IOSTAT = ios, ERR = 902 )
-902  IF( ios >  0 ) CALL ctl_nam ( ios , 'namzdf_osm in configuration namelist', lwp )
+902  IF( ios >  0 ) CALL ctl_nam ( ios , 'namzdf_osm in configuration namelist' )
      IF(lwm) WRITE ( numond, namzdf_osm )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfphy.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfphy.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfphy.F90	(revision 12143)
@@ -93,9 +93,9 @@
       REWIND( numnam_ref )              ! Namelist namzdf in reference namelist : Vertical mixing parameters
       READ  ( numnam_ref, namzdf, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namzdf in reference namelist : Vertical mixing parameters
       READ  ( numnam_cfg, namzdf, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf in configuration namelist' )
       IF(lwm)   WRITE ( numond, namzdf )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfric.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfric.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdfric.F90	(revision 12143)
@@ -80,9 +80,9 @@
       REWIND( numnam_ref )              ! Namelist namzdf_ric in reference namelist : Vertical diffusion Kz depends on Richardson number
       READ  ( numnam_ref, namzdf_ric, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_ric in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_ric in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namzdf_ric in configuration namelist : Vertical diffusion Kz depends on Richardson number
       READ  ( numnam_cfg, namzdf_ric, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namzdf_ric in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namzdf_ric in configuration namelist' )
       IF(lwm) WRITE ( numond, namzdf_ric )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdftke.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdftke.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/ZDF/zdftke.F90	(revision 12143)
@@ -658,9 +658,9 @@
       REWIND( numnam_ref )              ! Namelist namzdf_tke in reference namelist : Turbulent Kinetic Energy
       READ  ( numnam_ref, namzdf_tke, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_tke in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_tke in reference namelist' )
 
       REWIND( numnam_cfg )              ! Namelist namzdf_tke in configuration namelist : Turbulent Kinetic Energy
       READ  ( numnam_cfg, namzdf_tke, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namzdf_tke in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namzdf_tke in configuration namelist' )
       IF(lwm) WRITE ( numond, namzdf_tke )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/module_example
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/module_example	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/module_example	(revision 12143)
@@ -152,9 +152,9 @@
       REWIND( numnam_ref )              ! Namelist namexa in reference namelist : Example
       READ  ( numnam_ref, namexa, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namexa in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namexa in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namexa in configuration namelist : Example
       READ  ( numnam_cfg, namexa, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namexa in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namexa in configuration namelist' )
    ! Output namelist for control
       WRITE ( numond, namexa )
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/nemogcm.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/nemogcm.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/nemogcm.F90	(revision 12143)
@@ -59,4 +59,5 @@
    USE diaobs         ! Observation diagnostics       (dia_obs_init routine)
    USE diacfl         ! CFL diagnostics               (dia_cfl_init routine)
+   USE diaharm        ! tidal harmonics diagnostics  (dia_harm_init routine)
    USE step           ! NEMO time-stepping                 (stp     routine)
    USE isfstp         ! ice shelf                     (isf_stp_init routine)
@@ -104,4 +105,5 @@
 
 #if defined key_mpp_mpi
+   ! need MPI_Wtime
    INCLUDE 'mpif.h'
 #endif
@@ -129,4 +131,5 @@
       !!----------------------------------------------------------------------
       INTEGER ::   istp   ! time step index
+      REAL(wp)::   zstptiming   ! elapsed time for 1 time step
       !!----------------------------------------------------------------------
       !
@@ -189,11 +192,17 @@
          !
          DO WHILE( istp <= nitend .AND. nstop == 0 )
-#if defined key_mpp_mpi
+
             ncom_stp = istp
-            IF ( istp == ( nit000 + 1 ) ) elapsed_time = MPI_Wtime()
-            IF ( istp ==         nitend ) elapsed_time = MPI_Wtime() - elapsed_time
-#endif
+            IF( ln_timing ) THEN
+               zstptiming = MPI_Wtime()
+               IF ( istp == ( nit000 + 1 ) ) elapsed_time = zstptiming
+               IF ( istp ==         nitend ) elapsed_time = zstptiming - elapsed_time
+            ENDIF
+            
             CALL stp        ( istp ) 
             istp = istp + 1
+
+            IF( lwp .AND. ln_timing )   WRITE(numtime,*) 'timing step ', istp-1, ' : ', MPI_Wtime() - zstptiming
+
          END DO
          !
@@ -221,7 +230,6 @@
       !
       IF( nstop /= 0 .AND. lwp ) THEN        ! error print
-         WRITE(numout,cform_err)
-         WRITE(numout,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
-         WRITE(numout,*)
+         WRITE(ctmp1,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
+         CALL ctl_stop( ctmp1 )
       ENDIF
       !
@@ -235,5 +243,5 @@
 #else
       IF    ( lk_oasis ) THEN   ;   CALL cpl_finalize   ! end coupling and mpp communications with OASIS
-      ELSEIF( lk_mpp   ) THEN   ;   CALL mppstop( ldfinal = .TRUE. )   ! end mpp communications
+      ELSEIF( lk_mpp   ) THEN   ;   CALL mppstop      ! end mpp communications
       ENDIF
 #endif
@@ -241,5 +249,5 @@
       IF(lwm) THEN
          IF( nstop == 0 ) THEN   ;   STOP 0
-         ELSE                    ;   STOP 999
+         ELSE                    ;   STOP 123
          ENDIF
       ENDIF
@@ -254,7 +262,5 @@
       !! ** Purpose :   initialization of the NEMO GCM
       !!----------------------------------------------------------------------
-      INTEGER  ::   ji                 ! dummy loop indices
-      INTEGER  ::   ios, ilocal_comm   ! local integers
-      CHARACTER(len=120), DIMENSION(60) ::   cltxt, cltxt2, clnam
+      INTEGER ::   ios, ilocal_comm   ! local integers
       !!
       NAMELIST/namctl/ ln_ctl   , sn_cfctl, nn_print, nn_ictls, nn_ictle,   &
@@ -264,54 +270,21 @@
       !!----------------------------------------------------------------------
       !
-      cltxt  = ''
-      cltxt2 = ''
-      clnam  = ''  
       cxios_context = 'nemo'
       !
-      !                             ! Open reference namelist and configuration namelist files
-      CALL ctl_opn( numnam_ref, 'namelist_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-      CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-      !
-      REWIND( numnam_ref )              ! Namelist namctl in reference namelist
-      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. )
-      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
-      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. )
-      !
-      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
-      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. )
-      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
-      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
-
-      !                             !--------------------------!
-      !                             !  Set global domain size  !   (control print return in cltxt2)
-      !                             !--------------------------!
-      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
-         CALL domain_cfg ( cltxt2,        cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
-         !
-      ELSE                                ! user-defined namelist
-         CALL usr_def_nam( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
-      ENDIF
-      !
-      !
-      !                             !--------------------------------------------!
-      !                             !  set communicator & select the local node  !
-      !                             !  NB: mynode also opens output.namelist.dyn !
-      !                             !      on unit number numond on first proc   !
-      !                             !--------------------------------------------!
+      !                             !-------------------------------------------------!
+      !                             !     set communicator & select the local rank    !
+      !                             !  must be done as soon as possible to get narea  !
+      !                             !-------------------------------------------------!
+      !
 #if defined key_iomput
       IF( Agrif_Root() ) THEN
          IF( lk_oasis ) THEN
             CALL cpl_init( "oceanx", ilocal_comm )                               ! nemo local communicator given by oasis
-            CALL xios_initialize( "not used"       ,local_comm= ilocal_comm )    ! send nemo communicator to xios
+            CALL xios_initialize( "not used"       , local_comm =ilocal_comm )   ! send nemo communicator to xios
          ELSE
-            CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm )    ! nemo local communicator given by xios
+            CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
          ENDIF
       ENDIF
-      ! Nodes selection (control print return in cltxt)
-      narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm )
+      CALL mpp_start( ilocal_comm )
 #else
       IF( lk_oasis ) THEN
@@ -319,47 +292,46 @@
             CALL cpl_init( "oceanx", ilocal_comm )          ! nemo local communicator given by oasis
          ENDIF
-         ! Nodes selection (control print return in cltxt)
-         narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm )
+         CALL mpp_start( ilocal_comm )
       ELSE
-         ilocal_comm = 0                                    ! Nodes selection (control print return in cltxt)
-         narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop )
-      ENDIF
-#endif
-
-      narea = narea + 1                                     ! mynode return the rank of proc (0 --> jpnij -1 )
-
-      IF( sn_cfctl%l_config ) THEN
-         ! Activate finer control of report outputs
-         ! optionally switch off output from selected areas (note this only
-         ! applies to output which does not involve global communications)
-         IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax  ) .OR. &
-           & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) )    &
-           &   CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. )
-      ELSE
-         ! Use ln_ctl to turn on or off all options.
-         CALL nemo_set_cfctl( sn_cfctl, ln_ctl, .TRUE. )
-      ENDIF
-
-      lwm = (narea == 1)                                    ! control of output namelists
-      lwp = (narea == 1) .OR. ln_ctl                        ! control of all listing output print
-
-      IF(lwm) THEN               ! write merged namelists from earlier to output namelist 
-         !                       ! now that the file has been opened in call to mynode. 
-         !                       ! NB: nammpp has already been written in mynode (if lk_mpp_mpi)
-         WRITE( numond, namctl )
-         WRITE( numond, namcfg )
-         IF( .NOT.ln_read_cfg ) THEN
-            DO ji = 1, SIZE(clnam)
-               IF( TRIM(clnam(ji)) /= '' )   WRITE(numond, * ) clnam(ji)     ! namusr_def print
-            END DO
-         ENDIF
-      ENDIF
-
-      IF(lwp) THEN                            ! open listing units
-         !
-         CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
+         CALL mpp_start( )
+      ENDIF
+#endif
+      !
+      narea = mpprank + 1               ! mpprank: the rank of proc (0 --> mppsize -1 )
+      lwm = (narea == 1)                ! control of output namelists
+      !
+      !                             !---------------------------------------------------------------!
+      !                             ! Open output files, reference and configuration namelist files !
+      !                             !---------------------------------------------------------------!
+      !
+      ! open ocean.output as soon as possible to get all output prints (including errors messages)
+      IF( lwm )   CALL ctl_opn(     numout,        'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      ! open reference and configuration namelist files
+                  CALL ctl_opn( numnam_ref,        'namelist_ref',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+                  CALL ctl_opn( numnam_cfg,        'namelist_cfg',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      IF( lwm )   CALL ctl_opn(     numond, 'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      ! open /dev/null file to be able to supress output write easily
+                  CALL ctl_opn(     numnul,           '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      !
+      !                             !--------------------!
+      !                             ! Open listing units !  -> need ln_ctl from namctl to define lwp
+      !                             !--------------------!
+      !
+      REWIND( numnam_ref )              ! Namelist namctl in reference namelist
+      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist' )
+      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
+      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist' )
+      !
+      lwp = (narea == 1) .OR. ln_ctl    ! control of all listing output print
+      !
+      IF(lwp) THEN                      ! open listing units
+         !
+         IF( .NOT. lwm )   &            ! alreay opened for narea == 1
+            &            CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE., narea )
          !
          WRITE(numout,*)
-         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - INGV - CMCC'
+         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC'
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Ocean General Circulation Model'
@@ -380,22 +352,47 @@
          WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
          WRITE(numout,*)
-         
-         DO ji = 1, SIZE(cltxt)
-            IF( TRIM(cltxt (ji)) /= '' )   WRITE(numout,*) TRIM(cltxt(ji))    ! control print of mynode
-         END DO
-         WRITE(numout,*)
-         WRITE(numout,*)
-         DO ji = 1, SIZE(cltxt2)
-            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) TRIM(cltxt2(ji))   ! control print of domain size
-         END DO
          !
          WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
          !
       ENDIF
-      ! open /dev/null file to be able to supress output write easily
-      CALL ctl_opn( numnul, '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-      !
-      !                                      ! Domain decomposition
-      CALL mpp_init                          ! MPP
+      !
+      ! finalize the definition of namctl variables
+      IF( sn_cfctl%l_config ) THEN
+         ! Activate finer control of report outputs
+         ! optionally switch off output from selected areas (note this only
+         ! applies to output which does not involve global communications)
+         IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax  ) .OR. &
+           & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) )    &
+           &   CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. )
+      ELSE
+         ! Use ln_ctl to turn on or off all options.
+         CALL nemo_set_cfctl( sn_cfctl, ln_ctl, .TRUE. )
+      ENDIF
+      !
+      IF(lwm) WRITE( numond, namctl )
+      !
+      !                             !------------------------------------!
+      !                             !  Set global domain size parameters !
+      !                             !------------------------------------!
+      !
+      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
+      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist' )
+      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
+      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist' )   
+      !
+      IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
+         CALL domain_cfg ( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ELSE                              ! user-defined namelist
+         CALL usr_def_nam( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ENDIF
+      !
+      IF(lwm)   WRITE( numond, namcfg )
+      !
+      !                             !-----------------------------------------!
+      !                             ! mpp parameters and domain decomposition !
+      !                             !-----------------------------------------!
+      CALL mpp_init
 
       ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
@@ -485,8 +482,8 @@
      
       !                                      ! Diagnostics
-      IF( lk_floats    )   CALL     flo_init    ! drifting Floats
+                           CALL     flo_init    ! drifting Floats
       IF( ln_diacfl    )   CALL dia_cfl_init    ! Initialise CFL diagnostics
                            CALL dia_ptr_init    ! Poleward TRansports initialization
-      IF( lk_diadct    )   CALL dia_dct_init    ! Sections tranports
+                           CALL dia_dct_init    ! Sections tranports
                            CALL dia_hsb_init    ! heat content, salt content and volume budgets
                            CALL     trd_init    ! Mixed-layer/Vorticity/Integral constraints trends
@@ -494,5 +491,6 @@
                            CALL dia_tmb_init    ! TMB outputs
                            CALL dia_25h_init    ! 25h mean  outputs
-      IF( ln_diaobs    )   CALL dia_obs( nit000-1 )   ! Observation operator for restart
+                           CALL dia_harm_init   ! tidal harmonics outputs
+     IF( ln_diaobs    )    CALL dia_obs( nit000-1 )   ! Observation operator for restart
 
       !                                      ! Assimilation increments
@@ -512,5 +510,5 @@
       !! ** Purpose :   control print setting
       !!
-      !! ** Method  : - print namctl information and check some consistencies
+      !! ** Method  : - print namctl and namcfg information and check some consistencies
       !!----------------------------------------------------------------------
       !
@@ -655,7 +653,4 @@
       USE trc_oce   , ONLY : trc_oce_alloc
       USE bdy_oce   , ONLY : bdy_oce_alloc
-#if defined key_diadct 
-      USE diadct    , ONLY : diadct_alloc 
-#endif 
       !
       INTEGER :: ierr
@@ -669,8 +664,4 @@
       ierr = ierr + bdy_oce_alloc()    ! bdy masks (incl. initialization)
       !
-#if defined key_diadct 
-      ierr = ierr + diadct_alloc ()    ! 
-#endif 
-      !
       CALL mpp_sum( 'nemogcm', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' )
@@ -678,4 +669,5 @@
    END SUBROUTINE nemo_alloc
 
+   
    SUBROUTINE nemo_set_cfctl(sn_cfctl, setto, for_all )
       !!----------------------------------------------------------------------
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/step.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/step.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/step.F90	(revision 12143)
@@ -112,5 +112,5 @@
       IF( ln_tide    )   CALL sbc_tide( kstp )                   ! update tide potential
       IF( ln_apr_dyn )   CALL sbc_apr ( kstp )                   ! atmospheric pressure (NB: call before bdy_dta which needs ssh_ib) 
-      IF( ln_bdy     )   CALL bdy_dta ( kstp, time_offset=+1 )   ! update dynamic & tracer data at open boundaries
+      IF( ln_bdy     )   CALL bdy_dta ( kstp, kt_offset = +1 )   ! update dynamic & tracer data at open boundaries
       IF( ln_isf     )   CALL isf_stp ( kstp )                   ! ice shelf/ocean boundary condition
                          CALL sbc     ( kstp )                   ! Sea Boundary Condition (including sea-ice)
@@ -166,15 +166,4 @@
                             CALL eos    ( tsn, rhd, rhop, gdept_n(:,:,:) )  ! now in situ density for hpg computation
                             
-!!jc: fs simplification
-!!jc: lines below are useless if ln_linssh=F. Keep them here (which maintains a bug if ln_linssh=T and ln_zps=T, cf ticket #1636) 
-!!                                         but ensures reproductible results
-!!                                         with previous versions using split-explicit free surface          
-            IF( ln_zps .AND. .NOT. ln_isfcav )                               &
-               &            CALL zps_hde    ( kstp, jpts, tsn, gtsu, gtsv,   &  ! Partial steps: before horizontal gradient
-               &                                          rhd, gru , grv     )  ! of t, s, rd at the last ocean level
-            IF( ln_zps .AND.       ln_isfcav )                                          &
-               &            CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv, gtui, gtvi,  &  ! Partial steps for top cell (ISF)
-               &                                          rhd, gru , grv , grui, grvi   )  ! of t, s, rd at the first ocean level
-!!jc: fs simplification
                             
                          ua(:,:,:) = 0._wp            ! set dynamics trends to zero
@@ -215,10 +204,10 @@
       ! diagnostics and outputs
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      IF( lk_floats  )   CALL flo_stp ( kstp )        ! drifting Floats
+      IF( ln_floats  )   CALL flo_stp ( kstp )        ! drifting Floats
       IF( ln_diacfl  )   CALL dia_cfl ( kstp )        ! Courant number diagnostics
       IF( lk_diahth  )   CALL dia_hth ( kstp )        ! Thermocline depth (20 degres isotherm depth)
-      IF( lk_diadct  )   CALL dia_dct ( kstp )        ! Transports
+      IF( ln_diadct  )   CALL dia_dct ( kstp )        ! Transports
                          CALL dia_ar5 ( kstp )        ! ar5 diag
-      IF( lk_diaharm )   CALL dia_harm( kstp )        ! Tidal harmonic analysis
+      IF( ln_diaharm )   CALL dia_harm( kstp )        ! Tidal harmonic analysis
                          CALL dia_wri ( kstp )        ! ocean model: outputs
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/stpctl.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/stpctl.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/stpctl.F90	(revision 12143)
@@ -96,5 +96,5 @@
             IF( ln_zad_Aimp ) THEN
                istatus = NF90_DEF_VAR( idrun,   'abs_wi_max', NF90_DOUBLE, (/ idtime /), idw1  )
-               istatus = NF90_DEF_VAR( idrun,       'Cu_max', NF90_DOUBLE, (/ idtime /), idc1  )
+               istatus = NF90_DEF_VAR( idrun,       'Cf_max', NF90_DOUBLE, (/ idtime /), idc1  )
             ENDIF
             istatus = NF90_ENDDEF(idrun)
@@ -123,5 +123,5 @@
       IF( ln_zad_Aimp ) THEN
          zmax(8) = MAXVAL(  ABS( wi(:,:,:) ) , mask = wmask(:,:,:) == 1._wp ) ! implicit vertical vel. max
-         zmax(9) = MAXVAL(   Cu_adv(:,:,:)   , mask = tmask(:,:,:) == 1._wp ) !       cell Courant no. max
+         zmax(9) = MAXVAL(   Cu_adv(:,:,:)   , mask = tmask(:,:,:) == 1._wp ) ! partitioning coeff. max
       ENDIF
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/timing.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/timing.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OCE/timing.F90	(revision 12143)
@@ -347,4 +347,6 @@
 
       ! write output file
+      IF( lwriter ) WRITE(numtime,*) 
+      IF( lwriter ) WRITE(numtime,*) 
       IF( lwriter ) WRITE(numtime,*) 'Total timing (sum) :'
       IF( lwriter ) WRITE(numtime,*) '--------------------'
@@ -657,6 +659,6 @@
          ! Compute cpu/elapsed ratio
          zall_ratio(:) = all_ctime(:) / all_etime(:)
-         ztot_ratio    = SUM(zall_ratio(:))
-         zavg_ratio    = ztot_ratio/REAL(jpnij,wp)
+         ztot_ratio    = SUM(all_ctime(:))/SUM(all_etime(:))
+         zavg_ratio    = SUM(zall_ratio(:))/REAL(jpnij,wp)
          zmax_ratio    = MAXVAL(zall_ratio(:))
          zmin_ratio    = MINVAL(zall_ratio(:))   
@@ -667,6 +669,6 @@
          cllignes(2)='1x,"--------------------",//,'
          cllignes(3)='1x,"Process Rank |"," Elapsed Time (s) |"," CPU Time (s) |"," Ratio CPU/Elapsed",/,'
-         cllignes(4)='    (1x,i4,9x,"|",f12.3,6x,"|",f12.3,2x,"|",4x,f7.3,/),'
-         WRITE(cllignes(4)(1:4),'(I4)') jpnij
+         cllignes(4)='      (4x,i6,4x,"|",f12.3,6x,"|",f12.3,2x,"|",4x,f7.3,/),'
+         WRITE(cllignes(4)(1:6),'(I6)') jpnij
          cllignes(5)='1x,"Total        |",f12.3,6x,"|",F12.3,2x,"|",4x,f7.3,/,'
          cllignes(6)='1x,"Minimum      |",f12.3,6x,"|",F12.3,2x,"|",4x,f7.3,/,'
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OFF/dtadyn.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OFF/dtadyn.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OFF/dtadyn.F90	(revision 12143)
@@ -227,8 +227,8 @@
       REWIND( numnam_ref )              ! Namelist namdta_dyn in reference namelist : Offline: init. of dynamical data
       READ  ( numnam_ref, namdta_dyn, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdta_dyn in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdta_dyn in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namdta_dyn in configuration namelist : Offline: init. of dynamical data
       READ  ( numnam_cfg, namdta_dyn, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdta_dyn in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdta_dyn in configuration namelist' )
       IF(lwm) WRITE ( numond, namdta_dyn )
       !                                         ! store namelist information in an array
@@ -477,8 +477,8 @@
       REWIND( numnam_ref )              ! Namelist namdta_dyn in reference namelist : Offline: init. of dynamical data
       READ  ( numnam_ref, namdta_dyn, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdta_dyn in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdta_dyn in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namdta_dyn in configuration namelist : Offline: init. of dynamical data
       READ  ( numnam_cfg, namdta_dyn, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdta_dyn in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdta_dyn in configuration namelist' )
       IF(lwm) WRITE ( numond, namdta_dyn )
       !                                         ! store namelist information in an array
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OFF/nemogcm.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OFF/nemogcm.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/OFF/nemogcm.F90	(revision 12143)
@@ -114,7 +114,9 @@
 #else
                                 CALL dta_dyn    ( istp )         ! Interpolation of the dynamical fields
+#endif
+                                CALL trc_stp    ( istp )         ! time-stepping
+#if ! defined key_sed_off
          IF( .NOT.ln_linssh )   CALL dta_dyn_swp( istp )         ! swap of sea  surface height and vertical scale factors
 #endif
-                                CALL trc_stp    ( istp )         ! time-stepping
                                 CALL stp_ctl    ( istp, indic )  ! Time loop: control and print
          istp = istp + 1
@@ -131,7 +133,6 @@
 
       IF( nstop /= 0 .AND. lwp ) THEN                 ! error print
-         WRITE(numout,cform_err)
-         WRITE(numout,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
-         WRITE(numout,*)
+         WRITE(ctmp1,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
+         CALL ctl_stop( ctmp1 )
       ENDIF
       !
@@ -146,4 +147,10 @@
 #endif
       !
+      IF(lwm) THEN
+         IF( nstop == 0 ) THEN   ;   STOP 0
+         ELSE                    ;   STOP 123
+         ENDIF
+      ENDIF
+      !
    END SUBROUTINE nemo_gcm
 
@@ -155,7 +162,5 @@
       !! ** Purpose :   initialization of the nemo model in off-line mode
       !!----------------------------------------------------------------------
-      INTEGER  ::   ji                 ! dummy loop indices
-      INTEGER  ::   ios, ilocal_comm   ! local integers
-      CHARACTER(len=120), DIMENSION(30) ::   cltxt, cltxt2, clnam
+      INTEGER ::   ios, ilocal_comm   ! local integers
       !!
       NAMELIST/namctl/ ln_ctl   , sn_cfctl, nn_print, nn_ictls, nn_ictle,   &
@@ -165,54 +170,78 @@
       !!----------------------------------------------------------------------
       !
-      cltxt  = ''
-      cltxt2 = ''
-      clnam  = ''  
       cxios_context = 'nemo'
       !
-      !                             ! Open reference namelist and configuration namelist files
-      CALL ctl_opn( numnam_ref, 'namelist_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-      CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
+      !                             !-------------------------------------------------!
+      !                             !     set communicator & select the local rank    !
+      !                             !  must be done as soon as possible to get narea  !
+      !                             !-------------------------------------------------!
+      !
+#if defined key_iomput
+      CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
+      CALL mpp_start( ilocal_comm )
+#else
+      CALL mpp_start( )
+#endif
+      !
+      narea = mpprank + 1               ! mpprank: the rank of proc (0 --> mppsize -1 )
+      lwm = (narea == 1)                ! control of output namelists
+      !
+      !                             !---------------------------------------------------------------!
+      !                             ! Open output files, reference and configuration namelist files !
+      !                             !---------------------------------------------------------------!
+      !
+      ! open ocean.output as soon as possible to get all output prints (including errors messages)
+      IF( lwm )   CALL ctl_opn(     numout,        'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      ! open reference and configuration namelist files
+                  CALL ctl_opn( numnam_ref,        'namelist_ref',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+                  CALL ctl_opn( numnam_cfg,        'namelist_cfg',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      IF( lwm )   CALL ctl_opn(     numond, 'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      ! open /dev/null file to be able to supress output write easily
+                  CALL ctl_opn(     numnul,           '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      !
+      !                             !--------------------!
+      !                             ! Open listing units !  -> need ln_ctl from namctl to define lwp
+      !                             !--------------------!
       !
       REWIND( numnam_ref )              ! Namelist namctl in reference namelist
       READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
       READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. )
-      !
-      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
-      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. )
-      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
-      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
-
-      !                             !--------------------------!
-      !                             !  Set global domain size  !   (control print return in cltxt2)
-      !                             !--------------------------!
-      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
-         CALL domain_cfg ( cltxt2,        cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist' )
+      !
+      lwp = (narea == 1) .OR. ln_ctl    ! control of all listing output print
+      !
+      IF(lwp) THEN                            ! open listing units
          !
-      ELSE                                ! user-defined namelist
-         CALL usr_def_nam( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
-      ENDIF
-      !
-      l_offline = .true.                  ! passive tracers are run offline
-      !
-      !                             !--------------------------------------------!
-      !                             !  set communicator & select the local node  !
-      !                             !  NB: mynode also opens output.namelist.dyn !
-      !                             !      on unit number numond on first proc   !
-      !                             !--------------------------------------------!
-#if defined key_iomput
-      CALL  xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm )
-      narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm )   ! Nodes selection
-#else
-      ilocal_comm = 0
-      narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop )                ! Nodes selection (control print return in cltxt)
-#endif
-
-      narea = narea + 1                       ! mynode return the rank of proc (0 --> jpnij -1 )
-
+         IF( .NOT. lwm )   &           ! alreay opened for narea == 1
+            &     CALL ctl_opn(     numout,        'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE., narea )
+         !
+         WRITE(numout,*)
+         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC'
+         WRITE(numout,*) '                       NEMO team'
+         WRITE(numout,*) '                   Off-line TOP Model'
+         WRITE(numout,*) '                NEMO version 4.0  (2019) '
+         WRITE(numout,*)
+         WRITE(numout,*) "           ._      ._      ._      ._      ._    "
+         WRITE(numout,*) "       _.-._)`\_.-._)`\_.-._)`\_.-._)`\_.-._)`\_ "
+         WRITE(numout,*)
+         WRITE(numout,*) "           o         _,           _,             "
+         WRITE(numout,*) "            o      .' (        .-' /             "
+         WRITE(numout,*) "           o     _/..._'.    .'   /              "
+         WRITE(numout,*) "      (    o .-'`      ` '-./  _.'               "
+         WRITE(numout,*) "       )    ( o)           ;= <_         (       "
+         WRITE(numout,*) "      (      '-.,\\__ __.-;`\   '.        )      "
+         WRITE(numout,*) "       )  )       \) |`\ \)  '.   \      (   (   "
+         WRITE(numout,*) "      (  (           \_/       '-._\      )   )  "
+         WRITE(numout,*) "       )  )                        `     (   (   "
+         WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
+         WRITE(numout,*)
+         !
+         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
+         !
+      ENDIF
+      !
+      ! finalize the definition of namctl variables
       IF( sn_cfctl%l_config ) THEN
          ! Activate finer control of report outputs
@@ -226,61 +255,32 @@
          CALL nemo_set_cfctl( sn_cfctl, ln_ctl, .TRUE. )
       ENDIF
-
-      lwm = (narea == 1)                      ! control of output namelists
-      lwp = (narea == 1) .OR. ln_ctl          ! control of all listing output print
-
-      IF(lwm) THEN               ! write merged namelists from earlier to output namelist 
-         !                       ! now that the file has been opened in call to mynode. 
-         !                       ! NB: nammpp has already been written in mynode (if lk_mpp_mpi)
-         WRITE( numond, namctl )
-         WRITE( numond, namcfg )
-         IF( .NOT.ln_read_cfg ) THEN
-            DO ji = 1, SIZE(clnam)
-               IF( TRIM(clnam(ji)) /= '' )   WRITE(numond, * ) clnam(ji)     ! namusr_def print
-            END DO
-         ENDIF
-      ENDIF
-
-      IF(lwp) THEN                            ! open listing units
-         !
-         CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
-         !
-         WRITE(numout,*)
-         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - INGV - CMCC'
-         WRITE(numout,*) '                       NEMO team'
-         WRITE(numout,*) '                   Off-line TOP Model'
-         WRITE(numout,*) '                NEMO version 4.0  (2019) '
-         WRITE(numout,*)
-         WRITE(numout,*) "           ._      ._      ._      ._      ._    "
-         WRITE(numout,*) "       _.-._)`\_.-._)`\_.-._)`\_.-._)`\_.-._)`\_ "
-         WRITE(numout,*)
-         WRITE(numout,*) "           o         _,           _,             "
-         WRITE(numout,*) "            o      .' (        .-' /             "
-         WRITE(numout,*) "           o     _/..._'.    .'   /              "
-         WRITE(numout,*) "      (    o .-'`      ` '-./  _.'               "
-         WRITE(numout,*) "       )    ( o)           ;= <_         (       "
-         WRITE(numout,*) "      (      '-.,\\__ __.-;`\   '.        )      "
-         WRITE(numout,*) "       )  )       \) |`\ \)  '.   \      (   (   "
-         WRITE(numout,*) "      (  (           \_/       '-._\      )   )  "
-         WRITE(numout,*) "       )  )                        `     (   (   "
-         WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
-         WRITE(numout,*)
-         DO ji = 1, SIZE(cltxt)
-            IF( TRIM(cltxt (ji)) /= '' )   WRITE(numout,*) TRIM(cltxt(ji))    ! control print of mynode
-         END DO
-         WRITE(numout,*)
-         WRITE(numout,*)
-         DO ji = 1, SIZE(cltxt2)
-            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) TRIM(cltxt2(ji))   ! control print of domain size
-         END DO
-         !
-         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
-         !
-      ENDIF
-      ! open /dev/null file to be able to supress output write easily
-      CALL ctl_opn( numnul, '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-      !
-      !                                      ! Domain decomposition
-      CALL mpp_init                          ! MPP
+      !
+      IF(lwm) WRITE( numond, namctl )
+      !
+      !                             !------------------------------------!
+      !                             !  Set global domain size parameters !
+      !                             !------------------------------------!
+      !     
+      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
+      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist' )
+      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
+      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist' )   
+      !
+      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
+         CALL domain_cfg ( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ELSE                                ! user-defined namelist
+         CALL usr_def_nam( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ENDIF
+      !
+      IF(lwm)   WRITE( numond, namcfg )
+      l_offline = .true.                  ! passive tracers are run offline
+      !
+      !                             !-----------------------------------------!
+      !                             ! mpp parameters and domain decomposition !
+      !                             !-----------------------------------------!
+      !
+      CALL mpp_init
 
       ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/README.rst	(revision 12143)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/README.rst	(revision 12143)
@@ -0,0 +1,15 @@
+*******
+Sources
+*******
+
+.. todo::
+
+
+
+:file:`ICE`: |NEMO-ICE|
+
+:file:`NST`: AGRIF for embedded zooms
+
+:file:`OCE`: |NEMO-OCE|
+
+:file:`TOP`: |NEMO-MBG|
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAO/nemogcm.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAO/nemogcm.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAO/nemogcm.F90	(revision 12143)
@@ -89,7 +89,5 @@
       !! ** Purpose :   initialization of the NEMO GCM
       !!----------------------------------------------------------------------
-      INTEGER ::   ji                 ! dummy loop indices
       INTEGER ::   ios, ilocal_comm   ! local integer
-      CHARACTER(len=120), DIMENSION(30) ::   cltxt, cltxt2, clnam
       !
       NAMELIST/namctl/ ln_ctl   , sn_cfctl, nn_print, nn_ictls, nn_ictle,   &
@@ -99,103 +97,68 @@
       !!----------------------------------------------------------------------
       !
-      cltxt  = ''
-      cltxt2 = ''
-      clnam  = ''  
       cxios_context = 'nemo'
       !
-      !                             ! Open reference namelist and configuration namelist files
-      CALL ctl_opn( numnam_ref, 'namelist_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-      CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-      !
-      REWIND( numnam_ref )              ! Namelist namctl in reference namelist : Control prints
-      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. )
-      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
-      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. )
-      !
-      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist : Control prints
-      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. )
-      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist : Control prints & Benchmark
-      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
-
-      !                             !--------------------------!
-      !                             !  Set global domain size  !   (control print return in cltxt2)
-      !                             !--------------------------!
-      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
-         CALL domain_cfg ( cltxt2,        cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
-         !
-      ELSE                                ! user-defined namelist
-         CALL usr_def_nam( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
-      ENDIF
-      !
-      !
-      !                             !--------------------------------------------!
-      !                             !  set communicator & select the local node  !
-      !                             !  NB: mynode also opens output.namelist.dyn !
-      !                             !      on unit number numond on first proc   !
-      !                             !--------------------------------------------!
+      !                             !-------------------------------------------------!
+      !                             !     set communicator & select the local rank    !
+      !                             !  must be done as soon as possible to get narea  !
+      !                             !-------------------------------------------------!
+      !
 #if defined key_iomput
       IF( Agrif_Root() ) THEN
          IF( lk_oasis ) THEN
-            CALL cpl_init( "oceanx", ilocal_comm )                     ! nemo local communicator given by oasis
-            CALL xios_initialize( "not used",local_comm=ilocal_comm )    ! send nemo communicator to xios
+            CALL cpl_init( "oceanx", ilocal_comm )                               ! nemo local communicator given by oasis
+            CALL xios_initialize( "not used"       , local_comm =ilocal_comm )   ! send nemo communicator to xios
          ELSE
-            CALL  xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm )    ! nemo local communicator given by xios
+            CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
          ENDIF
       ENDIF
-      ! Nodes selection (control print return in cltxt)
-      narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm )
+      CALL mpp_start( ilocal_comm )
 #else
       IF( lk_oasis ) THEN
          IF( Agrif_Root() ) THEN
-            CALL cpl_init( "oceanx", ilocal_comm )                      ! nemo local communicator given by oasis
+            CALL cpl_init( "oceanx", ilocal_comm )          ! nemo local communicator given by oasis
          ENDIF
-         ! Nodes selection (control print return in cltxt)
-         narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm )
+         CALL mpp_start( ilocal_comm )
       ELSE
-         ilocal_comm = 0                                    ! Nodes selection (control print return in cltxt)
-         narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop )
+         CALL mpp_start( )
       ENDIF
 #endif
-
-      narea = narea + 1                                     ! mynode return the rank of proc (0 --> jpnij -1 )
-
-      IF( sn_cfctl%l_config ) THEN
-         ! Activate finer control of report outputs
-         ! optionally switch off output from selected areas (note this only
-         ! applies to output which does not involve global communications
-         IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax  ) .OR. &
-           & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) )    &
-           &   CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. )
-      ELSE
-         ! Use ln_ctl to turn on or off all options.
-         CALL nemo_set_cfctl( sn_cfctl, ln_ctl, .TRUE. )
-      ENDIF
-
-      lwm = (narea == 1)                                    ! control of output namelists
-      lwp = (narea == 1) .OR. ln_ctl                        ! control of all listing output print
-
-      IF(lwm) THEN
-         ! write merged namelists from earlier to output namelist now that the
-         ! file has been opened in call to mynode. nammpp has already been
-         ! written in mynode (if lk_mpp_mpi)
-         WRITE( numond, namctl )
-         WRITE( numond, namcfg )
-         IF( .NOT.ln_read_cfg ) THEN
-            DO ji = 1, SIZE(clnam)
-               IF( TRIM(clnam(ji)) /= '' )   WRITE(numond, * ) clnam(ji)     ! namusr_def print
-            END DO
-         ENDIF
-      ENDIF
-
-      IF(lwp) THEN                            ! open listing units
-         !
-         CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
-         !
-         WRITE(numout,*)
-         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - INGV - CMCC'
+      !
+      narea = mpprank + 1               ! mpprank: the rank of proc (0 --> mppsize -1 )
+      lwm = (narea == 1)                ! control of output namelists
+      !
+      !                             !---------------------------------------------------------------!
+      !                             ! Open output files, reference and configuration namelist files !
+      !                             !---------------------------------------------------------------!
+      !
+      ! open ocean.output as soon as possible to get all output prints (including errors messages)
+      IF( lwm )   CALL ctl_opn(     numout,        'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      ! open reference and configuration namelist files
+                  CALL ctl_opn( numnam_ref,        'namelist_ref',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+                  CALL ctl_opn( numnam_cfg,        'namelist_cfg',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      IF( lwm )   CALL ctl_opn(     numond, 'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      ! open /dev/null file to be able to supress output write easily
+                  CALL ctl_opn(     numnul,           '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      !
+      !                             !--------------------!
+      !                             ! Open listing units !  -> need ln_ctl from namctl to define lwp
+      !                             !--------------------!
+      !
+      REWIND( numnam_ref )              ! Namelist namctl in reference namelist
+      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist' )
+      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
+      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist' )
+      !
+      lwp = (narea == 1) .OR. ln_ctl    ! control of all listing output print
+      !
+      IF(lwp) THEN                      ! open listing units
+         !
+         IF( .NOT. lwm )   &            ! alreay opened for narea == 1
+            &            CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE., narea )
+         !
+         WRITE(numout,*)
+         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC'
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Stand Alone Observation operator'
@@ -213,21 +176,50 @@
          WRITE(numout,*) "       )  )       \) |`\ \)  '.   \      (   (   "
          WRITE(numout,*) "      (  (           \_/       '-._\      )   )  "
-         WRITE(numout,*) "       )  )                        `     (   (   "
+         WRITE(numout,*) "       )  ) jgs                     `    (   (   "
          WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
          WRITE(numout,*)
-         DO ji = 1, SIZE(cltxt)
-            IF( TRIM(cltxt (ji)) /= '' )   WRITE(numout,*) TRIM(cltxt(ji))    ! control print of mynode
-         END DO
-         WRITE(numout,*)
-         WRITE(numout,*)
-         DO ji = 1, SIZE(cltxt2)
-            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) TRIM(cltxt2(ji))   ! control print of domain size
-         END DO
          !
          WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
          !
       ENDIF
-      !                                      ! Domain decomposition
-      CALL mpp_init                          ! MPP
+      !
+      ! finalize the definition of namctl variables
+      IF( sn_cfctl%l_config ) THEN
+         ! Activate finer control of report outputs
+         ! optionally switch off output from selected areas (note this only
+         ! applies to output which does not involve global communications)
+         IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax  ) .OR. &
+           & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) )    &
+           &   CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. )
+      ELSE
+         ! Use ln_ctl to turn on or off all options.
+         CALL nemo_set_cfctl( sn_cfctl, ln_ctl, .TRUE. )
+      ENDIF
+      !
+      IF(lwm) WRITE( numond, namctl )
+      !
+      !                             !------------------------------------!
+      !                             !  Set global domain size parameters !
+      !                             !------------------------------------!
+      !
+      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
+      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist' )
+      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
+      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist' )   
+      !
+      IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
+         CALL domain_cfg ( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ELSE                              ! user-defined namelist
+         CALL usr_def_nam( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ENDIF
+      !
+      IF(lwm)   WRITE( numond, namcfg )
+      !
+      !                             !-----------------------------------------!
+      !                             ! mpp parameters and domain decomposition !
+      !                             !-----------------------------------------!
+      CALL mpp_init
 
       ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAO/sao_data.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAO/sao_data.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAO/sao_data.F90	(revision 12143)
@@ -54,8 +54,8 @@
       REWIND( numnam_ref )              ! Namelist namctl in reference namelist : Control prints & Benchmark
       READ  ( numnam_ref, namsao, IOSTAT = ios, ERR = 901 )
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsao in reference namelist', .TRUE. )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsao in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist : Control prints & Benchmark
       READ  ( numnam_cfg, namsao, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsao in configuration namelist', .TRUE. )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsao in configuration namelist' )
      
       lmask(:) = .FALSE.               ! count input files
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/diawri.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/diawri.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/diawri.F90	(revision 12143)
@@ -125,5 +125,5 @@
       !!      define all the NETCDF files and fields
       !!      At each time step call histdef to compute the mean if ncessary
-      !!      Each nwrite time step, output the instantaneous or mean fields
+      !!      Each nn_write time step, output the instantaneous or mean fields
       !!----------------------------------------------------------------------
       !!
@@ -138,6 +138,4 @@
       REAL(wp) ::   zsto, zout, zmax, zjulian                ! local scalars
       !!----------------------------------------------------------------------
-      ! 
-      IF( ln_timing )   CALL timing_start('dia_wri')
       !
       ! Output the initial state and forcings
@@ -147,4 +145,8 @@
       ENDIF
       !
+      IF( nn_write == -1 )   RETURN   ! we will never do any output
+      ! 
+      IF( ln_timing )   CALL timing_start('dia_wri')
+      !
       ! 0. Initialisation
       ! -----------------
@@ -159,5 +161,5 @@
       ENDIF
 #if defined key_diainstant
-      zsto = nwrite * rdt
+      zsto = nn_write * rdt
       clop = "inst("//TRIM(clop)//")"
 #else
@@ -165,5 +167,5 @@
       clop = "ave("//TRIM(clop)//")"
 #endif
-      zout = nwrite * rdt
+      zout = nn_write * rdt
       zmax = ( nitend - nit000 + 1 ) * rdt
 
@@ -196,5 +198,5 @@
          ! WRITE root name in date.file for use by postpro
          IF(lwp) THEN
-            CALL dia_nam( clhstnam, nwrite,' ' )
+            CALL dia_nam( clhstnam, nn_write,' ' )
             CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
             WRITE(inum,*) clhstnam
@@ -204,5 +206,5 @@
          ! Define the T grid FILE ( nid_T )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_T' )
+         CALL dia_nam( clhstnam, nn_write, 'grid_T' )
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
          CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
@@ -216,5 +218,5 @@
          ! Define the U grid FILE ( nid_U )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_U' )
+         CALL dia_nam( clhstnam, nn_write, 'grid_U' )
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
          CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu,           &  ! Horizontal grid: glamu and gphiu
@@ -228,5 +230,5 @@
          ! Define the V grid FILE ( nid_V )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_V' )                   ! filename
+         CALL dia_nam( clhstnam, nn_write, 'grid_V' )                   ! filename
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
          CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv,           &  ! Horizontal grid: glamv and gphiv
@@ -291,5 +293,5 @@
       ! donne le nombre d'elements, et ndex la liste des indices a sortir
 
-      IF( lwp .AND. MOD( itmod, nwrite ) == 0 ) THEN 
+      IF( lwp .AND. MOD( itmod, nn_write ) == 0 ) THEN 
          WRITE(numout,*) 'dia_wri : write model outputs in NetCDF files at ', kt, 'time-step'
          WRITE(numout,*) '~~~~~~ '
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/nemogcm.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/nemogcm.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/nemogcm.F90	(revision 12143)
@@ -151,7 +151,6 @@
       !
       IF( nstop /= 0 .AND. lwp ) THEN        ! error print
-         WRITE(numout,cform_err)
-         WRITE(numout,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
-         WRITE(numout,*)
+         WRITE(ctmp1,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
+         CALL ctl_stop( ctmp1 )
       ENDIF
       !
@@ -165,5 +164,5 @@
 #else
       IF    ( lk_oasis ) THEN   ;   CALL cpl_finalize   ! end coupling and mpp communications with OASIS
-      ELSEIF( lk_mpp   ) THEN   ;   CALL mppstop( ldfinal = .TRUE. )   ! end mpp communications
+      ELSEIF( lk_mpp   ) THEN   ;   CALL mppstop        ! end mpp communications
       ENDIF
 #endif
@@ -171,5 +170,5 @@
       IF(lwm) THEN
          IF( nstop == 0 ) THEN   ;   STOP 0
-         ELSE                    ;   STOP 999
+         ELSE                    ;   STOP 123
          ENDIF
       ENDIF
@@ -184,8 +183,5 @@
       !! ** Purpose :   initialization of the NEMO GCM
       !!----------------------------------------------------------------------
-      INTEGER  ::   ji                 ! dummy loop indices
-      INTEGER  ::   ios, ilocal_comm   ! local integers
-      CHARACTER(len=120), DIMENSION(30) ::   cltxt, cltxt2, clnam
-      CHARACTER(len=80)                 ::   clname
+      INTEGER ::   ios, ilocal_comm   ! local integers
       !!
       NAMELIST/namctl/ ln_ctl   , sn_cfctl, nn_print, nn_ictls, nn_ictle,   &
@@ -195,111 +191,81 @@
       !!----------------------------------------------------------------------
       !
-      cltxt  = ''
-      cltxt2 = ''
-      clnam  = ''  
-      cxios_context = 'nemo'
-      !
-      !                             ! Open reference namelist and configuration namelist files
-      IF( lk_oasis ) THEN 
-         CALL ctl_opn( numnam_ref, 'namelist_sas_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-         CALL ctl_opn( numnam_cfg, 'namelist_sas_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-         cxios_context = 'sas'
-         clname = 'output.namelist_sas.dyn'
-      ELSE
-         CALL ctl_opn( numnam_ref, 'namelist_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-         CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-         cxios_context = 'nemo'
-         clname = 'output.namelist.dyn'
-   ENDIF
-      !
-      REWIND( numnam_ref )              ! Namelist namctl in reference namelist
-      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. )
-      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
-      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. )
-      !
-      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
-      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. )
-      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
-      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
-
-      !                             !--------------------------!
-      !                             !  Set global domain size  !   (control print return in cltxt2)
-      !                             !--------------------------!
-      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
-         CALL domain_cfg ( cltxt2,        cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
-         !
-      ELSE                                ! user-defined namelist
-         CALL usr_def_nam( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
-      ENDIF
-      !
-      !
-      !                             !--------------------------------------------!
-      !                             !  set communicator & select the local node  !
-      !                             !  NB: mynode also opens output.namelist.dyn !
-      !                             !      on unit number numond on first proc   !
-      !                             !--------------------------------------------!
+      IF( lk_oasis ) THEN   ;   cxios_context = 'sas'
+      ELSE                  ;   cxios_context = 'nemo'
+      ENDIF
+      !
+      !                             !-------------------------------------------------!
+      !                             !     set communicator & select the local rank    !
+      !                             !  must be done as soon as possible to get narea  !
+      !                             !-------------------------------------------------!
+      !
 #if defined key_iomput
       IF( Agrif_Root() ) THEN
          IF( lk_oasis ) THEN
-            CALL cpl_init( "sas", ilocal_comm )                          ! nemo local communicator given by oasis 
-            CALL xios_initialize( "not used",local_comm=ilocal_comm )    ! send nemo communicator to xios
+            CALL cpl_init( "sas", ilocal_comm )                                  ! nemo local communicator given by oasis 
+            CALL xios_initialize( "not used",local_comm=ilocal_comm )            ! send nemo communicator to xios
          ELSE
             CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm )    ! nemo local communicator given by xios
          ENDIF
       ENDIF
-      narea = mynode ( cltxt, clname, numnam_ref, numnam_cfg, numond , nstop, ilocal_comm )  ! Nodes selection
+      CALL mpp_start( ilocal_comm )
 #else
       IF( lk_oasis ) THEN
          IF( Agrif_Root() ) THEN
-            CALL cpl_init( "sas", ilocal_comm )                          ! nemo local communicator given by oasis
+            CALL cpl_init( "sas", ilocal_comm )             ! nemo local communicator given by oasis
          ENDIF
-         narea = mynode( cltxt, clname, numnam_ref, numnam_cfg, numond , nstop, ilocal_comm )   ! Nodes selection (control print return in cltxt)
+         CALL mpp_start( ilocal_comm )
       ELSE
-         ilocal_comm = 0
-         narea = mynode( cltxt, clname, numnam_ref, numnam_cfg, numond , nstop )                ! Nodes selection (control print return in cltxt)
-      ENDIF
-#endif
-
-      narea = narea + 1                                     ! mynode return the rank of proc (0 --> jpnij -1 )
-
-      IF( sn_cfctl%l_config ) THEN
-         ! Activate finer control of report outputs
-         ! optionally switch off output from selected areas (note this only
-         ! applies to output which does not involve global communications)
-         IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax  ) .OR. &
-           & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) )    &
-           &   CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. )
+         CALL mpp_start( )
+      ENDIF
+#endif
+      !
+      narea = mpprank + 1                                   ! mpprank: the rank of proc (0 --> mppsize -1 )
+      lwm = (narea == 1)                ! control of output namelists
+      !
+      !                             !---------------------------------------------------------------!
+      !                             ! Open output files, reference and configuration namelist files !
+      !                             !---------------------------------------------------------------!
+      !
+      ! open ocean.output as soon as possible to get all output prints (including errors messages)
+      IF( lk_oasis ) THEN
+         IF( lwm )   CALL ctl_opn(     numout,              'sas.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+         ! open reference and configuration namelist files
+                     CALL ctl_opn( numnam_ref,        'namelist_sas_ref',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+                     CALL ctl_opn( numnam_cfg,        'namelist_sas_cfg',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+         IF( lwm )   CALL ctl_opn(     numond, 'output.namelist_sas.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
       ELSE
-         ! Use ln_ctl to turn on or off all options.
-         CALL nemo_set_cfctl( sn_cfctl, ln_ctl, .TRUE. )
-      ENDIF
-
-      lwm = (narea == 1)                                    ! control of output namelists
-      lwp = (narea == 1) .OR. ln_ctl                        ! control of all listing output print
-
-      IF(lwm) THEN               ! write merged namelists from earlier to output namelist 
-         !                       ! now that the file has been opened in call to mynode. 
-         !                       ! NB: nammpp has already been written in mynode (if lk_mpp_mpi)
-         WRITE( numond, namctl )
-         WRITE( numond, namcfg )
-         IF( .NOT.ln_read_cfg ) THEN
-            DO ji = 1, SIZE(clnam)
-               IF( TRIM(clnam(ji)) /= '' )   WRITE(numond, * ) clnam(ji)     ! namusr_def print
-            END DO
+         IF( lwm )   CALL ctl_opn(     numout,            'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+         ! open reference and configuration namelist files
+                     CALL ctl_opn( numnam_ref,            'namelist_ref',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+                     CALL ctl_opn( numnam_cfg,            'namelist_cfg',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+         IF( lwm )   CALL ctl_opn(     numond,     'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      ENDIF
+      ! open /dev/null file to be able to supress output write easily
+                     CALL ctl_opn(     numnul,               '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
+      !
+      !                             !--------------------!
+      !                             ! Open listing units !  -> need ln_ctl from namctl to define lwp
+      !                             !--------------------!
+      !
+      REWIND( numnam_ref )              ! Namelist namctl in reference namelist
+      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist' )
+      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
+      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist' )
+      !
+      lwp = (narea == 1) .OR. ln_ctl    ! control of all listing output print
+      !
+      IF(lwp) THEN                      ! open listing units
+         !
+         IF( .NOT. lwm ) THEN           ! alreay opened for narea == 1
+            IF(lk_oasis) THEN   ;   CALL ctl_opn( numout,   'sas.output','REPLACE','FORMATTED','SEQUENTIAL',-1,-1, .FALSE., narea )
+            ELSE                ;   CALL ctl_opn( numout, 'ocean.output','REPLACE','FORMATTED','SEQUENTIAL',-1,-1, .FALSE., narea )
+            ENDIF
          ENDIF
-      ENDIF
-
-      IF(lwp) THEN                            ! open listing units
-         !
-         IF( lk_oasis ) THEN   ;   CALL ctl_opn( numout,   'sas.output', 'REPLACE','FORMATTED','SEQUENTIAL', -1, 6, .FALSE., narea )
-         ELSE                  ;   CALL ctl_opn( numout, 'ocean.output', 'REPLACE','FORMATTED','SEQUENTIAL', -1, 6, .FALSE., narea )
-         ENDIF
          !
          WRITE(numout,*)
-         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - INGV - CMCC'
+         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC'
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Ocean General Circulation Model'
@@ -320,22 +286,48 @@
          WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
          WRITE(numout,*)
-
-         DO ji = 1, SIZE(cltxt)
-            IF( TRIM(cltxt (ji)) /= '' )   WRITE(numout,*) TRIM(cltxt(ji))    ! control print of mynode
-         END DO
          WRITE(numout,*)
-         WRITE(numout,*)
-         DO ji = 1, SIZE(cltxt2)
-            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) TRIM(cltxt2(ji))   ! control print of domain size
-         END DO
          !
          WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
          !
       ENDIF
-      ! open /dev/null file to be able to supress output write easily
-      CALL ctl_opn( numnul, '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
-      !
-      !                                      ! Domain decomposition
-      CALL mpp_init                          ! MPP
+     !
+      ! finalize the definition of namctl variables
+      IF( sn_cfctl%l_config ) THEN
+         ! Activate finer control of report outputs
+         ! optionally switch off output from selected areas (note this only
+         ! applies to output which does not involve global communications)
+         IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax  ) .OR. &
+           & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) )    &
+           &   CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. )
+      ELSE
+         ! Use ln_ctl to turn on or off all options.
+         CALL nemo_set_cfctl( sn_cfctl, ln_ctl, .TRUE. )
+      ENDIF
+      !
+      IF(lwm) WRITE( numond, namctl )
+      !
+      !                             !------------------------------------!
+      !                             !  Set global domain size parameters !
+      !                             !------------------------------------!
+      !
+      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
+      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist' )
+      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
+      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist' )   
+      !
+      IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
+         CALL domain_cfg ( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ELSE                              ! user-defined namelist
+         CALL usr_def_nam( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
+      ENDIF
+      !
+      IF(lwm)   WRITE( numond, namcfg )
+      !
+      !                             !-----------------------------------------!
+      !                             ! mpp parameters and domain decomposition !
+      !                             !-----------------------------------------!
+      CALL mpp_init
 
       ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/sbcssm.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/sbcssm.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/sbcssm.F90	(revision 12143)
@@ -188,8 +188,8 @@
       REWIND( numnam_ref )              ! Namelist namsbc_sas in reference namelist : Input fields
       READ  ( numnam_ref, namsbc_sas, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_sas in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_sas in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist namsbc_sas in configuration namelist : Input fields
       READ  ( numnam_cfg, namsbc_sas, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_sas in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_sas in configuration namelist' )
       IF(lwm) WRITE ( numond, namsbc_sas )
       !           
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/step.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/step.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/SAS/step.F90	(revision 12143)
@@ -96,5 +96,5 @@
       !           From SAS: ocean bdy data are wrong  (but we do not care) and ice bdy data are OK.  
       !           This is not clean and should be changed in the future. 
-      IF( ln_bdy     )       CALL bdy_dta ( kstp, time_offset=+1 )   ! update dynamic & tracer data at open boundaries
+      IF( ln_bdy     )       CALL bdy_dta ( kstp, kt_offset=+1 )   ! update dynamic & tracer data at open boundaries
       ! ==>
                              CALL sbc    ( kstp )         ! Sea Boundary Condition (including sea-ice)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/AGE/trcnam_age.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/AGE/trcnam_age.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/AGE/trcnam_age.F90	(revision 12143)
@@ -56,8 +56,8 @@
       REWIND( numnat_ref )              ! Namelist namagedate in reference namelist : AGE parameters
       READ  ( numnat_ref, namage, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namage in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namage in reference namelist' )
       REWIND( numnat_cfg )              ! Namelist namagedate in configuration namelist : AGE parameters
       READ  ( numnat_cfg, namage, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namage in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namage in configuration namelist' )
       IF(lwm) WRITE ( numont, namage )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/C14/trcnam_c14.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/C14/trcnam_c14.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/C14/trcnam_c14.F90	(revision 12143)
@@ -63,8 +63,8 @@
       REWIND( numtrc_ref )              ! Namelist namc14_typ in reference namelist :
       READ  ( numtrc_ref, namc14_typ, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc14_typ in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc14_typ in reference namelist' )
       REWIND( numtrc_cfg )              ! Namelist namcfcdate in configuration namelist 
       READ  ( numtrc_cfg, namc14_typ, IOSTAT = ios, ERR = 902)
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc14_typ in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc14_typ in configuration namelist' )
       IF(lwm) WRITE ( numonr, namc14_typ )
       !
@@ -80,8 +80,8 @@
       REWIND( numtrc_ref )              ! Namelist namc14_typ in reference namelist :
       READ  ( numtrc_ref, namc14_sbc, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc14_sbc in reference namelist', lwp )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc14_sbc in reference namelist' )
       REWIND( numtrc_cfg )              ! Namelist namcfcdate in configuration namelist 
       READ  ( numtrc_cfg, namc14_sbc, IOSTAT = ios, ERR = 904)
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc14_sbc in configuration namelist', lwp )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc14_sbc in configuration namelist' )
       IF(lwm) WRITE( numonr, namc14_sbc )
       !
@@ -96,8 +96,8 @@
       REWIND( numtrc_ref )              ! Namelist namc14_typ in reference namelist :
       READ  ( numtrc_ref, namc14_fcg, IOSTAT = ios, ERR = 905)
-905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc14_fcg in reference namelist', lwp )
+905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namc14_fcg in reference namelist' )
       REWIND( numtrc_cfg )              ! Namelist namcfcdate in configuration namelist 
       READ  ( numtrc_cfg, namc14_fcg, IOSTAT = ios, ERR = 906)
-906   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc14_fcg in configuration namelist', lwp )
+906   IF( ios >  0 )   CALL ctl_nam ( ios , 'namc14_fcg in configuration namelist' )
       IF(lwm) WRITE ( numonr, namc14_fcg )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/CFC/trcnam_cfc.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/CFC/trcnam_cfc.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/CFC/trcnam_cfc.F90	(revision 12143)
@@ -53,8 +53,8 @@
       REWIND( numtrc_ref )              ! Namelist namcfcdate in reference namelist : CFC parameters
       READ  ( numtrc_ref, namcfc, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfc in reference namelist' )
       REWIND( numtrc_cfg )              ! Namelist namcfcdate in configuration namelist : CFC parameters
       READ  ( numtrc_cfg, namcfc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfc in configuration namelist' )
       IF(lwm) WRITE( numonr, namcfc )
       IF(lwm) CALL FLUSH ( numonr )     ! flush output namelist CFC
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P2Z/p2zbio.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P2Z/p2zbio.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P2Z/p2zbio.F90	(revision 12143)
@@ -404,8 +404,8 @@
       REWIND( numnatp_ref )              ! Namelist namlobphy in reference namelist : Lobster biological parameters
       READ  ( numnatp_ref, namlobphy, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlobphy in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlobphy in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist namlobphy in configuration namelist : Lobster biological parameters
       READ  ( numnatp_cfg, namlobphy, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobphy in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobphy in configuration namelist' )
       IF(lwm) WRITE ( numonp, namlobphy )
       !
@@ -421,8 +421,8 @@
       REWIND( numnatp_ref )              ! Namelist namlobnut in reference namelist : Lobster nutriments parameters
       READ  ( numnatp_ref, namlobnut, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlobnut in reference namelist', lwp )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlobnut in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist namlobnut in configuration namelist : Lobster nutriments parameters
       READ  ( numnatp_cfg, namlobnut, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobnut in configuration namelist', lwp )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobnut in configuration namelist' )
       IF(lwm) WRITE ( numonp, namlobnut )
 
@@ -438,8 +438,8 @@
       REWIND( numnatp_ref )              ! Namelist namlobzoo in reference namelist : Lobster zooplankton parameters
       READ  ( numnatp_ref, namlobzoo, IOSTAT = ios, ERR = 905)
-905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlobzoo in reference namelist', lwp )
+905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlobzoo in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist namlobzoo in configuration namelist : Lobster zooplankton parameters
       READ  ( numnatp_cfg, namlobzoo, IOSTAT = ios, ERR = 906 )
-906   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobzoo in configuration namelist', lwp )
+906   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobzoo in configuration namelist' )
       IF(lwm) WRITE ( numonp, namlobzoo )
 
@@ -460,8 +460,8 @@
       REWIND( numnatp_ref )              ! Namelist namlobdet in reference namelist : Lobster detritus parameters
       READ  ( numnatp_ref, namlobdet, IOSTAT = ios, ERR = 907)
-907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlobdet in reference namelist', lwp )
+907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlobdet in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist namlobdet in configuration namelist : Lobster detritus parameters
       READ  ( numnatp_cfg, namlobdet, IOSTAT = ios, ERR = 908 )
-908   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobdet in configuration namelist', lwp )
+908   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobdet in configuration namelist' )
       IF(lwm) WRITE ( numonp, namlobdet )
 
@@ -475,8 +475,8 @@
       REWIND( numnatp_ref )              ! Namelist namlobdom in reference namelist : Lobster DOM breakdown rate
       READ  ( numnatp_ref, namlobdom, IOSTAT = ios, ERR = 909)
-909   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlobdom in reference namelist', lwp )
+909   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlobdom in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist namlobdom in configuration namelist : Lobster DOM breakdown rate
       READ  ( numnatp_cfg, namlobdom, IOSTAT = ios, ERR = 910 )
-910   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobdom in configuration namelist', lwp )
+910   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobdom in configuration namelist' )
       IF(lwm) WRITE ( numonp, namlobdom )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P2Z/p2zopt.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P2Z/p2zopt.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P2Z/p2zopt.F90	(revision 12143)
@@ -161,9 +161,9 @@
       REWIND( numnatp_ref )              ! Namelist namlobopt in reference namelist : Lobster options
       READ  ( numnatp_ref, namlobopt, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namlobopt in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namlobopt in reference namelist' )
 
       REWIND( numnatp_cfg )              ! Namelist namlobopt in configuration namelist : Lobster options
       READ  ( numnatp_cfg, namlobopt, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namlobopt in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namlobopt in configuration namelist' )
       IF(lwm) WRITE ( numonp, namlobopt )
 
@@ -183,9 +183,9 @@
       REWIND( numnatp_ref )              ! Namelist namlobrat in reference namelist : Lobster ratios
       READ  ( numnatp_ref, namlobrat, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namlobrat in reference namelist', lwp )
+903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namlobrat in reference namelist' )
 
       REWIND( numnatp_cfg )              ! Namelist namlobrat in configuration namelist : Lobster ratios
       READ  ( numnatp_cfg, namlobrat, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 ) CALL ctl_nam ( ios , 'namlobrat in configuration namelist', lwp )
+904   IF( ios >  0 ) CALL ctl_nam ( ios , 'namlobrat in configuration namelist' )
       IF(lwm) WRITE ( numonp, namlobrat )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P2Z/p2zsed.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P2Z/p2zsed.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P2Z/p2zsed.F90	(revision 12143)
@@ -134,8 +134,8 @@
       REWIND( numnatp_ref )              ! Namelist namlobsed in reference namelist : Lobster sediments
       READ  ( numnatp_ref, namlobsed, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlosed in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namlosed in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist namlobsed in configuration namelist : Lobster sediments
       READ  ( numnatp_cfg, namlobsed, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobsed in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namlobsed in configuration namelist' )
       IF(lwm) WRITE ( numonp, namlobsed )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zfechem.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zfechem.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zfechem.F90	(revision 12143)
@@ -256,8 +256,8 @@
       REWIND( numnatp_ref )            ! Namelist nampisfer in reference namelist : Pisces iron chemistry
       READ  ( numnatp_ref, nampisfer, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisfer in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisfer in reference namelist' )
       REWIND( numnatp_cfg )            ! Namelist nampisfer in configuration namelist : Pisces iron chemistry
       READ  ( numnatp_cfg, nampisfer, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisfer in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisfer in configuration namelist' )
       IF(lwm) WRITE( numonp, nampisfer )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zflx.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zflx.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zflx.F90	(revision 12143)
@@ -241,8 +241,8 @@
       REWIND( numnatp_ref )              ! Namelist nampisext in reference namelist : Pisces atm. conditions
       READ  ( numnatp_ref, nampisext, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisext in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisext in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampisext in configuration namelist : Pisces atm. conditions
       READ  ( numnatp_cfg, nampisext, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisext in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisext in configuration namelist' )
       IF(lwm) WRITE ( numonp, nampisext )
       !
@@ -322,8 +322,8 @@
          REWIND( numnatp_ref )              ! Namelist nampisatm in reference namelist : Pisces atm. sea level pressure file
          READ  ( numnatp_ref, nampisatm, IOSTAT = ios, ERR = 901)
-901      IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisatm in reference namelist', lwp )
+901      IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisatm in reference namelist' )
          REWIND( numnatp_cfg )              ! Namelist nampisatm in configuration namelist : Pisces atm. sea level pressure file 
          READ  ( numnatp_cfg, nampisatm, IOSTAT = ios, ERR = 902 )
-902      IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisatm in configuration namelist', lwp )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisatm in configuration namelist' )
          IF(lwm) WRITE ( numonp, nampisatm )
          !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zligand.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zligand.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zligand.F90	(revision 12143)
@@ -127,8 +127,8 @@
       REWIND( numnatp_ref )              ! Namelist nampislig in reference namelist : Pisces remineralization
       READ  ( numnatp_ref, nampislig, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampislig in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampislig in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampislig in configuration namelist : Pisces remineralization
       READ  ( numnatp_cfg, nampislig, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampislig in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampislig in configuration namelist' )
       IF(lwm) WRITE ( numonp, nampislig )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zlim.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zlim.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zlim.F90	(revision 12143)
@@ -254,8 +254,8 @@
       REWIND( numnatp_ref )              ! Namelist nampislim in reference namelist : Pisces nutrient limitation parameters
       READ  ( numnatp_ref, namp4zlim, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namp4zlim in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namp4zlim in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampislim in configuration namelist : Pisces nutrient limitation parameters 
       READ  ( numnatp_cfg, namp4zlim, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namp4zlim in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namp4zlim in configuration namelist' )
       IF(lwm) WRITE( numonp, namp4zlim )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zlys.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zlys.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zlys.F90	(revision 12143)
@@ -164,8 +164,8 @@
       REWIND( numnatp_ref )              ! Namelist nampiscal in reference namelist : Pisces CaCO3 dissolution
       READ  ( numnatp_ref, nampiscal, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampiscal in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampiscal in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampiscal in configuration namelist : Pisces CaCO3 dissolution
       READ  ( numnatp_cfg, nampiscal, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampiscal in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampiscal in configuration namelist' )
       IF(lwm) WRITE( numonp, nampiscal )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zmeso.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zmeso.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zmeso.F90	(revision 12143)
@@ -292,8 +292,8 @@
       REWIND( numnatp_ref )              ! Namelist nampismes in reference namelist : Pisces mesozooplankton
       READ  ( numnatp_ref, namp4zmes, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namp4zmes in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namp4zmes in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampismes in configuration namelist : Pisces mesozooplankton
       READ  ( numnatp_cfg, namp4zmes, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namp4zmes in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namp4zmes in configuration namelist' )
       IF(lwm) WRITE( numonp, namp4zmes )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zmicro.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zmicro.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zmicro.F90	(revision 12143)
@@ -245,8 +245,8 @@
       REWIND( numnatp_ref )              ! Namelist nampiszoo in reference namelist : Pisces microzooplankton
       READ  ( numnatp_ref, namp4zzoo, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namp4zzoo in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namp4zzoo in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampiszoo in configuration namelist : Pisces microzooplankton
       READ  ( numnatp_cfg, namp4zzoo, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namp4zzoo in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namp4zzoo in configuration namelist' )
       IF(lwm) WRITE( numonp, namp4zzoo )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zmort.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zmort.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zmort.F90	(revision 12143)
@@ -229,8 +229,8 @@
       REWIND( numnatp_ref )              ! Namelist nampismort in reference namelist : Pisces phytoplankton
       READ  ( numnatp_ref, namp4zmort, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namp4zmort in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namp4zmort in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampismort in configuration namelist : Pisces phytoplankton
       READ  ( numnatp_cfg, namp4zmort, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namp4zmort in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namp4zmort in configuration namelist' )
       IF(lwm) WRITE( numonp, namp4zmort )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zopt.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zopt.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zopt.F90	(revision 12143)
@@ -402,8 +402,8 @@
       REWIND( numnatp_ref )              ! Namelist nampisopt in reference namelist : Pisces attenuation coef. and PAR
       READ  ( numnatp_ref, nampisopt, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisopt in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisopt in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampisopt in configuration namelist : Pisces attenuation coef. and PAR
       READ  ( numnatp_cfg, nampisopt, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisopt in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisopt in configuration namelist' )
       IF(lwm) WRITE ( numonp, nampisopt )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zpoc.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zpoc.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zpoc.F90	(revision 12143)
@@ -499,8 +499,8 @@
       REWIND( numnatp_ref )              ! Namelist nampisrem in reference namelist : Pisces remineralization
       READ  ( numnatp_ref, nampispoc, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampispoc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampispoc in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampisrem in configuration namelist : Pisces remineralization
       READ  ( numnatp_cfg, nampispoc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampispoc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampispoc in configuration namelist' )
       IF(lwm) WRITE( numonp, nampispoc )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zprod.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zprod.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zprod.F90	(revision 12143)
@@ -492,8 +492,8 @@
       REWIND( numnatp_ref )              ! Namelist nampisprod in reference namelist : Pisces phytoplankton production
       READ  ( numnatp_ref, namp4zprod, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namp4zprod in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namp4zprod in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampisprod in configuration namelist : Pisces phytoplankton production
       READ  ( numnatp_cfg, namp4zprod, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namp4zprod in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namp4zprod in configuration namelist' )
       IF(lwm) WRITE( numonp, namp4zprod )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zrem.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zrem.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zrem.F90	(revision 12143)
@@ -329,8 +329,8 @@
       REWIND( numnatp_ref )              ! Namelist nampisrem in reference namelist : Pisces remineralization
       READ  ( numnatp_ref, nampisrem, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisrem in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisrem in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampisrem in configuration namelist : Pisces remineralization
       READ  ( numnatp_cfg, nampisrem, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisrem in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisrem in configuration namelist' )
       IF(lwm) WRITE( numonp, nampisrem )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zsbc.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zsbc.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zsbc.F90	(revision 12143)
@@ -232,8 +232,8 @@
       REWIND( numnatp_ref )              ! Namelist nampissbc in reference namelist : Pisces external sources of nutrients
       READ  ( numnatp_ref, nampissbc, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampissbc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampissbc in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampissbc in configuration namelist : Pisces external sources of nutrients
       READ  ( numnatp_cfg, nampissbc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampissbc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampissbc in configuration namelist' )
       IF(lwm) WRITE ( numonp, nampissbc )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zsms.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zsms.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p4zsms.F90	(revision 12143)
@@ -203,8 +203,8 @@
       REWIND( numnatp_ref )              ! Namelist nampisbio in reference namelist : Pisces variables
       READ  ( numnatp_ref, nampisbio, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisbio in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisbio in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampisbio in configuration namelist : Pisces variables
       READ  ( numnatp_cfg, nampisbio, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisbio in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisbio in configuration namelist' )
       IF(lwm) WRITE( numonp, nampisbio )
       !
@@ -234,8 +234,8 @@
       REWIND( numnatp_ref )              ! Namelist nampisdmp in reference namelist : Pisces damping
       READ  ( numnatp_ref, nampisdmp, IOSTAT = ios, ERR = 905)
-905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisdmp in reference namelist', lwp )
+905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampisdmp in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampisdmp in configuration namelist : Pisces damping
       READ  ( numnatp_cfg, nampisdmp, IOSTAT = ios, ERR = 906 )
-906   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisdmp in configuration namelist', lwp )
+906   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampisdmp in configuration namelist' )
       IF(lwm) WRITE( numonp, nampisdmp )
       !
@@ -249,8 +249,8 @@
       REWIND( numnatp_ref )              ! Namelist nampismass in reference namelist : Pisces mass conservation check
       READ  ( numnatp_ref, nampismass, IOSTAT = ios, ERR = 907)
-907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampismass in reference namelist', lwp )
+907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampismass in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampismass in configuration namelist : Pisces mass conservation check 
       READ  ( numnatp_cfg, nampismass, IOSTAT = ios, ERR = 908 )
-908   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampismass in configuration namelist', lwp )
+908   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampismass in configuration namelist' )
       IF(lwm) WRITE( numonp, nampismass )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zlim.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zlim.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zlim.F90	(revision 12143)
@@ -450,9 +450,9 @@
       REWIND( numnatp_ref )              ! Namelist nampislim in reference namelist : Pisces nutrient limitation parameters
       READ  ( numnatp_ref, namp5zlim, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampislim in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampislim in reference namelist' )
       !
       REWIND( numnatp_cfg )              ! Namelist nampislim in configuration namelist : Pisces nutrient limitation parameters 
       READ  ( numnatp_cfg, namp5zlim, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nampislim in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nampislim in configuration namelist' )
       IF(lwm) WRITE ( numonp, namp5zlim )
       !
@@ -491,9 +491,9 @@
       REWIND( numnatp_ref )              ! Namelist nampislim in reference namelist : Pisces nutrient limitation parameters
       READ  ( numnatp_ref, namp5zquota, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisquota in reference namelist', lwp )
+903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampisquota in reference namelist' )
       !
       REWIND( numnatp_cfg )              ! Namelist nampislim in configuration namelist : Pisces nutrient limitation parameters 
       READ  ( numnatp_cfg, namp5zquota, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 ) CALL ctl_nam ( ios , 'nampisquota in configuration namelist', lwp )
+904   IF( ios >  0 ) CALL ctl_nam ( ios , 'nampisquota in configuration namelist' )
       IF(lwm) WRITE ( numonp, namp5zquota )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zmeso.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zmeso.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zmeso.F90	(revision 12143)
@@ -409,9 +409,9 @@
       REWIND( numnatp_ref )              ! Namelist nampismes in reference namelist : Pisces mesozooplankton
       READ  ( numnatp_ref, namp5zmes, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampismes in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nampismes in reference namelist' )
       !
       REWIND( numnatp_cfg )              ! Namelist nampismes in configuration namelist : Pisces mesozooplankton
       READ  ( numnatp_cfg, namp5zmes, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nampismes in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nampismes in configuration namelist' )
       IF(lwm) WRITE ( numonp, namp5zmes )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zmicro.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zmicro.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zmicro.F90	(revision 12143)
@@ -351,9 +351,9 @@
       REWIND( numnatp_ref )              ! Namelist nampiszoo in reference namelist : Pisces microzooplankton
       READ  ( numnatp_ref, namp5zzoo, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namp5zzoo in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namp5zzoo in reference namelist' )
       !
       REWIND( numnatp_cfg )              ! Namelist nampiszoo in configuration namelist : Pisces microzooplankton
       READ  ( numnatp_cfg, namp5zzoo, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namp5zzoo in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namp5zzoo in configuration namelist' )
       IF(lwm) WRITE ( numonp, namp5zzoo )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zmort.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zmort.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zmort.F90	(revision 12143)
@@ -288,9 +288,9 @@
       REWIND( numnatp_ref )              ! Namelist nampismort in reference namelist : Pisces phytoplankton
       READ  ( numnatp_ref, namp5zmort, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namp5zmort in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namp5zmort in reference namelist' )
 
       REWIND( numnatp_cfg )              ! Namelist nampismort in configuration namelist : Pisces phytoplankton
       READ  ( numnatp_cfg, namp5zmort, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namp5zmort in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namp5zmort in configuration namelist' )
       IF(lwm) WRITE ( numonp, namp5zmort )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zprod.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zprod.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/P4Z/p5zprod.F90	(revision 12143)
@@ -584,9 +584,9 @@
       REWIND( numnatp_ref )              ! Namelist nampisprod in reference namelist : Pisces phytoplankton production
       READ  ( numnatp_ref, namp5zprod, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namp5zprod in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namp5zprod in reference namelist' )
 
       REWIND( numnatp_cfg )              ! Namelist nampisprod in configuration namelist : Pisces phytoplankton production
       READ  ( numnatp_cfg, namp5zprod, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namp5zprod in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'namp5zprod in configuration namelist' )
       IF(lwm) WRITE ( numonp, namp5zprod )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/SED/sedini.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/SED/sedini.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/SED/sedini.F90	(revision 12143)
@@ -460,9 +460,9 @@
       REWIND( numnamsed_ref )              ! Namelist nam_run in reference namelist : Pisces variables
       READ  ( numnamsed_ref, nam_run, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_run in reference namelist', lwp )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_run in reference namelist' )
 
       REWIND( numnamsed_cfg )              ! Namelist nam_run in reference namelist : Pisces variables
       READ  ( numnamsed_cfg, nam_run, IOSTAT = ios, ERR = 902)
-902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_run in configuration namelist', lwp )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_run in configuration namelist' )
 
       IF (lwp) THEN
@@ -476,9 +476,9 @@
       REWIND( numnamsed_ref )              ! Namelist nam_geom in reference namelist : Pisces variables
       READ  ( numnamsed_ref, nam_geom, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_geom in reference namelist', lwp )
+903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_geom in reference namelist' )
 
       REWIND( numnamsed_cfg )              ! Namelist nam_geom in reference namelist : Pisces variables
       READ  ( numnamsed_cfg, nam_geom, IOSTAT = ios, ERR = 904)
-904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_geom in configuration namelist', lwp )
+904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_geom in configuration namelist' )
 
       IF (lwp) THEN 
@@ -499,9 +499,9 @@
       REWIND( numnamsed_ref )              ! Namelist nam_trased in reference namelist : Pisces variables
       READ  ( numnamsed_ref, nam_trased, IOSTAT = ios, ERR = 905)
-905   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_trased in reference namelist', lwp )
+905   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_trased in reference namelist' )
 
       REWIND( numnamsed_cfg )              ! Namelist nam_trased in reference namelist : Pisces variables
       READ  ( numnamsed_cfg, nam_trased, IOSTAT = ios, ERR = 906)
-906   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_trased in configuration namelist', lwp )
+906   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_trased in configuration namelist' )
 
       DO jn = 1, jpsol
@@ -532,9 +532,9 @@
       REWIND( numnamsed_ref )              ! Namelist nam_diased in reference namelist : Pisces variables
       READ  ( numnamsed_ref, nam_diased, IOSTAT = ios, ERR = 907)
-907   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diased in reference namelist', lwp )
+907   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diased in reference namelist' )
 
       REWIND( numnamsed_cfg )              ! Namelist nam_diased in reference namelist : Pisces variables
       READ  ( numnamsed_cfg, nam_diased, IOSTAT = ios, ERR = 908)
-908   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diased in configuration namelist', lwp )
+908   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diased in configuration namelist' )
       
       DO jn = 1, jpdia3dsed
@@ -574,9 +574,9 @@
       REWIND( numnamsed_ref )              ! Namelist nam_inorg in reference namelist : Pisces variables
       READ  ( numnamsed_ref, nam_inorg, IOSTAT = ios, ERR = 909)
-909   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_inorg in reference namelist', lwp )
+909   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_inorg in reference namelist' )
 
       REWIND( numnamsed_cfg )              ! Namelist nam_inorg in reference namelist : Pisces variables
       READ  ( numnamsed_cfg, nam_inorg, IOSTAT = ios, ERR = 910)
-910   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_inorg in configuration namelist', lwp )
+910   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_inorg in configuration namelist' )
 
       IF (lwp) THEN
@@ -600,9 +600,9 @@
       REWIND( numnamsed_ref )              ! Namelist nam_poc in reference namelist : Pisces variables
       READ  ( numnamsed_ref, nam_poc, IOSTAT = ios, ERR = 911)
-911   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_poc in reference namelist', lwp )
+911   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_poc in reference namelist' )
 
       REWIND( numnamsed_cfg )              ! Namelist nam_poc in reference namelist : Pisces variables
       READ  ( numnamsed_cfg, nam_poc, IOSTAT = ios, ERR = 912)
-912   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_poc in configuration namelist', lwp )
+912   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_poc in configuration namelist' )
 
       IF (lwp) THEN
@@ -652,9 +652,9 @@
       REWIND( numnamsed_ref )              ! Namelist nam_btb in reference namelist : Pisces variables
       READ  ( numnamsed_ref, nam_btb, IOSTAT = ios, ERR = 913)
-913   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_btb in reference namelist', lwp )
+913   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_btb in reference namelist' )
 
       REWIND( numnamsed_cfg )              ! Namelist nam_btb in reference namelist : Pisces variables
       READ  ( numnamsed_cfg, nam_btb, IOSTAT = ios, ERR = 914)
-914   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_btb in configuration namelist', lwp )
+914   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_btb in configuration namelist' )
 
       IF (lwp) THEN
@@ -673,9 +673,9 @@
       REWIND( numnamsed_ref )              ! Namelist nam_rst in reference namelist : Pisces variables
       READ  ( numnamsed_ref, nam_rst, IOSTAT = ios, ERR = 915)
-915   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_rst in reference namelist', lwp )
+915   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_rst in reference namelist' )
 
       REWIND( numnamsed_cfg )              ! Namelist nam_rst in reference namelist : Pisces variables
       READ  ( numnamsed_cfg, nam_rst, IOSTAT = ios, ERR = 916)
-916   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_rst in configuration namelist', lwp )
+916   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_rst in configuration namelist' )
 
       IF (lwp) THEN
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/SED/sedrst.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/SED/sedrst.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/SED/sedrst.F90	(revision 12143)
@@ -49,12 +49,12 @@
             IF( ln_rst_list ) THEN
                nrst_lst = 1
-               nitrst = nstocklist( nrst_lst )
+               nitrst = nn_stocklist( nrst_lst )
             ELSE
                nitrst = nitend
             ENDIF
          ENDIF
-         IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nstock ) == 0 ) THEN
+         IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nn_stock ) == 0 ) THEN
             ! we use kt - 1 and not kt - nittrc000 to keep the same periodicity from the beginning of the experiment
-            nitrst = kt + nstock - 1                  ! define the next value of nitrst for restart writing
+            nitrst = kt + nn_stock - 1                  ! define the next value of nitrst for restart writing
             IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run
          ENDIF
@@ -62,9 +62,11 @@
          IF( kt == nittrc000 ) lrst_sed = .FALSE.
       ENDIF
+
+      IF( .NOT. ln_rst_list .AND. nn_stock == -1 )   RETURN   ! we will never do any restart
 
       ! to get better performances with NetCDF format:
       ! we open and define the tracer restart file one tracer time step before writing the data (-> at nitrst - 2*nn_dttrc + 1)
       ! except if we write tracer restart files every tracer time step or if a tracer restart file was writen at nitend - 2*nn_dttrc + 1
-      IF( kt == nitrst - 2*nn_dtsed .OR. nstock == nn_dtsed .OR. ( kt == nitend - nn_dtsed .AND. .NOT. lrst_sed ) ) THEN
+      IF( kt == nitrst - 2*nn_dtsed .OR. nn_stock == nn_dtsed .OR. ( kt == nitend - nn_dtsed .AND. .NOT. lrst_sed ) ) THEN
          ! beware of the format used to write kt (default is i8.8, that should be large enough)
          IF( nitrst > 1.0e9 ) THEN   ;   WRITE(clkt,*       ) nitrst
@@ -300,5 +302,5 @@
           IF( l_offline .AND. ln_rst_list ) THEN
              nrst_lst = nrst_lst + 1
-             nitrst = nstocklist( nrst_lst )
+             nitrst = nn_stocklist( nrst_lst )
           ENDIF
       ENDIF
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/trcnam_pisces.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/trcnam_pisces.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/PISCES/trcnam_pisces.F90	(revision 12143)
@@ -57,8 +57,8 @@
       REWIND( numnatp_ref )              ! Namelist nampisbio in reference namelist : Pisces variables
       READ  ( numnatp_ref, nampismod, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampismod in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nampismod in reference namelist' )
       REWIND( numnatp_cfg )              ! Namelist nampisbio in configuration namelist : Pisces variables
       READ  ( numnatp_cfg, nampismod, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampismod in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nampismod in configuration namelist' )
       IF(lwm) WRITE( numonp, nampismod )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/README.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/README.rst	(revision 12143)
@@ -3,46 +3,51 @@
 ***************
 
+.. todo::
+
+
+
 .. contents::
-	:local:
-
-TOP (Tracers in the Ocean Paradigm) is the NEMO hardwired interface toward biogeochemical models and
-provide the physical constraints/boundaries for oceanic tracers.
-It consists of a modular framework to handle multiple ocean tracers, including also a variety of built-in modules.
+   :local:
+
+TOP (Tracers in the Ocean Paradigm) is the NEMO hardwired interface toward
+biogeochemical models and provide the physical constraints/boundaries for oceanic tracers.
+It consists of a modular framework to handle multiple ocean tracers,
+including also a variety of built-in modules.
 
 This component of the NEMO framework allows one to exploit available modules (see below) and
 further develop a range of applications, spanning from the implementation of a dye passive tracer to
 evaluate dispersion processes (by means of MY_TRC), track water masses age (AGE module),
-assess the ocean interior penetration of persistent chemical compounds (e.g., gases like CFC or even PCBs),
-up to the full set of equations involving marine biogeochemical cycles.
+assess the ocean interior penetration of persistent chemical compounds
+(e.g., gases like CFC or even PCBs), up to the full set of equations involving
+marine biogeochemical cycles.
 
 Structure
 =========
 
-TOP interface has the following location in the source code ``./src/MBG/`` and
+TOP interface has the following location in the source code :file:`./src/TOP` and
 the following modules are available:
 
-``TRP``
-	Interface to NEMO physical core for computing tracers transport
-
-``CFC``
-	Inert carbon tracers (CFC11,CFC12,SF6)
-
-``C14``
-	Radiocarbon passive tracer
-
-``AGE``
-	Water age tracking
-
-``MY_TRC``
-	Template for creation of new modules and external BGC models coupling
-
-``PISCES``
-	Built in BGC model.
-	See [https://www.geosci-model-dev.net/8/2465/2015/gmd-8-2465-2015-discussion.html Aumont et al. (2015)] for
-	a throughout description. |
-
-The usage of TOP is activated i) by including in the configuration definition  the component ``MBG`` and
-ii) by adding the macro ``key_top`` in the configuration CPP file
-(see for more details [http://forge.ipsl.jussieu.fr/nemo/wiki/Users "Learn more about the model"]).
+:file:`TRP`
+   Interface to NEMO physical core for computing tracers transport
+
+:file:`CFC`
+   Inert carbon tracers (CFC11,CFC12,SF6)
+
+:file:`C14`
+   Radiocarbon passive tracer
+
+:file:`AGE`
+   Water age tracking
+
+:file:`MY_TRC`
+   Template for creation of new modules and external BGC models coupling
+
+:file:`PISCES`
+   Built in BGC model. See :cite:`gmd-8-2465-2015` for a throughout description.
+
+The usage of TOP is activated
+*i)* by including in the configuration definition the component ``TOP`` and
+*ii)* by adding the macro ``key_top`` in the configuration CPP file
+(see for more details :forge:`"Learn more about the model" <wiki/Users>`).
 
 As an example, the user can refer to already available configurations in the code,
@@ -51,5 +56,6 @@
 (see also Section 4) .
 
-Note that, since version 4.0, TOP interface core functionalities are activated by means of logical keys and
+Note that, since version 4.0,
+TOP interface core functionalities are activated by means of logical keys and
 all submodules preprocessing macros from previous versions were removed.
 
@@ -57,118 +63,131 @@
 
 ``key_iomput``
-	use XIOS I/O
+   use XIOS I/O
 
 ``key_agrif``
-	enable AGRIF coupling
+   enable AGRIF coupling
 
 ``key_trdtrc`` & ``key_trdmxl_trc``
-	trend computation for tracers
+   trend computation for tracers
 
 Synthetic Workflow
 ==================
 
-A synthetic description of the TOP interface workflow is given below to summarize the steps involved in
-the computation of biogeochemical and physical trends and their time integration and outputs,
+A synthetic description of the TOP interface workflow is given below to
+summarize the steps involved in the computation of biogeochemical and physical trends and
+their time integration and outputs,
 by reporting also the principal Fortran subroutine herein involved.
 
-**Model initialization (OPA_SRC/nemogcm.F90)**
-
-call to trc_init (trcini.F90)
-
-  ↳ call trc_nam (trcnam.F90) to initialize TOP tracers and run setting
-
-  ↳ call trc_ini_sms, to initialize each submodule
-
-  ↳ call trc_ini_trp, to initialize transport for tracers
-
-  ↳ call trc_ice_ini, to initialize tracers in seaice
-
-  ↳ call trc_ini_state, read passive tracers from a restart or input data
-
-  ↳ call trc_sub_ini, setup substepping if {{{nn_dttrc /= 1}}}
-
-**Time marching procedure (OPA_SRC/stp.F90)**
-
-call to trc_stp.F90 (trcstp.F90)
-
-  ↳ call trc_sub_stp, averaging physical variables for sub-stepping
-
-  ↳ call trc_wri, call XIOS for output of data
-
-  ↳ call trc_sms, compute BGC trends for each submodule
-
-    ↳ call trc_sms_my_trc, includes also surface and coastal BCs trends
-
-  ↳ call trc_trp (TRP/trctrp.F90), compute physical trends
-
-    ↳ call trc_sbc, get trend due to surface concentration/dilution
-
-    ↳ call trc_adv, compute tracers advection
-
-    ↳ call to trc_ldf, compute tracers lateral diffusion
-
-    ↳ call to trc_zdf, vertical mixing and after tracer fields
-
-    ↳ call to trc_nxt, tracer fields at next time step. Lateral Boundary Conditions are solved in here.
-
-    ↳ call to trc_rad, Correct artificial negative concentrations
-
-  ↳ call trc_rst_wri, output tracers restart files
+Model initialization (:file:`./src/OCE/nemogcm.F90`)
+----------------------------------------------------
+
+Call to ``trc_init`` subroutine (:file:`./src/TOP/trcini.F90`) to initialize TOP.
+
+.. literalinclude:: ../../../src/TOP/trcini.F90
+   :language:        fortran
+   :lines:           41-86
+   :emphasize-lines: 21,30-32,38-40
+   :caption:         ``trc_init`` subroutine
+
+Time marching procedure (:file:`./src/OCE/step.F90`)
+----------------------------------------------------
+
+Call to ``trc_stp`` subroutine (:file:`./src/TOP/trcstp.F90`) to compute/update passive tracers.
+
+.. literalinclude:: ../../../src/TOP/trcstp.F90
+   :language:        fortran
+   :lines:           46-125
+   :emphasize-lines: 42,55-57
+   :caption:         ``trc_stp`` subroutine
+
+BGC trends computation for each submodule (:file:`./src/TOP/trcsms.F90`)
+------------------------------------------------------------------------
+
+.. literalinclude:: ../../../src/TOP/trcsms.F90
+   :language:        fortran
+   :lines:           21
+   :caption:         :file:`trcsms` snippet
+
+Physical trends computation (:file:`./src/TOP/TRP/trctrp.F90`)
+--------------------------------------------------------------
+
+.. literalinclude:: ../../../src/TOP/TRP/trctrp.F90
+   :language:        fortran
+   :lines:           46-95
+   :emphasize-lines: 17,21,29,33-35
+   :caption:         ``trc_trp`` subroutine
 
 Namelists walkthrough
 =====================
 
-namelist_top
-------------
-
-Here below are listed the features/options of the TOP interface accessible through the namelist_top_ref and
-modifiable by means of namelist_top_cfg (as for NEMO physical ones).
-
-Note that ## is used to refer to a number in an array field.
+:file:`namelist_top`
+--------------------
+
+Here below are listed the features/options of the TOP interface accessible through
+the :file:`namelist_top_ref` and modifiable by means of :file:`namelist_top_cfg`
+(as for NEMO physical ones).
+
+Note that ``##`` is used to refer to a number in an array field.
 
 .. literalinclude:: ../../namelists/namtrc_run
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc_dta
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc_adv
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc_ldf
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc_rad
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc_snk
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc_dmp
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc_ice
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc_trd
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc_bc
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namtrc_bdy
+   :language: fortran
 
 .. literalinclude:: ../../namelists/namage
-
-Two main types of data structure are used within TOP interface to initialize tracer properties (1) and
+   :language: fortran
+
+Two main types of data structure are used within TOP interface
+to initialize tracer properties (1) and
 to provide related initial and boundary conditions (2).
 
-**1. TOP tracers initialization**: sn_tracer (namtrc)
+1. TOP tracers initialization: ``sn_tracer`` (``&namtrc``)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 Beside providing name and metadata for tracers,
-here are also defined the use of initial ({{{sn_tracer%llinit}}}) and
-boundary ({{{sn_tracer%llsbc, sn_tracer%llcbc, sn_tracer%llobc}}}) conditions.
-
-In the following, an example of the full structure definition is given for two idealized tracers both with
-initial conditions given, while the first has only surface boundary forcing and
+here are also defined the use of initial (``sn_tracer%llinit``) and
+boundary (``sn_tracer%llsbc, sn_tracer%llcbc, sn_tracer%llobc``) conditions.
+
+In the following, an example of the full structure definition is given for
+two idealized tracers both with initial conditions given,
+while the first has only surface boundary forcing and
 the second both surface and coastal forcings:
 
 .. code-block:: fortran
 
-	!             !    name   !           title of the field            !   units    ! initial data ! sbc   !   cbc  !   obc  !
-	sn_tracer(1)  = 'TRC1'    , 'Tracer 1 Concentration                ',   ' - '    ,  .true.      , .true., .false., .true.
-	sn_tracer(2)  = 'TRC2 '   , 'Tracer 2 Concentration                ',   ' - '    ,  .true.      , .true., .true. , .false.
+   !             !    name   !           title of the field            !   units    ! initial data ! sbc   !   cbc  !   obc  !
+   sn_tracer(1)  = 'TRC1'    , 'Tracer 1 Concentration                ',   ' - '    ,  .true.      , .true., .false., .true.
+   sn_tracer(2)  = 'TRC2 '   , 'Tracer 2 Concentration                ',   ' - '    ,  .true.      , .true., .true. , .false.
 
 As tracers in BGC models are increasingly growing,
@@ -177,94 +196,101 @@
 .. code-block:: fortran
 
-	!             !    name   !           title of the field            !   units    ! initial data !
-	sn_tracer(1)  = 'TRC1'    , 'Tracer 1 Concentration                ',   ' - '    ,   .true.
-	sn_tracer(2)  = 'TRC2 '   , 'Tracer 2 Concentration                ',   ' - '    ,   .true.
-	! sbc
-	sn_tracer(1)%llsbc = .true.
-	sn_tracer(2)%llsbc = .true.
-	! cbc
-	sn_tracer(2)%llcbc = .true.
+   !             !    name   !           title of the field            !   units    ! initial data !
+   sn_tracer(1)  = 'TRC1'    , 'Tracer 1 Concentration                ',   ' - '    ,   .true.
+   sn_tracer(2)  = 'TRC2 '   , 'Tracer 2 Concentration                ',   ' - '    ,   .true.
+   ! sbc
+   sn_tracer(1)%llsbc = .true.
+   sn_tracer(2)%llsbc = .true.
+   ! cbc
+   sn_tracer(2)%llcbc = .true.
 
 The data structure is internally initialized by code with dummy names and
-all initialization/forcing logical fields set to .false. .
-
-**2. Structures to read input initial and boundary conditions**: namtrc_dta (sn_trcdta), namtrc_bc (sn_trcsbc/sn_trccbc/sn_trcobc)
+all initialization/forcing logical fields set to ``.false.`` .
+
+2. Structures to read input initial and boundary conditions: ``&namtrc_dta`` (``sn_trcdta``), ``&namtrc_bc`` (``sn_trcsbc`` / ``sn_trccbc`` / ``sn_trcobc``)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 The overall data structure (Fortran type) is based on the general one defined for NEMO core in the SBC component
-(see details in User Manual SBC Chapter on Input Data specification).
-
-Input fields are prescribed within namtrc_dta (with sn_trcdta structure),
-while Boundary Conditions are applied to the model by means of namtrc_bc,
-with dedicated structure fields for surface (sn_trcsbc), riverine (sn_trccbc), and
-lateral open (sn_trcobc) boundaries.
+(see details in ``SBC`` Chapter of :doc:`Reference Manual <cite>` on Input Data specification).
+
+Input fields are prescribed within ``&namtrc_dta`` (with ``sn_trcdta`` structure),
+while Boundary Conditions are applied to the model by means of ``&namtrc_bc``,
+with dedicated structure fields for surface (``sn_trcsbc``), riverine (``sn_trccbc``), and
+lateral open (``sn_trcobc``) boundaries.
 
 The following example illustrates the data structure in the case of initial condition for
-a single tracer contained in the file named tracer_1_data.nc (.nc is implicitly assumed in namelist filename),
-with a doubled initial value, and located in the usr/work/model/inputdata/ folder:
+a single tracer contained in the file named :file:`tracer_1_data.nc`
+(``.nc`` is implicitly assumed in namelist filename),
+with a doubled initial value, and located in the :file:`usr/work/model/inputdata` folder:
 
 .. code-block:: fortran
 
-	!               !  file name             ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-	!               !                        !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-	  sn_trcdta(1)  = 'tracer_1_data'        ,        -12        ,  'TRC1'   ,    .false.   , .true. , 'yearly'  , ''       , ''       , ''
-	  rf_trfac(1) = 2.0
-	  cn_dir = “usr/work/model/inputdata/”
-
-Note that, the Lateral Open Boundaries conditions are applied on the segments defined for the physical core of NEMO
-(see BDY description in the User Manual).
-
-namelist_trc
-------------
-
-Here below the description of namelist_trc_ref used to handle Carbon tracers modules, namely CFC and C14.
-
-|||| &'''namcfc'''     !   CFC ||
-
-|||| &'''namc14_typ'''     !  C14 - type of C14 tracer, default values of C14/C and pco2 ||
-
-|||| &'''namc14_sbc'''     !  C14 - surface BC ||
-
-|||| &'''namc14_fcg'''     !  files & dates ||
+   !               !  file name             ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+   !               !                        !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+     sn_trcdta(1)  = 'tracer_1_data'        ,        -12        ,  'TRC1'   ,    .false.   , .true. , 'yearly'  , ''       , ''       , ''
+     rf_trfac(1) = 2.0
+     cn_dir = 'usr/work/model/inputdata/'
+
+Note that, the Lateral Open Boundaries conditions are applied on
+the segments defined for the physical core of NEMO
+(see ``BDY`` description in the :doc:`Reference Manual <cite>`).
+
+:file:`namelist_trc`
+--------------------
+
+Here below the description of :file:`namelist_trc_ref` used to handle Carbon tracers modules,
+namely CFC and C14.
+
+.. literalinclude:: ../../../cfgs/SHARED/namelist_trc_ref
+   :language: fortran
+   :lines: 7,17,26,34
+   :caption: :file:`namelist_trc_ref` snippet
 
 ``MY_TRC`` interface for coupling external BGC models
 =====================================================
 
-The generalized interface is pivoted on MY_TRC module that contains template files to build the coupling between
+The generalized interface is pivoted on MY_TRC module that contains template files to
+build the coupling between
 NEMO and any external BGC model.
 
-The call to MY_TRC is activated by setting ``ln_my_trc = .true.`` (in namtrc)
+The call to MY_TRC is activated by setting ``ln_my_trc = .true.`` (in ``&namtrc``)
 
 The following 6 fortran files are available in MY_TRC with the specific purposes here described.
 
-``par_my_trc.F90``
-	This module allows to define additional arrays and public variables to be used within the MY_TRC interface
-
-``trcini_my_trc.F90``
-	Here are initialized user defined namelists and the call to the external BGC model initialization procedures to
-	populate general tracer array (trn and trb). Here are also likely to be defined suport arrays related to
-	system metrics that could be needed by the BGC model.
-
-``trcnam_my_trc.F90``
-	This routine is called at the beginning of trcini_my_trc and should contain the initialization of
-	additional namelists for the BGC model or user-defined code.
-
-``trcsms_my_trc.F90``
-	The routine performs the call to Boundary Conditions and its main purpose is to
-	contain the Source-Minus-Sinks terms due to the biogeochemical processes of the external model.
-	Be aware that lateral boundary conditions are applied in trcnxt routine.
-	IMPORTANT: the routines to compute the light penetration along the water column and
-	the tracer vertical sinking should be defined/called in here, as generalized modules are still missing in
-	the code.
-
-``trcice_my_trc.F90``
-	Here it is possible to prescribe the tracers concentrations in the seaice that will be used as
-	boundary conditions when ice melting occurs (nn_ice_tr =1 in namtrc_ice).
-	See e.g. the correspondent PISCES subroutine.
-
-``trcwri_my_trc.F90``
-	This routine performs the output of the model tracers (only those defined in namtrc) using IOM module
-	(see Manual Chapter “Output and Diagnostics”).
-	It is possible to place here the output of additional variables produced by the model,
-	if not done elsewhere in the code, using the call to iom_put.
+:file:`par_my_trc.F90`
+   This module allows to define additional arrays and public variables to
+   be used within the MY_TRC interface
+
+:file:`trcini_my_trc.F90`
+   Here are initialized user defined namelists and
+   the call to the external BGC model initialization procedures to populate general tracer array
+   (``trn`` and ``trb``).
+   Here are also likely to be defined support arrays related to system metrics that
+   could be needed by the BGC model.
+
+:file:`trcnam_my_trc.F90`
+   This routine is called at the beginning of ``trcini_my_trc`` and
+   should contain the initialization of additional namelists for the BGC model or user-defined code.
+
+:file:`trcsms_my_trc.F90`
+   The routine performs the call to Boundary Conditions and its main purpose is to
+   contain the Source-Minus-Sinks terms due to the biogeochemical processes of the external model.
+   Be aware that lateral boundary conditions are applied in trcnxt routine.
+
+   .. warning::
+      The routines to compute the light penetration along the water column and
+      the tracer vertical sinking should be defined/called in here,
+      as generalized modules are still missing in the code.
+
+:file:`trcice_my_trc.F90`
+   Here it is possible to prescribe the tracers concentrations in the sea-ice that
+   will be used as boundary conditions when ice melting occurs (``nn_ice_tr = 1`` in ``&namtrc_ice``).
+   See e.g. the correspondent PISCES subroutine.
+
+:file:`trcwri_my_trc.F90`
+   This routine performs the output of the model tracers (only those defined in ``&namtrc``) using
+   IOM module (see chapter “Output and Diagnostics” in the :doc:`Reference Manual <cite>`).
+   It is possible to place here the output of additional variables produced by the model,
+   if not done elsewhere in the code, using the call to ``iom_put``.
 
 Coupling an external BGC model using NEMO framework
@@ -273,18 +299,20 @@
 The coupling with an external BGC model through the NEMO compilation framework can be achieved in
 different ways according to the degree of coding complexity of the Biogeochemical model, like e.g.,
-the whole code is made only by one file or it has multiple modules and interfaces spread across several subfolders.
-
-Beside the 6 core files of MY_TRC module, let’s assume an external BGC model named *MYBGC* and constituted by
-a rather essential coding structure, likely few Fortran files.
+the whole code is made only by one file or
+it has multiple modules and interfaces spread across several subfolders.
+
+Beside the 6 core files of MY_TRC module, let’s assume an external BGC model named *MYBGC* and
+constituted by a rather essential coding structure, likely few Fortran files.
 The new coupled configuration name is *NEMO_MYBGC*.
 
-The best solution is to have all files (the modified ``MY_TRC`` routines and the BGC model ones) placed in
-a unique folder with root ``MYBGCPATH`` and to use the makenemo external readdressing of ``MY_SRC`` folder.
-
-The coupled configuration listed in ``work_cfgs.txt`` will look like
+The best solution is to have all files (the modified ``MY_TRC`` routines and the BGC model ones)
+placed in a unique folder with root ``MYBGCPATH`` and
+to use the makenemo external readdressing of ``MY_SRC`` folder.
+
+The coupled configuration listed in :file:`work_cfgs.txt` will look like
 
 ::
 
-	NEMO_MYBGC OPA_SRC TOP_SRC
+   NEMO_MYBGC OCE TOP
 
 and the related ``cpp_MYBGC.fcm`` content will be
@@ -292,46 +320,46 @@
 .. code-block:: perl
 
-	bld::tool::fppkeys  key_iomput key_mpp_mpi key_top
-
-the compilation with ``makenemo`` will be executed through the following syntax
+   bld::tool::fppkeys key_iomput key_mpp_mpi key_top
+
+the compilation with :file:`makenemo` will be executed through the following syntax
 
 .. code-block:: console
 
-	$ makenemo -n 'NEMO_MYBGC' -m '<arch_my_machine>' -j 8 -e '<MYBGCPATH>'
-
-The makenemo feature “-e” was introduced to readdress at compilation time the standard MY_SRC folder
-(usually found in NEMO configurations) with a user defined external one.
-
-The compilation of more articulated BGC model code & infrastructure, like in the case of BFM
-([http://www.bfm-community.eu/publications/bfmnemomanual_r1.0_201508.pdf BFM-NEMO coupling manual]),
-requires some additional features.
+   $ makenemo -n 'NEMO_MYBGC' -m '<arch_my_machine>' -j 8 -e '<MYBGCPATH>'
+
+The makenemo feature ``-e`` was introduced to
+readdress at compilation time the standard MY_SRC folder (usually found in NEMO configurations) with
+a user defined external one.
+
+The compilation of more articulated BGC model code & infrastructure,
+like in the case of BFM (|BFM man|_), requires some additional features.
 
 As before, let’s assume a coupled configuration name *NEMO_MYBGC*,
-but in this case MYBGC model root becomes ``<MYBGCPATH>`` that contains 4 different subfolders for
-biogeochemistry, named ``initialization``, ``pelagic``, and ``benthic``, and
-a separate one named ``nemo_coupling`` including the modified ``MY_SRC`` routines.
+but in this case MYBGC model root becomes :file:`MYBGC` path that
+contains 4 different subfolders for biogeochemistry,
+named :file:`initialization`, :file:`pelagic`, and :file:`benthic`,
+and a separate one named :file:`nemo_coupling` including the modified `MY_SRC` routines.
 The latter folder containing the modified NEMO coupling interface will be still linked using
-the makenemo “-e” option.
+the makenemo ``-e`` option.
 
 In order to include the BGC model subfolders in the compilation of NEMO code,
-it will be necessary to extend the configuration ``cpp_NEMO_MYBGC.fcm`` file to include the specific paths of
-``MYBGC`` folders, as in the following example
+it will be necessary to extend the configuration :file:`cpp_NEMO_MYBGC.fcm` file to include the specific paths of :file:`MYBGC` folders, as in the following example
 
 .. code-block:: perl
 
-	bld::tool::fppkeys  key_iomput key_mpp_mpi key_top
-	
-	src::MYBGC::initialization         <MYBGCPATH>/initialization
-	src::MYBGC::pelagic                <MYBGCPATH>/pelagic
-	src::MYBGC::benthic                <MYBGCPATH>/benthic
-	
-	bld::pp::MYBGC      1
-	bld::tool::fppflags::MYBGC   %FPPFLAGS
-	bld::tool::fppkeys           %bld::tool::fppkeys MYBGC_MACROS
+   bld::tool::fppkeys  key_iomput key_mpp_mpi key_top
+
+   src::MYBGC::initialization         <MYBGCPATH>/initialization
+   src::MYBGC::pelagic                <MYBGCPATH>/pelagic
+   src::MYBGC::benthic                <MYBGCPATH>/benthic
+
+   bld::pp::MYBGC      1
+   bld::tool::fppflags::MYBGC   %FPPFLAGS
+   bld::tool::fppkeys           %bld::tool::fppkeys MYBGC_MACROS
 
 where *MYBGC_MACROS* is the space delimited list of macros used in *MYBGC* model for
 selecting/excluding specific parts of the code.
-The BGC model code will be preprocessed in the configuration ``BLD`` folder as for NEMO,
-but with an independent path, like ``NEMO_MYBGC/BLD/MYBGC/<subforlders>``.
+The BGC model code will be preprocessed in the configuration :file:`BLD` folder as for NEMO,
+but with an independent path, like :file:`NEMO_MYBGC/BLD/MYBGC/<subforlders>`.
 
 The compilation will be performed similarly to in the previous case with the following
@@ -339,20 +367,26 @@
 .. code-block:: console
 
-	$ makenemo -n 'NEMO_MYBGC' -m '<arch_my_machine>' -j 8 -e '<MYBGCPATH>/nemo_coupling'
-
-Note that, the additional lines specific for the BGC model source and build paths can be written into
-a separate file, e.g. named ``MYBGC.fcm``, and then simply included in the ``cpp_NEMO_MYBGC.fcm`` as follow
-
-.. code-block:: perl
-
-	bld::tool::fppkeys  key_zdftke key_dynspg_ts key_iomput key_mpp_mpi key_top
-	inc <MYBGCPATH>/MYBGC.fcm
-
-This will enable a more portable compilation structure for all MYBGC related configurations.
-
-**Important**: the coupling interface contained in nemo_coupling cannot be added using the FCM syntax,
-as the same files already exists in NEMO and they are overridden only with the readdressing of MY_SRC contents to
-avoid compilation conflicts due to duplicate routines.
-
-All modifications illustrated above, can be easily implemented using shell or python scripting to
-edit the NEMO configuration CPP.fcm file and to create the BGC model specific FCM compilation file with code paths.
+   $ makenemo -n 'NEMO_MYBGC' -m '<arch_my_machine>' -j 8 -e '<MYBGCPATH>/nemo_coupling'
+
+.. note::
+   The additional lines specific for the BGC model source and build paths can be written into
+   a separate file, e.g. named :file:`MYBGC.fcm`,
+   and then simply included in the :file:`cpp_NEMO_MYBGC.fcm` as follow
+
+   .. code-block:: perl
+
+      bld::tool::fppkeys  key_zdftke key_dynspg_ts key_iomput key_mpp_mpi key_top
+      inc <MYBGCPATH>/MYBGC.fcm
+
+   This will enable a more portable compilation structure for all MYBGC related configurations.
+
+.. warning::
+   The coupling interface contained in :file:`nemo_coupling` cannot be added using the FCM syntax,
+   as the same files already exists in NEMO and they are overridden only with
+   the readdressing of MY_SRC contents to avoid compilation conflicts due to duplicate routines.
+
+All modifications illustrated above, can be easily implemented using shell or python scripting
+to edit the NEMO configuration :file:`CPP.fcm` file and
+to create the BGC model specific FCM compilation file with code paths.
+
+.. |BFM man| replace:: BFM-NEMO coupling manual
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcadv.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcadv.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcadv.F90	(revision 12143)
@@ -166,8 +166,8 @@
       REWIND( numnat_ref )                   !  namtrc_adv in reference namelist 
       READ  ( numnat_ref, namtrc_adv, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_adv in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_adv in reference namelist' )
       REWIND( numnat_cfg )                   ! namtrc_adv in configuration namelist
       READ  ( numnat_cfg, namtrc_adv, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_adv in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_adv in configuration namelist' )
       IF(lwm) WRITE ( numont, namtrc_adv )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcdmp.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcdmp.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcdmp.F90	(revision 12143)
@@ -183,8 +183,8 @@
       REWIND( numnat_ref )              ! Namelist namtrc_dmp in reference namelist : Passive tracers newtonian damping
       READ  ( numnat_ref, namtrc_dmp, IOSTAT = ios, ERR = 909)
-909   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_dmp in reference namelist', lwp )
+909   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_dmp in reference namelist' )
       REWIND( numnat_cfg )              ! Namelist namtrc_dmp in configuration namelist : Passive tracers newtonian damping
       READ  ( numnat_cfg, namtrc_dmp, IOSTAT = ios, ERR = 910)
-910   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_dmp in configuration namelist', lwp )
+910   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_dmp in configuration namelist' )
       IF(lwm) WRITE ( numont, namtrc_dmp )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcldf.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcldf.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcldf.F90	(revision 12143)
@@ -145,9 +145,9 @@
       REWIND( numnat_ref )             !  namtrc_ldf in reference namelist 
       READ  ( numnat_ref, namtrc_ldf, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_ldf in reference namelist', lwp )
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_ldf in reference namelist' )
       !
       REWIND( numnat_cfg )             !  namtrc_ldf in configuration namelist 
       READ  ( numnat_cfg, namtrc_ldf, IOSTAT = ios, ERR = 904 )
-904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_ldf in configuration namelist', lwp )
+904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_ldf in configuration namelist' )
       IF(lwm) WRITE ( numont, namtrc_ldf )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcnxt.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcnxt.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcnxt.F90	(revision 12143)
@@ -139,5 +139,14 @@
       ENDIF
       !                                ! Leap-Frog + Asselin filter time stepping
-      IF( (neuler == 0 .AND. kt == nittrc000) .OR. ln_top_euler ) THEN    ! Euler time-stepping (only swap)
+      IF( (neuler == 0 .AND. kt == nittrc000) ) THEN
+         ! set up for leapfrog on second timestep
+         DO jn = 1, jptra
+            DO jk = 1, jpkm1
+               trb(:,:,jk,jn) = trn(:,:,jk,jn)  
+               trn(:,:,jk,jn) = tra(:,:,jk,jn)
+            END DO
+         END DO
+      ELSE IF( ln_top_euler ) THEN
+         ! always doing euler timestepping
          DO jn = 1, jptra
             DO jk = 1, jpkm1
@@ -146,4 +155,6 @@
             END DO
          END DO
+      ENDIF
+      IF( (neuler == 0 .AND. kt == nittrc000) .OR. ln_top_euler ) THEN    ! Euler time-stepping (only swap)
          IF (l_trdtrc .AND. .NOT. ln_linssh ) THEN   ! Zero Asselin filter contribution must be explicitly written out since for vvl
             !                                        ! Asselin filter is output by tra_nxt_vvl that is not called on this time step
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcrad.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcrad.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcrad.F90	(revision 12143)
@@ -89,8 +89,8 @@
       REWIND( numnat_ref )              ! namtrc_rad in reference namelist 
       READ  ( numnat_ref, namtrc_rad, IOSTAT = ios, ERR = 907)
-907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_rad in reference namelist', lwp )
+907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_rad in reference namelist' )
       REWIND( numnat_cfg )              ! namtrc_rad in configuration namelist 
       READ  ( numnat_cfg, namtrc_rad, IOSTAT = ios, ERR = 908 )
-908   IF( ios > 0 )   CALL ctl_nam ( ios , 'namtrc_rad in configuration namelist', lwp )
+908   IF( ios > 0 )   CALL ctl_nam ( ios , 'namtrc_rad in configuration namelist' )
       IF(lwm) WRITE( numont, namtrc_rad )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcsink.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcsink.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trcsink.F90	(revision 12143)
@@ -87,7 +87,10 @@
          DO jj = 1, jpj
             DO ji = 1, jpi
-               IF( tmask(ji,jj,jk) == 1 ) THEN
+               IF( tmask(ji,jj,jk) == 1.0 ) THEN
                  zwsmax = 0.5 * e3t_n(ji,jj,jk) * rday / rsfact
                  zwsink(ji,jj,jk) = MIN( pwsink(ji,jj,jk), zwsmax * REAL( iiter(ji,jj), wp ) )
+               ELSE
+                 ! provide a default value so there is no use of undefinite value in trc_sink2 for zwsink2 initialization
+                 zwsink(ji,jj,jk) = 0.
                ENDIF
             END DO
@@ -215,8 +218,8 @@
       REWIND( numnat_ref )              ! namtrc_rad in reference namelist 
       READ  ( numnat_ref, namtrc_snk, IOSTAT = ios, ERR = 907)
-907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_snk in reference namelist', lwp )
+907   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_snk in reference namelist' )
       REWIND( numnat_cfg )              ! namtrc_rad in configuration namelist 
       READ  ( numnat_cfg, namtrc_snk, IOSTAT = ios, ERR = 908 )
-908   IF( ios > 0 )   CALL ctl_nam ( ios , 'namtrc_snk in configuration namelist', lwp )
+908   IF( ios > 0 )   CALL ctl_nam ( ios , 'namtrc_snk in configuration namelist' )
       IF(lwm) WRITE( numont, namtrc_snk )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trdmxl_trc.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trdmxl_trc.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/TRP/trdmxl_trc.F90	(revision 12143)
@@ -108,5 +108,5 @@
          ! ... Set nmld(ji,jj) = index of first T point below control surf. or outside mixed-layer
          SELECT CASE ( nn_ctls_trc )                                ! choice of the control surface
-            CASE ( -2  )   ;   STOP 'trdmxl_trc : not ready '     !     -> isopycnal surface (see ???)
+            CASE ( -2  )   ;   CALL ctl_stop( 'STOP', 'trdmxl_trc : not ready ' )     !     -> isopycnal surface (see ???)
             CASE ( -1  )   ;   nmld_trc(:,:) = neln(:,:)          !     -> euphotic layer with light criterion
             CASE (  0  )   ;   nmld_trc(:,:) = nmln(:,:)          !     -> ML with density criterion (see zdfmxl)
@@ -431,5 +431,5 @@
 
 #if defined key_diainstant
-               STOP 'tmltrd_trc : key_diainstant was never checked within trdmxl. Comment this to proceed.'
+               CALL ctl_stop( 'STOP', 'tmltrd_trc : key_diainstant was never checked within trdmxl. Comment this to proceed.' )
 #endif
             ENDIF
@@ -857,5 +857,5 @@
 #  if defined key_diainstant
       IF( .NOT. ln_trdmxl_trc_instant ) THEN
-         STOP 'trd_mxl_trc : this was never checked. Comment this line to proceed...'
+         CALL ctl_stop( 'STOP', 'trd_mxl_trc : this was never checked. Comment this line to proceed...' )
       ENDIF
       zsto = nn_trd_trc * rdt
@@ -928,5 +928,5 @@
       !-- Define miscellaneous passive tracer mixed-layer variables 
       IF( jpltrd_trc /= jpmxl_trc_atf .OR.  jpltrd_trc - 1 /= jpmxl_trc_radb ) THEN
-         STOP 'Error : jpltrd_trc /= jpmxl_trc_atf .OR.  jpltrd_trc - 1 /= jpmxl_trc_radb'  ! see below
+         CALL ctl_stop( 'STOP', 'Error : jpltrd_trc /= jpmxl_trc_atf .OR.  jpltrd_trc - 1 /= jpmxl_trc_radb' ) ! see below
       ENDIF
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcbc.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcbc.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcbc.F90	(revision 12143)
@@ -44,5 +44,4 @@
    TYPE(FLD), SAVE, PUBLIC, ALLOCATABLE, DIMENSION(:), TARGET  :: sf_trcobc
 #endif
-   TYPE(MAP_POINTER), ALLOCATABLE, DIMENSION(:) :: nbmap_ptr   ! array of pointers to nbmap
 
    !! * Substitutions
@@ -123,8 +122,8 @@
       REWIND( numnat_ref )              ! Namelist namtrc_bc in reference namelist : Passive tracer data structure
       READ  ( numnat_ref, namtrc_bc, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_bc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_bc in reference namelist' )
       REWIND( numnat_cfg )              ! Namelist namtrc_bc in configuration namelist : Passive tracer data structure
       READ  ( numnat_cfg, namtrc_bc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_bc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_bc in configuration namelist' )
       IF(lwm) WRITE ( numont, namtrc_bc )
 
@@ -132,9 +131,11 @@
          REWIND( numnat_ref )              ! Namelist namtrc_bdy in reference namelist : Passive tracer data structure
          READ  ( numnat_ref, namtrc_bdy, IOSTAT = ios, ERR = 903)
-903      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_bdy in reference namelist', lwp )
-
+903      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_bdy in reference namelist' )
+         ! make sur that all elements of the namelist variables have a default definition from namelist_ref
+         cn_trc     (2:jp_bdy) = cn_trc     (1)
+         cn_trc_dflt(2:jp_bdy) = cn_trc_dflt(1)
          REWIND( numnat_cfg )              ! Namelist namtrc_bdy in configuration namelist : Passive tracer data structure
          READ  ( numnat_cfg, namtrc_bdy, IOSTAT = ios, ERR = 904 )
-904      IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_bdy in configuration namelist', lwp )
+904      IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_bdy in configuration namelist' )
          IF(lwm) WRITE ( numont, namtrc_bdy )
       
@@ -234,5 +235,5 @@
       ! OPEN Lateral boundary conditions
       IF( ln_bdy .AND. nb_trcobc > 0 ) THEN 
-         ALLOCATE ( sf_trcobc(nb_trcobc), rf_trofac(nb_trcobc), nbmap_ptr(nb_trcobc), STAT=ierr1 )
+         ALLOCATE ( sf_trcobc(nb_trcobc), rf_trofac(nb_trcobc), STAT=ierr1 )
          IF( ierr1 > 0 ) THEN
             CALL ctl_stop( 'trc_bc_ini: unable to allocate sf_trcobc structure' )   ;   RETURN
@@ -257,8 +258,4 @@
                   trcdta_bdy(jn,ib)%trc => sf_trcobc(jl)%fnow(:,1,:)
                   trcdta_bdy(jn,ib)%rn_fac = rf_trofac(jl)
-                  ! create OBC mapping array
-                  nbmap_ptr(jl)%ptr => idx_bdy(ib)%nbmap(:,igrd)
-                  nbmap_ptr(jl)%ll_unstruc = ln_coords_file(igrd)
-                  !
                ELSE                          !* Initialise obc arrays from initial conditions *!
                   ALLOCATE ( trcdta_bdy(jn,ib)%trc(nblen,jpk) )
@@ -276,4 +273,13 @@
          !
          CALL fld_fill( sf_trcobc, slf_i, cn_dir_obc, 'trc_bc_ini', 'Passive tracer OBC data', 'namtrc_bc' )
+         DO jn = 1, ntrc   ! define imap pointer, must be done after the call to fld_fill
+            DO ib = 1, nb_bdy
+               IF( ln_trc_obc(jn) ) THEN     !* Initialise from external data *!
+                  jl = n_trc_indobc(jn)
+                  sf_trcobc(jl)%imap => idx_bdy(ib)%nbmap(1:idx_bdy(ib)%nblen(igrd),igrd)
+               ENDIF
+            END DO
+         END DO
+         !
       ENDIF
 
@@ -362,8 +368,8 @@
       IF( PRESENT(jit) ) THEN 
          !
-         ! OPEN boundary conditions (use time_offset=+1 as they are applied at the end of the step)
+         ! OPEN boundary conditions (use kt_offset=+1 as they are applied at the end of the step)
          IF( nb_trcobc > 0 ) THEN
            if (lwp) write(numout,'(a,i5,a,i10)') '   reading OBC data for ', nb_trcobc ,' variable(s) at step ', kt
-           CALL fld_read( kt=kt, kn_fsbc=1, sd=sf_trcobc, map=nbmap_ptr, kit=jit, kt_offset=+1)
+           CALL fld_read( kt=kt, kn_fsbc=1, sd=sf_trcobc, kit=jit, kt_offset=+1)
          ENDIF
          !
@@ -382,8 +388,8 @@
       ELSE
          !
-         ! OPEN boundary conditions (use time_offset=+1 as they are applied at the end of the step)
+         ! OPEN boundary conditions (use kt_offset=+1 as they are applied at the end of the step)
          IF( nb_trcobc > 0 ) THEN
            if (lwp) write(numout,'(a,i5,a,i10)') '   reading OBC data for ', nb_trcobc ,' variable(s) at step ', kt
-           CALL fld_read( kt=kt, kn_fsbc=1, sd=sf_trcobc, map=nbmap_ptr, kt_offset=+1)
+           CALL fld_read( kt=kt, kn_fsbc=1, sd=sf_trcobc, kt_offset=+1)
          ENDIF
          !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcbdy.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcbdy.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcbdy.F90	(revision 12143)
@@ -22,5 +22,5 @@
    USE lbclnk                       ! ocean lateral boundary conditions (or mpp link)
    USE in_out_manager               ! I/O manager
-   USE bdy_oce, only: idx_bdy       ! ocean open boundary conditions
+   USE bdy_oce                      ! ocean open boundary conditions
 
    IMPLICIT NONE
@@ -46,7 +46,9 @@
       INTEGER, INTENT( in ) :: kt     ! Main time step counter
       !!
-      INTEGER                           :: ib_bdy ,jn ,igrd ! Loop indeces
+      INTEGER                           :: ib_bdy ,ir, jn ,igrd ! Loop indices
       REAL(wp), POINTER, DIMENSION(:,:) ::  ztrc
       REAL(wp), POINTER                 ::  zfac
+      LOGICAL                           :: llrim0               ! indicate if rim 0 is treated
+      LOGICAL, DIMENSION(4)             :: llsend1, llrecv1     ! indicate how communications are to be carried out
       !!----------------------------------------------------------------------
       !
@@ -54,28 +56,50 @@
       !
       igrd = 1 
-      !
-      DO ib_bdy=1, nb_bdy
-         DO jn = 1, jptra
-            !
-            ztrc => trcdta_bdy(jn,ib_bdy)%trc 
-            zfac => trcdta_bdy(jn,ib_bdy)%rn_fac
-            !
-            SELECT CASE( TRIM(trcdta_bdy(jn,ib_bdy)%cn_obc) )
-            CASE('none'        )   ;   CYCLE
-            CASE('frs'         )   ;   CALL bdy_frs( idx_bdy(ib_bdy),                tra(:,:,:,jn), ztrc*zfac )
-            CASE('specified'   )   ;   CALL bdy_spe( idx_bdy(ib_bdy),                tra(:,:,:,jn), ztrc*zfac )
-            CASE('neumann'     )   ;   CALL bdy_nmn( idx_bdy(ib_bdy), igrd         , tra(:,:,:,jn) )
-            CASE('orlanski'    )   ;   CALL bdy_orl( idx_bdy(ib_bdy), trb(:,:,:,jn), tra(:,:,:,jn), ztrc*zfac, ll_npo=.false. )
-            CASE('orlanski_npo')   ;   CALL bdy_orl( idx_bdy(ib_bdy), trb(:,:,:,jn), tra(:,:,:,jn), ztrc*zfac, ll_npo=.true. )
-            CASE DEFAULT           ;   CALL ctl_stop( 'trc_bdy : unrecognised option for open boundaries for passive tracers' )
+      llsend1(:) = .false.  ;   llrecv1(:) = .false.
+      DO ir = 1, 0, -1   ! treat rim 1 before rim 0
+         IF( ir == 0 ) THEN   ;   llrim0 = .TRUE.
+         ELSE                 ;   llrim0 = .FALSE.
+         END IF
+         DO ib_bdy=1, nb_bdy
+            DO jn = 1, jptra
+               !
+               ztrc => trcdta_bdy(jn,ib_bdy)%trc 
+               zfac => trcdta_bdy(jn,ib_bdy)%rn_fac
+               !
+               SELECT CASE( TRIM(trcdta_bdy(jn,ib_bdy)%cn_obc) )
+               CASE('none'        )   ;   CYCLE
+               CASE('frs'         )   ! treat the whole boundary at once
+                  IF( ir == 0 ) CALL bdy_frs( idx_bdy(ib_bdy),                tra(:,:,:,jn), ztrc*zfac )
+               CASE('specified'   )   ! treat the whole rim      at once
+                  IF( ir == 0 ) CALL bdy_spe( idx_bdy(ib_bdy),                tra(:,:,:,jn), ztrc*zfac )
+               CASE('neumann'     )   ;   CALL bdy_nmn( idx_bdy(ib_bdy), igrd         , tra(:,:,:,jn) )   ! tra masked
+               CASE('orlanski'    )   ;   CALL bdy_orl( idx_bdy(ib_bdy), trb(:,:,:,jn), tra(:,:,:,jn), ztrc*zfac, ll_npo=.false. )
+               CASE('orlanski_npo')   ;   CALL bdy_orl( idx_bdy(ib_bdy), trb(:,:,:,jn), tra(:,:,:,jn), ztrc*zfac, ll_npo=.true. )
+               CASE DEFAULT           ;   CALL ctl_stop( 'trc_bdy : unrecognised option for open boundaries for passive tracers' )
+               END SELECT
+               !
+            END DO
+         END DO
+         !
+         IF( nn_hls > 1 .AND. ir == 1 ) CYCLE   ! at least 2 halos will be corrected -> no need to correct rim 1 before rim 0
+         IF( nn_hls == 1 ) THEN   ;   llsend1(:) = .false.   ;   llrecv1(:) = .false.   ;   END IF
+         DO ib_bdy=1, nb_bdy
+            SELECT CASE( TRIM(cn_tra(ib_bdy)) )
+            CASE('neumann')
+               llsend1(:) = llsend1(:) .OR. lsend_bdyint(ib_bdy,1,:,ir)   ! possibly every direction, T points
+               llrecv1(:) = llrecv1(:) .OR. lrecv_bdyint(ib_bdy,1,:,ir)   ! possibly every direction, T points
+            CASE('orlanski','orlanski_npo')
+               llsend1(:) = llsend1(:) .OR. lsend_bdy(ib_bdy,1,:,ir)   ! possibly every direction, T points
+               llrecv1(:) = llrecv1(:) .OR. lrecv_bdy(ib_bdy,1,:,ir)   ! possibly every direction, T points
             END SELECT
-            ! Boundary points should be updated
-            CALL lbc_bdy_lnk( 'trcbdy', tra(:,:,:,jn), 'T', 1., ib_bdy )
-            !
          END DO
-      END DO
+         IF( ANY(llsend1) .OR. ANY(llrecv1) ) THEN   ! if need to send/recv in at least one direction
+            CALL lbc_lnk( 'trcbdy', tra, 'T',  1., kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
+         END IF
+         !
+      END DO   ! ir
       !
       IF( ln_timing )   CALL timing_stop('trc_bdy')
-
+      !
    END SUBROUTINE trc_bdy
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcdta.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcdta.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcdta.F90	(revision 12143)
@@ -100,8 +100,8 @@
       REWIND( numnat_ref )              ! Namelist namtrc_dta in reference namelist : Passive tracer input data
       READ  ( numnat_ref, namtrc_dta, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_dta_ini in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_dta_ini in reference namelist' )
       REWIND( numnat_cfg )              ! Namelist namtrc_dta in configuration namelist : Passive tracer input data
       READ  ( numnat_cfg, namtrc_dta, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_dta_ini in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_dta_ini in configuration namelist' )
       IF(lwm) WRITE ( numont, namtrc_dta )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcice.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcice.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcice.F90	(revision 12143)
@@ -87,8 +87,8 @@
       REWIND( numnat_ref )              ! Namelist namtrc_ice in reference namelist : Passive tracer input data
       READ  ( numnat_ref, namtrc_ice, IOSTAT = ios, ERR = 901)
- 901  IF( ios /= 0 )   CALL ctl_nam ( ios , ' namtrc_ice in reference namelist ', lwp )
+ 901  IF( ios /= 0 )   CALL ctl_nam ( ios , ' namtrc_ice in reference namelist ' )
       REWIND( numnat_cfg )              ! Namelist namtrc_ice in configuration namelist : Pisces external sources of nutrients
       READ  ( numnat_cfg, namtrc_ice, IOSTAT = ios, ERR = 902 )
- 902  IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_ice in configuration namelist', lwp )
+ 902  IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_ice in configuration namelist' )
 
       IF( lwp ) THEN
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcnam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcnam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcnam.F90	(revision 12143)
@@ -114,8 +114,8 @@
       REWIND( numnat_ref )              ! Namelist namtrc in reference namelist : Passive tracer variables
       READ  ( numnat_ref, namtrc_run, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc in reference namelist' )
       REWIND( numnat_cfg )              ! Namelist namtrc in configuration namelist : Passive tracer variables
       READ  ( numnat_cfg, namtrc_run, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc in configuration namelist' )
       IF(lwm) WRITE( numont, namtrc_run )
 
@@ -160,8 +160,8 @@
       REWIND( numnat_ref )              ! Namelist namtrc in reference namelist : Passive tracer variables
       READ  ( numnat_ref, namtrc, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc in reference namelist' )
       REWIND( numnat_cfg )              ! Namelist namtrc in configuration namelist : Passive tracer variables
       READ  ( numnat_cfg, namtrc, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc in configuration namelist' )
       IF(lwm) WRITE( numont, namtrc )
 
@@ -263,8 +263,8 @@
       REWIND( numnat_ref )              ! Namelist namtrc_trd in reference namelist : Passive tracer trends
       READ  ( numnat_ref, namtrc_trd, IOSTAT = ios, ERR = 905)
-905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_trd in reference namelist', lwp )
+905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_trd in reference namelist' )
       REWIND( numnat_cfg )              ! Namelist namtrc_trd in configuration namelist : Passive tracer trends
       READ  ( numnat_cfg, namtrc_trd, IOSTAT = ios, ERR = 906 )
-906   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_trd in configuration namelist', lwp )
+906   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_trd in configuration namelist' )
       IF(lwm) WRITE( numont, namtrc_trd )
 
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcrst.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcrst.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/src/TOP/trcrst.F90	(revision 12143)
@@ -58,5 +58,5 @@
             IF( ln_rst_list ) THEN
                nrst_lst = 1
-               nitrst = nstocklist( nrst_lst )
+               nitrst = nn_stocklist( nrst_lst )
             ELSE
                nitrst = nitend
@@ -64,7 +64,7 @@
          ENDIF
 
-         IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nstock ) == 0 ) THEN
+         IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nn_stock ) == 0 ) THEN
             ! we use kt - 1 and not kt - nittrc000 to keep the same periodicity from the beginning of the experiment
-            nitrst = kt + nstock - 1                  ! define the next value of nitrst for restart writing
+            nitrst = kt + nn_stock - 1                  ! define the next value of nitrst for restart writing
             IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run
          ENDIF
@@ -72,9 +72,11 @@
          IF( kt == nittrc000 ) lrst_trc = .FALSE.
       ENDIF
+
+      IF( .NOT. ln_rst_list .AND. nn_stock == -1 )   RETURN   ! we will never do any restart
 
       ! to get better performances with NetCDF format:
       ! we open and define the tracer restart file one tracer time step before writing the data (-> at nitrst - 2*nn_dttrc + 1)
       ! except if we write tracer restart files every tracer time step or if a tracer restart file was writen at nitend - 2*nn_dttrc + 1
-      IF( kt == nitrst - 2*nn_dttrc .OR. nstock == nn_dttrc .OR. ( kt == nitend - nn_dttrc .AND. .NOT. lrst_trc ) ) THEN
+      IF( kt == nitrst - 2*nn_dttrc .OR. nn_stock == nn_dttrc .OR. ( kt == nitend - nn_dttrc .AND. .NOT. lrst_trc ) ) THEN
          ! beware of the format used to write kt (default is i8.8, that should be large enough)
          IF( nitrst > 1.0e9 ) THEN   ;   WRITE(clkt,*       ) nitrst
@@ -153,5 +155,5 @@
           IF( l_offline .AND. ln_rst_list ) THEN
              nrst_lst = nrst_lst + 1
-             nitrst = nstocklist( nrst_lst )
+             nitrst = nn_stocklist( nrst_lst )
           ENDIF
       ENDIF
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/best_jpni_jpnj_eorca025
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/best_jpni_jpnj_eorca025	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/best_jpni_jpnj_eorca025	(revision 12143)
@@ -624,2 +624,16 @@
     nb_cores 36180 ( 180 x 201 ), nb_points 80 ( 10 x 8 )
     nb_cores 38560 ( 160 x 241 ), nb_points 77 ( 11 x 7 )
+    nb_cores 41406 ( 206 x 201 ), nb_points 72 ( 9 x 8 )
+    nb_cores 43380 ( 180 x 241 ), nb_points 70 ( 10 x 7 )
+    nb_cores 48240 ( 240 x 201 ), nb_points 64 ( 8 x 8 )
+    nb_cores 49646 ( 206 x 241 ), nb_points 63 ( 9 x 7 )
+    nb_cores 54360 ( 180 x 302 ), nb_points 60 ( 10 x 6 )
+    nb_cores 54360 ( 360 x 151 ), nb_points 60 ( 6 x 10 )
+    nb_cores 57840 ( 240 x 241 ), nb_points 56 ( 8 x 7 )
+    nb_cores 62212 ( 206 x 302 ), nb_points 54 ( 9 x 6 )
+    nb_cores 69408 ( 288 x 241 ), nb_points 49 ( 7 x 7 )
+    nb_cores 72360 ( 360 x 201 ), nb_points 48 ( 6 x 8 )
+    nb_cores 82812 ( 206 x 402 ), nb_points 45 ( 9 x 5 )
+    nb_cores 86760 ( 360 x 241 ), nb_points 42 ( 6 x 7 )
+    nb_cores 96480 ( 240 x 402 ), nb_points 40 ( 8 x 5 )
+    nb_cores 96480 ( 480 x 201 ), nb_points 40 ( 5 x 8 )
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/best_jpni_jpnj_eorca12
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/best_jpni_jpnj_eorca12	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/best_jpni_jpnj_eorca12	(revision 12143)
@@ -1300,2 +1300,49 @@
     nb_cores 49852 ( 206 x 242 ), nb_points 345 ( 23 x 15 )
     nb_cores 49950 ( 270 x 185 ), nb_points 342 ( 18 x 19 )
+    nb_cores 50400 ( 288 x 175 ), nb_points 340 ( 17 x 20 )
+    nb_cores 50400 ( 240 x 210 ), nb_points 340 ( 20 x 17 )
+    nb_cores 51294 ( 309 x 166 ), nb_points 336 ( 16 x 21 )
+    nb_cores 52272 ( 216 x 242 ), nb_points 330 ( 22 x 15 )
+    nb_cores 53190 ( 270 x 197 ), nb_points 324 ( 18 x 18 )
+    nb_cores 53280 ( 288 x 185 ), nb_points 323 ( 17 x 19 )
+    nb_cores 54000 ( 240 x 225 ), nb_points 320 ( 20 x 16 )
+    nb_cores 55176 ( 228 x 242 ), nb_points 315 ( 21 x 15 )
+    nb_cores 56199 ( 393 x 143 ), nb_points 312 ( 13 x 24 )
+    nb_cores 56700 ( 270 x 210 ), nb_points 306 ( 18 x 17 )
+    nb_cores 57165 ( 309 x 185 ), nb_points 304 ( 16 x 19 )
+    nb_cores 58080 ( 240 x 242 ), nb_points 300 ( 20 x 15 )
+    nb_cores 58916 ( 206 x 286 ), nb_points 299 ( 23 x 13 )
+    nb_cores 59760 ( 360 x 166 ), nb_points 294 ( 14 x 21 )
+    nb_cores 60480 ( 288 x 210 ), nb_points 289 ( 17 x 17 )
+    nb_cores 60750 ( 270 x 225 ), nb_points 288 ( 18 x 16 )
+    nb_cores 61605 ( 333 x 185 ), nb_points 285 ( 15 x 19 )
+    nb_cores 63000 ( 360 x 175 ), nb_points 280 ( 14 x 20 )
+    nb_cores 64800 ( 288 x 225 ), nb_points 272 ( 17 x 16 )
+    nb_cores 65340 ( 270 x 242 ), nb_points 270 ( 18 x 15 )
+    nb_cores 66600 ( 360 x 185 ), nb_points 266 ( 14 x 19 )
+    nb_cores 68040 ( 216 x 315 ), nb_points 264 ( 22 x 12 )
+    nb_cores 68640 ( 240 x 286 ), nb_points 260 ( 20 x 13 )
+    nb_cores 69525 ( 309 x 225 ), nb_points 256 ( 16 x 16 )
+    nb_cores 69696 ( 288 x 242 ), nb_points 255 ( 17 x 15 )
+    nb_cores 70920 ( 360 x 197 ), nb_points 252 ( 14 x 18 )
+    nb_cores 72705 ( 393 x 185 ), nb_points 247 ( 13 x 19 )
+    nb_cores 74778 ( 309 x 242 ), nb_points 240 ( 16 x 15 )
+    nb_cores 75600 ( 360 x 210 ), nb_points 238 ( 14 x 17 )
+    nb_cores 77220 ( 270 x 286 ), nb_points 234 ( 18 x 13 )
+    nb_cores 79680 ( 480 x 166 ), nb_points 231 ( 11 x 21 )
+    nb_cores 79920 ( 432 x 185 ), nb_points 228 ( 12 x 19 )
+    nb_cores 80586 ( 333 x 242 ), nb_points 225 ( 15 x 15 )
+    nb_cores 81000 ( 360 x 225 ), nb_points 224 ( 14 x 16 )
+    nb_cores 82368 ( 288 x 286 ), nb_points 221 ( 17 x 13 )
+    nb_cores 84000 ( 480 x 175 ), nb_points 220 ( 11 x 20 )
+    nb_cores 84000 ( 240 x 350 ), nb_points 220 ( 20 x 11 )
+    nb_cores 85050 ( 270 x 315 ), nb_points 216 ( 18 x 12 )
+    nb_cores 87120 ( 360 x 242 ), nb_points 210 ( 14 x 15 )
+    nb_cores 88374 ( 309 x 286 ), nb_points 208 ( 16 x 13 )
+    nb_cores 90720 ( 288 x 315 ), nb_points 204 ( 17 x 12 )
+    nb_cores 90720 ( 432 x 210 ), nb_points 204 ( 12 x 17 )
+    nb_cores 94500 ( 270 x 350 ), nb_points 198 ( 18 x 11 )
+    nb_cores 94680 ( 360 x 263 ), nb_points 196 ( 14 x 14 )
+    nb_cores 95106 ( 393 x 242 ), nb_points 195 ( 13 x 15 )
+    nb_cores 97200 ( 432 x 225 ), nb_points 192 ( 12 x 16 )
+    nb_cores 99900 ( 540 x 185 ), nb_points 190 ( 10 x 19 )
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_cfg_orca025_like
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_cfg_orca025_like	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_cfg_orca025_like	(revision 12143)
@@ -9,6 +9,6 @@
    nn_it000    =       1   !  first time step
    nn_itend    =    1000   !  last time step 
-   nn_stock    =       0   !  frequency of creation of a restart file (modulo referenced to 1)
-   nn_write    =       0   !  frequency of write in the output file   (modulo referenced to nn_it000)
+   nn_stock    =      -1   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =      -1   !  frequency of write in the output file   (modulo referenced to nn_it000)
 /
 !-----------------------------------------------------------------------
@@ -30,5 +30,4 @@
 &namctl        !   Control prints                                       (default: OFF)
 !-----------------------------------------------------------------------
-   ln_ctl      = .false.   !  trends control print (expensive!)
    nn_print    =    0      !  level of print (0 no extra print)
    ln_timing   = .false.   !  timing by routine write out in timing.output file
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_cfg_orca12_like
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_cfg_orca12_like	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_cfg_orca12_like	(revision 12143)
@@ -9,6 +9,6 @@
    nn_it000    =       1   !  first time step
    nn_itend    =    1000   !  last time step 
-   nn_stock    =       0   !  frequency of creation of a restart file (modulo referenced to 1)
-   nn_write    =       0   !  frequency of write in the output file   (modulo referenced to nn_it000)
+   nn_stock    =      -1   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =      -1   !  frequency of write in the output file   (modulo referenced to nn_it000)
 /
 !-----------------------------------------------------------------------
@@ -30,5 +30,4 @@
 &namctl        !   Control prints                                       (default: OFF)
 !-----------------------------------------------------------------------
-   ln_ctl      = .false.   !  trends control print (expensive!)
    nn_print    =    0      !  level of print (0 no extra print)
    ln_timing   = .false.   !  timing by routine write out in timing.output file
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_cfg_orca1_like
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_cfg_orca1_like	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_cfg_orca1_like	(revision 12143)
@@ -9,6 +9,6 @@
    nn_it000    =       1   !  first time step
    nn_itend    =    1000   !  last time step 
-   nn_stock    =       0   !  frequency of creation of a restart file (modulo referenced to 1)
-   nn_write    =       0   !  frequency of write in the output file   (modulo referenced to nn_it000)
+   nn_stock    =      -1   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =      -1   !  frequency of write in the output file   (modulo referenced to nn_it000)
 /
 !-----------------------------------------------------------------------
@@ -30,5 +30,4 @@
 &namctl        !   Control prints                                       (default: OFF)
 !-----------------------------------------------------------------------
-   ln_ctl      = .false.   !  trends control print (expensive!)
    nn_print    =    0      !  level of print (0 no extra print)
    ln_timing   = .false.   !  timing by routine write out in timing.output file
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_ice_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_ice_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_ice_cfg	(revision 12143)
@@ -74,4 +74,5 @@
 &namini         !   Ice initialization
 !------------------------------------------------------------------------------
+   rn_thres_sst     =   0.5           !  max delta temp. above Tfreeze with initial ice = (sst - tfreeze)
 /
 !------------------------------------------------------------------------------
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_top_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_top_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/namelist_top_cfg	(revision 12143)
@@ -57,12 +57,12 @@
 !          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_trcdta(1)  = 'data_DIC_nomask'        ,        -12        ,  'DIC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(2)  = 'data_Alkalini_nomask'   ,        -12        ,  'Alkalini',    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(3)  = 'data_O2_nomask'         ,        -1         ,  'O2'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(5)  = 'data_PO4_nomask'        ,        -1         ,  'PO4'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(7)  = 'data_Si_nomask'         ,        -1         ,  'Si'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(10) = 'data_DOC_nomask'        ,        -12        ,  'DOC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(14) = 'data_Fer_nomask'        ,        -12        ,  'Fer'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
-   sn_trcdta(23) = 'data_NO3_nomask'        ,        -1         ,  'NO3'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(1)  = 'data_DIC_nomask'        ,        -12.       ,  'DIC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(2)  = 'data_Alkalini_nomask'   ,        -12.       ,  'Alkalini',    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(3)  = 'data_O2_nomask'         ,        -1.        ,  'O2'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(5)  = 'data_PO4_nomask'        ,        -1.        ,  'PO4'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(7)  = 'data_Si_nomask'         ,        -1.        ,  'Si'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(10) = 'data_DOC_nomask'        ,        -12.       ,  'DOC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(14) = 'data_Fer_nomask'        ,        -12.       ,  'Fer'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(23) = 'data_NO3_nomask'        ,        -1.        ,  'NO3'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
    rn_trfac(1)   =   1.0e-06  !  multiplicative factor
    rn_trfac(2)   =   1.0e-06  !  -      -      -     -
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/sh_bench
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/sh_bench	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/sh_bench	(revision 12143)
@@ -9,4 +9,5 @@
 machine=$( hostname | sed -e "s/[0-9]*//g" )
 case $machine in 
+    "jean-zay")     ncore_node=40 ;;
     "beaufixlogin") ncore_node=40 ;;
     "curie")        ncore_node=16 ;;
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/submit_bench
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/submit_bench	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/EXPREF/submit_bench	(revision 12143)
@@ -6,5 +6,5 @@
 #
 set -u
-set -vx
+#set -vx
 #
 cores=$1
@@ -15,10 +15,73 @@
 #
 # number of processes for each executable
-    nproc_exe1=$( echo $cores | bc )
-  (( nproc = $nproc_exe1 ))
-(( nnode = $nproc / $ncore_node ))
-[ $nnode -lt 1 ] && nnode=1
+nproc_exe1=$( echo $cores | bc )
+nproc=$nproc_exe1
+nnode=$(( ( $nproc + $ncore_node - 1 )  / $ncore_node ))
 
 nproc5=$( printf "%05d\n" ${nproc_exe1} )
+
+case ${resolution} in
+    "1")
+	if [ $nproc_exe1 -lt 50 ]
+	then
+	    timejob=3600
+	elif [ $nproc_exe1 -lt 100 ]
+	then
+	    timejob=1800
+	elif [ $nproc_exe1 -lt 200 ]
+	then
+	    timejob=900
+	else
+	    timejob=600
+	fi
+	;;
+    "025")
+	if [ $nproc_exe1 -lt 50 ]
+	then
+	    timejob=15000
+	elif [ $nproc_exe1 -lt 100 ]
+	then
+	    timejob=7000
+	elif [ $nproc_exe1 -lt 200 ]
+	then
+	    timejob=3600
+	elif [ $nproc_exe1 -lt 400 ]
+	then
+	    timejob=2000
+	elif [ $nproc_exe1 -lt 800 ]
+	then
+	    timejob=1000
+	else
+	    timejob=600
+	fi
+	;;
+    "12")
+	if [ $nproc_exe1 -lt 200 ]
+	then
+	    timejob=30000
+	elif [ $nproc_exe1 -lt 400 ]
+	then
+	    timejob=15000
+	elif [ $nproc_exe1 -lt 800 ]
+	then
+	    timejob=20000
+	elif [ $nproc_exe1 -lt 1600 ]
+	then
+	    timejob=15000
+	elif [ $nproc_exe1 -lt 3200 ]
+	then
+	    timejob=7500
+	elif [ $nproc_exe1 -lt 10000 ]
+	then
+	    timejob=5000
+	elif [ $nproc_exe1 -lt 20000 ]
+	then
+	    timejob=2500
+	else
+	    timejob=1200
+	fi
+	;;
+esac
+
 
 ######################################################################
@@ -100,65 +163,11 @@
 if [[ ( "$machine" == "curie" ) || ( "$machine" == "irene" ) ]]
 then
-    
-    case ${resolution} in
-	"1")
-	    if [ $nproc_exe1 -lt 50 ]
-	    then
-		timejob=3600
-	    elif [ $nproc_exe1 -lt 100 ]
-	    then
-		timejob=1800
-	    elif [ $nproc_exe1 -lt 200 ]
-	    then
-		timejob=900
-	    else
-		timejob=600
-	    fi
-	    ;;
-	"025")
-	    if [ $nproc_exe1 -lt 50 ]
-	    then
-		timejob=15000
-	    elif [ $nproc_exe1 -lt 100 ]
-	    then
-		timejob=7000
-	    elif [ $nproc_exe1 -lt 200 ]
-	    then
-		timejob=3600
-	    elif [ $nproc_exe1 -lt 400 ]
-	    then
-		timejob=2000
-	    elif [ $nproc_exe1 -lt 800 ]
-	    then
-		timejob=1000
-	    else
-		timejob=600
-	    fi
-	    ;;
-	"12")
-	    if [ $nproc_exe1 -lt 200 ]
-	    then
-		timejob=30000
-	    elif [ $nproc_exe1 -lt 400 ]
-	    then
-		timejob=15000
-	    elif [ $nproc_exe1 -lt 800 ]
-	    then
-		timejob=8000
-	    elif [ $nproc_exe1 -lt 1600 ]
-	    then
-		timejob=5000
-	    elif [ $nproc_exe1 -lt 3200 ]
-	    then
-		timejob=2500
-	    else
-		timejob=1200
-	    fi
-	;;
-    esac
 
     [ "$machine" == "curie" ] && queuename=standard || queuename=skylake
     
-    jobname=$HOME/binrun/jobbench
+    EXPjob=../EXP_${resolution}_${nproc5}_${dateref}
+    mkdir -p ${EXPjob}
+    cd ${EXPjob}
+    jobname=jobbench
     cat > $jobname << EOF
 #!/bin/bash
@@ -176,18 +185,20 @@
 #
 
-cd \${BRIDGE_MSUB_PWD}/..
-
-
-EXPjob=EXP_${resolution}_${nproc5}_${dateref}
-rsync -av --exclude="*eo" EXPREF/ \${EXPjob}/
-rsync -av EXP00/nemo \${EXPjob}/nemo
-cd \${EXPjob}
+cd \${BRIDGE_MSUB_PWD}
+
+for ff in \${BRIDGE_MSUB_PWD}/../EXPREF/namelist_*cfg \${BRIDGE_MSUB_PWD}/../EXPREF/namelist_*ref \${BRIDGE_MSUB_PWD}/../BLD/bin/nemo.exe
+do
+    cp \$ff .
+done
 
 jpni=${cores/\**/}
 jpnj=${cores/?*\*/}
 
-sed -e "s/jpni *=.*/jpni = \${jpni}/" -e "s/jpnj *=.*/jpnj = \${jpnj}/" namelist_cfg_orca${resolution}_like > namelist_cfg
-
-time ccc_mprun -n \${BRIDGE_MSUB_NPROC} ./nemo > jobout_${resolution}_${nproc5}_${dateref}
+sed -e "s/jpni *=.*/jpni = \${jpni}/" \
+    -e "s/jpnj *=.*/jpnj = \${jpnj}/"\
+    -e "s/ln_timing *= *.false./ln_timing   =  .true./" \
+     \${BRIDGE_MSUB_PWD}/../EXPREF/namelist_cfg_orca${resolution}_like > namelist_cfg
+
+time ccc_mprun -n \${BRIDGE_MSUB_NPROC} ./nemo.exe > jobout_${resolution}_${nproc5}_${dateref} 2>&1
 
 EOF
@@ -196,2 +207,70 @@
 
 fi
+
+######################################################################
+### Jean-Zay
+######################################################################
+
+if [ "$machine" == "jean-zay" ]
+then
+    hh=$( printf "%02d\n" $(( ${timejob} / 3600 )) )
+    mm=$( printf "%02d\n" $(( ( ${timejob} % 3600 ) / 60 )) )
+    ss=$( printf "%02d\n" $(( ( ${timejob} % 3600 ) % 60 )) )
+
+    EXPjob=../EXP_${resolution}_${nproc5}_${dateref}
+    mkdir -p ${EXPjob}
+    cd ${EXPjob}
+    jobname=jobbench
+    cat > $jobname << EOF
+#!/bin/bash
+#SBATCH --job-name=Seq        # nom du job
+#SBATCH --partition=cpu_gct3   # demande d'allocation sur la partition CPU
+#SBATCH --nodes=${nnode}             # nombre de noeuds
+#SBATCH --ntasks-per-node=${ncore_node}  # nombre de taches MPI par noeud
+#SBATCH --ntasks-per-core=1        # 1 processus MPI par coeur physique (pas d'hyperthreading)
+#SBATCH --time=${hh}:${mm}:${ss}       # temps d execution maximum demande (HH:MM:SS)
+#SBATCH --output=bench_${resolution}_${nproc5}_%j.eo        # nom du fichier de sortie
+#SBATCH --error=bench_${resolution}_${nproc5}_%j.eo         # nom du fichier d'erreur (ici en commun avec la sortie)
+#==========================================
+set -u
+#set -xv
+#
+#cd \${SLURM_SUBMIT_DIR}
+cd \${JOBSCRATCH}
+pwd
+
+for ff in \${SLURM_SUBMIT_DIR}/../EXPREF/namelist_*cfg \${SLURM_SUBMIT_DIR}/../EXPREF/namelist_*ref \${SLURM_SUBMIT_DIR}/../BLD/bin/nemo.exe
+do
+    cp \$ff .
+done
+
+jpni=${cores/\**/}
+jpnj=${cores/?*\*/}
+
+sed -e "s/jpni *=.*/jpni = \${jpni}/" \
+    -e "s/jpnj *=.*/jpnj = \${jpnj}/" \
+    -e "s/ln_timing *= *.false./ln_timing   =  .true./" \
+    \${SLURM_SUBMIT_DIR}/../EXPREF/namelist_cfg_orca${resolution}_like > namelist_cfg
+
+ls -l
+
+echo 
+echo 
+echo " =========== start the model ==========="
+echo 
+echo 
+
+time srun --mpi=pmi2 --cpu-bind=cores -K1 -n ${nproc} ./nemo.exe > jobout_${resolution}_${nproc5}_${dateref} 2>&1
+
+ls -l
+
+if [ "\$( pwd )" != "\${SLURM_SUBMIT_DIR}" ]
+then 
+    rsync -av namelist_cfg time.step ocean.output jobout_${resolution}_${nproc5}_${dateref} communication_report.txt layout.dat timing.output output.namelist* \${SLURM_SUBMIT_DIR}
+fi
+
+EOF
+
+    sbatch $jobname
+
+fi
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/diawri.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/diawri.F90	(revision 12062)
+++ 	(revision )
@@ -1,491 +1,0 @@
-MODULE diawri
-   !!======================================================================
-   !!                     ***  MODULE  diawri  ***
-   !! Ocean diagnostics :  write ocean output files
-   !!=====================================================================
-   !! History :  OPA  ! 1991-03  (M.-A. Foujols)  Original code
-   !!            4.0  ! 1991-11  (G. Madec)
-   !!                 ! 1992-06  (M. Imbard)  correction restart file
-   !!                 ! 1992-07  (M. Imbard)  split into diawri and rstwri
-   !!                 ! 1993-03  (M. Imbard)  suppress writibm
-   !!                 ! 1998-01  (C. Levy)  NETCDF format using ioipsl INTERFACE
-   !!                 ! 1999-02  (E. Guilyardi)  name of netCDF files + variables
-   !!            8.2  ! 2000-06  (M. Imbard)  Original code (diabort.F)
-   !!   NEMO     1.0  ! 2002-06  (A.Bozec, E. Durand)  Original code (diainit.F)
-   !!             -   ! 2002-09  (G. Madec)  F90: Free form and module
-   !!             -   ! 2002-12  (G. Madec)  merge of diabort and diainit, F90
-   !!                 ! 2005-11  (V. Garnier) Surface pressure gradient organization
-   !!            3.2  ! 2008-11  (B. Lemaire) creation from old diawri
-   !!            3.7  ! 2014-01  (G. Madec) remove eddy induced velocity from no-IOM output
-   !!                 !                     change name of output variables in dia_wri_state
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   dia_wri       : create the standart output files
-   !!   dia_wri_state : create an output NetCDF file for a single instantaeous ocean state and forcing fields
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers 
-   USE dom_oce        ! ocean space and time domain
-   USE phycst         ! physical constants
-   USE dianam         ! build name of file (routine)
-   USE diahth         ! thermocline diagnostics
-   USE dynadv   , ONLY: ln_dynadv_vec
-   USE icb_oce        ! Icebergs
-   USE icbdia         ! Iceberg budgets
-   USE ldftra         ! lateral physics: eddy diffusivity coef.
-   USE ldfdyn         ! lateral physics: eddy viscosity   coef.
-   USE sbc_oce        ! Surface boundary condition: ocean fields
-   USE sbc_ice        ! Surface boundary condition: ice fields
-   USE sbcssr         ! restoring term toward SST/SSS climatology
-   USE sbcwave        ! wave parameters
-   USE wet_dry        ! wetting and drying
-   USE zdf_oce        ! ocean vertical physics
-   USE zdfdrg         ! ocean vertical physics: top/bottom friction
-   USE zdfmxl         ! mixed layer
-   !
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE in_out_manager ! I/O manager
-   USE diatmb         ! Top,middle,bottom output
-   USE dia25h         ! 25h Mean output
-   USE iom            ! 
-   USE ioipsl         ! 
-
-#if defined key_si3
-   USE ice
-   USE icewri 
-#endif
-   USE lib_mpp         ! MPP library
-   USE timing          ! preformance summary
-   USE diurnal_bulk    ! diurnal warm layer
-   USE cool_skin       ! Cool skin
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   dia_wri                 ! routines called by step.F90
-   PUBLIC   dia_wri_state
-   PUBLIC   dia_wri_alloc           ! Called by nemogcm module
-
-   INTEGER ::   nid_T, nz_T, nh_T, ndim_T, ndim_hT   ! grid_T file
-   INTEGER ::          nb_T              , ndim_bT   ! grid_T file
-   INTEGER ::   nid_U, nz_U, nh_U, ndim_U, ndim_hU   ! grid_U file
-   INTEGER ::   nid_V, nz_V, nh_V, ndim_V, ndim_hV   ! grid_V file
-   INTEGER ::   nid_W, nz_W, nh_W                    ! grid_W file
-   INTEGER ::   ndex(1)                              ! ???
-   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_hT, ndex_hU, ndex_hV
-   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_T, ndex_U, ndex_V
-   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_bT
-
-   !! * Substitutions
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: diawri.F90 9598 2018-05-15 22:47:16Z nicolasmartin $
-   !! Software governed by the CeCILL licence     (./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-#if defined key_iomput
-   !!----------------------------------------------------------------------
-   !!   'key_iomput'                                        use IOM library
-   !!----------------------------------------------------------------------
-   INTEGER FUNCTION dia_wri_alloc()
-      !
-      dia_wri_alloc = 0
-      !
-   END FUNCTION dia_wri_alloc
-
-   
-   SUBROUTINE dia_wri( kt )
-      !!---------------------------------------------------------------------
-      !!                  ***  ROUTINE dia_wri  ***
-      !!                   
-      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
-      !!      NETCDF format is used by default 
-      !!
-      !! ** Method  :  use iom_put
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
-      !!
-      INTEGER ::   ji, jj, jk       ! dummy loop indices
-      INTEGER ::   ikbot            ! local integer
-      REAL(wp)::   zztmp , zztmpx   ! local scalar
-      REAL(wp)::   zztmp2, zztmpy   !   -      -
-      REAL(wp), DIMENSION(jpi,jpj)     ::   z2d   ! 2D workspace
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   z3d   ! 3D workspace
-      !!----------------------------------------------------------------------
-      ! 
-      IF( ln_timing )   CALL timing_start('dia_wri')
-      ! 
-      ! Output the initial state and forcings
-      IF( ninist == 1 ) THEN                       
-         CALL dia_wri_state( 'output.init' )
-         ninist = 0
-      ENDIF
-
-      ! Output of initial vertical scale factor
-      CALL iom_put("e3t_0", e3t_0(:,:,:) )
-      CALL iom_put("e3u_0", e3u_0(:,:,:) )
-      CALL iom_put("e3v_0", e3v_0(:,:,:) )
-      !
-      CALL iom_put( "e3t" , e3t_n(:,:,:) )
-      CALL iom_put( "e3u" , e3u_n(:,:,:) )
-      CALL iom_put( "e3v" , e3v_n(:,:,:) )
-      CALL iom_put( "e3w" , e3w_n(:,:,:) )
-      IF( iom_use("e3tdef") )   &
-         CALL iom_put( "e3tdef"  , ( ( e3t_n(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2 )
-
-      IF( ll_wd ) THEN
-         CALL iom_put( "ssh" , (sshn+ssh_ref)*tmask(:,:,1) )   ! sea surface height (brought back to the reference used for wetting and drying)
-      ELSE
-         CALL iom_put( "ssh" , sshn )              ! sea surface height
-      ENDIF
-
-      IF( iom_use("wetdep") )   &                  ! wet depth
-         CALL iom_put( "wetdep" , ht_0(:,:) + sshn(:,:) )
-      
-      CALL iom_put( "toce", tsn(:,:,:,jp_tem) )    ! 3D temperature
-      CALL iom_put(  "sst", tsn(:,:,1,jp_tem) )    ! surface temperature
-      IF ( iom_use("sbt") ) THEN
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               ikbot = mbkt(ji,jj)
-               z2d(ji,jj) = tsn(ji,jj,ikbot,jp_tem)
-            END DO
-         END DO
-         CALL iom_put( "sbt", z2d )                ! bottom temperature
-      ENDIF
-      
-      CALL iom_put( "soce", tsn(:,:,:,jp_sal) )    ! 3D salinity
-      CALL iom_put(  "sss", tsn(:,:,1,jp_sal) )    ! surface salinity
-      IF ( iom_use("sbs") ) THEN
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               ikbot = mbkt(ji,jj)
-               z2d(ji,jj) = tsn(ji,jj,ikbot,jp_sal)
-            END DO
-         END DO
-         CALL iom_put( "sbs", z2d )                ! bottom salinity
-      ENDIF
-
-      IF ( iom_use("taubot") ) THEN                ! bottom stress
-         zztmp = rau0 * 0.25
-         z2d(:,:) = 0._wp
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zztmp2 = (  ( rCdU_bot(ji+1,jj)+rCdU_bot(ji  ,jj) ) * un(ji  ,jj,mbku(ji  ,jj))  )**2   &
-                  &   + (  ( rCdU_bot(ji  ,jj)+rCdU_bot(ji-1,jj) ) * un(ji-1,jj,mbku(ji-1,jj))  )**2   &
-                  &   + (  ( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj  ) ) * vn(ji,jj  ,mbkv(ji,jj  ))  )**2   &
-                  &   + (  ( rCdU_bot(ji,jj  )+rCdU_bot(ji,jj-1) ) * vn(ji,jj-1,mbkv(ji,jj-1))  )**2
-               z2d(ji,jj) = zztmp * SQRT( zztmp2 ) * tmask(ji,jj,1) 
-               !
-            END DO
-         END DO
-         CALL lbc_lnk( 'diawri', z2d, 'T', 1. )
-         CALL iom_put( "taubot", z2d )           
-      ENDIF
-         
-      CALL iom_put( "uoce", un(:,:,:) )            ! 3D i-current
-      CALL iom_put(  "ssu", un(:,:,1) )            ! surface i-current
-      IF ( iom_use("sbu") ) THEN
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               ikbot = mbku(ji,jj)
-               z2d(ji,jj) = un(ji,jj,ikbot)
-            END DO
-         END DO
-         CALL iom_put( "sbu", z2d )                ! bottom i-current
-      ENDIF
-      
-      CALL iom_put( "voce", vn(:,:,:) )            ! 3D j-current
-      CALL iom_put(  "ssv", vn(:,:,1) )            ! surface j-current
-      IF ( iom_use("sbv") ) THEN
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               ikbot = mbkv(ji,jj)
-               z2d(ji,jj) = vn(ji,jj,ikbot)
-            END DO
-         END DO
-         CALL iom_put( "sbv", z2d )                ! bottom j-current
-      ENDIF
-
-      CALL iom_put( "woce", wn )                   ! vertical velocity
-      IF( iom_use('w_masstr') .OR. iom_use('w_masstr2') ) THEN   ! vertical mass transport & its square value
-         ! Caution: in the VVL case, it only correponds to the baroclinic mass transport.
-         z2d(:,:) = rau0 * e1e2t(:,:)
-         DO jk = 1, jpk
-            z3d(:,:,jk) = wn(:,:,jk) * z2d(:,:)
-         END DO
-         CALL iom_put( "w_masstr" , z3d )  
-         IF( iom_use('w_masstr2') )   CALL iom_put( "w_masstr2", z3d(:,:,:) * z3d(:,:,:) )
-      ENDIF
-
-      CALL iom_put( "avt" , avt )                  ! T vert. eddy diff. coef.
-      CALL iom_put( "avs" , avs )                  ! S vert. eddy diff. coef.
-      CALL iom_put( "avm" , avm )                  ! T vert. eddy visc. coef.
-
-      IF( iom_use('logavt') )   CALL iom_put( "logavt", LOG( MAX( 1.e-20_wp, avt(:,:,:) ) ) )
-      IF( iom_use('logavs') )   CALL iom_put( "logavs", LOG( MAX( 1.e-20_wp, avs(:,:,:) ) ) )
-
-      IF ( iom_use("sstgrad") .OR. iom_use("sstgrad2") ) THEN
-         DO jj = 2, jpjm1                                    ! sst gradient
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zztmp  = tsn(ji,jj,1,jp_tem)
-               zztmpx = ( tsn(ji+1,jj,1,jp_tem) - zztmp ) * r1_e1u(ji,jj) + ( zztmp - tsn(ji-1,jj  ,1,jp_tem) ) * r1_e1u(ji-1,jj)
-               zztmpy = ( tsn(ji,jj+1,1,jp_tem) - zztmp ) * r1_e2v(ji,jj) + ( zztmp - tsn(ji  ,jj-1,1,jp_tem) ) * r1_e2v(ji,jj-1)
-               z2d(ji,jj) = 0.25 * ( zztmpx * zztmpx + zztmpy * zztmpy )   &
-                  &              * umask(ji,jj,1) * umask(ji-1,jj,1) * vmask(ji,jj,1) * umask(ji,jj-1,1)
-            END DO
-         END DO
-         CALL lbc_lnk( 'diawri', z2d, 'T', 1. )
-         CALL iom_put( "sstgrad2",  z2d )          ! square of module of sst gradient
-         z2d(:,:) = SQRT( z2d(:,:) )
-         CALL iom_put( "sstgrad" ,  z2d )          ! module of sst gradient
-      ENDIF
-         
-      ! heat and salt contents
-      IF( iom_use("heatc") ) THEN
-         z2d(:,:)  = 0._wp 
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_tem) * tmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         CALL iom_put( "heatc", rau0_rcp * z2d )   ! vertically integrated heat content (J/m2)
-      ENDIF
-
-      IF( iom_use("saltc") ) THEN
-         z2d(:,:)  = 0._wp 
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_sal) * tmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         CALL iom_put( "saltc", rau0 * z2d )          ! vertically integrated salt content (PSU*kg/m2)
-      ENDIF
-      !
-      IF ( iom_use("eken") ) THEN
-         z3d(:,:,jpk) = 0._wp 
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zztmp  = 0.25_wp * r1_e1e2t(ji,jj) / e3t_n(ji,jj,jk)
-                  z3d(ji,jj,jk) = zztmp * (  un(ji-1,jj,jk)**2 * e2u(ji-1,jj) * e3u_n(ji-1,jj,jk)   &
-                     &                     + un(ji  ,jj,jk)**2 * e2u(ji  ,jj) * e3u_n(ji  ,jj,jk)   &
-                     &                     + vn(ji,jj-1,jk)**2 * e1v(ji,jj-1) * e3v_n(ji,jj-1,jk)   &
-                     &                     + vn(ji,jj  ,jk)**2 * e1v(ji,jj  ) * e3v_n(ji,jj  ,jk)   )
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( 'diawri', z3d, 'T', 1. )
-         CALL iom_put( "eken", z3d )                 ! kinetic energy
-      ENDIF
-      !
-      CALL iom_put( "hdiv", hdivn )                  ! Horizontal divergence
-      !
-      IF( iom_use("u_masstr") .OR. iom_use("u_masstr_vint") .OR. iom_use("u_heattr") .OR. iom_use("u_salttr") ) THEN
-         z3d(:,:,jpk) = 0.e0
-         z2d(:,:) = 0.e0
-         DO jk = 1, jpkm1
-            z3d(:,:,jk) = rau0 * un(:,:,jk) * e2u(:,:) * e3u_n(:,:,jk) * umask(:,:,jk)
-            z2d(:,:) = z2d(:,:) + z3d(:,:,jk)
-         END DO
-         CALL iom_put( "u_masstr"     , z3d )         ! mass transport in i-direction
-         CALL iom_put( "u_masstr_vint", z2d )         ! mass transport in i-direction vertical sum
-      ENDIF
-      
-      IF( iom_use("u_heattr") ) THEN
-         z2d(:,:) = 0._wp 
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_tem) + tsn(ji+1,jj,jk,jp_tem) )
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( 'diawri', z2d, 'U', -1. )
-         CALL iom_put( "u_heattr", 0.5*rcp * z2d )    ! heat transport in i-direction
-      ENDIF
-
-      IF( iom_use("u_salttr") ) THEN
-         z2d(:,:) = 0.e0 
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_sal) + tsn(ji+1,jj,jk,jp_sal) )
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( 'diawri', z2d, 'U', -1. )
-         CALL iom_put( "u_salttr", 0.5 * z2d )        ! heat transport in i-direction
-      ENDIF
-
-      
-      IF( iom_use("v_masstr") .OR. iom_use("v_heattr") .OR. iom_use("v_salttr") ) THEN
-         z3d(:,:,jpk) = 0.e0
-         DO jk = 1, jpkm1
-            z3d(:,:,jk) = rau0 * vn(:,:,jk) * e1v(:,:) * e3v_n(:,:,jk) * vmask(:,:,jk)
-         END DO
-         CALL iom_put( "v_masstr", z3d )              ! mass transport in j-direction
-      ENDIF
-      
-      IF( iom_use("v_heattr") ) THEN
-         z2d(:,:) = 0.e0 
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_tem) + tsn(ji,jj+1,jk,jp_tem) )
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( 'diawri', z2d, 'V', -1. )
-         CALL iom_put( "v_heattr", 0.5*rcp * z2d )    !  heat transport in j-direction
-      ENDIF
-
-      IF( iom_use("v_salttr") ) THEN
-         z2d(:,:) = 0._wp 
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( tsn(ji,jj,jk,jp_sal) + tsn(ji,jj+1,jk,jp_sal) )
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( 'diawri', z2d, 'V', -1. )
-         CALL iom_put( "v_salttr", 0.5 * z2d )        !  heat transport in j-direction
-      ENDIF
-
-      IF( iom_use("tosmint") ) THEN
-         z2d(:,:) = 0._wp
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) *  tsn(ji,jj,jk,jp_tem)
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( 'diawri', z2d, 'T', -1. )
-         CALL iom_put( "tosmint", rau0 * z2d )        ! Vertical integral of temperature
-      ENDIF
-      IF( iom_use("somint") ) THEN
-         z2d(:,:)=0._wp
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  z2d(ji,jj) = z2d(ji,jj) + e3t_n(ji,jj,jk) * tsn(ji,jj,jk,jp_sal)
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( 'diawri', z2d, 'T', -1. )
-         CALL iom_put( "somint", rau0 * z2d )         ! Vertical integral of salinity
-      ENDIF
-
-      CALL iom_put( "bn2", rn2 )                      ! Brunt-Vaisala buoyancy frequency (N^2)
-      !
-
-      IF (ln_diatmb)   CALL dia_tmb                   ! tmb values 
-          
-      IF (ln_dia25h)   CALL dia_25h( kt )             ! 25h averaging
-
-      IF( ln_timing )   CALL timing_stop('dia_wri')
-      !
-   END SUBROUTINE dia_wri
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option                                  use IOIPSL  library
-   !!----------------------------------------------------------------------
-
-   INTEGER FUNCTION dia_wri_alloc()
-      !
-      dia_wri_alloc = 0
-      !
-   END FUNCTION dia_wri_alloc
-
-   SUBROUTINE dia_wri( kt )
-      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
-
-      IF( ninist == 1 ) THEN     !==  Output the initial state and forcings  ==!
-         CALL dia_wri_state( 'output.init' )
-         ninist = 0
-      ENDIF
-
-   END SUBROUTINE dia_wri
-
-#endif
-
-   SUBROUTINE dia_wri_state( cdfile_name )
-      !!---------------------------------------------------------------------
-      !!                 ***  ROUTINE dia_wri_state  ***
-      !!        
-      !! ** Purpose :   create a NetCDF file named cdfile_name which contains 
-      !!      the instantaneous ocean state and forcing fields.
-      !!        Used to find errors in the initial state or save the last
-      !!      ocean state in case of abnormal end of a simulation
-      !!
-      !! ** Method  :   NetCDF files using ioipsl
-      !!      File 'output.init.nc'  is created if ninist = 1 (namelist)
-      !!      File 'output.abort.nc' is created in case of abnormal job end
-      !!----------------------------------------------------------------------
-      CHARACTER (len=* ), INTENT( in ) ::   cdfile_name      ! name of the file created
-      !!
-      INTEGER :: inum
-      !!----------------------------------------------------------------------
-      ! 
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'dia_wri_state : single instantaneous ocean state'
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~   and forcing fields file created '
-      IF(lwp) WRITE(numout,*) '                and named :', cdfile_name, '...nc'
-
-#if defined key_si3
-     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl )
-#else
-     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. )
-#endif
-
-      CALL iom_rstput( 0, 0, inum, 'votemper', tsn(:,:,:,jp_tem) )    ! now temperature
-      CALL iom_rstput( 0, 0, inum, 'vosaline', tsn(:,:,:,jp_sal) )    ! now salinity
-      CALL iom_rstput( 0, 0, inum, 'sossheig', sshn              )    ! sea surface height
-      CALL iom_rstput( 0, 0, inum, 'vozocrtx', un                )    ! now i-velocity
-      CALL iom_rstput( 0, 0, inum, 'vomecrty', vn                )    ! now j-velocity
-      CALL iom_rstput( 0, 0, inum, 'vovecrtz', wn                )    ! now k-velocity
-      IF( ALLOCATED(ahtu) ) THEN
-         CALL iom_rstput( 0, 0, inum,  'ahtu', ahtu              )    ! aht at u-point
-         CALL iom_rstput( 0, 0, inum,  'ahtv', ahtv              )    ! aht at v-point
-      ENDIF
-      IF( ALLOCATED(ahmt) ) THEN
-         CALL iom_rstput( 0, 0, inum,  'ahmt', ahmt              )    ! ahmt at u-point
-         CALL iom_rstput( 0, 0, inum,  'ahmf', ahmf              )    ! ahmf at v-point
-      ENDIF
-      CALL iom_rstput( 0, 0, inum, 'sowaflup', emp - rnf         )    ! freshwater budget
-      CALL iom_rstput( 0, 0, inum, 'sohefldo', qsr + qns         )    ! total heat flux
-      CALL iom_rstput( 0, 0, inum, 'soshfldo', qsr               )    ! solar heat flux
-      CALL iom_rstput( 0, 0, inum, 'soicecov', fr_i              )    ! ice fraction
-      CALL iom_rstput( 0, 0, inum, 'sozotaux', utau              )    ! i-wind stress
-      CALL iom_rstput( 0, 0, inum, 'sometauy', vtau              )    ! j-wind stress
-      IF(  .NOT.ln_linssh  ) THEN             
-         CALL iom_rstput( 0, 0, inum, 'vovvldep', gdept_n        )    !  T-cell depth 
-         CALL iom_rstput( 0, 0, inum, 'vovvle3t', e3t_n          )    !  T-cell thickness  
-      END IF
-      IF( ln_wave .AND. ln_sdw ) THEN
-         CALL iom_rstput( 0, 0, inum, 'sdzocrtx', usd            )    ! now StokesDrift i-velocity
-         CALL iom_rstput( 0, 0, inum, 'sdmecrty', vsd            )    ! now StokesDrift j-velocity
-         CALL iom_rstput( 0, 0, inum, 'sdvecrtz', wsd            )    ! now StokesDrift k-velocity
-      ENDIF
- 
-#if defined key_si3
-      IF( nn_ice == 2 ) THEN   ! condition needed in case agrif + ice-model but no-ice in child grid
-         CALL ice_wri_state( inum )
-      ENDIF
-#endif
-      !
-      CALL iom_close( inum )
-      ! 
-   END SUBROUTINE dia_wri_state
-
-   !!======================================================================
-END MODULE diawri
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/usrdef_istate.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/usrdef_istate.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/usrdef_istate.F90	(revision 12143)
@@ -64,5 +64,5 @@
       DO jj = 1, jpj
          DO ji = 1, jpi
-            z2d(ji,jj) = 0.1 * ( 0.5 - REAL( nimpp + ji - 1 + ( njmpp + jj - 2 ) * jpiglo, wp ) / REAL( jpiglo * jpjglo, wp ) )
+            z2d(ji,jj) = 0.1 * ( 0.5 - REAL( mig(ji) + mjg(jj) * jpiglo, wp ) / REAL( jpiglo * jpjglo, wp ) )
          ENDDO
       ENDDO
@@ -73,7 +73,6 @@
       DO jk = 1, jpk
          zfact = REAL(jk-1,wp) / REAL(jpk-1,wp)   ! 0 to 1 to add a basic stratification
-         ! temperature choosen to lead to 20% ice
-         pts(:,:,jk,jp_tem) = 2._wp - 0.1_wp * zfact + z2d(:,:) * 100._wp ! 2 to 1.9 +/- 5 degG
-         WHERE ( pts(:,:,jk,jp_tem) < -1.5_wp ) pts(:,:,jk,jp_tem) = -1.5_wp + z2d(:,:) * 0.2_wp  
+         ! temperature choosen to lead to ~50% ice at the beginning if rn_thres_sst = 0.5
+         pts(:,:,jk,jp_tem) = 20._wp*z2d(:,:) - 1._wp - 0.5_wp * zfact    ! -1 to -1.5 +/-1.0 degG
          ! salinity:  
          pts(:,:,jk,jp_sal) = 30._wp + 1._wp * zfact + z2d(:,:)           ! 30 to 31 +/- 0.05 psu
@@ -84,7 +83,7 @@
       !
       CALL lbc_lnk('usrdef_istate', pssh, 'T',  1. )            ! apply boundary conditions
-      CALL lbc_lnk( 'usrdef_istate', pts, 'T',  1. )            ! apply boundary conditions
-      CALL lbc_lnk(  'usrdef_istate', pu, 'U', -1. )            ! apply boundary conditions
-      CALL lbc_lnk(  'usrdef_istate', pv, 'V', -1. )            ! apply boundary conditions
+      CALL lbc_lnk('usrdef_istate',  pts, 'T',  1. )            ! apply boundary conditions
+      CALL lbc_lnk('usrdef_istate',   pu, 'U', -1. )            ! apply boundary conditions
+      CALL lbc_lnk('usrdef_istate',   pv, 'V', -1. )            ! apply boundary conditions
       
    END SUBROUTINE usr_def_istate
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -29,5 +29,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -41,5 +41,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -48,5 +47,5 @@
       !
       !
-      INTEGER ::   ios, ii      ! Local integer
+      INTEGER ::   ios         ! Local integer
       !                              !!* namusr_def namelist *!!
       INTEGER ::   nn_isize    ! number of point in i-direction of global(local) domain if >0 (<0)  
@@ -55,29 +54,29 @@
       INTEGER ::   nn_perio    ! periodicity
       !                              !!* nammpp namelist *!!
-      CHARACTER(len=1) ::   cn_mpi_send
-      INTEGER          ::   nn_buffer, jpni, jpnj
+      INTEGER          ::   jpni, jpnj
       LOGICAL          ::   ln_nnogather
       !!
       NAMELIST/namusr_def/ nn_isize, nn_jsize, nn_ksize, nn_perio
-      NAMELIST/nammpp/ cn_mpi_send, nn_buffer, jpni, jpnj, ln_nnogather
+      NAMELIST/nammpp/ jpni, jpnj, ln_nnogather
       !!----------------------------------------------------------------------     
       !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 903 )
-903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
-      WRITE( ldnam(:), namusr_def )      
+903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
+      !
+      IF(lwm)   WRITE( numond, namusr_def )      
       !
       cd_cfg = 'BENCH'             ! name & resolution (not used)
       kk_cfg = 0
-
+      !
       IF( nn_isize < 0 .AND. nn_jsize < 0 ) THEN
       !
          REWIND( numnam_ref )              ! Namelist nammpp in reference namelist: mpi variables
          READ  ( numnam_ref, nammpp, IOSTAT = ios, ERR = 901)
-901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'nammpp in reference namelist', lwp )
+901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'nammpp in reference namelist' )
          !
          REWIND( numnam_cfg )              ! Namelist nammpp in configuration namelist: mpi variables
          READ  ( numnam_cfg, nammpp, IOSTAT = ios, ERR = 902 )
-902      IF( ios >  0 )   CALL ctl_nam ( ios , 'nammpp in configuration namelist', lwp )
+902      IF( ios >  0 )   CALL ctl_nam ( ios , 'nammpp in configuration namelist' )
 
          kpi = ( -nn_isize - 2*nn_hls ) * jpni + 2*nn_hls
@@ -87,30 +86,30 @@
          kpj = nn_jsize
       ENDIF
- 
+      !
       kpk = nn_ksize
       kperio = nn_perio
-
       !                             ! control print
-      ii = 1
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : BENCH test case'                                     ;   ii = ii + 1
-      IF( nn_isize > 0 ) THEN
-         WRITE(ldtxt(ii),*) '      global domain size-x            nn_isize = ',  nn_isize              ;   ii = ii + 1
-      ELSE
-         WRITE(ldtxt(ii),*) '                                          jpni = ', jpni                   ;   ii = ii + 1
-         WRITE(ldtxt(ii),*) '       local domain size-x           -nn_isize = ', -nn_isize              ;   ii = ii + 1
-         WRITE(ldtxt(ii),*) '      global domain size-x                 kpi = ', kpi                    ;   ii = ii + 1
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : BENCH test case'
+         IF( nn_isize > 0 ) THEN
+            WRITE(numout,*) '      global domain size-x            nn_isize = ',  nn_isize
+         ELSE
+            WRITE(numout,*) '                                          jpni = ', jpni
+            WRITE(numout,*) '       local domain size-x           -nn_isize = ', -nn_isize
+            WRITE(numout,*) '      global domain size-x                 kpi = ', kpi
+         ENDIF
+         IF( nn_jsize > 0 ) THEN
+            WRITE(numout,*) '      global domain size-y            nn_jsize = ', nn_jsize
+         ELSE
+            WRITE(numout,*) '                                          jpnj = ', jpnj
+            WRITE(numout,*) '       local domain size-y           -nn_jsize = ', -nn_jsize
+            WRITE(numout,*) '      global domain size-y                 kpj = ', kpj
+         ENDIF
+         WRITE(numout,*) '      global domain size-z            nn_ksize = ', nn_ksize
+         WRITE(numout,*) '      LBC of the global domain          kperio = ', kperio
       ENDIF
-      IF( nn_jsize > 0 ) THEN
-         WRITE(ldtxt(ii),*) '      global domain size-y            nn_jsize = ', nn_jsize               ;   ii = ii + 1
-      ELSE
-         WRITE(ldtxt(ii),*) '                                          jpnj = ', jpnj                   ;   ii = ii + 1
-         WRITE(ldtxt(ii),*) '       local domain size-y           -nn_jsize = ', -nn_jsize              ;   ii = ii + 1
-         WRITE(ldtxt(ii),*) '      global domain size-y                 kpj = ', kpj                    ;   ii = ii + 1
-      ENDIF
-      WRITE(ldtxt(ii),*) '      global domain size-z            nn_ksize = ', nn_ksize                  ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      LBC of the global domain          kperio = ', kperio                    ;   ii = ii + 1
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/usrdef_zgr.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/usrdef_zgr.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/usrdef_zgr.F90	(revision 12143)
@@ -194,4 +194,9 @@
       z2d(:,:) = REAL( jpkm1 , wp )          ! flat bottom
       !
+      IF( jperio == 3 .OR. jperio ==4 ) THEN   ! add a small island in the upper corners to avoid model instabilities...
+         z2d(mi0(       1):mi1(     3),mj0(jpjglo-2):mj1(jpjglo)) = 0.
+         z2d(mi0(jpiglo-2):mi1(jpiglo),mj0(jpjglo-2):mj1(jpjglo)) = 0.
+      ENDIF
+      !
       CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/zdfiwm.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/zdfiwm.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/BENCH/MY_SRC/zdfiwm.F90	(revision 12143)
@@ -406,9 +406,9 @@
       REWIND( numnam_ref )              ! Namelist namzdf_iwm in reference namelist : Wave-driven mixing
       READ  ( numnam_ref, namzdf_iwm, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf_iwm in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namzdf_iwm in reference namelist' )
       !
       REWIND( numnam_cfg )              ! Namelist namzdf_iwm in configuration namelist : Wave-driven mixing
       READ  ( numnam_cfg, namzdf_iwm, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf_iwm in configuration namelist', lwp )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namzdf_iwm in configuration namelist' )
       IF(lwm) WRITE ( numond, namzdf_iwm )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
@@ -18,13 +28,13 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/EXPREF/namelist_cfg	(revision 12143)
@@ -275,7 +275,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/MY_SRC/diawri.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/MY_SRC/diawri.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/MY_SRC/diawri.F90	(revision 12143)
@@ -531,5 +531,5 @@
       !!      define all the NETCDF files and fields
       !!      At each time step call histdef to compute the mean if ncessary
-      !!      Each nwrite time step, output the instantaneous or mean fields
+      !!      Each nn_write time step, output the instantaneous or mean fields
       !!----------------------------------------------------------------------
       INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
@@ -547,6 +547,4 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk) :: zw3d       ! 3D workspace
       !!----------------------------------------------------------------------
-      ! 
-      IF( ln_timing )   CALL timing_start('dia_wri')
       !
       IF( ninist == 1 ) THEN     !==  Output the initial state and forcings  ==!
@@ -555,4 +553,8 @@
       ENDIF
       !
+      IF( nn_write == -1 )   RETURN   ! we will never do any output
+      ! 
+      IF( ln_timing )   CALL timing_start('dia_wri')
+      !
       ! 0. Initialisation
       ! -----------------
@@ -564,5 +566,5 @@
       clop = "x"         ! no use of the mask value (require less cpu time and otherwise the model crashes)
 #if defined key_diainstant
-      zsto = nwrite * rdt
+      zsto = nn_write * rdt
       clop = "inst("//TRIM(clop)//")"
 #else
@@ -570,5 +572,5 @@
       clop = "ave("//TRIM(clop)//")"
 #endif
-      zout = nwrite * rdt
+      zout = nn_write * rdt
       zmax = ( nitend - nit000 + 1 ) * rdt
 
@@ -601,5 +603,5 @@
          ! WRITE root name in date.file for use by postpro
          IF(lwp) THEN
-            CALL dia_nam( clhstnam, nwrite,' ' )
+            CALL dia_nam( clhstnam, nn_write,' ' )
             CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
             WRITE(inum,*) clhstnam
@@ -609,5 +611,5 @@
          ! Define the T grid FILE ( nid_T )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_T' )
+         CALL dia_nam( clhstnam, nn_write, 'grid_T' )
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
          CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
@@ -645,5 +647,5 @@
          ! Define the U grid FILE ( nid_U )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_U' )
+         CALL dia_nam( clhstnam, nn_write, 'grid_U' )
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
          CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu,           &  ! Horizontal grid: glamu and gphiu
@@ -658,5 +660,5 @@
          ! Define the V grid FILE ( nid_V )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_V' )                   ! filename
+         CALL dia_nam( clhstnam, nn_write, 'grid_V' )                   ! filename
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
          CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv,           &  ! Horizontal grid: glamv and gphiv
@@ -671,5 +673,5 @@
          ! Define the W grid FILE ( nid_W )
 
-         CALL dia_nam( clhstnam, nwrite, 'grid_W' )                   ! filename
+         CALL dia_nam( clhstnam, nn_write, 'grid_W' )                   ! filename
          IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
          CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
@@ -762,5 +764,5 @@
          ENDIF
 
-         IF( .NOT. ln_cpl ) THEN
+         IF( ln_ssr ) THEN
             CALL histdef( nid_T, "sohefldp", "Surface Heat Flux: Damping"         , "W/m2"   ,   &  ! qrp
                &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
@@ -770,14 +772,5 @@
                &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
          ENDIF
-
-         IF( ln_cpl .AND. nn_ice <= 1 ) THEN
-            CALL histdef( nid_T, "sohefldp", "Surface Heat Flux: Damping"         , "W/m2"   ,   &  ! qrp
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-            CALL histdef( nid_T, "sowafldp", "Surface Water Flux: Damping"        , "Kg/m2/s",   &  ! erp
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-            CALL histdef( nid_T, "sosafldp", "Surface salt flux: Damping"         , "Kg/m2/s",   &  ! erp * sn
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         ENDIF
-         
+       
          clmx ="l_max(only(x))"    ! max index on a period
 !         CALL histdef( nid_T, "sobowlin", "Bowl Index"                         , "W-point",   &  ! bowl INDEX 
@@ -855,5 +848,5 @@
       ! donne le nombre d'elements, et ndex la liste des indices a sortir
 
-      IF( lwp .AND. MOD( itmod, nwrite ) == 0 ) THEN 
+      IF( lwp .AND. MOD( itmod, nn_write ) == 0 ) THEN 
          WRITE(numout,*) 'dia_wri : write model outputs in NetCDF files at ', kt, 'time-step'
          WRITE(numout,*) '~~~~~~ '
@@ -919,14 +912,8 @@
       ENDIF
 
-      IF( .NOT. ln_cpl ) THEN
+      IF( ln_ssr ) THEN
          CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping
          CALL histwrite( nid_T, "sowafldp", it, erp           , ndim_hT, ndex_hT )   ! freshwater flux damping
-         IF( ln_ssr ) zw2d(:,:) = erp(:,:) * tsn(:,:,1,jp_sal) * tmask(:,:,1)
-         CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
-      ENDIF
-      IF( ln_cpl .AND. nn_ice <= 1 ) THEN
-         CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping
-         CALL histwrite( nid_T, "sowafldp", it, erp           , ndim_hT, ndex_hT )   ! freshwater flux damping
-         IF( ln_ssr ) zw2d(:,:) = erp(:,:) * tsn(:,:,1,jp_sal) * tmask(:,:,1)
+         zw2d(:,:) = erp(:,:) * tsn(:,:,1,jp_sal) * tmask(:,:,1)
          CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
       ENDIF
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/MY_SRC/domvvl.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/MY_SRC/domvvl.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/MY_SRC/domvvl.F90	(revision 12143)
@@ -994,8 +994,8 @@
       REWIND( numnam_ref )              ! Namelist nam_vvl in reference namelist : 
       READ  ( numnam_ref, nam_vvl, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_vvl in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_vvl in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist nam_vvl in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, nam_vvl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist' )
       IF(lwm) WRITE ( numond, nam_vvl )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/CANAL/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -58,5 +58,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -70,5 +70,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -76,6 +75,6 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii      ! Local integer
-      REAL(wp)::   zh ! Local scalars
+      INTEGER ::   ios      ! Local integer
+      REAL(wp)::   zh       ! Local scalars
       !!
       NAMELIST/namusr_def/  rn_domszx, rn_domszy, rn_domszz, rn_dx, rn_dy, rn_dz, rn_0xratio, rn_0yratio   &
@@ -85,9 +84,9 @@
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
+      !
+      IF(lwm)   WRITE( numond, namusr_def )
       !
 #if defined key_agrif 
@@ -103,5 +102,5 @@
 #endif
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       cd_cfg = 'EW_CANAL'             ! name & resolution (not used)
@@ -120,40 +119,40 @@
       !
       zh  = (kpk-1)*rn_dz
-      !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : EW_CANAL test case'                                  ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal domain size-x          rn_domszx  = ', rn_domszx, ' km'      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal domain size-y          rn_domszy  = ', rn_domszy, ' km'      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      vertical   domain size-z          rn_domszz  = ', rn_domszz, '  m'      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal x-resolution           rn_dx      = ',     rn_dx, ' km'      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal y-resolution           rn_dy      = ',     rn_dy, ' km'      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      vertical resolution               rn_dz      = ',     rn_dz, '  m'      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      x-domain ratio of the 0           rn_0xratio = ', rn_0xratio            ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      y-domain ratio of the 0           rn_0yratio = ', rn_0yratio            ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '          H [m] : ', zh                                                       ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      F computation                     nn_fcase   = ',   nn_fcase            ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      Reference latitude                rn_ppgphi0 = ', rn_ppgphi0            ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      10m wind speed                    rn_u10     = ',     rn_u10, ' m/s'    ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         wind latitudinal extension     rn_windszy = ', rn_windszy, ' km'     ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         wind longitudinal extension    rn_windszx = ', rn_windszx, ' km'     ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         Uoce multiplicative factor     rn_uofac   = ',   rn_uofac            ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      initial Canal max current        rn_vtxmax  = ',  rn_vtxmax, ' m/s'    ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      initial zonal current             rn_uzonal  = ',  rn_uzonal, ' m/s'    ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         Jet latitudinal extension      rn_ujetszy = ', rn_ujetszy, ' km'     ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         Jet longitudinal extension     rn_ujetszx = ', rn_ujetszx, ' km'     ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      bottom definition (0:flat)        nn_botcase = ', nn_botcase            ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      initial condition case            nn_initcase= ', nn_initcase           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                   (0:rest, 1:zonal current, 10:shear)'                       ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      add random noise on initial ssh   ln_sshnoise= ', ln_sshnoise           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      Gaussian lambda parameter          rn_lambda = ', rn_lambda             ;   ii = ii + 1
-      !
       !                             ! Set the lateral boundary condition of the global domain
       kperio = 1                    ! EW_CANAL configuration : closed basin
-      !
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Lateral boundary condition of the global domain'                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      EW_CANAL : closed basin            jperio = ', kperio                   ;   ii = ii + 1
+      !                             ! control print
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : EW_CANAL test case'
+         WRITE(numout,*) '      horizontal domain size-x          rn_domszx  = ', rn_domszx, ' km'
+         WRITE(numout,*) '      horizontal domain size-y          rn_domszy  = ', rn_domszy, ' km'
+         WRITE(numout,*) '      vertical   domain size-z          rn_domszz  = ', rn_domszz, '  m'
+         WRITE(numout,*) '      horizontal x-resolution           rn_dx      = ',     rn_dx, ' km'
+         WRITE(numout,*) '      horizontal y-resolution           rn_dy      = ',     rn_dy, ' km'
+         WRITE(numout,*) '      vertical resolution               rn_dz      = ',     rn_dz, '  m'
+         WRITE(numout,*) '      x-domain ratio of the 0           rn_0xratio = ', rn_0xratio
+         WRITE(numout,*) '      y-domain ratio of the 0           rn_0yratio = ', rn_0yratio
+         WRITE(numout,*) '          H [m] : ', zh
+         WRITE(numout,*) '      F computation                     nn_fcase   = ',   nn_fcase
+         WRITE(numout,*) '      Reference latitude                rn_ppgphi0 = ', rn_ppgphi0
+         WRITE(numout,*) '      10m wind speed                    rn_u10     = ',     rn_u10, ' m/s'
+         WRITE(numout,*) '         wind latitudinal extension     rn_windszy = ', rn_windszy, ' km'
+         WRITE(numout,*) '         wind longitudinal extension    rn_windszx = ', rn_windszx, ' km'
+         WRITE(numout,*) '         Uoce multiplicative factor     rn_uofac   = ',   rn_uofac
+         WRITE(numout,*) '      initial Canal max current         rn_vtxmax  = ',  rn_vtxmax, ' m/s'
+         WRITE(numout,*) '      initial zonal current             rn_uzonal  = ',  rn_uzonal, ' m/s'
+         WRITE(numout,*) '         Jet latitudinal extension      rn_ujetszy = ', rn_ujetszy, ' km'
+         WRITE(numout,*) '         Jet longitudinal extension     rn_ujetszx = ', rn_ujetszx, ' km'
+         WRITE(numout,*) '      bottom definition (0:flat)        nn_botcase = ', nn_botcase
+         WRITE(numout,*) '      initial condition case            nn_initcase= ', nn_initcase
+         WRITE(numout,*) '                   (0:rest, 1:zonal current, 10:shear)'
+         WRITE(numout,*) '      add random noise on initial ssh   ln_sshnoise= ', ln_sshnoise
+         WRITE(numout,*) '      Gaussian lambda parameter          rn_lambda = ', rn_lambda
+         WRITE(numout,*) '   '
+         WRITE(numout,*) '   Lateral boundary condition of the global domain'
+         WRITE(numout,*) '      EW_CANAL : closed basin               jperio = ', kperio
+      ENDIF
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg	(revision 12143)
@@ -201,7 +201,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg_120pts
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg_120pts	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg_120pts	(revision 12143)
@@ -201,7 +201,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg_240pts
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg_240pts	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg_240pts	(revision 12143)
@@ -201,7 +201,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg_60pts
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg_60pts	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/EXPREF/namelist_cfg_60pts	(revision 12143)
@@ -201,7 +201,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV1D/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -40,5 +40,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -52,5 +52,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -58,5 +57,5 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii   ! Local integer
+      INTEGER ::   ios       ! Local integer
       REAL(wp)::   zlx, zly  ! Local scalars
       !!
@@ -64,11 +63,9 @@
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       cd_cfg = 'ICE_ADV1D'           ! name & resolution (not used)
@@ -82,25 +79,25 @@
       zlx = kpi*rn_dx*1.e-3
       zly = kpj*rn_dy*1.e-3
-      !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : ICE_ADV1D test case'                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution                    rn_dy  = ', rn_dy, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      ICE_ADV1D domain  '                                                     ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         LX [km]: ', zlx                                                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         LY [km]: ', zly                                                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         resulting global domain size :        jpiglo = ', kpi                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpjglo = ', kpj                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpkglo = ', kpk                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         Coriolis:', ln_corio                                                 ;   ii = ii + 1
-      !
       !                             ! Set the lateral boundary condition of the global domain
       kperio = 0                    ! ICE_ADV1D configuration : bi-periodic basin
-      !
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Lateral boundary condition of the global domain'                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      ICE_ADV1D : closed basin                    jperio = ', kperio          ;   ii = ii + 1
+      !                             ! control print
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : ICE_ADV1D test case'
+         WRITE(numout,*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'
+         WRITE(numout,*) '      horizontal resolution                    rn_dy  = ', rn_dy, ' meters'
+         WRITE(numout,*) '      ICE_ADV1D domain  '
+         WRITE(numout,*) '         LX [km]: ', zlx
+         WRITE(numout,*) '         LY [km]: ', zly
+         WRITE(numout,*) '         resulting global domain size :        jpiglo = ', kpi
+         WRITE(numout,*) '                                               jpjglo = ', kpj
+         WRITE(numout,*) '                                               jpkglo = ', kpk
+         WRITE(numout,*) '         Coriolis:', ln_corio
+         WRITE(numout,*) '   '
+         WRITE(numout,*) '   Lateral boundary condition of the global domain'
+         WRITE(numout,*) '      ICE_ADV1D : closed basin                 jperio = ', kperio
+      ENDIF
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV2D/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV2D/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV2D/EXPREF/namelist_cfg	(revision 12143)
@@ -201,7 +201,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV2D/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV2D/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_ADV2D/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -40,5 +40,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -52,5 +52,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -58,5 +57,5 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii   ! Local integer
+      INTEGER ::   ios       ! Local integer
       REAL(wp)::   zlx, zly  ! Local scalars
       !!
@@ -64,9 +63,9 @@
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
+      !
+      IF(lwm)   WRITE( numond, namusr_def )
       !
 #if defined key_agrif 
@@ -79,18 +78,16 @@
 #endif
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       cd_cfg = 'ICE_ADV2D'           ! name & resolution (not used)
-      kk_cfg = INT( rn_dx )
+      kk_cfg = NINT( rn_dx )
       !
-      ! Global Domain size:  ICE_ADV2D domain is  300 km x 300 Km x 10 m
-      kpi = INT( 300.e3 / rn_dx ) -1
-      kpj = INT( 300.e3 / rn_dy ) -1
-#if defined key_agrif
-      IF( .NOT. Agrif_Root() ) THEN
+      IF( Agrif_Root() ) THEN        ! Global Domain size:  ICE_AGRIF domain is  300 km x 300 Km x 10 m
+         kpi = NINT( 300.e3 / rn_dx ) - 1
+         kpj = NINT( 300.e3 / rn_dy ) - 1
+      ELSE
          kpi = nbcellsx + 2 + 2*nbghostcells
          kpj = nbcellsy + 2 + 2*nbghostcells
       ENDIF
-#endif
       kpk = 1
       !
@@ -99,30 +96,27 @@
       zlx = kpi*rn_dx*1.e-3
       zly = kpj*rn_dy*1.e-3
+      !
+      IF( Agrif_Root() ) THEN   ;   kperio = 7     ! ICE_AGRIF configuration : bi-periodic basin
+      ELSE                      ;   kperio = 0     ! closed periodicity for the zoom
+      ENDIF
       !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : ICE_ADV2D test case'                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution                    rn_dy  = ', rn_dy, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      ICE_ADV2D domain = 300 km x 300Km x 1 grid-point '                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         LX [km]: ', zlx                                                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         LY [km]: ', zly                                                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         resulting global domain size :        jpiglo = ', kpi                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpjglo = ', kpj                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpkglo = ', kpk                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         Coriolis:', ln_corio                                                 ;   ii = ii + 1
-      !
-      !                             ! Set the lateral boundary condition of the global domain
-      kperio = 7                    ! ICE_ADV2D configuration : bi-periodic basin
-#if defined key_agrif
-      IF( .NOT. Agrif_Root() ) THEN
-      kperio = 0
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : ICE_ADV2D test case'
+         WRITE(numout,*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'
+         WRITE(numout,*) '      horizontal resolution                    rn_dy  = ', rn_dy, ' meters'
+         WRITE(numout,*) '      ICE_ADV2D domain = 300 km x 300Km x 1 grid-point '
+         WRITE(numout,*) '         LX [km]: ', zlx
+         WRITE(numout,*) '         LY [km]: ', zly
+         WRITE(numout,*) '         resulting global domain size :        jpiglo = ', kpi
+         WRITE(numout,*) '                                               jpjglo = ', kpj
+         WRITE(numout,*) '                                               jpkglo = ', kpk
+         WRITE(numout,*) '         Coriolis:', ln_corio
+         WRITE(numout,*) '   '
+         WRITE(numout,*) '   Lateral boundary condition of the global domain'
+         WRITE(numout,*) '      ICE_ADV2D : bi-periodic basin            jperio = ', kperio
       ENDIF
-#endif
-      !
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Lateral boundary condition of the global domain'                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      ICE_ADV2D : bi-periodic basin               jperio = ', kperio          ;   ii = ii + 1
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_AGRIF/EXPREF/1_namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_AGRIF/EXPREF/1_namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_AGRIF/EXPREF/1_namelist_cfg	(revision 12143)
@@ -201,7 +201,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_AGRIF/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_AGRIF/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_AGRIF/EXPREF/namelist_cfg	(revision 12143)
@@ -201,7 +201,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_AGRIF/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_AGRIF/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ICE_AGRIF/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -40,5 +40,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -52,5 +52,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -58,5 +57,5 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii   ! Local integer
+      INTEGER ::   ios       ! Local integer
       REAL(wp)::   zlx, zly  ! Local scalars
       !!
@@ -64,9 +63,9 @@
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
+      !
+      IF(lwm)   WRITE( numond, namusr_def )
       !
 #if defined key_agrif 
@@ -79,18 +78,16 @@
 #endif
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       cd_cfg = 'ICE_AGRIF'           ! name & resolution (not used)
-      kk_cfg = INT( rn_dx )
+      kk_cfg = NINT( rn_dx )
       !
-      ! Global Domain size:  ICE_AGRIF domain is  300 km x 300 Km x 10 m
-      kpi = INT( 300.e3 / rn_dx ) -1
-      kpj = INT( 300.e3 / rn_dy ) -1
-#if defined key_agrif
-      IF( .NOT. Agrif_Root() ) THEN
+      IF( Agrif_Root() ) THEN        ! Global Domain size:  ICE_AGRIF domain is  300 km x 300 Km x 10 m
+         kpi = NINT( 300.e3 / rn_dx ) - 1
+         kpj = NINT( 300.e3 / rn_dy ) - 1
+      ELSE
          kpi = nbcellsx + 2 + 2*nbghostcells
          kpj = nbcellsy + 2 + 2*nbghostcells
       ENDIF
-#endif
       kpk = 1
       !
@@ -99,30 +96,27 @@
       zlx = kpi*rn_dx*1.e-3
       zly = kpj*rn_dy*1.e-3
+      !
+      IF( Agrif_Root() ) THEN   ;   kperio = 7     ! ICE_AGRIF configuration : bi-periodic basin
+      ELSE                      ;   kperio = 0     ! closed periodicity for the zoom
+      ENDIF
       !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : ICE_AGRIF test case'                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution                    rn_dy  = ', rn_dy, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      ICE_AGRIF domain = 300 km x 300Km x 1 grid-point '                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         LX [km]: ', zlx                                                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         LY [km]: ', zly                                                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         resulting global domain size :        jpiglo = ', kpi                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpjglo = ', kpj                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpkglo = ', kpk                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         Coriolis:', ln_corio                                                 ;   ii = ii + 1
-      !
-      !                             ! Set the lateral boundary condition of the global domain
-      kperio = 7                    ! ICE_AGRIF configuration : bi-periodic basin
-#if defined key_agrif
-      IF( .NOT. Agrif_Root() ) THEN
-      kperio = 0
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : ICE_AGRIF test case'
+         WRITE(numout,*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'
+         WRITE(numout,*) '      horizontal resolution                    rn_dy  = ', rn_dy, ' meters'
+         WRITE(numout,*) '      ICE_AGRIF domain = 300 km x 300Km x 1 grid-point '
+         WRITE(numout,*) '         LX [km]: ', zlx
+         WRITE(numout,*) '         LY [km]: ', zly
+         WRITE(numout,*) '         resulting global domain size :        jpiglo = ', kpi
+         WRITE(numout,*) '                                               jpjglo = ', kpj
+         WRITE(numout,*) '                                               jpkglo = ', kpk
+         WRITE(numout,*) '         Coriolis:', ln_corio
+         WRITE(numout,*) '   '
+         WRITE(numout,*) '   Lateral boundary condition of the global domain'
+         WRITE(numout,*) '      ICE_AGRIF : bi-periodic basin            jperio = ', kperio
       ENDIF
-#endif
-      !
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Lateral boundary condition of the global domain'                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      ICE_AGRIF : bi-periodic basin               jperio = ', kperio          ;   ii = ii + 1
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ISOMIP/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ISOMIP/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ISOMIP/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
@@ -18,13 +28,13 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ISOMIP/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ISOMIP/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ISOMIP/EXPREF/namelist_cfg	(revision 12143)
@@ -427,7 +427,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ISOMIP/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ISOMIP/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/ISOMIP/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -42,5 +42,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -54,5 +54,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -60,16 +59,14 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii   ! Local integer
+      INTEGER ::   ios   ! Local integer
       !!
       NAMELIST/namusr_def/ ln_zco, ln_zps, ln_sco, rn_e1deg, rn_e2deg, rn_e3
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       cd_cfg = 'ISOMIP'           ! name & resolution (not used)
@@ -81,29 +78,29 @@
       kpk = INT( rbathy / rn_e3    ) + 1     ! add 1 for t-point in the seafloor
       !
-      !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                              ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'       ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                     ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : ISOMIP test case'                                        ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      type of vertical coordinate : '                                             ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         z-coordinate flag                     ln_zco   = ', ln_zco               ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         z-partial-step coordinate flag        ln_zps   = ', ln_zps               ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         s-coordinate flag                     ln_sco   = ', ln_sco               ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      resolution'                                                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         zonal      resolution                 rn_e1deg = ', rn_e1deg, ' degrees' ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         meridional resolution                 rn_e1deg = ', rn_e1deg, ' degrees' ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         vertical   resolution                 rn_e3    = ', rn_e3   , ' meters'  ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      ISOMIP domain = 15° x 10° x 900 m'                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         resulting global domain size :        jpiglo   = ', kpi                  ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpjglo   = ', kpj                  ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpkglo   = ', kpk                  ;   ii = ii + 1
-      !
-      !
       !                             ! Set the lateral boundary condition of the global domain
       kperio = 0                    ! ISOMIP configuration : close basin
       !
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Lateral boundary condition of the global domain'                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      ISOMIP : closed basin                    jperio   = ', kperio             ;   ii = ii + 1
+      !                             ! control print
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : ISOMIP test case'
+         WRITE(numout,*) '      type of vertical coordinate : '
+         WRITE(numout,*) '         z-coordinate flag                     ln_zco   = ', ln_zco
+         WRITE(numout,*) '         z-partial-step coordinate flag        ln_zps   = ', ln_zps
+         WRITE(numout,*) '         s-coordinate flag                     ln_sco   = ', ln_sco
+         WRITE(numout,*) '      resolution'
+         WRITE(numout,*) '         zonal      resolution                 rn_e1deg = ', rn_e1deg, ' degrees'
+         WRITE(numout,*) '         meridional resolution                 rn_e1deg = ', rn_e1deg, ' degrees'
+         WRITE(numout,*) '         vertical   resolution                 rn_e3    = ', rn_e3   , ' meters'
+         WRITE(numout,*) '      ISOMIP domain = 15° x 10° x 900 m'
+         WRITE(numout,*) '         resulting global domain size :        jpiglo   = ', kpi
+         WRITE(numout,*) '                                               jpjglo   = ', kpj
+         WRITE(numout,*) '                                               jpkglo   = ', kpk
+         WRITE(numout,*) '   '
+         WRITE(numout,*) '   Lateral boundary condition of the global domain'
+         WRITE(numout,*) '      ISOMIP : closed basin                    jperio   = ', kperio
+      ENDIF
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/LOCK_EXCHANGE/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/LOCK_EXCHANGE/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/LOCK_EXCHANGE/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
@@ -18,13 +28,13 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_ubs_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_ubs_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_ubs_cfg	(revision 12143)
@@ -275,7 +275,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/LOCK_EXCHANGE/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/LOCK_EXCHANGE/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/LOCK_EXCHANGE/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -38,5 +38,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -50,5 +50,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -56,16 +55,14 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii   ! Local integer
+      INTEGER ::   ios   ! Local integer
       !!
       NAMELIST/namusr_def/ rn_dx, rn_dz
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       !
@@ -77,23 +74,23 @@
       kpj = 3
       kpk = INT(  20.  / rn_dz ) + 1
-      !
-      !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : LOCK_EXCHANGE test case'                             ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      vertical   resolution                    rn_dz  = ', rn_dz, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      LOCK_EXCHANGE domain = 64 km  x  3 grid-points  x  20 m'                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         resulting global domain size :        jpiglo = ', kpi                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpjglo = ', kpj                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpkglo = ', kpk                ;   ii = ii + 1
-      !
       !                             ! Set the lateral boundary condition of the global domain
       kperio = 0                    ! LOCK_EXCHANGE configuration : closed domain
       !
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Lateral boundary condition of the global domain'                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      closed                                   jperio = ', kperio             ;   ii = ii + 1
+      !                             ! control print
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : LOCK_EXCHANGE test case'
+         WRITE(numout,*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'
+         WRITE(numout,*) '      vertical   resolution                    rn_dz  = ', rn_dz, ' meters'
+         WRITE(numout,*) '      LOCK_EXCHANGE domain = 64 km  x  3 grid-points  x  20 m'
+         WRITE(numout,*) '         resulting global domain size :        jpiglo = ', kpi
+         WRITE(numout,*) '                                               jpjglo = ', kpj
+         WRITE(numout,*) '                                               jpkglo = ', kpk
+         WRITE(numout,*) '   '
+         WRITE(numout,*) '   Lateral boundary condition of the global domain'
+         WRITE(numout,*) '      closed                                   jperio = ', kperio
+      ENDIF
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
@@ -18,13 +28,13 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_cen-ahm1000_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_cen-ahm1000_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_cen-ahm1000_cfg	(revision 12143)
@@ -210,5 +210,5 @@
    !                       ! coefficients
    rn_avm0     =   1.e-4     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
-   rn_avt0     =   0.0e      !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avt0     =   0.0       !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
    nn_avb      =    0        !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0        !  horizontal shape for avtb (=1) or not (=0)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_ubs_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_ubs_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_ubs_cfg	(revision 12143)
@@ -210,5 +210,5 @@
    !                       ! coefficients
    rn_avm0     =   1.e-4     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
-   rn_avt0     =   0.0e      !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avt0     =   0.0       !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
    nn_avb      =    0        !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0        !  horizontal shape for avtb (=1) or not (=0)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_sco_FCT4_flux_ubs_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_sco_FCT4_flux_ubs_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_sco_FCT4_flux_ubs_cfg	(revision 12143)
@@ -210,5 +210,5 @@
    !                       ! coefficients
    rn_avm0     =   1.e-4     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
-   rn_avt0     =   0.0e      !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avt0     =   0.0       !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
    nn_avb      =    0        !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0        !  horizontal shape for avtb (=1) or not (=0)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_zps_FCT2_flux_ubs_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_zps_FCT2_flux_ubs_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_zps_FCT2_flux_ubs_cfg	(revision 12143)
@@ -211,5 +211,5 @@
    !                       ! coefficients
    rn_avm0     =   1.e-4     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
-   rn_avt0     =   0.0e      !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avt0     =   0.0       !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
    nn_avb      =    0        !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0        !  horizontal shape for avtb (=1) or not (=0)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_flux_ubs_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_flux_ubs_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_flux_ubs_cfg	(revision 12143)
@@ -34,9 +34,8 @@
    cn_exp      =   "OVF_zps_FCT4_flux_ubs"  !  experience name
    nn_it000    =       1   !  first time step
-   !nn_itend    =    6120  ! here 17h of simulation  (=6120 time-step) 
-   nn_itend    =    5760   ! here 16h of simulation  (=5760 time-step) abort after 5802 for zps: pb of physics conditions
+   nn_itend    =    6120   ! here 17h of simulation  (=6120 time-step) 
    nn_istate   =       0   !  output the initial state (1) or not (0)
-   nn_stock    =    1080   !  frequency of creation of a restart file (modulo referenced to 1)
-   nn_write    =    1080   !  frequency of write in the output file   (modulo referenced to nn_it000)
+   nn_stock    =    6120   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =    6120   !  frequency of write in the output file   (modulo referenced to nn_it000)
 /
 !-----------------------------------------------------------------------
@@ -255,4 +254,7 @@
 &namzdf        !   vertical physics manager                             (default: NO selection)
 !-----------------------------------------------------------------------
+   !                       ! adaptive-implicit vertical advection
+   ln_zad_Aimp = .true.       !  Courant number dependent scheme (Shchepetkin 2015)
+   !
    !                       ! type of vertical closure (required)
    ln_zdfcst   = .true.      !  constant mixing
@@ -279,5 +281,5 @@
    !                       ! coefficients
    rn_avm0     =   1.e-4     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
-   rn_avt0     =   0.0e      !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avt0     =   0.0       !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
    nn_avb      =    0        !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0        !  horizontal shape for avtb (=1) or not (=0)
@@ -291,7 +293,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_vect_een_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_vect_een_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_vect_een_cfg	(revision 12143)
@@ -210,5 +210,5 @@
    !                       ! coefficients
    rn_avm0     =   1.e-4     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
-   rn_avt0     =   0.0e      !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avt0     =   0.0       !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
    nn_avb      =    0        !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0        !  horizontal shape for avtb (=1) or not (=0)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/OVERFLOW/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -39,5 +39,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -51,5 +51,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -57,16 +56,14 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii   ! Local integer
+      INTEGER ::   ios   ! Local integer
       !!
       NAMELIST/namusr_def/ ln_zco, ln_zps, ln_sco, rn_dx, rn_dz
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       cd_cfg = 'OVERFLOW'           ! name & resolution (not used)
@@ -79,25 +76,25 @@
       !
       !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : OVERFLOW test case'                                  ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      type of vertical coordinate : '                                         ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         z-coordinate flag                     ln_zco = ', ln_zco             ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         z-partial-step coordinate flag        ln_zps = ', ln_zps             ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         s-coordinate flag                     ln_sco = ', ln_sco             ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      vertical   resolution                    rn_dz  = ', rn_dz, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      OVERFLOW domain = 200 km x 3 grid-points x 2000 m'                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         resulting global domain size :        jpiglo = ', kpi                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpjglo = ', kpj                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpkglo = ', kpk                ;   ii = ii + 1
+      WRITE(numout,*) '   '
+      WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+      WRITE(numout,*) '~~~~~~~~~~~ '
+      WRITE(numout,*) '   Namelist namusr_def : OVERFLOW test case'
+      WRITE(numout,*) '      type of vertical coordinate : '
+      WRITE(numout,*) '         z-coordinate flag                     ln_zco = ', ln_zco
+      WRITE(numout,*) '         z-partial-step coordinate flag        ln_zps = ', ln_zps
+      WRITE(numout,*) '         s-coordinate flag                     ln_sco = ', ln_sco
+      WRITE(numout,*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'
+      WRITE(numout,*) '      vertical   resolution                    rn_dz  = ', rn_dz, ' meters'
+      WRITE(numout,*) '      OVERFLOW domain = 200 km x 3 grid-points x 2000 m'
+      WRITE(numout,*) '         resulting global domain size :        jpiglo = ', kpi
+      WRITE(numout,*) '                                               jpjglo = ', kpj
+      WRITE(numout,*) '                                               jpkglo = ', kpk
       !
       !                             ! Set the lateral boundary condition of the global domain
       kperio = 0                    ! OVERFLOW configuration : close basin
       !
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Lateral boundary condition of the global domain'                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      OVERFLOW : closed basin                  jperio = ', kperio             ;   ii = ii + 1
+      WRITE(numout,*) '   '
+      WRITE(numout,*) '   Lateral boundary condition of the global domain'
+      WRITE(numout,*) '      OVERFLOW : closed basin                  jperio = ', kperio
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/README.rst
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/README.rst	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/README.rst	(revision 12143)
@@ -3,8 +3,21 @@
 **********************
 
-The complete and up-to-date set of test cases is available on
-`NEMO test cases Github repository <http://github.com/NEMO-ocean/NEMO-examples>`_.
-
-Download it directly in the ``./tests`` root directory with
+.. todo::
+
+   CANAL animated gif is missing
+
+.. contents::
+   :local:
+   :depth: 1
+
+Installation
+============
+
+Download
+--------
+
+| The complete and up-to-date set of test cases is available on
+  :github:`NEMO test cases repository <NEMO-examples>`.
+| Download it directly into the :file:`./tests` root directory with
 
 .. code-block:: console
@@ -12,140 +25,182 @@
    $ git clone http://github.com/NEMO-ocean/NEMO-examples
 
-.. contents::
-	:local:
-
-Procedure
-=========
-
-Compile test cases
-------------------
-
-The compilation of the test cases is very similar to the manner the reference configurations are compiled.
-If you are not familiar on how to compile NEMO, it is first recomended to read :doc:`the instructions <install>`
-
-| In the same manner as the ref. cfg are compiled with '-r' option, test cases can be compile by the use of makenemo with '-a' option.
-| Here an example to compile a copy named WAD2 of the wetting and drying test case (WAD) on the macport_osx architecture on 4 cores:
+Compilation
+-----------
+
+The compilation of the test cases is very similar to
+the manner the reference configurations are compiled.
+If you are not familiar on how to compile NEMO,
+it is first recomended to read :doc:`the instructions <install>`.
+
+| As the reference configurations are compiled with ``-r`` option,
+  test cases can be compiled by the use of :file:`makenemo` with ``-a`` option.
+| Here an example to compile a copy named WAD2 of the wetting and drying test case (WAD):
 
 .. code-block:: console
 
-   $ ./makenemo -n 'WAD2' -a 'WAD' -m 'macport_osx' -j '4'
-
-Run and analyse the test cases
-------------------------------
-
-There no requirement of specific input file for the test_cases presented here. The XIOS xml input files and namelist are already setup correctly. 
+   $ ./makenemo -n 'WAD2' -a 'WAD' -m 'my_arch' -j '4'
+
+Run and analysis
+----------------
+
+There no requirement of specific input file for the test_cases presented here.
+The XIOS xml input files and namelist are already setup correctly.
 For detailed description and Jupyter notebook, the reader is directed on
-the `NEMO test cases repository <http://github.com/NEMO-ocean/NEMO-examples>`_
+the :github:`NEMO test cases repository <NEMO-examples>`
 
 The description below is a brief advertisement of some test cases.
 
+List of test cases
+==================
+
 ICE_AGRIF
-=========
-  
-  This test case illustrates the advection of an ice patch across an East/West and North/South periodic channel
-  over a slab ocean (i.e. one ocean layer), and with an AGRIF zoom (1:3) in the center
-  The purpose of this configuration is to test the advection of the ice patch in  
-  and across the AGRIF boundary
-  One can either impose ice velocities or ice-atm. stresses and let rheology define velocities
-  (see README for details)
-
-  .. image:: _static/ICE_AGRIF_UDIAG_43days_UM5.gif
+---------
+
+.. figure:: _static/ICE_AGRIF_UDIAG_43days_UM5.gif
+   :width: 200px
+   :align: left
+
+   ..
+
+| This test case illustrates the advection of an ice patch across
+  an East/West and North/South periodic channel over a slab ocean (i.e. one ocean layer),
+  and with an AGRIF zoom (1:3) in the center.
+| The purpose of this configuration is to
+  test the advection of the ice patch in and across the AGRIF boundary.
+  One can either impose ice velocities or ice-atm.
+  Stresses and let rheology define velocities (see :file:`README` for details)
 
 VORTEX
-======
-  
-  This test case illustrates the propagation of an anticyclonic eddy over a Beta plan and a flat bottom.
-  It is implemented here with an online refined subdomain (1:3) out of which the vortex propagates.
-  It serves as a benchmark for quantitative estimates of nesting errors as in Debreu et al. (2012) :cite:`DEBREU2012`,
-  Penven et al. (2006) :cite:`PENVEN2006` or Spall and Holland (1991) :cite:`SPALL1991`.
-  
-  The animation below (sea level anomaly in meters) illustrates with two 1:2 successively nested grids how
-  the vortex smoothly propagates out of the refined grids.
-  
-  .. image:: _static/VORTEX_anim.gif
+------
+
+.. figure:: _static/VORTEX_anim.gif
+   :width: 200px
+   :align: right
+
+   ..
+
+This test case illustrates the propagation of an anticyclonic eddy over a Beta plan and a flat bottom.
+It is implemented here with an online refined subdomain (1:3) out of which the vortex propagates.
+It serves as a benchmark for quantitative estimates of nesting errors as in :cite:`DEBREU2012`,
+:cite:`PENVEN2006` or :cite:`SPALL1991`.
+
+The animation (sea level anomaly in meters) illustrates with
+two 1:2 successively nested grids how the vortex smoothly propagates out of the refined grids.
 
 ISOMIP
-======
-
-  The purpose of this test case is to evaluate the impact of various schemes and new development with the iceshelf cavities circulation and melt.
-  This configuration served as initial assesment of the ice shelf module in Losh et al. (2008) :cite:`LOSCH2008` and Mathiot et al. (2017) :cite:`MATHIOT2017`. 
-  The default setup is the one described `here <http://staff.acecrc.org.au/~bkgalton/ISOMIP/test_cavities.pdf>`_.
-  
-  The figure below (meridional overturning circulation) illustrates the circulation generated after 10000 days by the ice shelf melting (ice pump).
-
-  .. image:: _static/ISOMIP_moc.png
+------
+
+.. figure:: _static/ISOMIP_moc.png
+   :width: 200px
+   :align: left
+
+   ..
+
+| The purpose of this test case is to evaluate the impact of various schemes and new development with
+  the iceshelf cavities circulation and melt.
+  This configuration served as initial assesment of the ice shelf module in :cite:`LOSCH2008` and
+  :cite:`MATHIOT2017`.
+  The default setup is the one described |ISOMIP|_.
+| The figure (meridional overturning circulation) illustrates
+  the circulation generated after 10000 days by the ice shelf melting (ice pump).
+
+.. |ISOMIP| replace:: here
 
 LOCK_EXCHANGE
-=============
-
-  The LOCK EXCHANGE experiment is a classical fluid dynamics experiment that has been adapted
-  by Haidvogel and Beckmann (1999) :cite:`HAIDVOGEL1999` for testing advection schemes in ocean circulation models.
-  It has been used by several authors including Burchard and Bolding (2002) :cite:`BURCHARD2002` and Ilicak et al. (2012) :cite:`ILICAK2012`.
-  The LOCK EXCHANGE experiment can in particular illustrate the impact of different choices of numerical schemes 
-  and/or subgrid closures on spurious interior mixing.
-
-  Below the animation of the LOCK_EXCHANGE test case using the advection scheme FCT4 (forth order) for tracer and ubs for dynamics.
-
-  .. image:: _static/LOCK-FCT4_flux_ubs.gif
+-------------
+
+.. figure:: _static/LOCK-FCT4_flux_ubs.gif
+   :width: 200px
+   :align: right
+
+   ..
+
+| The LOCK EXCHANGE experiment is a classical fluid dynamics experiment that has been adapted
+  by :cite:`HAIDVOGEL1999` for testing advection schemes in ocean circulation models.
+  It has been used by several authors including :cite:`BURCHARD2002` and :cite:`ILICAK2012`.
+  The LOCK EXCHANGE experiment can in particular illustrate
+  the impact of different choices of numerical schemes and/or subgrid closures on
+  spurious interior mixing.
+| Here the animation of the LOCK_EXCHANGE test case using
+  the advection scheme FCT4 (forth order) for tracer and ubs for dynamics.
 
 OVERFLOW
-========
-
-  The OVERFLOW experiment illustrates the impact of different choices of numerical schemes 
-  and/or subgrid closures on spurious interior mixing close to bottom topography. 
-  The OVERFLOW experiment is adapted from the non-rotating overflow configuration described 
-  in Haidvogel and Beckmann (1999) :cite:`HAIDVOGEL1999` and further used by Ilicak et al. (2012) :cite:`ILICAK2012`.
-  Here we can assess the behaviour of the second-order tracer advection scheme FCT2 and fortht-order FCT4, z-coordinate and sigma coordinate (...).
-
-  Below the animation of the OVERFLOW test case in sigma coordinate with the forth-order advection scheme FCT4.
-
-  .. image:: _static/OVF-sco_FCT4_flux_cen-ahm1000.gif
+--------
+
+.. figure:: _static/OVF-sco_FCT4_flux_cen-ahm1000.gif
+   :width: 200px
+   :align: left
+
+   ..
+
+| The OVERFLOW experiment illustrates the impact of different choices of numerical schemes and/or
+  subgrid closures on spurious interior mixing close to bottom topography.
+  The OVERFLOW experiment is adapted from the non-rotating overflow configuration described in
+  :cite:`HAIDVOGEL1999` and further used by :cite:`ILICAK2012`.
+  Here we can assess the behaviour of the second-order tracer advection scheme FCT2 and
+  forth-order FCT4, z-coordinate and sigma coordinate (...).
+| Here the animation of the OVERFLOW test case in sigma coordinate with
+  the forth-order advection scheme FCT4.
 
 WAD
-===
-
-  A set of simple closed basin geometries for testing the Wetting and drying capabilities. 
-  Examples range from a closed channel with EW linear bottom slope to a parabolic EW channel with a Gaussian ridge.
-  
-  Below the animation of the test case 7. This test case is a simple linear slope with a mid-depth shelf with an open boundary forced with a sinusoidally varying ssh.
-  This test case has been introduced to emulate a typical coastal application with a tidally forced open boundary with an adverse SSH gradient that, when released, creates a surge up the slope.
-  The parameters are chosen such that the surge rises above sea-level before falling back and oscillating towards an equilibrium position
-
-  .. image:: _static/wad_testcase_7.gif
+---
+
+.. figure:: _static/wad_testcase_7.gif
+   :width: 200px
+   :align: right
+
+   ..
+
+| A set of simple closed basin geometries for testing the Wetting and drying capabilities.
+  Examples range from a closed channel with EW linear bottom slope to
+  a parabolic EW channel with a Gaussian ridge.
+| Here the animation of the test case 7.
+  This test case is a simple linear slope with a mid-depth shelf with
+  an open boundary forced with a sinusoidally varying ssh.
+  This test case has been introduced to emulate a typical coastal application with
+  a tidally forced open boundary with an adverse SSH gradient that,
+  when released, creates a surge up the slope.
+  The parameters are chosen such that
+  the surge rises above sea-level before falling back and oscillating towards an equilibrium position.
 
 CANAL
-=====
-
-  East-west periodic canal of variable size with several initial states and associated geostrophic currents (zonal jets or vortex).
-
-  .. image::_static/CANAL_image.gif
+-----
+
+.. figure:: _static/CANAL_image.gif
+   :width: 200px
+   :align: left
+
+   ..
+
+East-west periodic canal of variable size with several initial states and
+associated geostrophic currents (zonal jets or vortex).
 
 ICE_ADV2D
-=========
-  
-  This test case illustrates the advection of an ice patch across an East/West and North/South periodic channel
-  over a slab ocean (i.e. one ocean layer).
+---------
+
+| This test case illustrates the advection of an ice patch across
+  an East/West and North/South periodic channel over a slab ocean (i.e. one ocean layer).
   The configuration is similar to ICE_AGRIF, except for the AGRIF zoom.
-  The purpose of this configuration is to test the advection schemes available in the sea-ice code
+| The purpose of this configuration is to test the advection schemes available in the sea-ice code
   (for now, Prather and Ultimate-Macho from 1st to 5th order),
   especially the occurence of overshoots in ice thickness
-  
 
 ICE_ADV1D
-=========
-  
-  This experiment is the classical Schar & Smolarkiewicz (1996) test case :cite:`SCHAR1996`,
-  which has been used in :cite:`LIPSCOMB2004`,
-  and in which very specific shapes of ice concentration, thickness and volume converge toward the center of a basin.
+---------
+
+| This experiment is the classical :cite:`SCHAR1996` test case ,
+  which has been used in :cite:`LIPSCOMB2004`, and in which very specific shapes of ice concentration,
+  thickness and volume converge toward the center of a basin.
   Convergence is unidirectional (in x) while fields are homogeneous in y.
-  The purpose of this configuration is to test the caracteristics of advection schemes available in the sea-ice code
+| The purpose of this configuration is to
+  test the caracteristics of advection schemes available in the sea-ice code
   (for now, Prather and Ultimate-Macho from 1st to 5th order),
-  especially the constitency between concentration, thickness and volume, and the preservation of initial shapes.  
-
-References
-==========
-
-.. bibliography:: test_cases.bib
-	:all:
-	:style: unsrt
-	:labelprefix: T
+  especially the constitency between concentration, thickness and volume,
+  and the preservation of initial shapes.
+
+.. rubric:: References
+
+.. bibliography:: tests.bib
+   :all:
+   :style: unsrt
+   :labelprefix: T
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/EXPREF/1_namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/EXPREF/1_namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/EXPREF/1_namelist_cfg	(revision 12143)
@@ -272,7 +272,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
@@ -18,13 +28,13 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/EXPREF/namelist_cfg	(revision 12143)
@@ -263,7 +263,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default; OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/MY_SRC/domvvl.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/MY_SRC/domvvl.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/MY_SRC/domvvl.F90	(revision 12143)
@@ -1020,8 +1020,8 @@
       REWIND( numnam_ref )              ! Namelist nam_vvl in reference namelist : 
       READ  ( numnam_ref, nam_vvl, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_vvl in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_vvl in reference namelist' )
       REWIND( numnam_cfg )              ! Namelist nam_vvl in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, nam_vvl, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist', lwp )
+902   IF( ios >  0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist' )
       IF(lwm) WRITE ( numond, nam_vvl )
       !
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/VORTEX/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -40,5 +40,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -52,5 +52,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -58,5 +57,5 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii      ! Local integer
+      INTEGER ::   ios          ! Local integer
       REAL(wp)::   zlx, zly, zh ! Local scalars
       !!
@@ -64,9 +63,7 @@
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
       !
 #if defined key_agrif 
@@ -80,43 +77,41 @@
 #endif
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       cd_cfg = 'VORTEX'             ! name & resolution (not used)
-      kk_cfg = INT( rn_dx )
+      kk_cfg = nINT( rn_dx )
       !
-      ! Global Domain size:  VORTEX global domain is  1800 km x 1800 Km x 5000 m
-      kpi = INT( 1800.e3  / rn_dx ) + 3  
-      kpj = INT( 1800.e3  / rn_dy ) + 3 
-      kpk = INT( 5000._wp / rn_dz ) + 1
-#if defined key_agrif
-      IF( .NOT. Agrif_Root() ) THEN
+      IF( Agrif_Root() ) THEN       ! Global Domain size:  VORTEX global domain is  1800 km x 1800 Km x 5000 m
+         kpi = NINT( 1800.e3  / rn_dx ) + 3  
+         kpj = NINT( 1800.e3  / rn_dy ) + 3 
+      ELSE
          kpi  = nbcellsx + 2 + 2*nbghostcells
          kpj  = nbcellsy + 2 + 2*nbghostcells
       ENDIF
-#endif
+      kpk = NINT( 5000._wp / rn_dz ) + 1
       !
       zlx = (kpi-2)*rn_dx*1.e-3
       zly = (kpj-2)*rn_dy*1.e-3
       zh  = (kpk-1)*rn_dz
-      !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : VORTEX test case'                                    ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution             rn_dx  = ', rn_dx, ' m'               ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution             rn_dy  = ', rn_dy, ' m'               ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      vertical resolution               rn_dz  = ', rn_dz, ' m'               ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      VORTEX domain: '                                                        ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         LX [km]: ', zlx                                                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         LY [km]: ', zly                                                      ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '          H [m] : ', zh                                                       ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      Reference latitude            rn_ppgphi0 = ', rn_ppgphi0                ;   ii = ii + 1
-      !
       !                             ! Set the lateral boundary condition of the global domain
       kperio = 0                    ! VORTEX configuration : closed basin
-      !
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Lateral boundary condition of the global domain'                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      VORTEX : closed basin            jperio = ', kperio                     ;   ii = ii + 1
+      !                             ! control print
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : VORTEX test case'
+         WRITE(numout,*) '      horizontal resolution             rn_dx  = ', rn_dx, ' m'
+         WRITE(numout,*) '      horizontal resolution             rn_dy  = ', rn_dy, ' m'
+         WRITE(numout,*) '      vertical resolution               rn_dz  = ', rn_dz, ' m'
+         WRITE(numout,*) '      VORTEX domain: '
+         WRITE(numout,*) '         LX [km]: ', zlx
+         WRITE(numout,*) '         LY [km]: ', zly
+         WRITE(numout,*) '          H [m] : ', zh
+         WRITE(numout,*) '      Reference latitude            rn_ppgphi0 = ', rn_ppgphi0
+         WRITE(numout,*) '   '
+         WRITE(numout,*) '   Lateral boundary condition of the global domain'
+         WRITE(numout,*) '      VORTEX : closed basin            jperio = ', kperio
+      ENDIF
       !
    END SUBROUTINE usr_def_nam
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/EXPREF/context_nemo.xml	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/EXPREF/context_nemo.xml	(revision 12143)
@@ -6,4 +6,14 @@
 <context id="nemo">
 <!-- $id$ -->
+    <variable_definition>
+    <!-- Year of time origin for NetCDF files; defaults to 1800 -->
+       <variable id="ref_year" type="int"   > 1800 </variable>
+       <variable id="rau0"     type="float" > 1026.0 </variable>
+       <variable id="cpocean"  type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu" type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"    type="float" > 917.0 </variable>
+       <variable id="rhosn"    type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>
+    </variable_definition>
 <!-- Fields definition -->
     <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
@@ -18,13 +28,13 @@
     
     <axis_definition>
-      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
-      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
-      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
-      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
-      <axis id="nfloat" long_name="Float number"      unit="-"                 />
-      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
-      <axis id="ncatice" long_name="Ice category"       unit="1"               />
-      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
-      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+      <axis id="deptht"  long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"     unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"      unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"  unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"  unit="degC"              />
     </axis_definition>
  
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/EXPREF/namelist_cfg	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/EXPREF/namelist_cfg	(revision 12143)
@@ -180,11 +180,15 @@
 &nambdy_dta    !  open boundaries - external data                       
 !-----------------------------------------------------------------------
+   ln_zinterp  = .false.      !  T if a vertical interpolation is required. Variables gdep[tuv] and e3[tuv] must exist in the file
+   !                          !  automatically defined to T if the number of vertical levels in bdy dta /= jpk
+   ln_full_vel = .false.      !  T if [uv]3d are "full" velocities and not only its baroclinic components
+   !                          !  in this case, baroclinic and barotropic velocities will be recomputed -> [uv]2d not needed
+   !
+   cn_dir  =  './'
 !              !  file name      ! frequency (hours) ! variable  ! time interp. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                 !  (if <0  months)  !   name    !  (logical)   !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
-   bn_ssh =     'bdyssh_tc7' ,         1        , 'sshbdy',     .true.     , .true.  ,  'daily'  ,    ''    ,   ''     , ''
-   bn_u2d =     'bdyuv_tc7'  ,         1        , 'ubdy'  ,     .true.     , .true.  ,  'daily'  ,    ''    ,   ''     , ''
-   bn_v2d =     'bdyuv_tc7'  ,         1        , 'vbdy'  ,     .true.     , .true.  ,  'daily'  ,    ''    ,   ''     , ''
-   cn_dir      =    './'   !  root directory for the location of the bulk files
-   ln_full_vel = .false.        !
+   bn_ssh =     'bdyssh_tc7' ,         1.       , 'sshbdy',     .true.     , .true.  ,  'daily'  ,    ''    ,   ''     , ''
+   bn_u2d =     'bdyuv_tc7'  ,         1.       , 'ubdy'  ,     .true.     , .true.  ,  'daily'  ,    ''    ,   ''     , ''
+   bn_v2d =     'bdyuv_tc7'  ,         1.       , 'vbdy'  ,     .true.     , .true.  ,  'daily'  ,    ''    ,   ''     , ''
 /
 !-----------------------------------------------------------------------
@@ -417,7 +421,7 @@
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
 !!   namdiu       Cool skin and warm layer models                       (default: OFF)
-!!   namflo       float parameters                                      ("key_float")
-!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
-!!   namdct       transports through some sections                      ("key_diadct")
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diaharm  Harmonic analysis of tidal constituents               (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
 !!   nam_diatmb   Top Middle Bottom Output                              (default: OFF)
 !!   nam_dia25h   25h Mean Output                                       (default: OFF)
@@ -439,6 +443,7 @@
 /
 !-----------------------------------------------------------------------
-&namdct        ! transports through some sections                       ("key_diadct")
-!-----------------------------------------------------------------------
+&nam_diadct    !   transports through some sections                     (default: OFF)
+!-----------------------------------------------------------------------
+    ln_diadct  = .false.   ! Calculate transport thru sections or not
     nn_dct      = 60       !  time step frequency for transports computing
     nn_dctwri   = 60       !  time step frequency for transports writing
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/MY_SRC/bdyini.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/MY_SRC/bdyini.F90	(revision 12062)
+++ 	(revision )
@@ -1,1702 +1,0 @@
-MODULE bdyini
-   !!======================================================================
-   !!                       ***  MODULE  bdyini  ***
-   !! Unstructured open boundaries : initialisation
-   !!======================================================================
-   !! History :  1.0  !  2005-01  (J. Chanut, A. Sellar)  Original code
-   !!             -   !  2007-01  (D. Storkey) Update to use IOM module
-   !!             -   !  2007-01  (D. Storkey) Tidal forcing
-   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
-   !!            3.3  !  2010-09  (E.O'Dea) updates for Shelf configurations
-   !!            3.3  !  2010-09  (D.Storkey) add ice boundary conditions
-   !!            3.4  !  2011     (D. Storkey) rewrite in preparation for OBC-BDY merge
-   !!            3.4  !  2012     (J. Chanut) straight open boundary case update
-   !!            3.5  !  2012     (S. Mocavero, I. Epicoco) optimization of BDY communications
-   !!            3.7  !  2016     (T. Lovato) Remove bdy macro, call here init for dta and tides
-   !!----------------------------------------------------------------------
-   !!   bdy_init      : Initialization of unstructured open boundaries
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers variables
-   USE dom_oce        ! ocean space and time domain
-   USE bdy_oce        ! unstructured open boundary conditions
-   USE bdydta         ! open boundary cond. setting   (bdy_dta_init routine)
-   USE bdytides       ! open boundary cond. setting   (bdytide_init routine)
-   USE sbctide        ! Tidal forcing or not
-   USE phycst   , ONLY: rday
-   !
-   USE in_out_manager ! I/O units
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE lib_mpp        ! for mpp_sum  
-   USE iom            ! I/O
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   bdy_init   ! routine called in nemo_init
-
-   INTEGER, PARAMETER ::   jp_nseg = 100   ! 
-   INTEGER, PARAMETER ::   nrimmax =  20   ! maximum rimwidth in structured
-                                               ! open boundary data files
-   ! Straight open boundary segment parameters:
-   INTEGER  ::   nbdysege, nbdysegw, nbdysegn, nbdysegs 
-   INTEGER, DIMENSION(jp_nseg) ::   jpieob, jpjedt, jpjeft, npckge   !
-   INTEGER, DIMENSION(jp_nseg) ::   jpiwob, jpjwdt, jpjwft, npckgw   !
-   INTEGER, DIMENSION(jp_nseg) ::   jpjnob, jpindt, jpinft, npckgn   !
-   INTEGER, DIMENSION(jp_nseg) ::   jpjsob, jpisdt, jpisft, npckgs   !
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$ 
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE bdy_init
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE bdy_init  ***
-      !!
-      !! ** Purpose :   Initialization of the dynamics and tracer fields with
-      !!              unstructured open boundaries.
-      !!
-      !! ** Method  :   Read initialization arrays (mask, indices) to identify
-      !!              an unstructured open boundary
-      !!
-      !! ** Input   :  bdy_init.nc, input file for unstructured open boundaries
-      !!----------------------------------------------------------------------
-      NAMELIST/nambdy/ ln_bdy, nb_bdy, ln_coords_file, cn_coords_file,         &
-         &             ln_mask_file, cn_mask_file, cn_dyn2d, nn_dyn2d_dta,     &
-         &             cn_dyn3d, nn_dyn3d_dta, cn_tra, nn_tra_dta,             &
-         &             ln_tra_dmp, ln_dyn3d_dmp, rn_time_dmp, rn_time_dmp_out, &
-         &             cn_ice, nn_ice_dta,                                     &
-         &             rn_ice_tem, rn_ice_sal, rn_ice_age,                     &
-         &             ln_vol, nn_volctl, nn_rimwidth, nb_jpk_bdy
-         !
-      INTEGER  ::   ios                 ! Local integer output status for namelist read
-      !!----------------------------------------------------------------------
-
-      ! ------------------------
-      ! Read namelist parameters
-      ! ------------------------
-      REWIND( numnam_ref )              ! Namelist nambdy in reference namelist :Unstructured open boundaries
-      READ  ( numnam_ref, nambdy, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist', lwp )
-      REWIND( numnam_cfg )              ! Namelist nambdy in configuration namelist :Unstructured open boundaries
-      READ  ( numnam_cfg, nambdy, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist', lwp )
-      IF(lwm) WRITE ( numond, nambdy )
-
-      IF( .NOT. Agrif_Root() ) ln_bdy = .FALSE.   ! forced for Agrif children
-      
-      ! -----------------------------------------
-      ! unstructured open boundaries use control
-      ! -----------------------------------------
-      IF ( ln_bdy ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'bdy_init : initialization of open boundaries'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~'
-         !
-         ! Open boundaries definition (arrays and masks)
-         CALL bdy_segs
-         !
-         ! Open boundaries initialisation of external data arrays
-         CALL bdy_dta_init
-         !
-         ! Open boundaries initialisation of tidal harmonic forcing
-         IF( ln_tide ) CALL bdytide_init
-         !
-      ELSE
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'bdy_init : open boundaries not used (ln_bdy = F)'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~'
-         !
-      ENDIF
-      !
-   END SUBROUTINE bdy_init
-
-
-   SUBROUTINE bdy_segs
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE bdy_init  ***
-      !!         
-      !! ** Purpose :   Definition of unstructured open boundaries.
-      !!
-      !! ** Method  :   Read initialization arrays (mask, indices) to identify 
-      !!              an unstructured open boundary
-      !!
-      !! ** Input   :  bdy_init.nc, input file for unstructured open boundaries
-      !!----------------------------------------------------------------------      
-      INTEGER  ::   ib_bdy, ii, ij, ik, igrd, ib, ir, iseg ! dummy loop indices
-      INTEGER  ::   icount, icountr, ibr_max, ilen1, ibm1  ! local integers
-      INTEGER  ::   iwe, ies, iso, ino, inum, id_dummy     !   -       -
-      INTEGER  ::   igrd_start, igrd_end, jpbdta           !   -       -
-      INTEGER  ::   jpbdtau, jpbdtas                       !   -       -
-      INTEGER  ::   ib_bdy1, ib_bdy2, ib1, ib2             !   -       -
-      INTEGER  ::   i_offset, j_offset                     !   -       -
-      INTEGER , POINTER  ::  nbi, nbj, nbr                 ! short cuts
-      REAL(wp), POINTER  ::  flagu, flagv                  !    -   -
-      REAL(wp), POINTER, DIMENSION(:,:)       ::   pmask    ! pointer to 2D mask fields
-      REAL(wp) ::   zefl, zwfl, znfl, zsfl                 ! local scalars
-      INTEGER, DIMENSION (2)                  ::   kdimsz
-      INTEGER, DIMENSION(jpbgrd,jp_bdy)       ::   nblendta         ! Length of index arrays 
-      INTEGER, ALLOCATABLE, DIMENSION(:,:,:)  ::   nbidta, nbjdta   ! Index arrays: i and j indices of bdy dta
-      INTEGER, ALLOCATABLE, DIMENSION(:,:,:)  ::   nbrdta           ! Discrete distance from rim points
-      CHARACTER(LEN=1),DIMENSION(jpbgrd)      ::   cgrid
-      INTEGER :: com_east, com_west, com_south, com_north          ! Flags for boundaries sending
-      INTEGER :: com_east_b, com_west_b, com_south_b, com_north_b  ! Flags for boundaries receiving
-      INTEGER :: iw_b(4), ie_b(4), is_b(4), in_b(4)                ! Arrays for neighbours coordinates
-      REAL(wp), TARGET, DIMENSION(jpi,jpj) ::   zfmask  ! temporary fmask array excluding coastal boundary condition (shlat)
-      !!
-      CHARACTER(LEN=1)                     ::   ctypebdy   !     -        - 
-      INTEGER                              ::   nbdyind, nbdybeg, nbdyend
-      !!
-      NAMELIST/nambdy_index/ ctypebdy, nbdyind, nbdybeg, nbdyend
-      INTEGER  ::   ios                 ! Local integer output status for namelist read
-      !!----------------------------------------------------------------------
-      !
-      cgrid = (/'t','u','v'/)
-
-      ! -----------------------------------------
-      ! Check and write out namelist parameters
-      ! -----------------------------------------
-      IF( jperio /= 0 )   CALL ctl_stop( 'bdy_segs: Cyclic or symmetric,',   &
-         &                               ' and general open boundary condition are not compatible' )
-
-      IF( nb_bdy == 0 ) THEN 
-        IF(lwp) WRITE(numout,*) 'nb_bdy = 0, NO OPEN BOUNDARIES APPLIED.'
-      ELSE
-        IF(lwp) WRITE(numout,*) 'Number of open boundary sets : ', nb_bdy
-      ENDIF
-
-      DO ib_bdy = 1,nb_bdy
-        IF(lwp) WRITE(numout,*) ' ' 
-        IF(lwp) WRITE(numout,*) '------ Open boundary data set ',ib_bdy,'------' 
-
-        IF( ln_coords_file(ib_bdy) ) THEN
-           IF(lwp) WRITE(numout,*) 'Boundary definition read from file '//TRIM(cn_coords_file(ib_bdy))
-        ELSE
-           IF(lwp) WRITE(numout,*) 'Boundary defined in namelist.'
-        ENDIF
-        IF(lwp) WRITE(numout,*)
-
-        IF(lwp) WRITE(numout,*) 'Boundary conditions for barotropic solution:  '
-        SELECT CASE( cn_dyn2d(ib_bdy) )                  
-          CASE( 'none' )         
-             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
-             dta_bdy(ib_bdy)%ll_ssh = .false.
-             dta_bdy(ib_bdy)%ll_u2d = .false.
-             dta_bdy(ib_bdy)%ll_v2d = .false.
-          CASE( 'frs' )          
-             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
-             dta_bdy(ib_bdy)%ll_ssh = .false.
-             dta_bdy(ib_bdy)%ll_u2d = .true.
-             dta_bdy(ib_bdy)%ll_v2d = .true.
-          CASE( 'flather' )      
-             IF(lwp) WRITE(numout,*) '      Flather radiation condition'
-             dta_bdy(ib_bdy)%ll_ssh = .true.
-             dta_bdy(ib_bdy)%ll_u2d = .true.
-             dta_bdy(ib_bdy)%ll_v2d = .true.
-          CASE( 'orlanski' )     
-             IF(lwp) WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_ssh = .false.
-             dta_bdy(ib_bdy)%ll_u2d = .true.
-             dta_bdy(ib_bdy)%ll_v2d = .true.
-          CASE( 'orlanski_npo' ) 
-             IF(lwp) WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_ssh = .false.
-             dta_bdy(ib_bdy)%ll_u2d = .true.
-             dta_bdy(ib_bdy)%ll_v2d = .true.
-          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_dyn2d' )
-        END SELECT
-        IF( cn_dyn2d(ib_bdy) /= 'none' ) THEN
-           SELECT CASE( nn_dyn2d_dta(ib_bdy) )                   ! 
-              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
-              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
-              CASE( 2 )      ;   IF(lwp) WRITE(numout,*) '      tidal harmonic forcing taken from file'
-              CASE( 3 )      ;   IF(lwp) WRITE(numout,*) '      boundary data AND tidal harmonic forcing taken from files'
-              CASE DEFAULT   ;   CALL ctl_stop( 'nn_dyn2d_dta must be between 0 and 3' )
-           END SELECT
-           IF (( nn_dyn2d_dta(ib_bdy) .ge. 2 ).AND.(.NOT.ln_tide)) THEN
-             CALL ctl_stop( 'You must activate with ln_tide to add tidal forcing at open boundaries' )
-           ENDIF
-        ENDIF
-        IF(lwp) WRITE(numout,*)
-
-        IF(lwp) WRITE(numout,*) 'Boundary conditions for baroclinic velocities:  '
-        SELECT CASE( cn_dyn3d(ib_bdy) )                  
-          CASE('none')
-             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
-             dta_bdy(ib_bdy)%ll_u3d = .false.
-             dta_bdy(ib_bdy)%ll_v3d = .false.
-          CASE('frs')       
-             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
-             dta_bdy(ib_bdy)%ll_u3d = .true.
-             dta_bdy(ib_bdy)%ll_v3d = .true.
-          CASE('specified')
-             IF(lwp) WRITE(numout,*) '      Specified value'
-             dta_bdy(ib_bdy)%ll_u3d = .true.
-             dta_bdy(ib_bdy)%ll_v3d = .true.
-          CASE('neumann')
-             IF(lwp) WRITE(numout,*) '      Neumann conditions'
-             dta_bdy(ib_bdy)%ll_u3d = .false.
-             dta_bdy(ib_bdy)%ll_v3d = .false.
-          CASE('zerograd')
-             IF(lwp) WRITE(numout,*) '      Zero gradient for baroclinic velocities'
-             dta_bdy(ib_bdy)%ll_u3d = .false.
-             dta_bdy(ib_bdy)%ll_v3d = .false.
-          CASE('zero')
-             IF(lwp) WRITE(numout,*) '      Zero baroclinic velocities (runoff case)'
-             dta_bdy(ib_bdy)%ll_u3d = .false.
-             dta_bdy(ib_bdy)%ll_v3d = .false.
-          CASE('orlanski')
-             IF(lwp) WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_u3d = .true.
-             dta_bdy(ib_bdy)%ll_v3d = .true.
-          CASE('orlanski_npo')
-             IF(lwp) WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_u3d = .true.
-             dta_bdy(ib_bdy)%ll_v3d = .true.
-          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_dyn3d' )
-        END SELECT
-        IF( cn_dyn3d(ib_bdy) /= 'none' ) THEN
-           SELECT CASE( nn_dyn3d_dta(ib_bdy) )                   ! 
-              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
-              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
-              CASE DEFAULT   ;   CALL ctl_stop( 'nn_dyn3d_dta must be 0 or 1' )
-           END SELECT
-        ENDIF
-
-        IF ( ln_dyn3d_dmp(ib_bdy) ) THEN
-           IF ( cn_dyn3d(ib_bdy) == 'none' ) THEN
-              IF(lwp) WRITE(numout,*) 'No open boundary condition for baroclinic velocities: ln_dyn3d_dmp is set to .false.'
-              ln_dyn3d_dmp(ib_bdy)=.false.
-           ELSEIF ( cn_dyn3d(ib_bdy) == 'frs' ) THEN
-              CALL ctl_stop( 'Use FRS OR relaxation' )
-           ELSE
-              IF(lwp) WRITE(numout,*) '      + baroclinic velocities relaxation zone'
-              IF(lwp) WRITE(numout,*) '      Damping time scale: ',rn_time_dmp(ib_bdy),' days'
-              IF((lwp).AND.rn_time_dmp(ib_bdy)<0) CALL ctl_stop( 'Time scale must be positive' )
-              dta_bdy(ib_bdy)%ll_u3d = .true.
-              dta_bdy(ib_bdy)%ll_v3d = .true.
-           ENDIF
-        ELSE
-           IF(lwp) WRITE(numout,*) '      NO relaxation on baroclinic velocities'
-        ENDIF
-        IF(lwp) WRITE(numout,*)
-
-        IF(lwp) WRITE(numout,*) 'Boundary conditions for temperature and salinity:  '
-        SELECT CASE( cn_tra(ib_bdy) )                  
-          CASE('none')
-             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
-             dta_bdy(ib_bdy)%ll_tem = .false.
-             dta_bdy(ib_bdy)%ll_sal = .false.
-          CASE('frs')
-             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
-             dta_bdy(ib_bdy)%ll_tem = .true.
-             dta_bdy(ib_bdy)%ll_sal = .true.
-          CASE('specified')
-             IF(lwp) WRITE(numout,*) '      Specified value'
-             dta_bdy(ib_bdy)%ll_tem = .true.
-             dta_bdy(ib_bdy)%ll_sal = .true.
-          CASE('neumann')
-             IF(lwp) WRITE(numout,*) '      Neumann conditions'
-             dta_bdy(ib_bdy)%ll_tem = .false.
-             dta_bdy(ib_bdy)%ll_sal = .false.
-          CASE('runoff')
-             IF(lwp) WRITE(numout,*) '      Runoff conditions : Neumann for T and specified to 0.1 for salinity'
-             dta_bdy(ib_bdy)%ll_tem = .false.
-             dta_bdy(ib_bdy)%ll_sal = .false.
-          CASE('orlanski')
-             IF(lwp) WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_tem = .true.
-             dta_bdy(ib_bdy)%ll_sal = .true.
-          CASE('orlanski_npo')
-             IF(lwp) WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
-             dta_bdy(ib_bdy)%ll_tem = .true.
-             dta_bdy(ib_bdy)%ll_sal = .true.
-          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_tra' )
-        END SELECT
-        IF( cn_tra(ib_bdy) /= 'none' ) THEN
-           SELECT CASE( nn_tra_dta(ib_bdy) )                   ! 
-              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
-              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
-              CASE DEFAULT   ;   CALL ctl_stop( 'nn_tra_dta must be 0 or 1' )
-           END SELECT
-        ENDIF
-
-        IF ( ln_tra_dmp(ib_bdy) ) THEN
-           IF ( cn_tra(ib_bdy) == 'none' ) THEN
-              IF(lwp) WRITE(numout,*) 'No open boundary condition for tracers: ln_tra_dmp is set to .false.'
-              ln_tra_dmp(ib_bdy)=.false.
-           ELSEIF ( cn_tra(ib_bdy) == 'frs' ) THEN
-              CALL ctl_stop( 'Use FRS OR relaxation' )
-           ELSE
-              IF(lwp) WRITE(numout,*) '      + T/S relaxation zone'
-              IF(lwp) WRITE(numout,*) '      Damping time scale: ',rn_time_dmp(ib_bdy),' days'
-              IF(lwp) WRITE(numout,*) '      Outflow damping time scale: ',rn_time_dmp_out(ib_bdy),' days'
-              IF((lwp).AND.rn_time_dmp(ib_bdy)<0) CALL ctl_stop( 'Time scale must be positive' )
-              dta_bdy(ib_bdy)%ll_tem = .true.
-              dta_bdy(ib_bdy)%ll_sal = .true.
-           ENDIF
-        ELSE
-           IF(lwp) WRITE(numout,*) '      NO T/S relaxation'
-        ENDIF
-        IF(lwp) WRITE(numout,*)
-
-#if defined key_si3
-         IF(lwp) WRITE(numout,*) 'Boundary conditions for sea ice:  '
-         SELECT CASE( cn_ice(ib_bdy) )                  
-         CASE('none')
-             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
-             dta_bdy(ib_bdy)%ll_a_i = .false.
-             dta_bdy(ib_bdy)%ll_h_i = .false.
-             dta_bdy(ib_bdy)%ll_h_s = .false.
-         CASE('frs')
-             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
-             dta_bdy(ib_bdy)%ll_a_i = .true.
-             dta_bdy(ib_bdy)%ll_h_i = .true.
-             dta_bdy(ib_bdy)%ll_h_s = .true.
-         CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_ice' )
-         END SELECT
-        IF( cn_ice(ib_bdy) /= 'none' ) THEN 
-           SELECT CASE( nn_ice_dta(ib_bdy) )                   ! 
-              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
-              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
-              CASE DEFAULT   ;   CALL ctl_stop( 'nn_ice_dta must be 0 or 1' )
-           END SELECT
-        ENDIF
-        IF(lwp) WRITE(numout,*)
-        IF(lwp) WRITE(numout,*) '      tem of bdy sea-ice = ', rn_ice_tem(ib_bdy)         
-        IF(lwp) WRITE(numout,*) '      sal of bdy sea-ice = ', rn_ice_sal(ib_bdy)         
-        IF(lwp) WRITE(numout,*) '      age of bdy sea-ice = ', rn_ice_age(ib_bdy)         
-#endif
-
-        IF(lwp) WRITE(numout,*) '      Width of relaxation zone = ', nn_rimwidth(ib_bdy)
-        IF(lwp) WRITE(numout,*)
-         !
-      END DO
-
-     IF( nb_bdy > 0 ) THEN
-        IF( ln_vol ) THEN                     ! check volume conservation (nn_volctl value)
-          IF(lwp) WRITE(numout,*) 'Volume correction applied at open boundaries'
-          IF(lwp) WRITE(numout,*)
-          SELECT CASE ( nn_volctl )
-            CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      The total volume will be constant'
-            CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      The total volume will vary according to the surface E-P flux'
-            CASE DEFAULT   ;   CALL ctl_stop( 'nn_volctl must be 0 or 1' )
-          END SELECT
-          IF(lwp) WRITE(numout,*)
-        ELSE
-          IF(lwp) WRITE(numout,*) 'No volume correction applied at open boundaries'
-          IF(lwp) WRITE(numout,*)
-        ENDIF
-        IF( nb_jpk_bdy > 0 ) THEN
-           IF(lwp) WRITE(numout,*) '*** open boundary will be interpolate in the vertical onto the native grid ***'
-        ELSE
-           IF(lwp) WRITE(numout,*) '*** open boundary will be read straight onto the native grid without vertical interpolation ***'
-        ENDIF
-     ENDIF
-
-      ! -------------------------------------------------
-      ! Initialise indices arrays for open boundaries
-      ! -------------------------------------------------
-
-      ! Work out global dimensions of boundary data
-      ! ---------------------------------------------
-      REWIND( numnam_cfg )     
-
-      nblendta(:,:) = 0
-      nbdysege = 0
-      nbdysegw = 0
-      nbdysegn = 0
-      nbdysegs = 0
-      icount   = 0 ! count user defined segments
-      ! Dimensions below are used to allocate arrays to read external data
-      jpbdtas = 1 ! Maximum size of boundary data (structured case)
-      jpbdtau = 1 ! Maximum size of boundary data (unstructured case)
-
-      DO ib_bdy = 1, nb_bdy
-
-         IF( .NOT. ln_coords_file(ib_bdy) ) THEN ! Work out size of global arrays from namelist parameters
- 
-            icount = icount + 1
-            ! No REWIND here because may need to read more than one nambdy_index namelist.
-            ! Read only namelist_cfg to avoid unseccessfull overwrite 
-            ! keep full control of the configuration namelist
-            READ  ( numnam_cfg, nambdy_index, IOSTAT = ios, ERR = 904 )
-904         IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy_index in configuration namelist', lwp )
-            IF(lwm) WRITE ( numond, nambdy_index )
-
-            SELECT CASE ( TRIM(ctypebdy) )
-              CASE( 'N' )
-                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
-                    nbdyind  = jpjglo - 2  ! set boundary to whole side of model domain.
-                    nbdybeg  = 2
-                    nbdyend  = jpiglo - 1
-                 ENDIF
-                 nbdysegn = nbdysegn + 1
-                 npckgn(nbdysegn) = ib_bdy ! Save bdy package number
-                 jpjnob(nbdysegn) = nbdyind
-                 jpindt(nbdysegn) = nbdybeg
-                 jpinft(nbdysegn) = nbdyend
-                 !
-              CASE( 'S' )
-                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
-                    nbdyind  = 2           ! set boundary to whole side of model domain.
-                    nbdybeg  = 2
-                    nbdyend  = jpiglo - 1
-                 ENDIF
-                 nbdysegs = nbdysegs + 1
-                 npckgs(nbdysegs) = ib_bdy ! Save bdy package number
-                 jpjsob(nbdysegs) = nbdyind
-                 jpisdt(nbdysegs) = nbdybeg
-                 jpisft(nbdysegs) = nbdyend
-                 !
-              CASE( 'E' )
-                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
-                    nbdyind  = jpiglo - 2  ! set boundary to whole side of model domain.
-                    nbdybeg  = 2
-                    nbdyend  = jpjglo - 1
-                 ENDIF
-                 nbdysege = nbdysege + 1 
-                 npckge(nbdysege) = ib_bdy ! Save bdy package number
-                 jpieob(nbdysege) = nbdyind
-                 jpjedt(nbdysege) = nbdybeg
-                 jpjeft(nbdysege) = nbdyend
-                 !
-              CASE( 'W' )
-                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
-                    nbdyind  = 2           ! set boundary to whole side of model domain.
-                    nbdybeg  = 2
-                    nbdyend  = jpjglo - 1
-                 ENDIF
-                 nbdysegw = nbdysegw + 1
-                 npckgw(nbdysegw) = ib_bdy ! Save bdy package number
-                 jpiwob(nbdysegw) = nbdyind
-                 jpjwdt(nbdysegw) = nbdybeg
-                 jpjwft(nbdysegw) = nbdyend
-                 !
-              CASE DEFAULT   ;   CALL ctl_stop( 'ctypebdy must be N, S, E or W' )
-            END SELECT
-
-            ! For simplicity we assume that in case of straight bdy, arrays have the same length
-            ! (even if it is true that last tangential velocity points
-            ! are useless). This simplifies a little bit boundary data format (and agrees with format
-            ! used so far in obc package)
-
-            nblendta(1:jpbgrd,ib_bdy) =  (nbdyend - nbdybeg + 1) * nn_rimwidth(ib_bdy)
-            jpbdtas = MAX(jpbdtas, (nbdyend - nbdybeg + 1))
-            IF (lwp.and.(nn_rimwidth(ib_bdy)>nrimmax)) &
-            & CALL ctl_stop( 'rimwidth must be lower than nrimmax' )
-
-         ELSE            ! Read size of arrays in boundary coordinates file.
-            CALL iom_open( cn_coords_file(ib_bdy), inum )
-            DO igrd = 1, jpbgrd
-               id_dummy = iom_varid( inum, 'nbi'//cgrid(igrd), kdimsz=kdimsz )  
-               nblendta(igrd,ib_bdy) = MAXVAL(kdimsz)
-               jpbdtau = MAX(jpbdtau, MAXVAL(kdimsz))
-            END DO
-            CALL iom_close( inum )
-            !
-         ENDIF 
-         !
-      END DO ! ib_bdy
-
-      IF (nb_bdy>0) THEN
-         jpbdta = MAXVAL(nblendta(1:jpbgrd,1:nb_bdy))
-
-         ! Allocate arrays
-         !---------------
-         ALLOCATE( nbidta(jpbdta, jpbgrd, nb_bdy), nbjdta(jpbdta, jpbgrd, nb_bdy),    &
-            &      nbrdta(jpbdta, jpbgrd, nb_bdy) )
-
-         IF( nb_jpk_bdy>0 ) THEN
-            ALLOCATE( dta_global(jpbdtau, 1, nb_jpk_bdy) )
-            ALLOCATE( dta_global_z(jpbdtau, 1, nb_jpk_bdy) )
-            ALLOCATE( dta_global_dz(jpbdtau, 1, nb_jpk_bdy) )
-         ELSE
-            ALLOCATE( dta_global(jpbdtau, 1, jpk) )
-            ALLOCATE( dta_global_z(jpbdtau, 1, jpk) ) ! needed ?? TODO
-            ALLOCATE( dta_global_dz(jpbdtau, 1, jpk) )! needed ?? TODO
-         ENDIF
-
-         IF ( icount>0 ) THEN
-            IF( nb_jpk_bdy>0 ) THEN
-               ALLOCATE( dta_global2(jpbdtas, nrimmax, nb_jpk_bdy) )
-               ALLOCATE( dta_global2_z(jpbdtas, nrimmax, nb_jpk_bdy) )
-               ALLOCATE( dta_global2_dz(jpbdtas, nrimmax, nb_jpk_bdy) )
-            ELSE
-               ALLOCATE( dta_global2(jpbdtas, nrimmax, jpk) )
-               ALLOCATE( dta_global2_z(jpbdtas, nrimmax, jpk) ) ! needed ?? TODO
-               ALLOCATE( dta_global2_dz(jpbdtas, nrimmax, jpk) )! needed ?? TODO  
-            ENDIF
-         ENDIF
-         ! 
-      ENDIF
-
-      ! Now look for crossings in user (namelist) defined open boundary segments:
-      !--------------------------------------------------------------------------
-      IF( icount>0 )   CALL bdy_ctl_seg
-
-      ! Calculate global boundary index arrays or read in from file
-      !------------------------------------------------------------               
-      ! 1. Read global index arrays from boundary coordinates file.
-      DO ib_bdy = 1, nb_bdy
-         !
-         IF( ln_coords_file(ib_bdy) ) THEN
-            !
-            CALL iom_open( cn_coords_file(ib_bdy), inum )
-            DO igrd = 1, jpbgrd
-               CALL iom_get( inum, jpdom_unknown, 'nbi'//cgrid(igrd), dta_global(1:nblendta(igrd,ib_bdy),:,1) )
-               DO ii = 1,nblendta(igrd,ib_bdy)
-                  nbidta(ii,igrd,ib_bdy) = INT( dta_global(ii,1,1) )
-               END DO
-               CALL iom_get( inum, jpdom_unknown, 'nbj'//cgrid(igrd), dta_global(1:nblendta(igrd,ib_bdy),:,1) )
-               DO ii = 1,nblendta(igrd,ib_bdy)
-                  nbjdta(ii,igrd,ib_bdy) = INT( dta_global(ii,1,1) )
-               END DO
-               CALL iom_get( inum, jpdom_unknown, 'nbr'//cgrid(igrd), dta_global(1:nblendta(igrd,ib_bdy),:,1) )
-               DO ii = 1,nblendta(igrd,ib_bdy)
-                  nbrdta(ii,igrd,ib_bdy) = INT( dta_global(ii,1,1) )
-               END DO
-               !
-               ibr_max = MAXVAL( nbrdta(:,igrd,ib_bdy) )
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' Maximum rimwidth in file is ', ibr_max
-               IF(lwp) WRITE(numout,*) ' nn_rimwidth from namelist is ', nn_rimwidth(ib_bdy)
-               IF (ibr_max < nn_rimwidth(ib_bdy))   &
-                     CALL ctl_stop( 'nn_rimwidth is larger than maximum rimwidth in file',cn_coords_file(ib_bdy) )
-            END DO
-            CALL iom_close( inum )
-            !
-         ENDIF 
-         !
-      END DO      
-    
-      ! 2. Now fill indices corresponding to straight open boundary arrays:
-      ! East
-      !-----
-      DO iseg = 1, nbdysege
-         ib_bdy = npckge(iseg)
-         !
-         ! ------------ T points -------------
-         igrd=1
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ij = jpjedt(iseg), jpjeft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 2 - ir
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ U points -------------
-         igrd=2
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ij = jpjedt(iseg), jpjeft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 1 - ir
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ V points -------------
-         igrd=3
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-!            DO ij = jpjedt(iseg), jpjeft(iseg) - 1
-            DO ij = jpjedt(iseg), jpjeft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 2 - ir
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-         ENDDO
-      ENDDO
-      !
-      ! West
-      !-----
-      DO iseg = 1, nbdysegw
-         ib_bdy = npckgw(iseg)
-         !
-         ! ------------ T points -------------
-         igrd=1
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ij = jpjwdt(iseg), jpjwft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ U points -------------
-         igrd=2
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ij = jpjwdt(iseg), jpjwft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ V points -------------
-         igrd=3
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-!            DO ij = jpjwdt(iseg), jpjwft(iseg) - 1
-            DO ij = jpjwdt(iseg), jpjwft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
-               nbjdta(icount, igrd, ib_bdy) = ij
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-         ENDDO
-      ENDDO
-      !
-      ! North
-      !-----
-      DO iseg = 1, nbdysegn
-         ib_bdy = npckgn(iseg)
-         !
-         ! ------------ T points -------------
-         igrd=1
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ii = jpindt(iseg), jpinft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 2 - ir 
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ U points -------------
-         igrd=2
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-!            DO ii = jpindt(iseg), jpinft(iseg) - 1
-            DO ii = jpindt(iseg), jpinft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 2 - ir
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-         ENDDO
-         !
-         ! ------------ V points -------------
-         igrd=3
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ii = jpindt(iseg), jpinft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 1 - ir
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-      ENDDO
-      !
-      ! South
-      !-----
-      DO iseg = 1, nbdysegs
-         ib_bdy = npckgs(iseg)
-         !
-         ! ------------ T points -------------
-         igrd=1
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ii = jpisdt(iseg), jpisft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-         !
-         ! ------------ U points -------------
-         igrd=2
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-!            DO ii = jpisdt(iseg), jpisft(iseg) - 1
-            DO ii = jpisdt(iseg), jpisft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
-         ENDDO
-         !
-         ! ------------ V points -------------
-         igrd=3
-         icount=0
-         DO ir = 1, nn_rimwidth(ib_bdy)
-            DO ii = jpisdt(iseg), jpisft(iseg)
-               icount = icount + 1
-               nbidta(icount, igrd, ib_bdy) = ii
-               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
-               nbrdta(icount, igrd, ib_bdy) = ir
-            ENDDO
-         ENDDO
-      ENDDO
-
-      !  Deal with duplicated points
-      !-----------------------------
-      ! We assign negative indices to duplicated points (to remove them from bdy points to be updated)
-      ! if their distance to the bdy is greater than the other
-      ! If their distance are the same, just keep only one to avoid updating a point twice
-      DO igrd = 1, jpbgrd
-         DO ib_bdy1 = 1, nb_bdy
-            DO ib_bdy2 = 1, nb_bdy
-               IF (ib_bdy1/=ib_bdy2) THEN
-                  DO ib1 = 1, nblendta(igrd,ib_bdy1)
-                     DO ib2 = 1, nblendta(igrd,ib_bdy2)
-                        IF ((nbidta(ib1, igrd, ib_bdy1)==nbidta(ib2, igrd, ib_bdy2)).AND. &
-                        &   (nbjdta(ib1, igrd, ib_bdy1)==nbjdta(ib2, igrd, ib_bdy2))) THEN
-!                           IF ((lwp).AND.(igrd==1)) WRITE(numout,*) ' found coincident point ji, jj:', & 
-!                                                       &              nbidta(ib1, igrd, ib_bdy1),      & 
-!                                                       &              nbjdta(ib2, igrd, ib_bdy2)
-                           ! keep only points with the lowest distance to boundary:
-                           IF (nbrdta(ib1, igrd, ib_bdy1)<nbrdta(ib2, igrd, ib_bdy2)) THEN
-                             nbidta(ib2, igrd, ib_bdy2) =-ib_bdy2
-                             nbjdta(ib2, igrd, ib_bdy2) =-ib_bdy2
-                           ELSEIF (nbrdta(ib1, igrd, ib_bdy1)>nbrdta(ib2, igrd, ib_bdy2)) THEN
-                             nbidta(ib1, igrd, ib_bdy1) =-ib_bdy1
-                             nbjdta(ib1, igrd, ib_bdy1) =-ib_bdy1
-                           ! Arbitrary choice if distances are the same:
-                           ELSE
-                             nbidta(ib1, igrd, ib_bdy1) =-ib_bdy1
-                             nbjdta(ib1, igrd, ib_bdy1) =-ib_bdy1
-                           ENDIF
-                        END IF
-                     END DO
-                  END DO
-               ENDIF
-            END DO
-         END DO
-      END DO
-
-      ! Work out dimensions of boundary data on each processor
-      ! ------------------------------------------------------
-
-      ! Rather assume that boundary data indices are given on global domain
-      ! TO BE DISCUSSED ?
-!      iw = mig(1) + 1            ! if monotasking and no zoom, iw=2
-!      ie = mig(1) + nlci-1 - 1   ! if monotasking and no zoom, ie=jpim1
-!      is = mjg(1) + 1            ! if monotasking and no zoom, is=2
-!      in = mjg(1) + nlcj-1 - 1   ! if monotasking and no zoom, in=jpjm1      
-      iwe = mig(1) - 1 + 2         ! if monotasking and no zoom, iw=2
-      ies = mig(1) + nlci-1 - 1  ! if monotasking and no zoom, ie=jpim1
-      iso = mjg(1) - 1 + 2         ! if monotasking and no zoom, is=2
-      ino = mjg(1) + nlcj-1 - 1  ! if monotasking and no zoom, in=jpjm1
-
-      ALLOCATE( nbondi_bdy(nb_bdy))
-      ALLOCATE( nbondj_bdy(nb_bdy))
-      nbondi_bdy(:)=2
-      nbondj_bdy(:)=2
-      ALLOCATE( nbondi_bdy_b(nb_bdy))
-      ALLOCATE( nbondj_bdy_b(nb_bdy))
-      nbondi_bdy_b(:)=2
-      nbondj_bdy_b(:)=2
-
-      ! Work out dimensions of boundary data on each neighbour process
-      IF(nbondi == 0) THEN
-         iw_b(1) = 1 + nimppt(nowe+1)
-         ie_b(1) = 1 + nimppt(nowe+1)+nlcit(nowe+1)-3
-         is_b(1) = 1 + njmppt(nowe+1)
-         in_b(1) = 1 + njmppt(nowe+1)+nlcjt(nowe+1)-3
-
-         iw_b(2) = 1 + nimppt(noea+1)
-         ie_b(2) = 1 + nimppt(noea+1)+nlcit(noea+1)-3
-         is_b(2) = 1 + njmppt(noea+1)
-         in_b(2) = 1 + njmppt(noea+1)+nlcjt(noea+1)-3
-      ELSEIF(nbondi == 1) THEN
-         iw_b(1) = 1 + nimppt(nowe+1)
-         ie_b(1) = 1 + nimppt(nowe+1)+nlcit(nowe+1)-3
-         is_b(1) = 1 + njmppt(nowe+1)
-         in_b(1) = 1 + njmppt(nowe+1)+nlcjt(nowe+1)-3
-      ELSEIF(nbondi == -1) THEN
-         iw_b(2) = 1 + nimppt(noea+1)
-         ie_b(2) = 1 + nimppt(noea+1)+nlcit(noea+1)-3
-         is_b(2) = 1 + njmppt(noea+1)
-         in_b(2) = 1 + njmppt(noea+1)+nlcjt(noea+1)-3
-      ENDIF
-
-      IF(nbondj == 0) THEN
-         iw_b(3) = 1 + nimppt(noso+1)
-         ie_b(3) = 1 + nimppt(noso+1)+nlcit(noso+1)-3
-         is_b(3) = 1 + njmppt(noso+1)
-         in_b(3) = 1 + njmppt(noso+1)+nlcjt(noso+1)-3
-
-         iw_b(4) = 1 + nimppt(nono+1)
-         ie_b(4) = 1 + nimppt(nono+1)+nlcit(nono+1)-3
-         is_b(4) = 1 + njmppt(nono+1)
-         in_b(4) = 1 + njmppt(nono+1)+nlcjt(nono+1)-3
-      ELSEIF(nbondj == 1) THEN
-         iw_b(3) = 1 + nimppt(noso+1)
-         ie_b(3) = 1 + nimppt(noso+1)+nlcit(noso+1)-3
-         is_b(3) = 1 + njmppt(noso+1)
-         in_b(3) = 1 + njmppt(noso+1)+nlcjt(noso+1)-3
-      ELSEIF(nbondj == -1) THEN
-         iw_b(4) = 1 + nimppt(nono+1)
-         ie_b(4) = 1 + nimppt(nono+1)+nlcit(nono+1)-3
-         is_b(4) = 1 + njmppt(nono+1)
-         in_b(4) = 1 + njmppt(nono+1)+nlcjt(nono+1)-3
-      ENDIF
-
-      DO ib_bdy = 1, nb_bdy
-         DO igrd = 1, jpbgrd
-            icount  = 0
-            icountr = 0
-            idx_bdy(ib_bdy)%nblen(igrd)    = 0
-            idx_bdy(ib_bdy)%nblenrim(igrd) = 0
-            DO ib = 1, nblendta(igrd,ib_bdy)
-               ! check that data is in correct order in file
-               ibm1 = MAX(1,ib-1)
-               IF(lwp) THEN         ! Since all procs read global data only need to do this check on one proc...
-                  IF( nbrdta(ib,igrd,ib_bdy) < nbrdta(ibm1,igrd,ib_bdy) ) THEN
-                     CALL ctl_stop('bdy_segs : ERROR : boundary data in file must be defined ', &
-                          &        ' in order of distance from edge nbr A utility for re-ordering ', &
-                          &        ' boundary coordinates and data files exists in the TOOLS/OBC directory')
-                  ENDIF    
-               ENDIF
-               ! check if point is in local domain
-               IF(  nbidta(ib,igrd,ib_bdy) >= iwe .AND. nbidta(ib,igrd,ib_bdy) <= ies .AND.   &
-                  & nbjdta(ib,igrd,ib_bdy) >= iso .AND. nbjdta(ib,igrd,ib_bdy) <= ino      ) THEN
-                  !
-                  icount = icount  + 1
-                  !
-                  IF( nbrdta(ib,igrd,ib_bdy) == 1 )   icountr = icountr+1
-               ENDIF
-            END DO
-            idx_bdy(ib_bdy)%nblenrim(igrd) = icountr !: length of rim boundary data on each proc
-            idx_bdy(ib_bdy)%nblen   (igrd) = icount  !: length of boundary data on each proc        
-         END DO  ! igrd
-
-         ! Allocate index arrays for this boundary set
-         !--------------------------------------------
-         ilen1 = MAXVAL( idx_bdy(ib_bdy)%nblen(:) )
-         ALLOCATE( idx_bdy(ib_bdy)%nbi   (ilen1,jpbgrd) ,   &
-            &      idx_bdy(ib_bdy)%nbj   (ilen1,jpbgrd) ,   &
-            &      idx_bdy(ib_bdy)%nbr   (ilen1,jpbgrd) ,   &
-            &      idx_bdy(ib_bdy)%nbd   (ilen1,jpbgrd) ,   &
-            &      idx_bdy(ib_bdy)%nbdout(ilen1,jpbgrd) ,   &
-            &      idx_bdy(ib_bdy)%nbmap (ilen1,jpbgrd) ,   &
-            &      idx_bdy(ib_bdy)%nbw   (ilen1,jpbgrd) ,   &
-            &      idx_bdy(ib_bdy)%flagu (ilen1,jpbgrd) ,   &
-            &      idx_bdy(ib_bdy)%flagv (ilen1,jpbgrd) )
-
-         ! Dispatch mapping indices and discrete distances on each processor
-         ! -----------------------------------------------------------------
-
-         com_east  = 0
-         com_west  = 0
-         com_south = 0
-         com_north = 0
-
-         com_east_b  = 0
-         com_west_b  = 0
-         com_south_b = 0
-         com_north_b = 0
-
-         DO igrd = 1, jpbgrd
-            icount  = 0
-            ! Loop on rimwidth to ensure outermost points come first in the local arrays.
-            DO ir=1, nn_rimwidth(ib_bdy)
-               DO ib = 1, nblendta(igrd,ib_bdy)
-                  ! check if point is in local domain and equals ir
-                  IF(  nbidta(ib,igrd,ib_bdy) >= iwe .AND. nbidta(ib,igrd,ib_bdy) <= ies .AND.   &
-                     & nbjdta(ib,igrd,ib_bdy) >= iso .AND. nbjdta(ib,igrd,ib_bdy) <= ino .AND.   &
-                     & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                     !
-                     icount = icount  + 1
-
-                     ! Rather assume that boundary data indices are given on global domain
-                     ! TO BE DISCUSSED ?
-!                     idx_bdy(ib_bdy)%nbi(icount,igrd)   = nbidta(ib,igrd,ib_bdy)- mig(1)+1
-!                     idx_bdy(ib_bdy)%nbj(icount,igrd)   = nbjdta(ib,igrd,ib_bdy)- mjg(1)+1
-                     idx_bdy(ib_bdy)%nbi(icount,igrd)   = nbidta(ib,igrd,ib_bdy)- mig(1)+1
-                     idx_bdy(ib_bdy)%nbj(icount,igrd)   = nbjdta(ib,igrd,ib_bdy)- mjg(1)+1
-                     ! check if point has to be sent
-                     ii = idx_bdy(ib_bdy)%nbi(icount,igrd)
-                     ij = idx_bdy(ib_bdy)%nbj(icount,igrd)
-                     if((com_east .ne. 1) .and. (ii == (nlci-1)) .and. (nbondi .le. 0)) then
-                        com_east = 1
-                     elseif((com_west .ne. 1) .and. (ii == 2) .and. (nbondi .ge. 0) .and. (nbondi .ne. 2)) then
-                        com_west = 1
-                     endif 
-                     if((com_south .ne. 1) .and. (ij == 2) .and. (nbondj .ge. 0) .and. (nbondj .ne. 2)) then
-                        com_south = 1
-                     elseif((com_north .ne. 1) .and. (ij == (nlcj-1)) .and. (nbondj .le. 0)) then
-                        com_north = 1
-                     endif 
-                     idx_bdy(ib_bdy)%nbr(icount,igrd)   = nbrdta(ib,igrd,ib_bdy)
-                     idx_bdy(ib_bdy)%nbmap(icount,igrd) = ib
-                  ENDIF
-                  ! check if point has to be received from a neighbour
-                  IF(nbondi == 0) THEN
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(1) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(1) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(1) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(1) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(1)+2
-                       if((com_west_b .ne. 1) .and. (ii == (nlcit(nowe+1)-1))) then
-                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(1)+2
-                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
-                            com_south = 1
-                          elseif((ij == nlcjt(nowe+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
-                            com_north = 1
-                          endif
-                          com_west_b = 1
-                       endif 
-                     ENDIF
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(2) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(2) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(2) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(2) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(2)+2
-                       if((com_east_b .ne. 1) .and. (ii == 2)) then
-                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(2)+2
-                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
-                            com_south = 1
-                          elseif((ij == nlcjt(noea+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
-                            com_north = 1
-                          endif
-                          com_east_b = 1
-                       endif 
-                     ENDIF
-                  ELSEIF(nbondi == 1) THEN
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(1) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(1) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(1) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(1) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(1)+2
-                       if((com_west_b .ne. 1) .and. (ii == (nlcit(nowe+1)-1))) then
-                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(1)+2
-                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
-                            com_south = 1
-                          elseif((ij == nlcjt(nowe+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
-                            com_north = 1
-                          endif
-                          com_west_b = 1
-                       endif 
-                     ENDIF
-                  ELSEIF(nbondi == -1) THEN
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(2) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(2) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(2) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(2) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(2)+2
-                       if((com_east_b .ne. 1) .and. (ii == 2)) then
-                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(2)+2
-                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
-                            com_south = 1
-                          elseif((ij == nlcjt(noea+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
-                            com_north = 1
-                          endif
-                          com_east_b = 1
-                       endif 
-                     ENDIF
-                  ENDIF
-                  IF(nbondj == 0) THEN
-                     IF(com_north_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(4)-1  &
-                       & .OR. nbidta(ib,igrd,ib_bdy) == ie_b(4)+1) .AND. &
-                       & nbjdta(ib,igrd,ib_bdy) == is_b(4) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
-                       com_north_b = 1 
-                     ENDIF
-                     IF(com_south_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(3)-1  &
-                       &.OR. nbidta(ib,igrd,ib_bdy) == ie_b(3)+1) .AND. &
-                       & nbjdta(ib,igrd,ib_bdy) == in_b(3) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
-                       com_south_b = 1 
-                     ENDIF
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(3) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(3) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(3) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(3) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(3)+2
-                       if((com_south_b .ne. 1) .and. (ij == (nlcjt(noso+1)-1))) then
-                          com_south_b = 1
-                       endif 
-                     ENDIF
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(4) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(4) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(4) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(4) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(4)+2
-                       if((com_north_b .ne. 1) .and. (ij == 2)) then
-                          com_north_b = 1
-                       endif 
-                     ENDIF
-                  ELSEIF(nbondj == 1) THEN
-                     IF( com_south_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(3)-1 .OR. &
-                       & nbidta(ib,igrd,ib_bdy) == ie_b(3)+1) .AND. &
-                       & nbjdta(ib,igrd,ib_bdy) == in_b(3) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
-                       com_south_b = 1 
-                     ENDIF
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(3) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(3) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(3) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(3) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(3)+2
-                       if((com_south_b .ne. 1) .and. (ij == (nlcjt(noso+1)-1))) then
-                          com_south_b = 1
-                       endif 
-                     ENDIF
-                  ELSEIF(nbondj == -1) THEN
-                     IF(com_north_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(4)-1  &
-                       & .OR. nbidta(ib,igrd,ib_bdy) == ie_b(4)+1) .AND. &
-                       & nbjdta(ib,igrd,ib_bdy) == is_b(4) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
-                       com_north_b = 1 
-                     ENDIF
-                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(4) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(4) .AND.   &
-                       & nbjdta(ib,igrd,ib_bdy) >= is_b(4) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(4) .AND.   &
-                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
-                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(4)+2
-                       if((com_north_b .ne. 1) .and. (ij == 2)) then
-                          com_north_b = 1
-                       endif 
-                     ENDIF
-                  ENDIF
-               ENDDO
-            ENDDO
-         ENDDO 
-
-         ! definition of the i- and j- direction local boundaries arrays used for sending the boundaries
-         IF(     (com_east  == 1) .and. (com_west  == 1) ) THEN   ;   nbondi_bdy(ib_bdy) =  0
-         ELSEIF( (com_east  == 1) .and. (com_west  == 0) ) THEN   ;   nbondi_bdy(ib_bdy) = -1
-         ELSEIF( (com_east  == 0) .and. (com_west  == 1) ) THEN   ;   nbondi_bdy(ib_bdy) =  1
-         ENDIF
-         IF(     (com_north == 1) .and. (com_south == 1) ) THEN   ;   nbondj_bdy(ib_bdy) =  0
-         ELSEIF( (com_north == 1) .and. (com_south == 0) ) THEN   ;   nbondj_bdy(ib_bdy) = -1
-         ELSEIF( (com_north == 0) .and. (com_south == 1) ) THEN   ;   nbondj_bdy(ib_bdy) =  1
-         ENDIF
-
-         ! definition of the i- and j- direction local boundaries arrays used for receiving the boundaries
-         IF(     (com_east_b  == 1) .and. (com_west_b  == 1) ) THEN   ;   nbondi_bdy_b(ib_bdy) =  0
-         ELSEIF( (com_east_b  == 1) .and. (com_west_b  == 0) ) THEN   ;   nbondi_bdy_b(ib_bdy) = -1
-         ELSEIF( (com_east_b  == 0) .and. (com_west_b  == 1) ) THEN   ;   nbondi_bdy_b(ib_bdy) =  1
-         ENDIF
-         IF(     (com_north_b == 1) .and. (com_south_b == 1) ) THEN   ;   nbondj_bdy_b(ib_bdy) =  0
-         ELSEIF( (com_north_b == 1) .and. (com_south_b == 0) ) THEN   ;   nbondj_bdy_b(ib_bdy) = -1
-         ELSEIF( (com_north_b == 0) .and. (com_south_b == 1) ) THEN   ;   nbondj_bdy_b(ib_bdy) =  1
-         ENDIF
-
-         ! Compute rim weights for FRS scheme
-         ! ----------------------------------
-         DO igrd = 1, jpbgrd
-            DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
-               nbr => idx_bdy(ib_bdy)%nbr(ib,igrd)
-               idx_bdy(ib_bdy)%nbw(ib,igrd) = 1.- TANH( REAL( nbr - 1 ) *0.5 )      ! tanh formulation
-!               idx_bdy(ib_bdy)%nbw(ib,igrd) = (REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy)))**2.  ! quadratic
-!               idx_bdy(ib_bdy)%nbw(ib,igrd) =  REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy))       ! linear
-            END DO
-         END DO 
-
-         ! Compute damping coefficients
-         ! ----------------------------
-         DO igrd = 1, jpbgrd
-            DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
-               nbr => idx_bdy(ib_bdy)%nbr(ib,igrd)
-               idx_bdy(ib_bdy)%nbd(ib,igrd) = 1. / ( rn_time_dmp(ib_bdy) * rday ) & 
-               & *(REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy)))**2.   ! quadratic
-               idx_bdy(ib_bdy)%nbdout(ib,igrd) = 1. / ( rn_time_dmp_out(ib_bdy) * rday ) & 
-               & *(REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy)))**2.   ! quadratic
-            END DO
-         END DO 
-
-      END DO
-
-      ! ------------------------------------------------------
-      ! Initialise masks and find normal/tangential directions
-      ! ------------------------------------------------------
-
-      ! Read global 2D mask at T-points: bdytmask
-      ! -----------------------------------------
-      ! bdytmask = 1  on the computational domain AND on open boundaries
-      !          = 0  elsewhere   
- 
-      bdytmask(:,:) = ssmask(:,:)
-
-      ! Derive mask on U and V grid from mask on T grid
-
-      bdyumask(:,:) = 0._wp
-      bdyvmask(:,:) = 0._wp
-      DO ij = 1, jpjm1
-         DO ii = 1, jpim1
-            bdyumask(ii,ij) = bdytmask(ii,ij) * bdytmask(ii+1, ij )
-            bdyvmask(ii,ij) = bdytmask(ii,ij) * bdytmask(ii  ,ij+1)  
-         END DO
-      END DO
-      CALL lbc_lnk_multi( 'bdyini', bdyumask, 'U', 1. , bdyvmask, 'V', 1. )   ! Lateral boundary cond. 
-
-      ! bdy masks are now set to zero on boundary points:
-      !
-      igrd = 1
-      DO ib_bdy = 1, nb_bdy
-        DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)      
-          bdytmask(idx_bdy(ib_bdy)%nbi(ib,igrd), idx_bdy(ib_bdy)%nbj(ib,igrd)) = 0._wp
-        END DO
-      END DO
-      !
-      igrd = 2
-      DO ib_bdy = 1, nb_bdy
-        DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
-          bdyumask(idx_bdy(ib_bdy)%nbi(ib,igrd), idx_bdy(ib_bdy)%nbj(ib,igrd)) = 0._wp
-        END DO
-      END DO
-      !
-      igrd = 3
-      DO ib_bdy = 1, nb_bdy
-        DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
-          bdyvmask(idx_bdy(ib_bdy)%nbi(ib,igrd), idx_bdy(ib_bdy)%nbj(ib,igrd)) = 0._wp
-        END DO
-      END DO
-
-      ! For the flagu/flagv calculation below we require a version of fmask without
-      ! the land boundary condition (shlat) included:
-      zfmask(:,:) = 0
-      DO ij = 2, jpjm1
-         DO ii = 2, jpim1
-            zfmask(ii,ij) = tmask(ii,ij  ,1) * tmask(ii+1,ij  ,1)   &
-           &              * tmask(ii,ij+1,1) * tmask(ii+1,ij+1,1)
-         END DO      
-      END DO
-
-      ! Lateral boundary conditions
-      CALL lbc_lnk( 'bdyini', zfmask, 'F', 1. ) 
-      CALL lbc_lnk_multi( 'bdyini', bdyumask, 'U', 1. , bdyvmask, 'V', 1., bdytmask, 'T', 1. )
-      DO ib_bdy = 1, nb_bdy       ! Indices and directions of rim velocity components
-
-         idx_bdy(ib_bdy)%flagu(:,:) = 0._wp
-         idx_bdy(ib_bdy)%flagv(:,:) = 0._wp
-         icount = 0 
-
-         ! Calculate relationship of U direction to the local orientation of the boundary
-         ! flagu = -1 : u component is normal to the dynamical boundary and its direction is outward
-         ! flagu =  0 : u is tangential
-         ! flagu =  1 : u is normal to the boundary and is direction is inward
-  
-         DO igrd = 1, jpbgrd 
-            SELECT CASE( igrd )
-               CASE( 1 )   ;   pmask => umask   (:,:,1)   ;   i_offset = 0
-               CASE( 2 )   ;   pmask => bdytmask(:,:)     ;   i_offset = 1
-               CASE( 3 )   ;   pmask => zfmask  (:,:)     ;   i_offset = 0
-            END SELECT 
-            icount = 0
-            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)  
-               nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
-               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
-               zefl = pmask(nbi+i_offset-1,nbj)
-               zwfl = pmask(nbi+i_offset,nbj)
-               ! This error check only works if you are using the bdyXmask arrays
-               IF( i_offset == 1 .and. zefl + zwfl == 2 ) THEN
-                  icount = icount + 1
-                  IF(lwp) WRITE(numout,*) 'Problem with igrd = ',igrd,' at (global) nbi, nbj : ',mig(nbi),mjg(nbj)
-               ELSE
-                  idx_bdy(ib_bdy)%flagu(ib,igrd) = -zefl + zwfl
-               ENDIF
-            END DO
-            IF( icount /= 0 ) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
-                  ' are not boundary points (flagu calculation). Check nbi, nbj, indices for boundary set ',ib_bdy
-               IF(lwp) WRITE(numout,*) ' ========== '
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
-            ENDIF 
-         END DO
-
-         ! Calculate relationship of V direction to the local orientation of the boundary
-         ! flagv = -1 : v component is normal to the dynamical boundary but its direction is outward
-         ! flagv =  0 : v is tangential
-         ! flagv =  1 : v is normal to the boundary and is direction is inward
-
-         DO igrd = 1, jpbgrd 
-            SELECT CASE( igrd )
-               CASE( 1 )   ;   pmask => vmask (:,:,1)   ;   j_offset = 0
-               CASE( 2 )   ;   pmask => zfmask(:,:)     ;   j_offset = 0
-               CASE( 3 )   ;   pmask => bdytmask        ;   j_offset = 1
-            END SELECT 
-            icount = 0
-            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)  
-               nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
-               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
-               znfl = pmask(nbi,nbj+j_offset-1)
-               zsfl = pmask(nbi,nbj+j_offset  )
-               ! This error check only works if you are using the bdyXmask arrays
-               IF( j_offset == 1 .and. znfl + zsfl == 2 ) THEN
-                  IF(lwp) WRITE(numout,*) 'Problem with igrd = ',igrd,' at (global) nbi, nbj : ',mig(nbi),mjg(nbj)
-                  icount = icount + 1
-               ELSE
-                  idx_bdy(ib_bdy)%flagv(ib,igrd) = -znfl + zsfl
-               END IF
-            END DO
-            IF( icount /= 0 ) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
-                  ' are not boundary points (flagv calculation). Check nbi, nbj, indices for boundary set ',ib_bdy
-               IF(lwp) WRITE(numout,*) ' ========== '
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
-            ENDIF 
-         END DO
-         !
-      END DO
-
-      ! Compute total lateral surface for volume correction:
-      ! ----------------------------------------------------
-      ! JC: this must be done at each time step with non-linear free surface
-      bdysurftot = 0._wp 
-      IF( ln_vol ) THEN  
-         igrd = 2      ! Lateral surface at U-points
-         DO ib_bdy = 1, nb_bdy
-            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
-               nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
-               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
-               flagu => idx_bdy(ib_bdy)%flagu(ib,igrd)
-               bdysurftot = bdysurftot + hu_n   (nbi  , nbj)                           &
-                  &                    * e2u    (nbi  , nbj) * ABS( flagu ) &
-                  &                    * tmask_i(nbi  , nbj)                           &
-                  &                    * tmask_i(nbi+1, nbj)                   
-            END DO
-         END DO
-
-         igrd=3 ! Add lateral surface at V-points
-         DO ib_bdy = 1, nb_bdy
-            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
-               nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
-               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
-               flagv => idx_bdy(ib_bdy)%flagv(ib,igrd)
-               bdysurftot = bdysurftot + hv_n   (nbi, nbj  )                           &
-                  &                    * e1v    (nbi, nbj  ) * ABS( flagv ) &
-                  &                    * tmask_i(nbi, nbj  )                           &
-                  &                    * tmask_i(nbi, nbj+1)
-            END DO
-         END DO
-         !
-         CALL mpp_sum( 'bdyini', bdysurftot )      ! sum over the global domain
-      END IF   
-      !
-      ! Tidy up
-      !--------
-      IF( nb_bdy>0 )   DEALLOCATE( nbidta, nbjdta, nbrdta )
-      !
-   END SUBROUTINE bdy_segs
-
-
-   SUBROUTINE bdy_ctl_seg
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE bdy_ctl_seg  ***
-      !!
-      !! ** Purpose :   Check straight open boundary segments location
-      !!
-      !! ** Method  :   - Look for open boundary corners
-      !!                - Check that segments start or end on land 
-      !!----------------------------------------------------------------------
-      INTEGER  ::   ib, ib1, ib2, ji ,jj, itest  
-      INTEGER, DIMENSION(jp_nseg,2) :: icorne, icornw, icornn, icorns  
-      REAL(wp), DIMENSION(2) ::   ztestmask
-      !!----------------------------------------------------------------------
-      !
-      IF (lwp) WRITE(numout,*) ' '
-      IF (lwp) WRITE(numout,*) 'bdy_ctl_seg: Check analytical segments'
-      IF (lwp) WRITE(numout,*) '~~~~~~~~~~~~'
-      !
-      IF(lwp) WRITE(numout,*) 'Number of east  segments     : ', nbdysege
-      IF(lwp) WRITE(numout,*) 'Number of west  segments     : ', nbdysegw
-      IF(lwp) WRITE(numout,*) 'Number of north segments     : ', nbdysegn
-      IF(lwp) WRITE(numout,*) 'Number of south segments     : ', nbdysegs
-      ! 1. Check bounds
-      !----------------
-      DO ib = 1, nbdysegn
-         IF (lwp) WRITE(numout,*) '**check north seg bounds pckg: ', npckgn(ib)
-         IF ((jpjnob(ib).ge.jpjglo-1).or.& 
-            &(jpjnob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
-         IF (jpindt(ib).ge.jpinft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
-         IF (jpindt(ib).le.1     )     CALL ctl_stop( 'Start index out of domain' )
-         IF (jpinft(ib).ge.jpiglo)     CALL ctl_stop( 'End index out of domain' )
-      END DO
-      !
-      DO ib = 1, nbdysegs
-         IF (lwp) WRITE(numout,*) '**check south seg bounds pckg: ', npckgs(ib)
-         IF ((jpjsob(ib).ge.jpjglo-1).or.& 
-            &(jpjsob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
-         IF (jpisdt(ib).ge.jpisft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
-         IF (jpisdt(ib).le.1     )     CALL ctl_stop( 'Start index out of domain' )
-         IF (jpisft(ib).ge.jpiglo)     CALL ctl_stop( 'End index out of domain' )
-      END DO
-      !
-      DO ib = 1, nbdysege
-         IF (lwp) WRITE(numout,*) '**check east  seg bounds pckg: ', npckge(ib)
-         IF ((jpieob(ib).ge.jpiglo-1).or.& 
-            &(jpieob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
-         IF (jpjedt(ib).ge.jpjeft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
-         IF (jpjedt(ib).lt.1     )     CALL ctl_stop( 'Start index out of domain' )!ACC
-         IF (jpjeft(ib).gt.jpjglo)     CALL ctl_stop( 'End index out of domain' )!ACC
-      END DO
-      !
-      DO ib = 1, nbdysegw
-         IF (lwp) WRITE(numout,*) '**check west  seg bounds pckg: ', npckgw(ib)
-         IF ((jpiwob(ib).ge.jpiglo-1).or.& 
-            &(jpiwob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
-         IF (jpjwdt(ib).ge.jpjwft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
-         IF (jpjwdt(ib).lt.1     )     CALL ctl_stop( 'Start index out of domain' ) !ACC
-         IF (jpjwft(ib).gt.jpjglo)     CALL ctl_stop( 'End index out of domain' ) !ACC
-      ENDDO
-      !
-      !      
-      ! 2. Look for segment crossings
-      !------------------------------ 
-      IF (lwp) WRITE(numout,*) '**Look for segments corners  :'
-      !
-      itest = 0 ! corner number
-      !
-      ! flag to detect if start or end of open boundary belongs to a corner
-      ! if not (=0), it must be on land.
-      ! if a corner is detected, save bdy package number for further tests
-      icorne(:,:)=0. ; icornw(:,:)=0. ; icornn(:,:)=0. ; icorns(:,:)=0.
-      ! South/West crossings
-      IF ((nbdysegw > 0).AND.(nbdysegs > 0)) THEN
-         DO ib1 = 1, nbdysegw        
-            DO ib2 = 1, nbdysegs
-               IF (( jpisdt(ib2)<=jpiwob(ib1)).AND. &
-                &  ( jpisft(ib2)>=jpiwob(ib1)).AND. &
-                &  ( jpjwdt(ib1)<=jpjsob(ib2)).AND. &
-                &  ( jpjwft(ib1)>=jpjsob(ib2))) THEN
-                  IF ((jpjwdt(ib1)==jpjsob(ib2)).AND.(jpisdt(ib2)==jpiwob(ib1))) THEN 
-                     ! We have a possible South-West corner                      
-!                     WRITE(numout,*) ' Found a South-West corner at (i,j): ', jpisdt(ib2), jpjwdt(ib1) 
-!                     WRITE(numout,*) ' between segments: ', npckgw(ib1), npckgs(ib2)
-                     icornw(ib1,1) = npckgs(ib2)
-                     icorns(ib2,1) = npckgw(ib1)
-                  ELSEIF ((jpisft(ib2)==jpiwob(ib1)).AND.(jpjwft(ib1)==jpjsob(ib2))) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
-                     &                                     jpisft(ib2), jpjwft(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with West segment: ',npckgw(ib1), & 
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
-                  ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check South and West Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1) , &
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop+1
-                  END IF
-               END IF
-            END DO
-         END DO
-      END IF
-      !
-      ! South/East crossings
-      IF ((nbdysege > 0).AND.(nbdysegs > 0)) THEN
-         DO ib1 = 1, nbdysege
-            DO ib2 = 1, nbdysegs
-               IF (( jpisdt(ib2)<=jpieob(ib1)+1).AND. &
-                &  ( jpisft(ib2)>=jpieob(ib1)+1).AND. &
-                &  ( jpjedt(ib1)<=jpjsob(ib2)  ).AND. &
-                &  ( jpjeft(ib1)>=jpjsob(ib2)  )) THEN
-                  IF ((jpjedt(ib1)==jpjsob(ib2)).AND.(jpisft(ib2)==jpieob(ib1)+1)) THEN
-                     ! We have a possible South-East corner 
-!                     WRITE(numout,*) ' Found a South-East corner at (i,j): ', jpisft(ib2), jpjedt(ib1) 
-!                     WRITE(numout,*) ' between segments: ', npckge(ib1), npckgs(ib2)
-                     icorne(ib1,1) = npckgs(ib2)
-                     icorns(ib2,2) = npckge(ib1)
-                  ELSEIF ((jpjeft(ib1)==jpjsob(ib2)).AND.(jpisdt(ib2)==jpieob(ib1)+1)) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
-                     &                                     jpisdt(ib2), jpjeft(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
-                  ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check South and East Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and South segment: ',npckgs(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
-                  END IF
-               END IF
-            END DO
-         END DO
-      END IF
-      !
-      ! North/West crossings
-      IF ((nbdysegn > 0).AND.(nbdysegw > 0)) THEN
-         DO ib1 = 1, nbdysegw        
-            DO ib2 = 1, nbdysegn
-               IF (( jpindt(ib2)<=jpiwob(ib1)  ).AND. &
-                &  ( jpinft(ib2)>=jpiwob(ib1)  ).AND. &
-                &  ( jpjwdt(ib1)<=jpjnob(ib2)+1).AND. &
-                &  ( jpjwft(ib1)>=jpjnob(ib2)+1)) THEN
-                  IF ((jpjwft(ib1)==jpjnob(ib2)+1).AND.(jpindt(ib2)==jpiwob(ib1))) THEN
-                     ! We have a possible North-West corner 
-!                     WRITE(numout,*) ' Found a North-West corner at (i,j): ', jpindt(ib2), jpjwft(ib1) 
-!                     WRITE(numout,*) ' between segments: ', npckgw(ib1), npckgn(ib2)
-                     icornw(ib1,2) = npckgn(ib2)
-                     icornn(ib2,1) = npckgw(ib1)
-                  ELSEIF ((jpjwdt(ib1)==jpjnob(ib2)+1).AND.(jpinft(ib2)==jpiwob(ib1))) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
-                     &                                     jpinft(ib2), jpjwdt(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with West segment: ',npckgw(ib1), &
-                     &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
-                  ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check North and West Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1), &
-                     &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
-                  END IF
-               END IF
-            END DO
-         END DO
-      END IF
-      !
-      ! North/East crossings
-      IF ((nbdysegn > 0).AND.(nbdysege > 0)) THEN
-         DO ib1 = 1, nbdysege        
-            DO ib2 = 1, nbdysegn
-               IF (( jpindt(ib2)<=jpieob(ib1)+1).AND. &
-                &  ( jpinft(ib2)>=jpieob(ib1)+1).AND. &
-                &  ( jpjedt(ib1)<=jpjnob(ib2)+1).AND. &
-                &  ( jpjeft(ib1)>=jpjnob(ib2)+1)) THEN
-                  IF ((jpjeft(ib1)==jpjnob(ib2)+1).AND.(jpinft(ib2)==jpieob(ib1)+1)) THEN
-                     ! We have a possible North-East corner 
-!                     WRITE(numout,*) ' Found a North-East corner at (i,j): ', jpinft(ib2), jpjeft(ib1)
-!                     WRITE(numout,*) ' between segments: ', npckge(ib1), npckgn(ib2)
-                     icorne(ib1,2) = npckgn(ib2)
-                     icornn(ib2,2) = npckge(ib1)
-                  ELSEIF ((jpjedt(ib1)==jpjnob(ib2)+1).AND.(jpindt(ib2)==jpieob(ib1)+1)) THEN
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
-                     &                                     jpindt(ib2), jpjedt(ib1)
-                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
-                     IF(lwp) WRITE(numout,*) '             Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
-                  ELSE
-                     IF(lwp) WRITE(numout,*)
-                     IF(lwp) WRITE(numout,*) ' E R R O R : Check North and East Open boundary indices'
-                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
-                     &                                                    ' and North segment: ',npckgn(ib2)
-                     IF(lwp) WRITE(numout,*)
-                     nstop = nstop + 1
-                  END IF
-               END IF
-            END DO
-         END DO
-      END IF
-      !
-      ! 3. Check if segment extremities are on land
-      !-------------------------------------------- 
-      !
-      ! West segments
-      DO ib = 1, nbdysegw
-         ! get mask at boundary extremities:
-         ztestmask(1:2)=0.
-         DO ji = 1, jpi
-            DO jj = 1, jpj             
-              IF (((ji + nimpp - 1) == jpiwob(ib)).AND. & 
-               &  ((jj + njmpp - 1) == jpjwdt(ib))) ztestmask(1)=tmask(ji,jj,1)
-              IF (((ji + nimpp - 1) == jpiwob(ib)).AND. & 
-               &  ((jj + njmpp - 1) == jpjwft(ib))) ztestmask(2)=tmask(ji,jj,1)  
-            END DO
-         END DO
-         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
-
-         IF (ztestmask(1)==1) THEN 
-            IF (icornw(ib,1)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgw(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
-            ELSE
-               ! This is a corner
-               IF(lwp) WRITE(numout,*) 'Found a South-West corner at (i,j): ', jpiwob(ib), jpjwdt(ib)
-               CALL bdy_ctl_corn(npckgw(ib), icornw(ib,1))
-               itest=itest+1
-            ENDIF
-         ENDIF
-         IF (ztestmask(2)==1) THEN
-            IF (icornw(ib,2)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgw(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
-            ELSE
-               ! This is a corner
-               IF(lwp) WRITE(numout,*) 'Found a North-West corner at (i,j): ', jpiwob(ib), jpjwft(ib)
-               CALL bdy_ctl_corn(npckgw(ib), icornw(ib,2))
-               itest=itest+1
-            ENDIF
-         ENDIF
-      END DO
-      !
-      ! East segments
-      DO ib = 1, nbdysege
-         ! get mask at boundary extremities:
-         ztestmask(1:2)=0.
-         DO ji = 1, jpi
-            DO jj = 1, jpj             
-              IF (((ji + nimpp - 1) == jpieob(ib)+1).AND. & 
-               &  ((jj + njmpp - 1) == jpjedt(ib))) ztestmask(1)=tmask(ji,jj,1)
-              IF (((ji + nimpp - 1) == jpieob(ib)+1).AND. & 
-               &  ((jj + njmpp - 1) == jpjeft(ib))) ztestmask(2)=tmask(ji,jj,1)  
-            END DO
-         END DO
-         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
-
-         IF (ztestmask(1)==1) THEN
-            IF (icorne(ib,1)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckge(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1 
-            ELSE
-               ! This is a corner
-               IF(lwp) WRITE(numout,*) 'Found a South-East corner at (i,j): ', jpieob(ib)+1, jpjedt(ib)
-               CALL bdy_ctl_corn(npckge(ib), icorne(ib,1))
-               itest=itest+1
-            ENDIF
-         ENDIF
-         IF (ztestmask(2)==1) THEN
-            IF (icorne(ib,2)==0) THEN
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckge(ib)
-               IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
-               IF(lwp) WRITE(numout,*)
-               nstop = nstop + 1
-            ELSE
-               ! This is a corner
-               IF(lwp) WRITE(numout,*) 'Found a North-East corner at (i,j): ', jpieob(ib)+1, jpjeft(ib)
-               CALL bdy_ctl_corn(npckge(ib), icorne(ib,2))
-               itest=itest+1
-            ENDIF
-         ENDIF
-      END DO
-      !
-      ! South segments
-      DO ib = 1, nbdysegs
-         ! get mask at boundary extremities:
-         ztestmask(1:2)=0.
-         DO ji = 1, jpi
-            DO jj = 1, jpj             
-              IF (((jj + njmpp - 1) == jpjsob(ib)).AND. & 
-               &  ((ji + nimpp - 1) == jpisdt(ib))) ztestmask(1)=tmask(ji,jj,1)
-              IF (((jj + njmpp - 1) == jpjsob(ib)).AND. & 
-               &  ((ji + nimpp - 1) == jpisft(ib))) ztestmask(2)=tmask(ji,jj,1)  
-            END DO
-         END DO
-         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
-
-         IF ((ztestmask(1)==1).AND.(icorns(ib,1)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgs(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
-         ENDIF
-         IF ((ztestmask(2)==1).AND.(icorns(ib,2)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgs(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
-         ENDIF
-      END DO
-      !
-      ! North segments
-      DO ib = 1, nbdysegn
-         ! get mask at boundary extremities:
-         ztestmask(1:2)=0.
-         DO ji = 1, jpi
-            DO jj = 1, jpj             
-              IF (((jj + njmpp - 1) == jpjnob(ib)+1).AND. & 
-               &  ((ji + nimpp - 1) == jpindt(ib))) ztestmask(1)=tmask(ji,jj,1)
-              IF (((jj + njmpp - 1) == jpjnob(ib)+1).AND. & 
-               &  ((ji + nimpp - 1) == jpinft(ib))) ztestmask(2)=tmask(ji,jj,1)  
-            END DO
-         END DO
-         CALL mpp_sum( 'bdyini', ztestmask, 2 )   ! sum over the global domain
-
-         IF ((ztestmask(1)==1).AND.(icornn(ib,1)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgn(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not start on land'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
-         ENDIF
-         IF ((ztestmask(2)==1).AND.(icornn(ib,2)==0)) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgn(ib)
-            IF(lwp) WRITE(numout,*) ' ==========  does not end on land'                                                  
-            IF(lwp) WRITE(numout,*)
-            nstop = nstop + 1
-         ENDIF
-      END DO
-      !
-      IF ((itest==0).AND.(lwp)) WRITE(numout,*) 'NO open boundary corner found'
-      !
-      ! Other tests TBD: 
-      ! segments completly on land
-      ! optimized open boundary array length according to landmask
-      ! Nudging layers that overlap with interior domain
-      !
-   END SUBROUTINE bdy_ctl_seg
-
-
-   SUBROUTINE bdy_ctl_corn( ib1, ib2 )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE bdy_ctl_corn  ***
-      !!
-      !! ** Purpose :   Check numerical schemes consistency between
-      !!                segments having a common corner
-      !!
-      !! ** Method  :   
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in)  ::   ib1, ib2
-      INTEGER :: itest
-      !!----------------------------------------------------------------------
-      itest = 0
-
-      IF( cn_dyn2d(ib1) /= cn_dyn2d(ib2) )   itest = itest + 1
-      IF( cn_dyn3d(ib1) /= cn_dyn3d(ib2) )   itest = itest + 1
-      IF( cn_tra  (ib1) /= cn_tra  (ib2) )   itest = itest + 1
-      !
-      IF( nn_dyn2d_dta(ib1) /= nn_dyn2d_dta(ib2) )   itest = itest + 1
-      IF( nn_dyn3d_dta(ib1) /= nn_dyn3d_dta(ib2) )   itest = itest + 1
-      IF( nn_tra_dta  (ib1) /= nn_tra_dta  (ib2) )   itest = itest + 1
-      !
-      IF( nn_rimwidth(ib1) /= nn_rimwidth(ib2) )   itest = itest + 1   
-      !
-      IF( itest>0 ) THEN
-         IF(lwp) WRITE(numout,*) ' E R R O R : Segments ', ib1, 'and ', ib2
-         IF(lwp) WRITE(numout,*) ' ==========  have different open bdy schemes'                                                  
-         IF(lwp) WRITE(numout,*)
-         nstop = nstop + 1
-      ENDIF
-      !
-   END SUBROUTINE bdy_ctl_corn
-
-   !!=================================================================================
-END MODULE bdyini
Index: NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/MY_SRC/usrdef_nam.F90
===================================================================
--- NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/MY_SRC/usrdef_nam.F90	(revision 12062)
+++ NEMO/branches/2019/ENHANCE-02_ISF_nemo/tests/WAD/MY_SRC/usrdef_nam.F90	(revision 12143)
@@ -39,5 +39,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( ldtxt, ldnam, cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -51,5 +51,4 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), DIMENSION(:), INTENT(out) ::   ldtxt, ldnam    ! stored print information
       CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
       INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
@@ -57,16 +56,14 @@
       INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
       !
-      INTEGER ::   ios, ii   ! Local integer
+      INTEGER ::   ios   ! Local integer
       !!
       NAMELIST/namusr_def/ rn_dx, rn_dz, nn_wad_test
       !!----------------------------------------------------------------------
       !
-      ii = 1
-      !
       REWIND( numnam_cfg )          ! Namelist namusr_def (exist in namelist_cfg only)
       READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist', .TRUE. )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
       !
-      WRITE( ldnam(:), namusr_def )
+      IF(lwm)   WRITE( numond, namusr_def )
       !
       !
@@ -79,24 +76,24 @@
       kpj = INT(  32.e3 / rn_dx ) + 2
       kpk = INT(  10.  / rn_dz ) + 1
-      !
-      !                             ! control print
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '~~~~~~~~~~~ '                                                                 ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Namelist namusr_def : WAD_TEST_CASES test case'                             ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      vertical   resolution                    rn_dz  = ', rn_dz, ' meters'   ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      WAD_TEST_CASES domain = 52 km  x  34 km x 10 m'                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '         resulting global domain size :        jpiglo = ', kpi                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpjglo = ', kpj                ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '                                               jpkglo = ', kpk                ;   ii = ii + 1
-      !
       !                             ! Set the lateral boundary condition of the global domain
       kperio = 0                    ! WAD_TEST_CASES configuration : closed domain
       IF( nn_wad_test == 8 ) kperio = 7 ! North-South cyclic test
       !
-      WRITE(ldtxt(ii),*) '   '                                                                          ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '   Lateral boundary condition of the global domain'                           ;   ii = ii + 1
-      WRITE(ldtxt(ii),*) '      closed                                   jperio = ', kperio             ;   ii = ii + 1
+      !                             ! control print
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : WAD_TEST_CASES test case'
+         WRITE(numout,*) '      horizontal resolution                    rn_dx  = ', rn_dx, ' meters'
+         WRITE(numout,*) '      vertical   resolution                    rn_dz  = ', rn_dz, ' meters'
+         WRITE(numout,*) '      WAD_TEST_CASES domain = 52 km  x  34 km x 10 m'
+         WRITE(numout,*) '         resulting global domain size :        jpiglo = ', kpi
+         WRITE(numout,*) '                                               jpjglo = ', kpj
+         WRITE(numout,*) '                                               jpkglo = ', kpk
+         WRITE(numout,*) '   '
+         WRITE(numout,*) '   Lateral boundary condition of the global domain'
+         WRITE(numout,*) '      closed                                   jperio = ', kperio
+      ENDIF
       !
    END SUBROUTINE usr_def_nam
