Index: branches/2016/dev_NOC_2016/NEMOGCM/ARCH/arch-THALASSA.fcm
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/ARCH/arch-THALASSA.fcm	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/ARCH/arch-THALASSA.fcm	(revision 7339)
@@ -0,0 +1,68 @@
+# generic gfortran compiler options for OSX installed with macport, http://www.macports.org/
+#
+# port packages needed:
+#    sudo port install openmpi +gcc48
+#    sudo port install hdf5-18 +cxx +fortran +openmpi (I'am not sure cxx is needed)
+#    sudo port install netcdf         +openmpi
+#    sudo port install netcdf-fortran +openmpi
+#    sudo port install netcdf-cxx     +openmpi (I'am not sure it is needed)
+#    sudo port install p5-uri
+# add to your PATH /opt/local/lib/openmpi/bin so that mpif90 is properly known
+#
+# NCDF_HOME   root directory containing lib and include subdirectories for netcdf4
+# HDF5_HOME   root directory containing lib and include subdirectories for HDF5
+# XIOS_HOME   root directory containing lib for XIOS
+# OASIS_HOME  root directory containing lib for OASIS
+#
+# NCDF_INC    netcdf4 include file
+# NCDF_LIB    netcdf4 library
+# XIOS_INC    xios include file    (taken into accound only if key_iomput is activated)
+# XIOS_LIB    xios library         (taken into accound only if key_iomput is activated)
+# OASIS_INC   oasis include file   (taken into accound only if key_oasis3 is activated)
+# OASIS_LIB   oasis library        (taken into accound only if key_oasis3 is activated)
+#
+# FC          Fortran compiler command
+# FCFLAGS     Fortran compiler flags
+# FFLAGS      Fortran 77 compiler flags
+# LD          linker
+# LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries
+# FPPFLAGS    pre-processing flags
+# AR          assembler
+# ARFLAGS     assembler flags
+# MK          make
+# USER_INC    complete list of include files
+# USER_LIB    complete list of libraries to pass to the linker
+# CC          C compiler used to compile conv for AGRIF
+# CFLAGS      compiler flags used with CC
+#
+# Note that:
+#  - unix variables "$..." are accpeted and will be evaluated before calling fcm.
+#  - fcm variables are starting with a % (and not a $)
+#
+%NCDF_HOME           /nerc/packages/netcdf/4.3.3.1
+%HDF5_HOME           /nerc/packages/hdf5/1.8.15
+%XIOS_HOME           /noc/msm/working/nemo/acc/XIOS/xios-1.0
+%OASIS_HOME          
+
+%NCDF_INC            -I%NCDF_HOME/include -I%HDF5_HOME/include
+%NCDF_LIB            -L%NCDF_HOME/lib -lnetcdff -lnetcdf
+%XIOS_INC            -I%XIOS_HOME/inc 
+%XIOS_LIB            -L%XIOS_HOME/lib -lxios
+%OASIS_INC           
+%OASIS_LIB           
+
+%CPP	             cpp
+%FC	             mpif90
+%FCFLAGS             -fdefault-real-8 -O3 -funroll-all-loops -fcray-pointer -ffree-line-length-none
+%FFLAGS              %FCFLAGS
+%LD                  %FC
+%LDFLAGS             -lstdc++
+%FPPFLAGS            -P -C -traditional
+%AR                  ar
+%ARFLAGS             rs
+%MK                  make
+%USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
+%USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
+
+%CC                  cc
+%CFLAGS              -O0
Index: branches/2016/dev_NOC_2016/NEMOGCM/ARCH/arch-macport_osx.fcm
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/ARCH/arch-macport_osx.fcm	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/ARCH/arch-macport_osx.fcm	(revision 7339)
@@ -54,5 +54,5 @@
 %CPP	             cpp-mp-4.8
 %FC	             mpif90 
-%FCFLAGS             -fdefault-real-8 -O3 -funroll-all-loops -fcray-pointer 
+%FCFLAGS             -fdefault-real-8 -O3 -funroll-all-loops -fcray-pointer -ffree-line-length-none
 %FFLAGS              %FCFLAGS
 %LD                  %FC
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/SHARED/field_def.xml
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 7339)
@@ -380,4 +380,5 @@
       <field_group id="grid_U"   grid_ref="grid_U_2D">
          <field id="e3u"          long_name="U-cell thickness"                                       standard_name="cell_thickness"              unit="m"          grid_ref="grid_U_3D" />
+         <field id="e3u_0"        long_name="Initial U-cell thickness"                               standard_name="ref_cell_thickness"          unit="m"          grid_ref="grid_U_3D"/>
          <field id="utau"         long_name="Wind Stress along i-axis"                               standard_name="surface_downward_x_stress"   unit="N/m2"                            />
          <field id="uoce"         long_name="ocean current along i-axis"                             standard_name="sea_water_x_velocity"        unit="m/s"        grid_ref="grid_U_3D" />
@@ -421,4 +422,5 @@
       <field_group id="grid_V"   grid_ref="grid_V_2D">
          <field id="e3v"          long_name="V-cell thickness"                                       standard_name="cell_thickness"              unit="m"          grid_ref="grid_V_3D" />
+         <field id="e3v_0"        long_name="Initial V-cell thickness"                               standard_name="ref_cell_thickness"          unit="m"          grid_ref="grid_V_3D"/>
          <field id="vtau"         long_name="Wind Stress along j-axis"                               standard_name="surface_downward_y_stress"   unit="N/m2"                            />
          <field id="voce"         long_name="ocean current along j-axis"                             standard_name="sea_water_y_velocity"        unit="m/s"        grid_ref="grid_V_3D" />
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/README.py
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/README.py	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/README.py	(revision 7339)
@@ -0,0 +1,2 @@
+ncks -d y,17,17,1 WAD_1ts_00010101_00010101_grid_T.nc sshtime.nc
+ncks -4 -A -v gdepw_0,bathy -d y,17,17,1 -d z,9,9,1 -C mesh_mask_wad1.nc sshtime.nc
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/domain_def.xml
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/domain_def.xml	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/domain_def.xml	(revision 7339)
@@ -0,0 +1,1 @@
+link ../../SHARED/domain_def.xml
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/field_def.xml
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/field_def.xml	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/field_def.xml	(revision 7339)
@@ -0,0 +1,1111 @@
+<!--
+<?xml version="1.0"?>
+       -->
+ 
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+   <field_definition level="1" prec="4" operation="average" enabled=".TRUE." default_value="1.e20" > <!-- time step automaticaly defined -->
+
+    <!-- 
+============================================================================================================
+                                  Physical ocean and ice model variables
+============================================================================================================
+    -->
+
+      <!-- T grid -->
+      
+      <field_group id="grid_T" grid_ref="grid_T_2D" >
+         <field id="e3t"          long_name="T-cell thickness"   standard_name="cell_thickness"   unit="m"   grid_ref="grid_T_3D"/>
+         <field id="e3t_0"        long_name="Initial T-cell thickness"   standard_name="ref_cell_thickness"   unit="m"   grid_ref="grid_T_3D"/>
+
+         <field id="toce"         long_name="temperature"         standard_name="sea_water_potential_temperature"   unit="degC"     grid_ref="grid_T_3D"/>
+         <field id="toce_e3t"     long_name="temperature (thickness weighted)"                                      unit="degC"     grid_ref="grid_T_3D" > toce * e3t </field >
+         <field id="soce"         long_name="salinity"            standard_name="sea_water_practical_salinity"      unit="1e-3"     grid_ref="grid_T_3D"/>
+         <field id="soce_e3t"     long_name="salinity    (thickness weighted)"                                      unit="1e-3"     grid_ref="grid_T_3D" > soce * e3t </field >
+
+	      <!-- t-eddy viscosity coefficients (ldfdyn) -->
+	      <field id="ahmt_2d"      long_name=" surface t-eddy viscosity coefficient"   unit="m2/s or m4/s" />
+	      <field id="ahmt_3d"      long_name=" 3D      t-eddy viscosity coefficient"   unit="m2/s or m4/s"                           grid_ref="grid_T_3D"/>
+
+         <field id="wdmask"          long_name="ocean tpt limiter mask "                unit="#"                             />
+         <field id="sst"          long_name="sea surface temperature"             standard_name="sea_surface_temperature"             unit="degC"     />
+         <field id="sst2"         long_name="square of sea surface temperature"   standard_name="square_of_sea_surface_temperature"   unit="degC2"     > sst * sst </field >
+         <field id="sstmax"       long_name="max of sea surface temperature"   field_ref="sst"   operation="maximum"                                  />
+         <field id="sstmin"       long_name="min of sea surface temperature"   field_ref="sst"   operation="minimum"                                  />
+         <field id="sstgrad"      long_name="module of sst gradient"                                                                  unit="degC/m"   />
+         <field id="sstgrad2"     long_name="square of module of sst gradient"                                                        unit="degC2/m2" />
+         <field id="sbt"          long_name="sea bottom temperature"                                                                  unit="degC"     />
+         <field id="sst_wl"       long_name="Delta SST of warm layer"                                                                 unit="degC"     />
+         <field id="sst_cs"       long_name="Delta SST of cool skin"                                                                  unit="degC"     />
+	 <field id="temp_3m"      long_name="temperature at 3m"                                                                       unit="degC"     />
+         
+         <field id="sss"          long_name="sea surface salinity"             standard_name="sea_surface_salinity"   unit="1e-3" />
+         <field id="sss2"         long_name="square of sea surface salinity"                                          unit="1e-6"  > sss * sss </field >
+         <field id="sssmax"       long_name="max of sea surface salinity"   field_ref="sss"   operation="maximum"                 />
+         <field id="sssmin"       long_name="min of sea surface salinity"   field_ref="sss"   operation="minimum"                 />
+         <field id="sbs"          long_name="sea bottom salinity"                                                     unit="1e-3" />
+
+         <field id="taubot"       long_name="bottom stress module"                                                    unit="N/m2" /> 
+
+         <field id="ssh"          long_name="sea surface height"             standard_name="sea_surface_height_above_geoid"             unit="m" />
+         <field id="ssh2"         long_name="square of sea surface height"   standard_name="square_of_sea_surface_height_above_geoid"   unit="m2" > ssh * ssh </field >
+         <field id="wetdep"       long_name="wet depth"                      standard_name="wet_depth"                unit="m" />
+         <field id="sshmax"       long_name="max of sea surface height"   field_ref="ssh"   operation="maximum"                                  />
+
+         <field id="mldkz5"       long_name="Turbocline depth (Kz = 5e-4)"                       standard_name="ocean_mixed_layer_thickness_defined_by_vertical_tracer_diffusivity"                unit="m"          />
+         <field id="mldr10_1"     long_name="Mixed Layer Depth (dsigma = 0.01 wrt 10m)"          standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"                                unit="m"          />
+         <field id="mldr10_1max"  long_name="Max of Mixed Layer Depth (dsigma = 0.01 wrt 10m)"   field_ref="mldr10_1"   operation="maximum"                                                                          />
+         <field id="mldr10_1min"  long_name="Min of Mixed Layer Depth (dsigma = 0.01 wrt 10m)"   field_ref="mldr10_1"   operation="minimum"                                                                          />
+         <field id="heatc"        long_name="Heat content vertically integrated"                 standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"       />
+         <field id="saltc"        long_name="Salt content vertically integrated"                                                                                                                   unit="1e-3*kg/m2" />
+
+         <!-- EOS -->
+         <field id="alpha"        long_name="thermal expansion"                                                         unit="degC-1" grid_ref="grid_T_3D" />
+         <field id="beta"         long_name="haline contraction"                                                        unit="1e3"    grid_ref="grid_T_3D" />
+         <field id="bn2"          long_name="squared Brunt-Vaisala frequency"                                           unit="s-1"    grid_ref="grid_T_3D" />
+         <field id="rhop"         long_name="potential density (sigma0)"        standard_name="sea_water_sigma_theta"   unit="kg/m3"  grid_ref="grid_T_3D" />
+
+         <!-- Energy - horizontal divergence -->
+         <field id="eken"         long_name="kinetic energy"          standard_name="specific_kinetic_energy_of_sea_water"   unit="m2/s2"  grid_ref="grid_T_3D" />
+         <field id="hdiv"         long_name="horizontal divergence"                                                          unit="s-1"    grid_ref="grid_T_3D" />
+
+         <!-- variables available with MLE -->
+         <field id="Lf_NHpf"      long_name="MLE: Lf = N H / f"   unit="m" />
+
+         <!-- next variables available with key_diahth -->
+         <field id="mlddzt"       long_name="Thermocline Depth (depth of max dT/dz)"         standard_name="depth_at_maximum_upward_derivative_of_sea_water_potential_temperature"             unit="m"                         />
+         <field id="mldr10_3"     long_name="Mixed Layer Depth (dsigma = 0.03 wrt 10m)"      standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"                                unit="m"                         />
+         <field id="mldr0_1"      long_name="Mixed Layer Depth (dsigma = 0.01 wrt sfc)"      standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"                                unit="m"                         />
+         <field id="mldr0_3"      long_name="Mixed Layer Depth (dsigma = 0.03 wrt sfc)"      standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"                                unit="m"                         />
+         <field id="mld_dt02"     long_name="Mixed Layer Depth (|dT| = 0.2 wrt 10m)"         standard_name="ocean_mixed_layer_thickness_defined_by_temperature"                                unit="m"                         />
+         <field id="topthdep"     long_name="Top of Thermocline Depth (dT = -0.2 wrt 10m)"   standard_name="ocean_mixed_layer_thickness_defined_by_temperature"                                unit="m"                         />
+         <field id="pycndep"      long_name="Pycnocline Depth (dsigma[dT=-0.2] wrt 10m)"     standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"                                unit="m"                         />
+         <field id="BLT"          long_name="Barrier Layer Thickness"                                                                                                                          unit="m"                          > topthdep - pycndep </field>
+         <field id="tinv"         long_name="Max of vertical invertion of temperature"                                                                                                         unit="degC"                      />
+         <field id="depti"        long_name="Depth of max. vert. inv. of temperature"                                                                                                          unit="m"                         />
+         <field id="20d"          long_name="Depth of 20C isotherm"                          standard_name="depth_of_isosurface_of_sea_water_potential_temperature"                            unit="m"      axis_ref="iax_20C" />
+         <field id="28d"          long_name="Depth of 28C isotherm"                          standard_name="depth_of_isosurface_of_sea_water_potential_temperature"                            unit="m"      axis_ref="iax_28C" />
+         <field id="hc300"        long_name="Heat content 0-300m"                            standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"                      />
+
+         <!-- variables available with key_diaar5 -->
+         <field id="botpres"      long_name="Pressure at sea floor"   standard_name="sea_water_pressure_at_sea_floor"   unit="dbar" />
+
+         <!-- variables available with key_vvl -->
+         <field id="tpt_dep"      long_name="T-point depth"                  standard_name="depth_below_geoid"   unit="m"   grid_ref="grid_T_3D" />
+         <field id="e3tdef"       long_name="T-cell thickness deformation"                                       unit="%"   grid_ref="grid_T_3D" />
+      </field_group>
+
+      <!-- Tides -->
+
+      <field_group id="Tides_T" grid_ref="grid_T_2D" operation="once" >
+         <!-- tidal composante -->
+         <field id="M2x"          long_name="M2 Elevation harmonic real part "                             unit="m"        />
+         <field id="M2y"          long_name="M2 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="S2x"          long_name="S2 Elevation harmonic real part "                             unit="m"        />
+         <field id="S2y"          long_name="S2 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="N2x"          long_name="N2 Elevation harmonic real part "                             unit="m"        />
+         <field id="N2y"          long_name="N2 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="K1x"          long_name="K1 Elevation harmonic real part "                             unit="m"        />
+         <field id="K1y"          long_name="K1 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="O1x"          long_name="O1 Elevation harmonic real part "                             unit="m"        />
+         <field id="O1y"          long_name="O1 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="Q1x"          long_name="Q1 Elevation harmonic real part "                             unit="m"        />
+         <field id="Q1y"          long_name="Q1 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="M4x"          long_name="M4 Elevation harmonic real part "                             unit="m"        />
+         <field id="M4y"          long_name="M4 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="K2x"          long_name="K2 Elevation harmonic real part "                             unit="m"        />
+         <field id="K2y"          long_name="K2 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="P1x"          long_name="P1 Elevation harmonic real part "                             unit="m"        />
+         <field id="P1y"          long_name="P1 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="Mfx"          long_name="Mf Elevation harmonic real part "                             unit="m"        />
+         <field id="Mfy"          long_name="Mf Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="Mmx"          long_name="Mm Elevation harmonic real part "                             unit="m"        />
+         <field id="Mmy"          long_name="Mm Elevation harmonic imaginary part"                         unit="m"        />
+      </field_group>
+	 
+      <field_group id="Tides_U" grid_ref="grid_U_2D" operation="once" >
+         <field id="M2x_u"        long_name="M2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="M2y_u"        long_name="M2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="S2x_u"        long_name="S2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="S2y_u"        long_name="S2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="N2x_u"        long_name="N2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="N2y_u"        long_name="N2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="K1x_u"        long_name="K1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="K1y_u"        long_name="K1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="O1x_u"        long_name="O1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="O1y_u"        long_name="O1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Q1x_u"        long_name="Q1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="Q1y_u"        long_name="Q1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="M4x_u"        long_name="M4 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="M4y_u"        long_name="M4 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="K2x_u"        long_name="K2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="K2y_u"        long_name="K2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="P1x_u"        long_name="P1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="P1y_u"        long_name="P1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Mfx_u"        long_name="Mf current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="Mfy_u"        long_name="Mf current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Mmx_u"        long_name="Mm current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="Mmy_u"        long_name="Mm current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+      </field_group>
+	 
+      <field_group id="Tides_V" grid_ref="grid_V_2D" operation="once" >
+         <field id="M2x_v"        long_name="M2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="M2y_v"        long_name="M2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="S2x_v"        long_name="S2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="S2y_v"        long_name="S2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="N2x_v"        long_name="N2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="N2y_v"        long_name="N2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="K1x_v"        long_name="K1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="K1y_v"        long_name="K1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="O1x_v"        long_name="O1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="O1y_v"        long_name="O1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Q1x_v"        long_name="Q1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="Q1y_v"        long_name="Q1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="M4x_v"        long_name="M4 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="M4y_v"        long_name="M4 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="K2x_v"        long_name="K2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="K2y_v"        long_name="K2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="P1x_v"        long_name="P1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="P1y_v"        long_name="P1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Mfx_v"        long_name="Mf current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="Mfy_v"        long_name="Mf current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Mmx_v"        long_name="Mm current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="Mmy_v"        long_name="Mm current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />	 
+      </field_group>
+
+      <!-- SBC -->
+      
+      <field_group id="SBC" grid_ref="grid_T_2D" > <!-- time step automaticaly defined based on nn_fsbc -->
+         <field id="empmr"        long_name="Net Upward Water Flux"                standard_name="water_flux_out_of_sea_ice_and_sea_water"                              unit="kg/m2/s"   />
+         <field id="empbmr"       long_name="Net Upward Water Flux at pre. tstep"  standard_name="water_flux_out_of_sea_ice_and_sea_water"                              unit="kg/m2/s"   />
+         <field id="saltflx"      long_name="Downward salt flux"                                                                                                        unit="1e-3/m2/s" />
+         <field id="fmmflx"       long_name="Water flux due to freezing/melting"                                                                                        unit="kg/m2/s"   />
+         <field id="snowpre"      long_name="Snow precipitation"                   standard_name="snowfall_flux"                                                        unit="kg/m2/s"   />
+         <field id="runoffs"      long_name="River Runoffs"                        standard_name="water_flux_into_sea_water_from_rivers"                                unit="kg/m2/s"   />
+         <field id="precip"       long_name="Total precipitation"                  standard_name="precipitation_flux"                                                   unit="kg/m2/s"   />
+ 
+         <field id="qt"           long_name="Net Downward Heat Flux"                standard_name="surface_downward_heat_flux_in_sea_water"                              unit="W/m2"                           />
+         <field id="qns"          long_name="non solar Downward Heat Flux"                                                                                               unit="W/m2"                           />
+         <field id="qsr"          long_name="Shortwave Radiation"                   standard_name="net_downward_shortwave_flux_at_sea_water_surface"                     unit="W/m2"                           />
+         <field id="qsr3d"        long_name="Shortwave Radiation 3D distribution"   standard_name="downwelling_shortwave_flux_in_sea_water"                              unit="W/m2"      grid_ref="grid_T_3D" />
+         <field id="qrp"          long_name="Surface Heat Flux: Damping"            standard_name="heat_flux_into_sea_water_due_to_newtonian_relaxation"                 unit="W/m2"                           />
+         <field id="erp"          long_name="Surface Water Flux: Damping"           standard_name="water_flux_out_of_sea_water_due_to_newtonian_relaxation"              unit="kg/m2/s"                        />
+         <field id="taum"         long_name="wind stress module"                    standard_name="magnitude_of_surface_downward_stress"                                 unit="N/m2"                           />
+         <field id="wspd"         long_name="wind speed module"                     standard_name="wind_speed"                                                           unit="m/s"                            />
+         
+         <!-- * variable relative to atmospheric pressure forcing : available with ln_apr_dyn -->
+         <field id="ssh_ib"       long_name="Inverse barometer sea surface height"  standard_name="sea_surface_height_correction_due_to_air_pressure_at_low_frequency"   unit="m"        />
+
+         <!-- * variable related to ice shelf forcing * -->
+         <field id="fwfisf"       long_name="Ice shelf melting"                                            unit="Kg/m2/s"  />
+         <field id="qisf"         long_name="Ice Shelf Heat Flux"                                          unit="W/m2"     />
+         <field id="isfgammat"    long_name="transfert coefficient for isf (temperature) "                 unit="m/s"      />
+         <field id="isfgammas"    long_name="transfert coefficient for isf (salinity)    "                 unit="m/s"      />
+ 	 <field id="stbl"         long_name="salinity in the Losh tbl                    "                 unit="PSU"      />
+	 <field id="ttbl"         long_name="temperature in the Losh tbl                 "                 unit="C"        />
+	 <field id="utbl"         long_name="zonal current in the Losh tbl at T point    "                 unit="m/s"      />
+	 <field id="vtbl"         long_name="merid current in the Losh tbl at T point    "                 unit="m/s"      />
+	 <field id="thermald"     long_name="thermal driving of ice shelf melting        "                 unit="C"        />
+	 <field id="tfrz"         long_name="top freezing point (used to compute melt)   "                 unit="C"        />
+	 <field id="tinsitu"      long_name="top insitu temperature (used to cmpt melt)  "                 unit="C"        />
+	 <field id="ustar"        long_name="ustar at T point used in ice shelf melting  "                 unit="m/s"      />
+
+         <!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
+         <field id="qlw_oce"      long_name="Longwave Downward Heat Flux over open ocean"  standard_name="surface_net_downward_longwave_flux"   unit="W/m2"  />
+         <field id="qsb_oce"      long_name="Sensible Downward Heat Flux over open ocean"  standard_name="surface_downward_sensible_heat_flux"  unit="W/m2"  />
+         <field id="qla_oce"      long_name="Latent Downward Heat Flux over open ocean"    standard_name="surface_downward_latent_heat_flux"    unit="W/m2"  />
+         <field id="qemp_oce"     long_name="Downward Heat Flux from E-P over open ocean"                                                       unit="W/m2"  />
+         <field id="taum_oce"     long_name="wind stress module over open ocean"           standard_name="magnitude_of_surface_downward_stress" unit="N/m2"  />
+
+         <!-- available key_oasis3 -->
+         <field id="snow_ao_cea"  long_name="Snow over ice-free ocean (cell average)"   standard_name="snowfall_flux"                             unit="kg/m2/s"  />
+         <field id="snow_ai_cea"  long_name="Snow over sea-ice (cell average)"          standard_name="snowfall_flux"                             unit="kg/m2/s"  />
+         <field id="subl_ai_cea"  long_name="Sublimation over sea-ice (cell average)"   standard_name="surface_snow_and_ice_sublimation_flux"     unit="kg/m2/s"  />
+         <field id="icealb_cea"   long_name="Ice albedo (cell average)"                 standard_name="sea_ice_albedo"                            unit="1"        />
+         <field id="calving_cea"  long_name="Calving"                                   standard_name="water_flux_into_sea_water_from_icebergs"   unit="kg/m2/s"  />
+
+         <!-- available if key_oasis3 + conservative method -->
+         <field id="rain"          long_name="Liquid precipitation"                                     standard_name="rainfall_flux"                                                                 unit="kg/m2/s"  />
+         <field id="evap_ao_cea"   long_name="Evaporation over ice-free ocean (cell average)"           standard_name="water_evaporation_flux"                                                        unit="kg/m2/s"  />
+         <field id="isnwmlt_cea"   long_name="Snow over Ice melting (cell average)"                     standard_name="surface_snow_melt_flux"                                                        unit="kg/m2/s"  />
+         <field id="fsal_virt_cea" long_name="Virtual salt flux due to ice formation (cell average)"    standard_name="virtual_salt_flux_into_sea_water_due_to_sea_ice_thermodynamics"                unit="kg/m2/s"  />
+         <field id="fsal_real_cea" long_name="Real salt flux due to ice formation (cell average)"       standard_name="downward_sea_ice_basal_salt_flux"                                              unit="kg/m2/s"  />
+         <field id="hflx_rain_cea" long_name="heat flux due to rainfall"                                standard_name="temperature_flux_due_to_rainfall_expressed_as_heat_flux_into_sea_water"        unit="W/m2"     />
+         <field id="hflx_evap_cea" long_name="heat flux due to evaporation"                             standard_name="temperature_flux_due_to_evaporation_expressed_as_heat_flux_out_of_sea_water"   unit="W/m2"     />
+         <field id="hflx_snow_cea" long_name="heat flux due to snow falling over ice-free ocean"        standard_name="heat_flux_into_sea_water_due_to_snow_thermodynamics"                           unit="W/m2"     />
+         <field id="hflx_ice_cea"  long_name="heat flux due to ice thermodynamics"                      standard_name="heat_flux_into_sea_water_due_to_sea_ice_thermodynamics"                        unit="W/m2"     />
+         <field id="hflx_rnf_cea"  long_name="heat flux due to runoffs"                                 standard_name="temperature_flux_due_to_runoff_expressed_as_heat_flux_into_sea_water"          unit="W/m2"     />
+         <field id="hflx_cal_cea"  long_name="heat flux due to calving"                                 standard_name="heat_flux_into_sea_water_due_to_iceberg_thermodynamics"                        unit="W/m2"     />
+         <field id="bicemel_cea"   long_name="Rate of Melt at Sea Ice Base (cell average)"              standard_name="tendency_of_sea_ice_amount_due_to_basal_melting"                               unit="kg/m2/s"  />
+         <field id="licepro_cea"   long_name="Lateral Sea Ice Growth Rate (cell average)"               standard_name="tendency_of_sea_ice_amount_due_to_lateral_growth_of_ice_floes"                 unit="kg/m2/s"  />
+         <field id="snowmel_cea"   long_name="Snow Melt Rate (cell average)"                            standard_name="surface_snow_melt_flux"                                                        unit="kg/m2/s"  />
+         <field id="sntoice_cea"   long_name="Snow-Ice Formation Rate (cell average)"                   standard_name="tendency_of_sea_ice_amount_due_to_snow_conversion"                             unit="kg/m2/s"  />
+         <field id="ticemel_cea"   long_name="Rate of Melt at Upper Surface of Sea Ice (cell average)"  standard_name="tendency_of_sea_ice_amount_due_to_surface_melting"                             unit="kg/m2/s"  />
+
+         <!-- ice fields -->
+         <field id="ice_cover"    long_name="Ice fraction"                                                 standard_name="sea_ice_area_fraction"                              unit="1"            />
+
+         <field id="qsr_ai_cea"   long_name="Air-Ice downward solar heat flux (cell average)"              standard_name="surface_downwelling_shortwave_flux_in_air"          unit="W/m2"         />
+         <field id="qns_ai_cea"   long_name="Air-Ice downward non-solar heat flux (cell average)"                                                                             unit="W/m2"         />
+         <field id="qla_ai_cea"   long_name="Air-Ice downward Latent heat flux (cell average)"             standard_name="surface_downward_latent_heat_flux"                  unit="W/m2"         />
+         
+         <field id="qsr_io_cea"   long_name="Ice-Oce downward solar heat flux (cell average)"              standard_name="net_downward_shortwave_flux_at_sea_water_surface"   unit="W/m2"         />
+         <field id="qns_io_cea"   long_name="Ice-Oce downward non-solar heat flux (cell average)"                                                                             unit="W/m2"         />
+         
+         <field id="snowthic_cea" long_name="Snow thickness (cell average)"                                standard_name="surface_snow_thickness"                             unit="m"            />
+         <field id="icethic_cea"  long_name="Ice thickness (cell average)"                                 standard_name="sea_ice_thickness"                                  unit="m"            />
+         <field id="iceprod_cea"  long_name="Ice production (cell average)"                                                                                                   unit="m/s"          />
+         <field id="iiceconc"     long_name="Ice concentration"                                            standard_name="sea_ice_area_fraction"                              unit="1"            />
+         
+         <field id="ice_pres"     long_name="Ice presence"                                                                                                                    unit=""             />
+         <field id="ist_cea"      long_name="Ice surface temperature (cell average)"                       standard_name="surface_temperature"                                unit="degC"         />
+         <field id="ist_ipa"      long_name="Ice surface temperature (ice presence average)"               standard_name="surface_temperature"                                unit="degC"         />      
+         <field id="uice_ipa"     long_name="Ice velocity along i-axis at I-point (ice presence average)"  standard_name="sea_ice_x_velocity"                                 unit="m/s"          />      
+         <field id="vice_ipa"     long_name="Ice velocity along j-axis at I-point (ice presence average)"  standard_name="sea_ice_y_velocity"                                 unit="m/s"          />      
+         
+         <field id="utau_ice"     long_name="Wind stress along i-axis over the ice at i-point"             standard_name="surface_downward_x_stress"                          unit="N/m2"         />
+         <field id="vtau_ice"     long_name="Wind stress along j-axis over the ice at i-point"             standard_name="surface_downward_y_stress"                          unit="N/m2"         />
+         
+         <field id="u_imasstr"    long_name="Sea-ice mass transport along i-axis"                          standard_name="sea_ice_x_transport"                                unit="kg/s"         />
+         <field id="v_imasstr"    long_name="Sea-ice mass transport along j-axis"                          standard_name="sea_ice_y_transport"                                unit="kg/s"         />
+         <field id="emp_x_sst"    long_name="Concentration/Dilution term on SST"                                                                                              unit="kg*degC/m2/s" />
+         <field id="emp_x_sss"    long_name="Concentration/Dilution term on SSS"                                                                                              unit="kg*1e-3/m2/s" />        
+       
+         <field id="iceconc"      long_name="ice concentration"                                            standard_name="sea_ice_area_fraction"                              unit="%"            />
+       	 <field id="isst"         long_name="sea surface temperature"                                      standard_name="sea_surface_temperature"                            unit="degC"         />
+         <field id="isss"         long_name="sea surface salinity"                                         standard_name="sea_surface_salinity"                               unit="1e-3"         /> 
+         <field id="qt_oce"       long_name="total flux at ocean surface"                                  standard_name="surface_downward_heat_flux_in_sea_water"            unit="W/m2"         />
+         <field id="qsr_oce"      long_name="solar heat flux at ocean surface"                             standard_name="net_downward_shortwave_flux_at_sea_water_surface"   unit="W/m2"         />
+         <field id="qns_oce"      long_name="non-solar heat flux at ocean surface"                                                                                            unit="W/m2"         />
+         <field id="qt_ice"       long_name="total heat flux at ice surface: sum over categories"          standard_name="surface_downward_heat_flux_in_air"                  unit="W/m2"         />
+         <field id="qsr_ice"      long_name="solar heat flux at ice surface: sum over categories"          standard_name="surface_downwelling_shortwave_flux_in_air"          unit="W/m2"         />
+         <field id="qns_ice"      long_name="non-solar heat flux at ice surface: sum over categories"                                                                         unit="W/m2"         />
+         <field id="qtr_ice"      long_name="solar heat flux transmitted through ice: sum over categories"                                                                    unit="W/m2"         />
+         <field id="qemp_ice"     long_name="Downward Heat Flux from E-P over ice"                                                                                            unit="W/m2"         />
+         <field id="micesalt"     long_name="Mean ice salinity"                                                                                                               unit="1e-3"         />
+         <field id="miceage"      long_name="Mean ice age"                                                                                                                    unit="years"        />
+
+         <field id="iceage_cat"   long_name="Ice age for categories"                                       unit="days"   axis_ref="ncatice" />
+         <field id="iceconc_cat"  long_name="Ice concentration for categories"                             unit="%"      axis_ref="ncatice" />
+         <field id="icethic_cat"  long_name="Ice thickness for categories"                                 unit="m"      axis_ref="ncatice" />
+         <field id="snowthic_cat" long_name="Snow thicknessi for categories"                               unit="m"      axis_ref="ncatice" />
+         <field id="salinity_cat" long_name="Sea-Ice Bulk salinity for categories"                         unit="g/kg"   axis_ref="ncatice" />
+         <field id="brinevol_cat" long_name="Brine volume for categories"                                  unit="%"      axis_ref="ncatice" />
+         <field id="icetemp_cat"  long_name="Ice temperature for categories"                               unit="degC"   axis_ref="ncatice" />
+         <field id="snwtemp_cat"  long_name="Snow temperature for categories"                              unit="degC"   axis_ref="ncatice" />
+
+         <field id="micet"        long_name="Mean ice temperature"                                         unit="degC"     />
+         <field id="icehc"        long_name="ice total heat content"                                       unit="10^9J"    /> 
+         <field id="isnowhc"      long_name="snow total heat content"                                      unit="10^9J"    />
+         <field id="icest"        long_name="ice surface temperature"                                      unit="degC"     />
+         <field id="ibrinv"       long_name="brine volume"                                                 unit="%"        />
+         <field id="icecolf"      long_name="frazil ice collection thickness"                              unit="m"        />
+         <field id="icestr"       long_name="ice strength"                                                 unit="N/m"      />
+         <field id="icevel"       long_name="ice velocity"                                                 unit="m/s"      />
+         <field id="idive"        long_name="divergence"                                                   unit="1e-8s-1"  />
+         <field id="ishear"       long_name="shear"                                                        unit="1e-8s-1"  />
+         <field id="icevolu"      long_name="ice volume"                                                   unit="m"        />
+         <field id="snowvol"      long_name="snow volume"                                                  unit="m"        />
+
+         <field id="icetrp"       long_name="ice volume transport"                                         unit="m/day"          />
+         <field id="snwtrp"       long_name="snw volume transport"                                         unit="m/day"          />
+         <field id="saltrp"       long_name="salt content transport"                                       unit="1e-3*kg/m2/day" />
+         <field id="deitrp"       long_name="advected ice enthalpy"                                        unit="W/m2"           />
+         <field id="destrp"       long_name="advected snw enthalpy"                                        unit="W/m2"           />
+
+         <field id="sfxbri"       long_name="brine salt flux"                                              unit="1e-3*kg/m2/day" />
+         <field id="sfxdyn"       long_name="salt flux from ridging rafting"                               unit="1e-3*kg/m2/day" />
+         <field id="sfxres"       long_name="salt flux from lipupdate (resultant)"                         unit="1e-3*kg/m2/day" />
+         <field id="sfxbog"       long_name="salt flux from bot growth"                                    unit="1e-3*kg/m2/day" />
+         <field id="sfxbom"       long_name="salt flux from bot melt"                                      unit="1e-3*kg/m2/day" />
+         <field id="sfxsum"       long_name="salt flux from surf melt"                                     unit="1e-3*kg/m2/day" />
+         <field id="sfxsni"       long_name="salt flux from snow-ice formation"                            unit="1e-3*kg/m2/day" />
+         <field id="sfxopw"       long_name="salt flux from open water ice formation"                      unit="1e-3*kg/m2/day" />
+         <field id="sfx"          long_name="salt flux total"                                              unit="1e-3*kg/m2/day" />
+
+         <field id="vfxbog"       long_name="daily bottom thermo ice prod."                                unit="m/day"   />
+         <field id="vfxdyn"       long_name="daily  dynamic ice prod."                                     unit="m/day"   />
+         <field id="vfxopw"       long_name="daily lateral thermo ice prod."                               unit="m/day"   />
+         <field id="vfxsni"       long_name="daily snowice ice prod."                                      unit="m/day"   />
+         <field id="vfxsum"       long_name="surface melt"                                                 unit="m/day"   />
+         <field id="vfxbom"       long_name="bottom melt"                                                  unit="m/day"   />
+         <field id="vfxres"       long_name="daily resultant ice prod./melting from limupdate"             unit="m/day"   />
+         <field id="vfxice"       long_name="ice melt/growth"                                              unit="m/day"   />
+         <field id="vfxsnw"       long_name="snw melt/growth"                                              unit="m/day"   />
+         <field id="vfxsub"       long_name="snw sublimation"                                              unit="m/day"   />
+         <field id="vfxspr"       long_name="snw precipitation on ice"                                     unit="m/day"   />
+
+         <field id="afxtot"       long_name="area tendency (total)"                                        unit="day-1"   />
+         <field id="afxdyn"       long_name="area tendency (dynamics)"                                     unit="day-1"   />
+         <field id="afxthd"       long_name="area tendency (thermo)"                                       unit="day-1"   />
+
+         <field id="hfxsum"       long_name="heat fluxes causing surface ice melt"                         unit="W/m2"  />
+         <field id="hfxbom"       long_name="heat fluxes causing bottom ice melt"                          unit="W/m2"  />
+         <field id="hfxbog"       long_name="heat fluxes causing bottom ice growth"                        unit="W/m2"  />
+         <field id="hfxdif"       long_name="heat fluxes causing ice temperature change"                   unit="W/m2"  />
+         <field id="hfxopw"       long_name="heat fluxes causing open water ice formation"                 unit="W/m2"  />
+         <field id="hfxsnw"       long_name="heat fluxes causing snow melt"                                unit="W/m2"  />
+         <field id="hfxerr"       long_name="heat fluxes error after heat diffusion"                       unit="W/m2"  />
+         <field id="hfxerr_rem"   long_name="heat fluxes error after remapping"                            unit="W/m2"  />
+         <field id="hfxout"       long_name="total heat fluxes received by the ocean"                      unit="W/m2"  />
+         <field id="hfxin"        long_name="total heat fluxes at the ice/ocean surface"                   unit="W/m2"  />
+
+         <!-- heat flux associated with mass exchange -->
+         <field id="hfxthd"       long_name="heat fluxes from ice-ocean mass exchange during thermo"       unit="W/m2"  />
+         <field id="hfxdyn"       long_name="heat fluxes from ice-ocean mass exchange during dynamic"      unit="W/m2"  />
+         <field id="hfxres"       long_name="heat fluxes from ice-ocean mass exchange during resultant"    unit="W/m2"  />
+         <field id="hfxsub"       long_name="heat fluxes from ice-atm. mass exchange during sublimation"   unit="W/m2"  />
+         <field id="hfxspr"       long_name="heat fluxes from ice-atm. mass exchange during snow precip"   unit="W/m2"  />
+
+         <!-- diags -->
+         <field id="hfxdhc"       long_name="Heat content variation in snow and ice"                       unit="W/m2" />
+         <field id="hfxtur"       long_name="turbulent heat flux at the ice base"                          unit="W/m2" />
+	 <!-- sbcssm variables -->
+         <field id="sst_m"    unit="degC" />
+         <field id="sss_m"    unit="psu"  />
+         <field id="ssu_m"    unit="m/s"  />
+         <field id="ssv_m"    unit="m/s"  />
+         <field id="ssh_m"    unit="m"    />
+         <field id="e3t_m"    unit="m"    />
+         <field id="frq_m"    unit="-"    />
+
+      </field_group>
+
+      <!-- U grid -->
+      
+      <field_group id="grid_U"   grid_ref="grid_U_2D">
+         <field id="e3u"          long_name="U-cell thickness"                                       standard_name="cell_thickness"              unit="m"          grid_ref="grid_U_3D" />
+         <field id="e3u_0"        long_name="Initial U-cell thickness"                               standard_name="ref_cell_thickness"          unit="m"          grid_ref="grid_U_3D"/>
+         <field id="utau"         long_name="Wind Stress along i-axis"                               standard_name="surface_downward_x_stress"   unit="N/m2"                            />
+         <field id="ucli"         long_name="uncorrected ocean current along i-axis"                             standard_name="uc_sea_water_x_velocity"        unit="m/s"        grid_ref="grid_U_3D" />
+         <field id="ucli2"         long_name="uncorrected2 ocean current along i-axis"                             standard_name="uc2_sea_water_x_velocity"        unit="m/s"        grid_ref="grid_U_3D" />
+         <field id="un_b"         long_name="un_b ocean barotropic current along i-axis"                                                              unit="m/s"                             />
+         <field id="uoce"         long_name="ocean current along i-axis"                             standard_name="sea_water_x_velocity"        unit="m/s"        grid_ref="grid_U_3D" />
+         <field id="uoce_e3u"     long_name="ocean current along i-axis  (thickness weighted)"                                                   unit="m/s"        grid_ref="grid_U_3D"  > uoce * e3u </field>
+         <field id="ssu"          long_name="ocean surface current along i-axis"                                                                 unit="m/s"                             />
+         <field id="wdlmtu"          long_name="ocean current limiter along i-axis"                unit="#"                             />
+         <field id="sbu"          long_name="ocean bottom current along i-axis"                                                                  unit="m/s"                             />
+         <field id="ubar"         long_name="ocean barotropic current along i-axis"                                                              unit="m/s"                             />
+         <field id="uocetr_eff"   long_name="Effective ocean transport along i-axis"                 standard_name="ocean_volume_x_transport"    unit="m3/s"       grid_ref="grid_U_3D" />
+         <field id="uocet"        long_name="ocean transport along i-axis times temperature (CRS)"                                               unit="degC*m/s"   grid_ref="grid_U_3D" />
+         <field id="uoces"        long_name="ocean transport along i-axis times salinity (CRS)"                                                  unit="1e-3*m/s"   grid_ref="grid_U_3D" />
+
+	      <!-- u-eddy coefficients (ldftra) -->
+	      <field id="ahtu_2d"      long_name=" surface u-eddy diffusivity coefficient"   unit="m2/s or m4/s" />
+	      <field id="ahtu_3d"      long_name=" 3D u-EIV coefficient"                     unit="m2/s or m4/s"      grid_ref="grid_U_3D"/>
+	      <field id="aeiu_2d"      long_name=" surface u-EIV coefficient"                unit="m2/s" />
+	      <field id="aeiu_3d"      long_name=" 3D u-EIV coefficient"                     unit="m2/s"              grid_ref="grid_U_3D"/>
+
+         <!-- variables available with MLE -->
+         <field id="psiu_mle"     long_name="MLE streamfunction along i-axis"   unit="m3/s"   grid_ref="grid_U_3D" />
+
+         <!-- uoce_eiv: available EIV -->
+         <field id="uoce_eiv"     long_name="EIV ocean current along i-axis"   standard_name="bolus_sea_water_x_velocity"   unit="m/s"   grid_ref="grid_U_3D" />
+
+         <!-- uoce_eiv: available with key_trabbl -->
+         <field id="uoce_bbl"     long_name="BBL ocean current along i-axis"    unit="m/s"  />
+         <field id="ahu_bbl"      long_name="BBL diffusive flux along i-axis"   unit="m3/s" />
+
+         <!-- variable for ice shelves -->
+         <field id="utbl"         long_name="zonal current in the Losh tbl"     unit="m/s" />
+
+         <!-- variables available with key_diaar5 -->
+         <field id="u_masstr"     long_name="ocean eulerian mass transport along i-axis"    standard_name="ocean_mass_x_transport"                          unit="kg/s"        grid_ref="grid_U_3D" />
+         <field id="u_heattr"     long_name="ocean eulerian heat transport along i-axis"    standard_name="ocean_heat_x_transport"                          unit="W"                                />
+         <field id="u_salttr"     long_name="ocean eulerian salt transport along i-axis"    standard_name="ocean_salt_x_transport"                          unit="1e-3*kg/s"                        />
+         <field id="ueiv_heattr"  long_name="ocean bolus heat transport along i-axis"       standard_name="ocean_heat_x_transport_due_to_bolus_advection"   unit="W"                                />
+         <field id="udiff_heattr" long_name="ocean diffusion heat transport along i-axis"   standard_name="ocean_heat_x_transport_due_to_diffusion"         unit="W"                                />
+      </field_group>
+      
+      <!-- V grid -->
+      
+      <field_group id="grid_V"   grid_ref="grid_V_2D">
+         <field id="e3v"          long_name="V-cell thickness"                                       standard_name="cell_thickness"              unit="m"          grid_ref="grid_V_3D" />
+         <field id="e3v_0"        long_name="Initial V-cell thickness"                               standard_name="ref_cell_thickness"          unit="m"          grid_ref="grid_V_3D"/>
+         <field id="vtau"         long_name="Wind Stress along j-axis"                               standard_name="surface_downward_y_stress"   unit="N/m2"                            />
+         <field id="voce"         long_name="ocean current along j-axis"                             standard_name="sea_water_y_velocity"        unit="m/s"        grid_ref="grid_V_3D" />
+         <field id="voce_e3v"     long_name="ocean current along j-axis  (thickness weighted)"                                                   unit="m/s"        grid_ref="grid_V_3D"  > voce * e3v </field>
+         <field id="ssv"          long_name="ocean surface current along j-axis"                                                                 unit="m/s"                             />
+         <field id="sbv"          long_name="ocean bottom current along j-axis"                                                                  unit="m/s"                             />
+         <field id="vbar"         long_name="ocean barotropic current along j-axis"                                                              unit="m/s"                             />
+         <field id="vocetr_eff"   long_name="Effective ocean transport along j-axis"                 standard_name="ocean_volume_y_transport"    unit="m3/s"       grid_ref="grid_V_3D" />
+         <field id="vocet"        long_name="ocean transport along j-axis times temperature (CRS)"                                               unit="degC*m/s"   grid_ref="grid_V_3D" />
+         <field id="voces"        long_name="ocean transport along j-axis times salinity (CRS)"                                                  unit="1e-3*m/s"   grid_ref="grid_V_3D" />
+
+	      <!-- v-eddy coefficients (ldftra, ldfdyn) -->
+	      <field id="ahtv_2d"      long_name=" surface v-eddy diffusivity coefficient"     unit="m2/s or (m4/s)^1/2" />
+	      <field id="ahtv_3d"      long_name=" 3D v-eddy diffusivity coefficient"          unit="m2/s or (m4/s)^1/2"           grid_ref="grid_V_3D"/>
+	      <field id="aeiv_2d"      long_name=" surface v-EIV coefficient"                  unit="m2/s" />
+	      <field id="aeiv_3d"      long_name=" 3D v-EIV coefficient"                       unit="m2/s"                         grid_ref="grid_V_3D" />
+
+         <!-- variables available with MLE -->
+         <field id="psiv_mle"     long_name="MLE streamfunction along j-axis"   unit="m3/s"   grid_ref="grid_V_3D" />
+
+         <!-- voce_eiv: available with EIV -->
+         <field id="voce_eiv"     long_name="EIV ocean current along j-axis"   standard_name="bolus_sea_water_y_velocity"   unit="m/s"   grid_ref="grid_V_3D" />
+
+         <!-- voce_eiv: available with key_trabbl -->
+         <field id="voce_bbl"     long_name="BBL ocean current along j-axis"    unit="m/s"  />
+         <field id="ahv_bbl"      long_name="BBL diffusive flux along j-axis"   unit="m3/s" />
+
+         <!-- variable for ice shelves -->
+         <field id="vtbl"         long_name="meridional current in the Losh tbl"   unit="m/s" />
+
+         <!-- variables available with key_diaar5 -->
+         <field id="v_masstr"     long_name="ocean eulerian mass transport along j-axis"    standard_name="ocean_mass_y_transport"                          unit="kg/s"        grid_ref="grid_V_3D" />
+         <field id="v_heattr"     long_name="ocean eulerian heat transport along j-axis"    standard_name="ocean_heat_y_transport"                          unit="W"                                />
+         <field id="v_salttr"     long_name="ocean eulerian salt transport along i-axis"    standard_name="ocean_salt_y_transport"                          unit="1e-3*kg/s"                        />
+         <field id="veiv_heattr"  long_name="ocean bolus heat transport along j-axis"       standard_name="ocean_heat_y_transport_due_to_bolus_advection"   unit="W"                                />
+         <field id="vdiff_heattr" long_name="ocean diffusion heat transport along j-axis"   standard_name="ocean_heat_y_transport_due_to_diffusion"         unit="W"                                />
+      </field_group>
+      
+      <!-- W grid -->
+      
+      <field_group id="grid_W" grid_ref="grid_W_3D">
+        <field id="e3w"          long_name="W-cell thickness"                     standard_name="cell_thickness"              unit="m"    />
+        <field id="woce"         long_name="ocean vertical velocity"              standard_name="upward_sea_water_velocity"   unit="m/s"  />
+        <field id="wocetr_eff"   long_name="effective ocean vertical transport"                                               unit="m3/s" />
+
+        <!-- woce_eiv: available with EIV -->
+        <field id="woce_eiv"     long_name="EIV ocean vertical velocity"   standard_name="bolus_upward_sea_water_velocity"   unit="m/s" />
+
+
+        <field id="avt"          long_name="vertical eddy diffusivity"   standard_name="ocean_vertical_heat_diffusivity"       unit="m2/s" />
+        <field id="logavt"       long_name="logarithm of vertical eddy diffusivity"   standard_name="ocean_vertical_heat_diffusivity"       unit="m2/s" />
+        <field id="avm"          long_name="vertical eddy viscosity"     standard_name="ocean_vertical_momentum_diffusivity"   unit="m2/s" />
+
+        <!-- avs: available with key_zdfddm -->
+        <field id="avs"          long_name="salt vertical eddy diffusivity"   standard_name="ocean_vertical_salt_diffusivity"   unit="m2/s" />
+        <field id="logavs"       long_name="logarithm of salt vertical eddy diffusivity"   standard_name="ocean_vertical_heat_diffusivity"       unit="m2/s" />
+
+        <!-- avt_evd and avm_evd: available with ln_zdfevd -->
+        <field id="avt_evd"      long_name="convective enhancement of vertical diffusivity"   standard_name="ocean_vertical_tracer_diffusivity_due_to_convection"     unit="m2/s" />
+        <field id="avm_evd"      long_name="convective enhancement of vertical viscosity"     standard_name="ocean_vertical_momentum_diffusivity_due_to_convection"   unit="m2/s" />
+
+        <!-- avt_tide: available with key_zdftmx -->
+        <field id="av_tide"      long_name="tidal vertical diffusivity"   standard_name="ocean_vertical_tracer_diffusivity_due_to_tides"   unit="m2/s" />
+
+        <!-- variables available with key_diaar5 -->   
+        <field id="w_masstr"     long_name="vertical mass transport"             standard_name="upward_ocean_mass_transport"             unit="kg/s"   />
+        <field id="w_masstr2"    long_name="square of vertical mass transport"   standard_name="square_of_upward_ocean_mass_transport"   unit="kg2/s2" />
+
+        <!-- aht2d and  aht2d_eiv -->
+        <field id="aht2d"        long_name="lateral eddy diffusivity"       standard_name="ocean_tracer_xy_laplacian_diffusivity"      unit="m2/s"   grid_ref="grid_W_2D" />
+        <field id="aht2d_eiv"    long_name="EIV lateral eddy diffusivity"   standard_name="ocean_tracer_bolus_laplacian_diffusivity"   unit="m2/s"   grid_ref="grid_W_2D" />
+      </field_group>
+        
+      <!-- F grid -->
+	      <!-- f-eddy viscosity coefficients (ldfdyn) -->
+	      <field id="ahmf_2d"      long_name=" surface f-eddy viscosity coefficient"   unit="m2/s or m4/s" />
+	      <field id="ahmf_3d"      long_name=" 3D      f-eddy viscosity coefficient"   unit="m2/s or m4/s"                           grid_ref="grid_T_3D"/>
+
+      <!-- scalar variables available with key_diaar5 -->
+
+      <field_group id="scalar"  domain_ref="1point" >
+         <field id="voltot"     long_name="global total volume"                          standard_name="sea_water_volume"                               unit="m3"   />
+         <field id="sshtot"     long_name="global mean ssh"                              standard_name="global_average_sea_level_change"                unit="m"    />
+         <field id="sshsteric"  long_name="global mean ssh steric"                       standard_name="global_average_steric_sea_level_change"         unit="m"    />
+         <field id="sshthster"  long_name="global mean ssh thermosteric"                 standard_name="global_average_thermosteric_sea_level_change"   unit="m"    />
+         <field id="masstot"    long_name="global total mass"                            standard_name="sea_water_mass"                                 unit="kg"   />
+         <field id="temptot"    long_name="global mean temperature"                      standard_name="sea_water_potential_temperature"                unit="degC" />
+         <field id="saltot"     long_name="global mean salinity"                         standard_name="sea_water_salinity"                             unit="1e-3" />
+         <field id="fram_trans" long_name="Sea Ice Mass Transport Through Fram Strait"   standard_name="sea_ice_transport_across_line"                  unit="kg/s" />
+
+      	 <!-- available with ln_diahsb -->
+    	 <field id="bgtemper"     long_name="drift in global mean temperature wrt timestep 1"                 standard_name="change_over_time_in_sea_water_potential_temperature"   unit="degC"     />
+    	 <field id="bgsaline"     long_name="drift in global mean salinity wrt timestep 1"                    standard_name="change_over_time_in_sea_water_practical_salinity"      unit="1e-3"     />
+    	 <field id="bgheatco"     long_name="drift in global mean heat content wrt timestep 1"                                                                                      unit="10^9J"    />
+    	 <field id="bgsaltco"     long_name="drift in global mean salt content wrt timestep 1"                                                                                      unit="1e-3*m3"  />
+    	 <field id="bgvolssh"     long_name="drift in global mean ssh volume wrt timestep 1"                                                                                        unit="km3"      />
+         <field id="bgvole3t"     long_name="drift in global mean volume variation (e3t) wrt timestep 1"                                                                            unit="km3"      />
+    	 <field id="bgvoltot"     long_name="drift in global mean volume wrt timestep 1"                                                                                            unit="km3"      />
+         <!-- NOTE: No matching iom_put call -->
+    	 <field id="bgsshtot"     long_name="drift in global mean ssh wrt timestep 1"                         standard_name="global_average_sea_level_change"                       unit="m"        />
+    	 <field id="bgfrcvol"     long_name="drift in global mean volume from forcing wrt timestep 1"                                                                               unit="km3"      />
+    	 <field id="bgfrctem"     long_name="drift in global mean heat content from forcing wrt timestep 1"                                                                         unit="10^9J"    />
+    	 <field id="bgfrcsal"     long_name="drift in global mean salt content from forcing wrt timestep 1"                                                                         unit="1e-3*km3" />
+    	 <field id="bgmistem"     long_name="global mean temperature error due to free surface"                                                                                     unit="degC"     />
+    	 <field id="bgmissal"     long_name="global mean salinity error due to free surface"                                                                                        unit="1e-3"     />
+      </field_group>
+
+      <!-- LIM3 scalar variables -->
+
+      <field_group id="SBC_scalar"  domain_ref="1point" >
+         <!-- available with ln_limdiaout -->
+         <field id="ibgvoltot"    long_name="global mean ice volume"                                 unit="km3"        />
+         <field id="sbgvoltot"    long_name="global mean snow volume"                                unit="km3"        />
+         <field id="ibgarea"      long_name="global mean ice area"                                   unit="km2"        />
+         <field id="ibgsaline"    long_name="global mean ice salinity"                               unit="1e-3"       />
+         <field id="ibgtemper"    long_name="global mean ice temperature"                            unit="degC"       />
+         <field id="ibgheatco"    long_name="global mean ice heat content"                           unit="10^20J"     />
+         <field id="sbgheatco"    long_name="global mean snow heat content"                          unit="10^20J"     />
+         <field id="ibgsaltco"    long_name="global mean ice salt content"                           unit="1e-3*km3"   />
+
+         <field id="ibgvfx"       long_name="global mean volume flux (emp)"                          unit="m/day"      />
+         <field id="ibgvfxbog"    long_name="global mean volume flux (bottom growth)"                unit="m/day"      />
+         <field id="ibgvfxopw"    long_name="global mean volume flux (open water growth)"            unit="m/day"      />
+         <field id="ibgvfxsni"    long_name="global mean volume flux (snow-ice growth)"              unit="m/day"      />
+         <field id="ibgvfxdyn"    long_name="global mean volume flux (dynamic growth)"               unit="m/day"      />
+         <field id="ibgvfxbom"    long_name="global mean volume flux (bottom melt)"                  unit="m/day"      />
+         <field id="ibgvfxsum"    long_name="global mean volume flux (surface melt)"                 unit="m/day"      />
+         <field id="ibgvfxres"    long_name="global mean volume flux (resultant)"                    unit="m/day"      />
+         <field id="ibgvfxspr"    long_name="global mean volume flux (snow precip)"                  unit="m/day"      />
+         <field id="ibgvfxsnw"    long_name="global mean volume flux (snow melt)"                    unit="m/day"      />
+         <field id="ibgvfxsub"    long_name="global mean volume flux (snow sublimation)"             unit="m/day"      />
+
+         <field id="ibgsfx"       long_name="global mean salt flux (total)"                          unit="1e-3*m/day" />
+         <field id="ibgsfxbri"    long_name="global mean salt flux (brines)"                         unit="1e-3*m/day" />
+         <field id="ibgsfxdyn"    long_name="global mean salt flux (dynamic)"                        unit="1e-3*m/day" />
+         <field id="ibgsfxres"    long_name="global mean salt flux (resultant)"                      unit="1e-3*m/day" />
+         <field id="ibgsfxbog"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
+         <field id="ibgsfxopw"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
+         <field id="ibgsfxsni"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
+         <field id="ibgsfxbom"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
+         <field id="ibgsfxsum"    long_name="global mean salt flux (thermo)"                         unit="1e-3*m/day" />
+
+         <field id="ibghfxdhc"    long_name="Heat content variation in snow and ice"                 unit="W"          />
+         <field id="ibghfxspr"    long_name="Heat content of snow precip"                            unit="W"          />
+
+         <field id="ibghfxthd"    long_name="heat fluxes from ice-ocean exchange during thermo"      unit="W"          />
+         <field id="ibghfxsum"    long_name="heat fluxes causing surface ice melt"                   unit="W"          />
+         <field id="ibghfxbom"    long_name="heat fluxes causing bottom ice melt"                    unit="W"          />
+         <field id="ibghfxbog"    long_name="heat fluxes causing bottom ice growth"                  unit="W"          />
+         <field id="ibghfxdif"    long_name="heat fluxes causing ice temperature change"             unit="W"          />
+         <field id="ibghfxopw"    long_name="heat fluxes causing open water ice formation"           unit="W"          />
+         <field id="ibghfxdyn"    long_name="heat fluxes from ice-ocean exchange during dynamic"     unit="W"          />
+         <field id="ibghfxres"    long_name="heat fluxes from ice-ocean exchange during resultant"   unit="W"          />
+         <field id="ibghfxsub"    long_name="heat fluxes from sublimation"                           unit="W"          />
+         <field id="ibghfxsnw"    long_name="heat fluxes from snow-ocean exchange"                   unit="W"          />
+         <field id="ibghfxout"    long_name="non solar heat fluxes received by the ocean"            unit="W"          />
+         <field id="ibghfxin"     long_name="total heat fluxes at the ice surface"                   unit="W"          />
+
+         <field id="ibgfrcvol"    long_name="global mean forcing volume (emp)"                       unit="km3"        />
+         <field id="ibgfrcsfx"    long_name="global mean forcing salt   (sfx)"                       unit="1e-3*km3"   />
+         <field id="ibgvolgrm"    long_name="global mean ice growth+melt volume"                     unit="km3"        />
+      </field_group>
+  
+      <!-- variables available with key_float -->
+
+      <field_group id="floatvar" domain_ref="1point" axis_ref="nfloat" operation="instant" >
+        <field id="traj_lon"      long_name="floats longitude"                                                           unit="degrees_east"  />
+        <field id="traj_lat"      long_name="floats latitude"                                                            unit="degrees_north" />
+        <field id="traj_dep"      long_name="floats depth"                                                               unit="m"             />
+        <field id="traj_temp"     long_name="floats temperature"       standard_name="sea_water_potential_temperature"   unit="degC"          />
+        <field id="traj_salt"     long_name="floats salinity"          standard_name="sea_water_practical_salinity"      unit="1e-3"          />
+        <field id="traj_dens"     long_name="floats in-situ density"   standard_name="sea_water_density"                 unit="kg/m3"         />
+        <field id="traj_group"    long_name="floats group"                                                               unit="1"             />
+      </field_group>
+
+      <!-- variables available with iceberg trajectories -->
+
+      <field_group id="icbvar" domain_ref="grid_T"  > 
+        <field id="berg_melt"          long_name="icb melt rate of icebergs"                       unit="kg/m2/s"                    />
+        <field id="berg_buoy_melt"     long_name="icb buoyancy component of iceberg melt rate"     unit="kg/m2/s"                    />
+        <field id="berg_eros_melt"     long_name="icb erosion component of iceberg melt rate"      unit="kg/m2/s"                    />
+        <field id="berg_conv_melt"     long_name="icb convective component of iceberg melt rate"   unit="kg/m2/s"                    />
+        <field id="berg_virtual_area"  long_name="icb virtual coverage by icebergs"                unit="m2"                         />
+        <field id="bits_src"           long_name="icb mass source of bergy bits"                   unit="kg/m2/s"                    />
+        <field id="bits_melt"          long_name="icb melt rate of bergy bits"                     unit="kg/m2/s"                    />
+        <field id="bits_mass"          long_name="icb bergy bit density field"                     unit="kg/m2"                      />
+        <field id="berg_mass"          long_name="icb iceberg density field"                       unit="kg/m2"                      />
+        <field id="calving"            long_name="icb calving mass input"                          unit="kg/s"                       />
+        <field id="berg_floating_melt" long_name="icb melt rate of icebergs + bits"                unit="kg/m2/s"                    />
+        <field id="berg_real_calving"  long_name="icb calving into iceberg class"                  unit="kg/s"     axis_ref="icbcla" />
+        <field id="berg_stored_ice"    long_name="icb accumulated ice mass by class"               unit="kg"       axis_ref="icbcla" />
+      </field_group>
+
+      <!-- Poleward transport : ptr -->     
+      <field_group id="diaptr" domain_ref="ptr" > 
+        <field id="zomsfglo"          long_name="Meridional Stream-Function: Global"           unit="Sv"       grid_ref="gznl_W_3D" />
+        <field id="zomsfatl"          long_name="Meridional Stream-Function: Atlantic"         unit="Sv"       grid_ref="gznl_W_3D" />
+        <field id="zomsfpac"          long_name="Meridional Stream-Function: Pacific"          unit="Sv"       grid_ref="gznl_W_3D" />
+        <field id="zomsfind"          long_name="Meridional Stream-Function: Indian"           unit="Sv"       grid_ref="gznl_W_3D" />
+        <field id="zomsfipc"          long_name="Meridional Stream-Function: Pacific+Indian"   unit="Sv"       grid_ref="gznl_W_3D" />
+        <field id="zotemglo"          long_name="Zonal Mean Temperature : Global"              unit="degC"     grid_ref="gznl_T_3D" />
+        <field id="zotematl"          long_name="Zonal Mean Temperature : Atlantic"            unit="degC"     grid_ref="gznl_T_3D" />
+        <field id="zotempac"          long_name="Zonal Mean Temperature : Pacific"             unit="degC"     grid_ref="gznl_T_3D" />
+        <field id="zotemind"          long_name="Zonal Mean Temperature : Indian"              unit="degC"     grid_ref="gznl_T_3D" />
+        <field id="zotemipc"          long_name="Zonal Mean Temperature : Pacific+Indian"      unit="degC"     grid_ref="gznl_T_3D" />
+        <field id="zosalglo"          long_name="Zonal Mean Salinity : Global"                 unit="1e-3"     grid_ref="gznl_T_3D" />
+        <field id="zosalatl"          long_name="Zonal Mean Salinity : Atlantic"               unit="1e-3"     grid_ref="gznl_T_3D" />
+        <field id="zosalpac"          long_name="Zonal Mean Salinity : Pacific"                unit="1e-3"     grid_ref="gznl_T_3D" />
+        <field id="zosalind"          long_name="Zonal Mean Salinity : Indian"                 unit="1e-3"     grid_ref="gznl_T_3D" />
+        <field id="zosalipc"          long_name="Zonal Mean Salinity : Pacific+Indian"         unit="1e-3"     grid_ref="gznl_T_3D" />
+        <field id="zosrfglo"          long_name="Zonal Mean Surface"                           unit="m2"       grid_ref="gznl_T_3D" />
+        <field id="zosrfatl"          long_name="Zonal Mean Surface : Atlantic"                unit="m2"       grid_ref="gznl_T_3D" />
+        <field id="zosrfpac"          long_name="Zonal Mean Surface : Pacific"                 unit="m2"       grid_ref="gznl_T_3D" />
+        <field id="zosrfind"          long_name="Zonal Mean Surface : Indian"                  unit="m2"       grid_ref="gznl_T_3D" />
+        <field id="zosrfipc"          long_name="Zonal Mean Surface : Pacific+Indian"          unit="m2"       grid_ref="gznl_T_3D" />
+        <field id="sophtadv"          long_name="Advective Heat Transport"                     unit="PW"       grid_ref="gznl_T_2D" />
+        <field id="sophtldf"          long_name="Diffusive Heat Transport"                     unit="PW"       grid_ref="gznl_T_2D" />
+        <field id="sopstadv"          long_name="Advective Salt Transport"                     unit="Giga g/s" grid_ref="gznl_T_2D" />
+        <field id="sopstldf"          long_name="Diffusive Salt Transport"                     unit="Giga g/s" grid_ref="gznl_T_2D" />
+      </field_group>
+
+    <!-- 
+============================================================================================================
+                  Physical ocean model trend diagnostics : temperature, KE, PE, momentum
+============================================================================================================
+    -->
+
+    <field_group id="trendT" grid_ref="grid_T_3D">
+      <!-- variables available with ln_tra_trd -->
+      <field id="ttrd_xad"      long_name="temperature-trend: i-advection"                                                                                          unit="degC/s"                        />
+      <field id="strd_xad"      long_name="salinity   -trend: i-advection"                                                                                          unit="1e-3/s"                        />
+      <field id="ttrd_yad"      long_name="temperature-trend: j-advection"                                                                                          unit="degC/s"                        />
+      <field id="strd_yad"      long_name="salinity   -trend: j-advection"                                                                                          unit="1e-3/s"                        />
+      <field id="ttrd_zad"      long_name="temperature-trend: k-advection"                                                                                          unit="degC/s"                        />
+      <field id="strd_zad"      long_name="salinity   -trend: k-advection"                                                                                          unit="1e-3/s"                        />
+      <field id="ttrd_ad"       long_name="temperature-trend: advection"               standard_name="tendency_of_sea_water_temperature_due_to_advection"           unit="degC/s"                         > sqrt( ttrd_xad^2 + ttrd_yad^2 + ttrd_zad^2 ) </field>
+      <field id="strd_ad"       long_name="salinity   -trend: advection"               standard_name="tendency_of_sea_water_salinity_due_to_advection"              unit="1e-3/s"                         > sqrt( strd_xad^2 + strd_yad^2 + strd_zad^2 ) </field>
+      <field id="ttrd_sad"      long_name="temperature-trend: surface adv. (no-vvl)"                                                                                unit="degC/s"   grid_ref="grid_T_2D" />
+      <field id="strd_sad"      long_name="salinity   -trend: surface adv. (no-vvl)"                                                                                unit="1e-3/s"   grid_ref="grid_T_2D" />
+      <field id="ttrd_ldf"      long_name="temperature-trend: lateral  diffusion"      standard_name="tendency_of_sea_water_temperature_due_to_horizontal_mixing"   unit="degC/s"                        />
+      <field id="strd_ldf"      long_name="salinity   -trend: lateral  diffusion"      standard_name="tendency_of_sea_water_salinity_due_to_horizontal_mixing"      unit="1e-3/s"                        />
+      <field id="ttrd_zdf"      long_name="temperature-trend: vertical diffusion"      standard_name="tendency_of_sea_water_temperature_due_to_vertical_mixing"     unit="degC/s"                        />
+      <field id="strd_zdf"      long_name="salinity   -trend: vertical diffusion"      standard_name="tendency_of_sea_water_salinity_due_to_vertical_mixing"        unit="1e-3/s"                        />
+
+      <!-- ln_traldf_iso=T only (iso-neutral diffusion) -->
+      <field id="ttrd_zdfp"     long_name="temperature-trend: pure vert. diffusion"   unit="degC/s" />
+      <field id="strd_zdfp"     long_name="salinity   -trend: pure vert. diffusion"   unit="1e-3/s" />
+
+      <!-- -->
+      <field id="ttrd_dmp"      long_name="temperature-trend: interior restoring"        unit="degC/s" />
+      <field id="strd_dmp"      long_name="salinity   -trend: interior restoring"        unit="1e-3/s" />
+      <field id="ttrd_bbl"      long_name="temperature-trend: bottom boundary layer"     unit="degC/s" />
+      <field id="strd_bbl"      long_name="salinity   -trend: bottom boundary layer"     unit="1e-3/s" />
+      <field id="ttrd_npc"      long_name="temperature-trend: non-penetrative conv."     unit="degC/s" />
+      <field id="strd_npc"      long_name="salinity   -trend: non-penetrative conv."     unit="1e-3/s" />
+      <field id="ttrd_qns"      long_name="temperature-trend: non-solar flux + runoff"   unit="degC/s" />
+      <field id="strd_cdt"      long_name="salinity   -trend: C/D term       + runoff"   unit="degC/s" />
+      <field id="ttrd_qsr"      long_name="temperature-trend: solar penetr. heating"     unit="degC/s" />
+      <field id="ttrd_bbc"      long_name="temperature-trend: geothermal heating"        unit="degC/s" />
+      <field id="ttrd_atf"      long_name="temperature-trend: asselin time filter"       unit="degC/s" />
+      <field id="strd_atf"      long_name="salinity   -trend: asselin time filter"       unit="1e-3/s" />
+
+      <!-- variables available with ln_KE_trd -->
+      <field id="ketrd_hpg"     long_name="ke-trend: hydrostatic pressure gradient"          unit="W/s^3"                        />
+      <field id="ketrd_spg"     long_name="ke-trend: surface     pressure gradient"          unit="W/s^3"                        />
+      <field id="ketrd_spgexp"  long_name="ke-trend: surface pressure gradient (explicit)"   unit="W/s^3"                        />
+      <field id="ketrd_spgflt"  long_name="ke-trend: surface pressure gradient (filter)"     unit="W/s^3"                        />
+      <field id="ssh_flt"       long_name="filtered contribution to ssh (dynspg_flt)"        unit="m"       grid_ref="grid_T_2D" />
+      <field id="w0"            long_name="surface vertical velocity"                        unit="m/s"     grid_ref="grid_T_2D" />
+      <field id="pw0_exp"       long_name="surface pressure flux due to ssh"                 unit="W/s^2"   grid_ref="grid_T_2D" />
+      <field id="pw0_flt"       long_name="surface pressure flux due to filtered ssh"        unit="W/s^2"   grid_ref="grid_T_2D" />
+      <field id="ketrd_keg"     long_name="ke-trend: KE gradient         or hor. adv."       unit="W/s^3"                        />
+      <field id="ketrd_rvo"     long_name="ke-trend: relative  vorticity or metric term"     unit="W/s^3"                        />
+      <field id="ketrd_pvo"     long_name="ke-trend: planetary vorticity"                    unit="W/s^3"                        />
+      <field id="ketrd_zad"     long_name="ke-trend: vertical  advection"                    unit="W/s^3"                        />
+      <field id="ketrd_udx"     long_name="ke-trend: U.dx[U]"                                unit="W/s^3"                        />
+      <field id="ketrd_ldf"     long_name="ke-trend: lateral   diffusion"                    unit="W/s^3"                        />
+      <field id="ketrd_zdf"     long_name="ke-trend: vertical  diffusion"                    unit="W/s^3"                        />
+      <field id="ketrd_tau"     long_name="ke-trend: wind stress "                           unit="W/s^3"   grid_ref="grid_T_2D" />
+      <field id="ketrd_bfr"     long_name="ke-trend: bottom friction (explicit)"             unit="W/s^3"                        />   
+      <field id="ketrd_bfri"    long_name="ke-trend: bottom friction (implicit)"             unit="W/s^3"                        />   
+      <field id="ketrd_atf"     long_name="ke-trend: asselin time filter trend"              unit="W/s^3"                        />  
+      <field id="ketrd_convP2K" long_name="ke-trend: conversion (potential to kinetic)"      unit="W/s^3"                        />
+      <field id="KE"            long_name="kinetic energy: u(n)*u(n+1)/2"                    unit="W/s^2"                        />   
+
+      <!-- variables available with ln_PE_trd -->
+      <field id="petrd_xad"     long_name="pe-trend: i-advection"                unit="W/m^3"                        />
+      <field id="petrd_yad"     long_name="pe-trend: j-advection"                unit="W/m^3"                        />
+      <field id="petrd_zad"     long_name="pe-trend: k-advection"                unit="W/m^3"                        />
+      <field id="petrd_sad"     long_name="pe-trend: surface adv. (no-vvl)"      unit="W/m^3"   grid_ref="grid_T_2D" />
+      <field id="petrd_ldf"     long_name="pe-trend: lateral  diffusion"         unit="W/m^3"                        />
+      <field id="petrd_zdf"     long_name="pe-trend: vertical diffusion"         unit="W/m^3"                        />
+      <field id="petrd_zdfp"    long_name="pe-trend: pure vert. diffusion"       unit="W/m^3"                        />
+      <field id="petrd_dmp"     long_name="pe-trend: interior restoring"         unit="W/m^3"                        />
+      <field id="petrd_bbl"     long_name="pe-trend: bottom boundary layer"      unit="W/m^3"                        />
+      <field id="petrd_npc"     long_name="pe-trend: non-penetrative conv."      unit="W/m^3"                        />
+      <field id="petrd_nsr"     long_name="pe-trend: surface forcing + runoff"   unit="W/m^3"                        />
+      <field id="petrd_qsr"     long_name="pe-trend: solar penetr. heating"      unit="W/m^3"                        />
+      <field id="petrd_bbc"     long_name="pe-trend: geothermal heating"         unit="W/m^3"                        />
+      <field id="petrd_atf"     long_name="pe-trend: asselin time filter"        unit="W/m^3"                        />
+      <field id="PEanom"        long_name="potential energy anomaly"             unit="1"                            />   
+      <field id="alphaPE"       long_name="partial deriv. of PEanom wrt T"       unit="degC-1"                       />   
+      <field id="betaPE"        long_name="partial deriv. of PEanom wrt S"       unit="1e3"                          />   
+    </field_group>
+
+    <field_group id="trendU" grid_ref="grid_U_3D">
+     <!-- variables available with ln_dyn_trd -->
+     <field id="utrd_hpg"       long_name="i-trend: hydrostatic pressure gradient"          unit="m/s^2"                        />
+     <field id="utrd_spg"       long_name="i-trend: surface     pressure gradient"          unit="m/s^2"                        />
+     <field id="utrd_spgexp"    long_name="i-trend: surface pressure gradient (explicit)"   unit="m/s^2"                        />
+     <field id="utrd_spgflt"    long_name="i-trend: surface pressure gradient (filtered)"   unit="m/s^2"                        />
+     <field id="utrd_keg"       long_name="i-trend: KE gradient         or hor. adv."       unit="m/s^2"                        />
+     <field id="utrd_rvo"       long_name="i-trend: relative  vorticity or metric term"     unit="m/s^2"                        />
+     <field id="utrd_pvo"       long_name="i-trend: planetary vorticity"                    unit="m/s^2"                        />
+     <field id="utrd_zad"       long_name="i-trend: vertical  advection"                    unit="m/s^2"                        />
+     <field id="utrd_udx"       long_name="i-trend: U.dx[U]"                                unit="m/s^2"                        />
+     <field id="utrd_ldf"       long_name="i-trend: lateral   diffusion"                    unit="m/s^2"                        />
+     <field id="utrd_zdf"       long_name="i-trend: vertical  diffusion"                    unit="m/s^2"                        />
+     <field id="utrd_tau"       long_name="i-trend: wind stress "                           unit="m/s^2"   grid_ref="grid_U_2D" />
+     <field id="utrd_bfr"       long_name="i-trend: bottom friction (explicit)"             unit="m/s^2"                        />   
+     <field id="utrd_bfri"      long_name="i-trend: bottom friction (implicit)"             unit="m/s^2"                        />   
+     <field id="utrd_tot"       long_name="i-trend: total momentum trend before atf"        unit="m/s^2"                        />   
+     <field id="utrd_atf"       long_name="i-trend: asselin time filter trend"              unit="m/s^2"                        />   
+    </field_group>
+
+    <field_group id="trendV" grid_ref="grid_V_3D">
+     <!-- variables available with ln_dyn_trd -->
+     <field id="vtrd_hpg"       long_name="j-trend: hydrostatic pressure gradient"          unit="m/s^2"                        />
+     <field id="vtrd_spg"       long_name="j-trend: surface     pressure gradient"          unit="m/s^2"                        />
+     <field id="vtrd_spgexp"    long_name="j-trend: surface pressure gradient (explicit)"   unit="m/s^2"                        />
+     <field id="vtrd_spgflt"    long_name="j-trend: surface pressure gradient (filtered)"   unit="m/s^2"                        />
+     <field id="vtrd_keg"       long_name="j-trend: KE gradient         or hor. adv."       unit="m/s^2"                        />
+     <field id="vtrd_rvo"       long_name="j-trend: relative  vorticity or metric term"     unit="m/s^2"                        />
+     <field id="vtrd_pvo"       long_name="j-trend: planetary vorticity"                    unit="m/s^2"                        />
+     <field id="vtrd_zad"       long_name="j-trend: vertical  advection"                    unit="m/s^2"                        />
+     <field id="vtrd_vdy"       long_name="i-trend: V.dx[V]"                                unit="m/s^2"                        />
+     <field id="vtrd_ldf"       long_name="j-trend: lateral   diffusion"                    unit="m/s^2"                        />
+     <field id="vtrd_zdf"       long_name="j-trend: vertical  diffusion"                    unit="m/s^2"                        />
+     <field id="vtrd_tau"       long_name="j-trend: wind stress "                           unit="m/s^2"   grid_ref="grid_V_2D" />
+     <field id="vtrd_bfr"       long_name="j-trend: bottom friction (explicit)"             unit="m/s^2"                        />   
+     <field id="vtrd_bfri"      long_name="j-trend: bottom friction (implicit)"             unit="m/s^2"                        />   
+     <field id="vtrd_tot"       long_name="j-trend: total momentum trend before atf"        unit="m/s^2"                        />   
+     <field id="vtrd_atf"       long_name="j-trend: asselin time filter trend"              unit="m/s^2"                        />   
+    </field_group>
+
+    <!-- 
+============================================================================================================
+                                     Biogeochemistry model variables
+============================================================================================================
+    -->
+
+      <!-- ptrc on T grid -->
+
+     <field_group id="ptrc_T" grid_ref="grid_T_3D">
+       <field id="DIC"          long_name="Dissolved inorganic Concentration"        unit="mmol/m3" />
+       <field id="DIC_E3T"      long_name="DIC * E3T"                                unit="mmol/m2" > DIC * e3t </field >
+       <field id="Alkalini"     long_name="Total Alkalinity Concentration"           unit="mmol/m3" />
+       <field id="Alkalini_E3T" long_name="Alkalini * E3T"                           unit="mmol/m2"  > Alkalini * e3t </field >
+       <field id="O2"           long_name="Oxygen Concentration"                     unit="mmol/m3" />
+       <field id="O2_E3T"       long_name="O2 * E3T"                                 unit="mmol/m2"  > O2 * e3t </field >
+       <field id="CaCO3"        long_name="Calcite Concentration"                    unit="mmol/m3" />
+       <field id="CaCO3_E3T"    long_name="CaCO3 * E3T"                              unit="mmol/m2"  > CaCO3 * e3t </field >
+       <field id="PO4"          long_name="Phosphate Concentration"                  unit="mmol/m3" />
+       <field id="PO4_E3T"      long_name="PO4 * E3T"                                unit="mmol/m2"  > PO4 * e3t </field >
+       <field id="POC"          long_name="Small organic carbon Concentration"       unit="mmol/m3" />
+       <field id="POC_E3T"      long_name="POC * E3T"                                unit="mmol/m2"  > POC * e3t </field >
+       <field id="Si"           long_name="Silicate Concentration"                   unit="mmol/m3" />
+       <field id="Si_E3T"       long_name="Si * E3T"                                 unit="mmol/m2"  > Si * e3t </field >
+       <field id="PHY"          long_name="(Nano)Phytoplankton Concentration"        unit="mmol/m3" />
+       <field id="PHY_E3T"      long_name="PHY * E3T"                                unit="mmol/m2"  > PHY * e3t </field >
+       <field id="ZOO"          long_name="(Micro)Zooplankton Concentration"         unit="mmol/m3" />
+       <field id="ZOO_E3T"      long_name="ZOO2 * E3T"                               unit="mmol/m2"  > ZOO * e3t </field >
+       <field id="DOC"          long_name="Dissolved organic Concentration"          unit="mmol/m3" />
+       <field id="DOC_E3T"      long_name="DOC * E3T"                                unit="mmol/m2"  > DOC * e3t </field >
+       <field id="PHY2"         long_name="Diatoms Concentration"                    unit="mmol/m3" />
+       <field id="PHY2_E3T"     long_name="PHY2 * E3T"                               unit="mmol/m2"  > PHY2 * e3t </field >
+       <field id="ZOO2"         long_name="Mesozooplankton Concentration"            unit="mmol/m3" />
+       <field id="ZOO2_E3T"     long_name="ZOO2 * E3T"                               unit="mmol/m2"  > ZOO2 * e3t </field >
+       <field id="DSi"          long_name="Diatoms Silicate Concentration"           unit="mmol/m3" />
+       <field id="DSi_E3T"      long_name="Dsi * E3T"                                unit="mmol/m2"  > DSi * e3t </field >
+       <field id="Fer"          long_name="Dissolved Iron Concentration"             unit="mmol/m3" />
+       <field id="Fer_E3T"      long_name="Fer * E3T"                                unit="mmol/m2"  > Fer * e3t </field >
+       <field id="BFe"          long_name="Big iron particles Concentration"         unit="mmol/m3" />
+       <field id="BFe_E3T"      long_name="BFe * E3T"                                unit="mmol/m2"  > BFe * e3t </field >
+       <field id="GOC"          long_name="Big organic carbon Concentration"         unit="mmol/m3" />
+       <field id="GOC_E3T"      long_name="GOC * E3T"                                unit="mmol/m2"  > GOC * e3t </field >
+       <field id="SFe"          long_name="Small iron particles Concentration"       unit="mmol/m3" />
+       <field id="SFe_E3T"      long_name="SFe * E3T"                                unit="mmol/m2"  > SFe * e3t </field >
+       <field id="DFe"          long_name="Diatoms iron  Concentration"              unit="mmol/m3" />
+       <field id="DFe_E3T"      long_name="DFe * E3T"                                unit="mmol/m2"  > DFe * e3t </field >
+       <field id="GSi"          long_name="Sinking biogenic Silicate Concentration"  unit="mmol/m3" />
+       <field id="GSi_E3T"      long_name="GSi * E3T"                                unit="mmol/m2"  > GSi * e3t </field >
+       <field id="NFe"          long_name="Nano iron Concentration"                  unit="mmol/m3" />
+       <field id="NFe_E3T"      long_name="NFe * E3T"                                unit="mmol/m2"  > NFe * e3t </field >
+       <field id="NCHL"         long_name="Nano chlorophyl Concentration"            unit="mg/m3"   />
+       <field id="NCHL_E3T"     long_name="NCHL * E3T"                               unit="mmol/m2"  > NCHL * e3t </field >
+       <field id="DCHL"         long_name="Diatoms chlorophyl Concentration"         unit="mg/m3"   />
+       <field id="DCHL_E3T"     long_name="DCHL * E3T"                               unit="mmol/m2"  > DCHL * e3t </field >
+       <field id="NO3"          long_name="Nitrate Concentration"                    unit="mmol/m3" />
+       <field id="NO3_E3T"      long_name="NO3 * E3T"                                unit="mmol/m2"  > NO3 * e3t </field >
+       <field id="NH4"          long_name="Ammonium Concentration"                   unit="mmol/m3" />
+       <field id="NH4_E3T"      long_name="NH4 * E3T"                                unit="mmol/m2"  > NH4 * e3t </field >
+
+       <!-- PISCES with Kriest parametisation : variables available with key_kriest -->
+       <field id="Num"         long_name="Number of organic particles"              unit="1" />
+       <field id="Num_E3T"     long_name="Num * E3T"                                unit="m"  > Num * e3t </field >
+
+       <!-- PISCES light : variables available with key_pisces_reduced -->
+       <field id="DET"         long_name="Detritus"                                 unit="mmol-N/m3" />
+       <field id="DET_E3T"     long_name="DET * E3T"                                unit="mmol-N/m2"  > DET * e3t </field >
+       <field id="DOM"         long_name="Dissolved Organic Matter"                 unit="mmol-N/m3" />
+       <field id="DOM_E3T"     long_name="DOM * E3T"                                unit="mmol-N/m2"  > DOM * e3t </field >
+
+       <!-- CFC11 : variables available with key_cfc -->
+       <field id="CFC11"       long_name="CFC-11 Concentration"                     unit="umol/m3" />
+       <field id="CFC11_E3T"   long_name="CFC11 * E3T"                              unit="umol/m2"  > CFC11 * e3t </field >
+       <!-- Bomb C14 : variables available with key_c14b -->
+       <field id="C14B"     long_name="Bomb C14 Concentration"                      unit="1"         />
+       <field id="C14B_E3T"    long_name="C14B * E3T"                               unit="m"  > C14B * e3t </field >
+     </field_group>
+
+     <!-- PISCES additional diagnostics on T grid  -->
+
+     <field_group id="diad_T" grid_ref="grid_T_2D">
+       <field id="PH"          long_name="PH"                                      unit="1"          grid_ref="grid_T_3D" />
+       <field id="CO3"         long_name="Bicarbonates"                            unit="mol/m3"     grid_ref="grid_T_3D" />
+       <field id="CO3sat"      long_name="CO3 saturation"                          unit="mol/m3"     grid_ref="grid_T_3D" />
+       <field id="PAR"         long_name="Photosynthetically Available Radiation"  unit="W/m2"       grid_ref="grid_T_3D" />
+       <field id="PARDM"       long_name="Daily mean PAR"                          unit="W/m2"       grid_ref="grid_T_3D" />
+       <field id="PPPHY"       long_name="Primary production of nanophyto"         unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="PPPHY2"      long_name="Primary production of diatoms"           unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="PPNEWN"      long_name="New Primary production of nanophyto"     unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="PPNEWD"      long_name="New Primary production of diatoms"       unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="PBSi"        long_name="Primary production of Si diatoms"        unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="PFeN"        long_name="Primary production of nano iron"         unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="PFeD"        long_name="Primary production of diatoms iron"      unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="xfracal"     long_name="Calcifying fraction"                     unit="1"          grid_ref="grid_T_3D" />
+       <field id="PCAL"        long_name="Calcite production"                      unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="DCAL"        long_name="Calcite dissolution"                     unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="GRAZ1"       long_name="Grazing by microzooplankton"             unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="GRAZ2"       long_name="Grazing by mesozooplankton"              unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="REMIN"       long_name="Oxic remineralization of OM"             unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="DENIT"       long_name="Anoxic remineralization of OM"           unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="Nfix"        long_name="Nitrogen fixation"                       unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="Mumax"       long_name="Maximum growth rate"                     unit="s-1"        grid_ref="grid_T_3D" />
+       <field id="MuN"         long_name="Realized growth rate for nanophyto"      unit="s-1"        grid_ref="grid_T_3D" />
+       <field id="MuD"         long_name="Realized growth rate for diatomes"       unit="s-1"        grid_ref="grid_T_3D" />
+       <field id="LNnut"       long_name="Nutrient limitation term in Nanophyto"   unit=""           grid_ref="grid_T_3D" />
+       <field id="LDnut"       long_name="Nutrient limitation term in Diatoms"     unit=""           grid_ref="grid_T_3D" />
+       <field id="LNFe"        long_name="Iron limitation term in Nanophyto"       unit=""           grid_ref="grid_T_3D" />
+       <field id="LDFe"        long_name="Iron limitation term in Diatoms"         unit=""           grid_ref="grid_T_3D" />
+       <field id="LNlight"     long_name="Light limitation term in Nanophyto"      unit=""           grid_ref="grid_T_3D" />
+       <field id="LDlight"     long_name="Light limitation term in Diatoms"        unit=""           grid_ref="grid_T_3D" />
+       <field id="Fe2"         long_name="Iron II concentration"                   unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="Fe3"         long_name="Iron III concentration"                  unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="FeL1"        long_name="Complexed Iron concentration with L1"    unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="FeL2"        long_name="Complexed Iron concentration with L2"    unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="FeP"         long_name="Precipitated Iron III"                   unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="TL1"         long_name="Total L1 concentration"                  unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="TL2"         long_name="Total L2 concentration"                  unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="pdust"       long_name="dust concentration"                      unit="g/m3"                            />
+       <field id="Totlig"      long_name="Total ligand concentation"               unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="Biron"       long_name="Bioavailable iron"                       unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="Sdenit"      long_name="Nitrate reduction in the sediments"      unit="mol/m2/s"                        />
+       <field id="Ironice"     long_name="Iron input/uptake due to sea ice"        unit="mol/m2/s"                        />
+       <field id="HYDR"        long_name="Iron input from hydrothemal vents"       unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="EPC100"      long_name="Export of carbon particles at 100 m"     unit="mol/m2/s"                        />
+       <field id="EPFE100"     long_name="Export of biogenic iron at 100 m"        unit="mol/m2/s"                        />
+       <field id="EPSI100"     long_name="Export of Silicate at 100 m"             unit="mol/m2/s"                        />
+       <field id="EPCAL100"    long_name="Export of Calcite at 100 m"              unit="mol/m2/s"                        />
+       <field id="EXPC"        long_name="Export of carbon"                        unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="EXPFE"       long_name="Export of biogenic iron"                 unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="EXPSI"       long_name="Export of Silicate"                      unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="EXPCAL"      long_name="Export of Calcite"                       unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="Cflx"        long_name="DIC flux"                                unit="mol/m2/s"                        />
+       <field id="Oflx"        long_name="Oxygen flux"                             unit="mol/m2/s"                        />
+       <field id="Kg"          long_name="Gas transfer"                            unit="mol/m2/s/uatm"                   />
+       <field id="Dpco2"       long_name="Delta CO2"                               unit="uatm"                            />
+       <field id="Dpo2"        long_name="Delta O2"                                unit="uatm"                            />
+       <field id="Heup"        long_name="Euphotic layer depth"                    unit="m"                               />
+       <field id="Irondep"     long_name="Iron deposition from dust"               unit="mol/m2/s"                        />
+       <field id="Ironsed"     long_name="Iron deposition from sediment"           unit="mol/m2/s"   grid_ref="grid_T_3D" />
+
+
+       <!-- PISCES with Kriest parametisation : variables available with key_kriest -->
+       <field id="EPN100"      long_name="Particulate number flux at 100 m"        unit="mol/m2/s"                        />
+       <field id="EXPN"        long_name="Particulate number flux"                 unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="XNUM"        long_name="Number of particles in aggregats"        unit="1"          grid_ref="grid_T_3D" />
+       <field id="WSC"         long_name="sinking speed of mass flux"              unit="m2/s"       grid_ref="grid_T_3D" />
+       <field id="WSN"         long_name="sinking speed of number flux"            unit="m2/s"       grid_ref="grid_T_3D" />
+
+       <!-- dbio_T on T grid : variables available with key_diaar5 -->
+       <field id="TPP"         long_name="Total Primary production of phyto"                   unit="mol/m3/s"  grid_ref="grid_T_3D" />
+       <field id="TPNEW"       long_name="New Primary production of phyto"                     unit="mol/m3/s"  grid_ref="grid_T_3D" />
+       <field id="TPBFE"       long_name="Total biogenic iron production"                      unit="mol/m3/s"  grid_ref="grid_T_3D" />
+       <field id="INTDIC"      long_name="DIC content"                                         unit="kg/m2"                          />
+       <field id="O2MIN"       long_name="Oxygen minimum concentration"                        unit="mol/m3"                          />
+       <field id="ZO2MIN"      long_name="Depth of oxygen minimum concentration"               unit="m"                              />
+       <field id="INTNFIX"     long_name="Nitrogen fixation rate : vert. integrated"           unit="mol/m2/s"                       />
+       <field id="INTPPPHY"    long_name="Vertically integrated primary production by nanophy" unit="mol/m2/s"                       />
+       <field id="INTPPPHY2"   long_name="Vertically integrated primary production by diatom"  unit="mol/m2/s"                       />
+       <field id="INTPP"       long_name="Vertically integrated primary production by phyto"   unit="mol/m2/s"                       />
+       <field id="INTPNEW"     long_name="Vertically integrated new primary production"        unit="mol/m2/s"                       />
+       <field id="INTPBFE"     long_name="Vertically integrated of biogenic iron production"   unit="mol/m2/s"                       />
+       <field id="INTPBSI"     long_name="Vertically integrated of biogenic Si production"     unit="mol/m2/s"                       />
+       <field id="INTPCAL"     long_name="Vertically integrated of calcite production"         unit="mol/m2/s"                       />
+
+       <!-- PISCES light : variables available with key_pisces_reduced -->
+       <field id="FNO3PHY"     long_name="FNO3PHY"                                 unit=""          grid_ref="grid_T_3D" /> 
+       <field id="FNH4PHY"     long_name="FNH4PHY"                                 unit=""          grid_ref="grid_T_3D" /> 
+       <field id="FNH4NO3"     long_name="FNH4NO3"                                 unit=""          grid_ref="grid_T_3D" /> 
+       <field id="TNO3PHY"     long_name="TNO3PHY"                                 unit=""  /> 
+       <field id="TNH4PHY"     long_name="TNH4PHY"                                 unit=""  /> 
+       <field id="TPHYDOM"     long_name="TPHYDOM"                                 unit=""  /> 
+       <field id="TPHYNH4"     long_name="TPHYNH4"                                 unit=""  /> 
+       <field id="TPHYZOO"     long_name="TPHYZOO"                                 unit=""  /> 
+       <field id="TPHYDET"     long_name="TPHYDET"                                 unit=""  /> 
+       <field id="TDETZOO"     long_name="TDETZOO"                                 unit=""  /> 
+       <field id="TZOODET"     long_name="TZOODET"                                 unit=""  /> 
+       <field id="TZOOBOD"     long_name="TZOOBOD"                                 unit=""  /> 
+       <field id="TZOONH4"     long_name="TZOONH4"                                 unit=""  /> 
+       <field id="TZOODOM"     long_name="TZOODOM"                                 unit=""  /> 
+       <field id="TNH4NO3"     long_name="TNH4NO3"                                 unit=""  /> 
+       <field id="TDOMNH4"     long_name="TDOMNH4"                                 unit=""  /> 
+       <field id="TDETNH4"     long_name="TDETNH4"                                 unit=""  /> 
+       <field id="TPHYTOT"     long_name="TPHYTOT"                                 unit=""  /> 
+       <field id="TZOOTOT"     long_name="TZOOTOT"                                 unit=""  /> 
+       <field id="SEDPOC"      long_name="SEDPOC"                                  unit=""  /> 
+       <field id="TDETSED"     long_name="TDETSED"                                 unit=""  /> 
+
+       <!-- CFC11 : variables available with key_cfc -->
+       <field id="qtrCFC11"    long_name="Air-sea flux of CFC-11"                  unit="mol/m2/s"   />
+       <field id="qintCFC11"   long_name="Cumulative air-sea flux of CFC-11"       unit="mol/m2"     />
+
+       <!-- Bomb C14 : variables available with key_c14b -->
+       <field id="qtrC14b"     long_name="Air-sea flux of Bomb C14"                unit="mol/m2/s"   />
+       <field id="qintC14b"    long_name="Cumulative air-sea flux of Bomb C14"     unit="mol/m2"     />
+       <field id="fdecay"      long_name="Radiactive decay of Bomb C14"            unit="mol/m3"  grid_ref="grid_T_3D"  />
+     </field_group>
+
+     <field_group id="PISCES_scalar"  domain_ref="1point" >
+       <field id="pno3tot"         long_name="global mean nitrate concentration"                  unit="mol/m3"   />
+       <field id="ppo4tot"         long_name="global mean phosphorus concentration"               unit="mol/m3"   />
+       <field id="psiltot"         long_name="global mean silicate concentration"                 unit="mol/m3"   />
+       <field id="palktot"         long_name="global mean alkalinity concentration"               unit="mol/m3"   />
+       <field id="pfertot"         long_name="global mean iron concentration"                     unit="mol/m3"   />
+       <field id="tcflx"           long_name="total Flux of Carbon out of the ocean"              unit="mol/s"   />
+       <field id="tcflxcum"        long_name="cumulative total Flux of Carbon out of the ocean"   unit="mol/s"   />
+       <field id="tcexp"           long_name="total Carbon export at 100m"                        unit="mol/s"   />
+       <field id="tintpp"          long_name="global total integrated primary production"         unit="mol/s"   />
+       <field id="tnfix"           long_name="global total nitrogen fixation"                     unit="mol/s"   />
+       <field id="tdenit"          long_name="Total denitrification"                              unit="mol/s"   />
+     </field_group>
+
+    <!-- 
+============================================================================================================
+                                        Definitions for iodef_demo.xml
+============================================================================================================
+    -->
+
+    <field_group id="mooring" >
+      <field field_ref="toce"         name="thetao"   long_name="sea_water_potential_temperature"      />
+      <field field_ref="soce"         name="so"       long_name="sea_water_salinity"                   />
+      <field field_ref="uoce"         name="uo"       long_name="sea_water_x_velocity"                 />
+      <field field_ref="voce"         name="vo"       long_name="sea_water_y_velocity"                 />
+      <field field_ref="woce"         name="wo"       long_name="sea_water_z_velocity"                 />
+      <field field_ref="avt"          name="difvho"   long_name="ocean_vertical_heat_diffusivity"      />
+      <field field_ref="avm"          name="difvmo"   long_name="ocean_vertical_momentum_diffusivity"  />
+   
+      <field field_ref="sst"          name="tos"      long_name="sea_surface_temperature"                       />
+      <field field_ref="sst2"         name="tossq"    long_name="square_of_sea_surface_temperature"             />
+      <field field_ref="sstgrad"      name="tosgrad"  long_name="module_of_sea_surface_temperature_gradient"    />
+      <field field_ref="sss"          name="sos"      long_name="sea_surface_salinity"                          />
+      <field field_ref="ssh"          name="zos"      long_name="sea_surface_height_above_geoid"                />
+      <field field_ref="empmr"        name="wfo"      long_name="water_flux_into_sea_water"                     />
+      <field field_ref="qsr"          name="rsntds"   long_name="surface_net_downward_shortwave_flux"           />
+      <field field_ref="qt"           name="tohfls"   long_name="surface_net_downward_total_heat_flux"          />
+      <field field_ref="taum"                                                                                   />
+      <field field_ref="20d"                                                                                    />
+      <field field_ref="mldkz5"                                                                                 />
+      <field field_ref="mldr10_1"                                                                               />
+      <field field_ref="mldr10_3"                                                                               />
+      <field field_ref="mldr0_1"                                                                                />
+      <field field_ref="mldr0_3"                                                                                />
+      <field field_ref="mld_dt02"                                                                               />
+      <field field_ref="topthdep"                                                                               />
+      <field field_ref="pycndep"                                                                                />
+      <field field_ref="tinv"                                                                                   />
+      <field field_ref="depti"                                                                                  />
+      <field field_ref="BLT"          name="blt"      long_name="barrier_layer_thickness"                       />
+      <field field_ref="utau"         name="tauuo"    long_name="surface_downward_x_stress"                     />
+      <field field_ref="vtau"         name="tauvo"    long_name="surface_downward_y_stress"                     />
+    </field_group>
+
+    <field_group id="groupT" >
+      <field field_ref="toce"         name="thetao"   long_name="sea_water_potential_temperature"               />
+      <field field_ref="soce"         name="so"       long_name="sea_water_salinity"                            />
+      <field field_ref="sst"          name="tos"      long_name="sea_surface_temperature"                       />
+      <field field_ref="sst2"         name="tossq"    long_name="square_of_sea_surface_temperature"             />
+      <field field_ref="sss"          name="sos"      long_name="sea_surface_salinity"                          />
+      <field field_ref="ssh"          name="zos"      long_name="sea_surface_height_above_geoid"                />
+      <field field_ref="empmr"        name="wfo"      long_name="water_flux_into_sea_water"                     />
+      <field field_ref="qsr"          name="rsntds"   long_name="surface_net_downward_shortwave_flux"           />
+      <field field_ref="qt"           name="tohfls"   long_name="surface_net_downward_total_heat_flux"          />
+      <field field_ref="taum"                                                                                   />
+      <field field_ref="20d"                                                                                    />
+      <field field_ref="mldkz5"                                                                                 />
+      <field field_ref="mldr10_1"                                                                               />
+      <field field_ref="mldr10_3"                                                                               />
+      <field field_ref="mld_dt02"                                                                               />
+      <field field_ref="topthdep"                                                                               />
+      <field field_ref="pycndep"                                                                                />
+      <field field_ref="tinv"                                                                                   />
+      <field field_ref="depti"                                                                                  />
+      <field field_ref="BLT"          name="blt"      long_name="Barrier Layer Thickness"                       />
+    </field_group>
+    
+    <field_group id="groupU" >
+      <field field_ref="uoce"         name="uo"      long_name="sea_water_x_velocity"      />
+      <field field_ref="ssu"          name="uos"     long_name="sea_surface_x_velocity"    />
+      <field field_ref="utau"         name="tauuo"   long_name="surface_downward_x_stress" />
+    </field_group>
+    
+    <field_group id="groupV" >
+      <field field_ref="voce"         name="vo"      long_name="sea_water_y_velocity"      />
+      <field field_ref="ssv"          name="vos"     long_name="sea_surface_y_velocity"    />
+      <field field_ref="vtau"         name="tauvo"   long_name="surface_downward_y_stress" />
+    </field_group>
+    
+    <field_group id="groupW" >
+      <field field_ref="woce"         name="wo"       long_name="ocean vertical velocity"  />
+    </field_group>
+
+       <!-- TMB diagnostic output -->
+    <field_group  id="1h_grid_T_tmb" grid_ref="grid_T_2D" operation="instant">
+     <field id="top_temp"           name="votemper_top"  unit="degC"  />
+     <field id="mid_temp"           name="votemper_mid"  unit="degC"  />
+     <field id="bot_temp"           name="votemper_bot"  unit="degC"  />
+     <field id="top_sal"            name="vosaline_top"  unit="psu"   />
+     <field id="mid_sal"            name="vosaline_mid"  unit="psu"   />
+     <field id="bot_sal"            name="vosaline_bot"  unit="psu"   />
+     <field id="sshnmasked"         name="sossheig"      unit="m"     /> 
+   </field_group>
+    <field_group  id="1h_grid_U_tmb" grid_ref="grid_U_2D" operation="instant">
+     <field id="top_u"           name="vozocrtx_top"  unit="m/s"  />
+     <field id="mid_u"           name="vozocrtx_mid"  unit="m/s"  />
+     <field id="bot_u"           name="vozocrtx_bot"  unit="m/s"  />
+     <field id="baro_u"          name="vobtcrtx"      unit="m/s"  />
+   </field_group>
+    <field_group  id="1h_grid_V_tmb" grid_ref="grid_V_2D" operation="instant">
+     <field id="top_v"           name="vomecrty_top"  unit="m/s"  />
+     <field id="mid_v"           name="vomecrty_mid"  unit="m/s"  />
+     <field id="bot_v"           name="vomecrty_bot"  unit="m/s"  />
+     <field id="baro_v"          name="vobtcrty"      unit="m/s"  />
+   </field_group>
+       <!-- 25h diagnostic output -->
+      <field_group id="25h_grid_T" grid_ref="grid_T_3D" operation="instant">
+   <field id="temper25h"         name="potential temperature 25h mean"    unit="degC" />
+   <field id="tempis25h"         name="insitu temperature 25h mean"    unit="degC" />
+   <field id="salin25h"          name="salinity 25h mean"                 unit="psu"  />
+   <field id="ssh25h"            name="sea surface height 25h mean"  grid_ref="grid_T_2D"      unit="m"    />
+      </field_group>
+
+      <field_group id="25h_grid_U" grid_ref="grid_U_3D" operation="instant" >
+   <field id="vozocrtx25h"         name="i current 25h mean"    unit="m/s"   />
+      </field_group>
+
+      <field_group id="25h_grid_V" grid_ref="grid_V_3D" operation="instant">
+   <field id="vomecrty25h"         name="j current 25h mean"    unit="m/s"    />
+      </field_group>
+
+      <field_group id="25h_grid_W" grid_ref="grid_W_3D" operation="instant">
+   <field id="vomecrtz25h"         name="k current 25h mean"                 unit="m/s"      />
+   <field id="avt25h"             name="vertical diffusivity25h mean"       unit="m2/s" />
+   <field id="avm25h"              name="vertical viscosity 25h mean"        unit="m2/s" />
+   <field id="tke25h"              name="turbulent kinetic energy 25h mean" />
+   <field id="mxln25h"             name="mixing length 25h mean"             unit="m" />
+      </field_group>
+
+
+
+   </field_definition>
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/iodef.xml
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/iodef.xml	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/iodef.xml	(revision 7339)
@@ -0,0 +1,170 @@
+<?xml version="1.0"?>
+<simulation> 
+
+ <context id="nemo" time_origin="1900-01-01 00:00:00" >
+    
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    <field_definition src="./field_def.xml"/>
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+    
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1d" min_digits="4">
+    
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."> <!-- 1 time step files -->
+	<file id="file96" name_suffix="_grid_T" description="ocean T grid variables" >
+	  <field field_ref="ssh"          name="sossheig"  />
+          <field field_ref="sss"          name="sosaline"  />
+	  <!--
+	  <field field_ref="wdmask"       name="wdmask"  />
+	  <field field_ref="wetdep"       name="wetdepth"  />
+          <field field_ref="toce"         name="votemper"  />
+          <field field_ref="soce"         name="vosaline"  />
+          -->
+        </file>
+	<file id="file87" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <!--
+          <field field_ref="un_b"         name="un_b"    operation="instant"/>
+          <field field_ref="uoce"         name="vozocrtx" operation="instant"  />
+          -->
+          <field field_ref="ubar"         name="ubaro"    operation="instant"/>
+	  <!--
+          <field field_ref="un_b"         name="un_b"    operation="instant"/>
+          <field field_ref="ucli"         name="uc_un" operation="instant"  />
+          <field field_ref="ucli2"         name="uc_un2" operation="instant"  />
+          <field field_ref="ssu"         name="r1_hu_a" operation="instant"  />
+          <field field_ref="wdlmtu"         name="wdlmtu" operation="instant"  />
+          -->
+        </file>
+	<file id="file88" name_suffix="_grid_V" description="ocean V grid variables" >
+          <field field_ref="vbar"         name="vbaro"    operation="instant"/>
+        </file>
+      </file_group>
+      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE."> <!-- 1h files -->
+	<file id="file97" name_suffix="_grid_T" description="ocean T grid variables" >
+	  <field field_ref="ssh"          name="sossheig"  operation="instant"  />
+	  <field field_ref="e3t"          name="e3t"  operation="instant"  />
+          <field field_ref="toce"         name="votemper"  />
+      </file>
+      <file id="file98" name_suffix="_grid_U" description="ocean U grid variables" >
+          <field field_ref="ubar"         name="ubaro"    operation="instant"/>
+      </file>
+      </file_group>
+      <file_group id="2h" output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+      <file_group id="3h" output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+      <file_group id="4h" output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+      <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->
+     
+      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE."/> <!-- 1d files -->
+      <file_group id="3d" output_freq="3d"  output_level="10" enabled=".TRUE."/> <!-- 3d 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"         name="votemper"  />
+	  <field field_ref="soce"         name="vosaline"  />
+	  <field field_ref="sst"          name="sosstsst"  />
+	  <field field_ref="sss"          name="sosaline"  />
+	  <field field_ref="ssh"          name="sossheig"  />
+	  <field field_ref="empmr"        name="sowaflup"  />
+	  <field field_ref="qsr"          name="soshfldo"  />
+      <field field_ref="saltflx"      name="sosfldow"  />
+	  <field field_ref="qt"           name="sohefldo"  />
+	  <field field_ref="mldr10_1"     name="somxl010"  />
+	  <field field_ref="mldkz5"       name="somixhgt"  />
+    </file>
+	
+	<file id="file2" name_suffix="_grid_U" description="ocean U grid variables" >
+          <field field_ref="uoce"         name="vozocrtx"  />
+          <field field_ref="utau"         name="sozotaux"  />
+    </file>
+	
+	<file id="file3" name_suffix="_grid_V" description="ocean V grid variables" >
+          <field field_ref="voce"         name="vomecrty"  /> 
+          <field field_ref="vtau"         name="sometauy"  /> 
+    </file>
+	
+	<file id="file4" name_suffix="_grid_W" description="ocean W grid variables" >
+          <field field_ref="woce"         name="vovecrtz" />
+          <field field_ref="avt"          name="votkeavt" />
+          <field field_ref="aht2d"        name="soleahtw" />
+    </file>
+
+      </file_group>
+
+      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."/> <!-- real monthly files -->
+      <file_group id="2m" output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+      <file_group id="3m" output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+      <file_group id="4m" output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+      <file_group id="6m" output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+
+      <file_group id="1y"  output_freq="1y" output_level="10" enabled=".TRUE."/> <!-- real yearly files -->
+      <file_group id="2y"  output_freq="2y" output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+      <file_group id="5y"  output_freq="5y" output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+      <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+
+   </file_definition>
+    
+    <!-- 
+============================================================================================================
+= grid definition = = DO NOT CHANGE =
+============================================================================================================
+    -->
+    
+   <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="1"                 />
+      <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> 
+    
+   <domain_definition src="./domain_def.xml"/>
+   
+   <grid_definition>    
+     <grid id="grid_T_2D" domain_ref="grid_T"/>
+     <grid id="grid_T_3D" domain_ref="grid_T" axis_ref="deptht"/>
+     <grid id="grid_U_2D" domain_ref="grid_U"/>
+     <grid id="grid_U_3D" domain_ref="grid_U" axis_ref="depthu"/>
+     <grid id="grid_V_2D" domain_ref="grid_V"/>
+     <grid id="grid_V_3D" domain_ref="grid_V" axis_ref="depthv"/>
+     <grid id="grid_W_2D" domain_ref="grid_W"/>
+     <grid id="grid_W_3D" domain_ref="grid_W" axis_ref="depthw"/>
+    </grid_definition> 
+
+  </context>
+  
+
+  <context id="xios">
+
+      <variable_definition>
+	
+     <!-- 
+        We must have buffer_size > jpi*jpj*jpk*8 (with jpi and jpj the subdomain size)
+-->
+	  <variable id="buffer_size"               type="integer">10000000</variable>
+	  <variable id="buffer_server_factor_size" type="integer">2</variable>
+	  <variable id="info_level"                type="integer">0</variable>
+	  <variable id="using_server"              type="boolean">true</variable>
+	  <variable id="using_oasis"               type="boolean">false</variable>
+	  <variable id="oasis_codes_id"            type="string" >oceanx</variable>
+	
+      </variable_definition>
+               
+  </context>
+  
+</simulation>
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/matpoly2.py
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/matpoly2.py	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/matpoly2.py	(revision 7339)
@@ -0,0 +1,119 @@
+import numpy as np
+import netCDF4
+
+import matplotlib.pyplot as plt
+import matplotlib
+from matplotlib.patches import Polygon
+from matplotlib.collections import PatchCollection
+from netCDF4 import Dataset
+import sys
+
+print sys.argv[1]
+pathin =  sys.argv[1]
+
+nx = 34 
+ny = 1
+nt = 24
+print nx
+print ny
+
+
+fw = Dataset(pathin)
+ssh = fw.variables['sossheig'][:,:,:]
+#bat = fw.variables['gdepw_0'][0,0,:,:]
+bat = fw.variables['bathy'][0,:,:]
+#vot = fw.variables['votemper'][:,0,:,:]
+vot = fw.variables['sosaline'][:,:,:]
+print ssh.shape
+print "bat"
+print bat.shape 
+print "vot"
+print vot.shape 
+nt = ssh.shape[0]
+nx = ssh.shape[2]
+print nx,nt
+fw.close()
+
+bat = -1.*bat
+batmin = np.amin(bat)
+batmax = np.amax(bat)
+brange = batmax - batmin
+tol = 0.1*brange
+print batmin,batmax,' ho'
+
+#for t in range(300,313):
+
+for t in range(0,nt,3):
+ wadfr = "wadfr{:0>4d}.png".format(t)
+ t24  = np.mod(t,24)
+ dy   = np.int(t/24.0)
+
+ tfac = 12.0/3600.0
+ t24  = np.int(np.mod(t*tfac,24))
+ dy   = np.int(t*tfac/24.0)
+ mn   = np.int(np.rint((np.mod(t*tfac,24) - t24 )*60))
+ hour  = "t={:0>2d}:{:0>2d}:{:0>2d} ".format(dy,t24,mn)
+ hour2  = "  (days:hrs:mins)"
+ batpts = np.zeros((nx+4,2))
+ sshpts = np.zeros((2*nx,2))
+ votpts = np.zeros((nx,2))
+ #codes = np.ones(nx,int)
+ #codes[0] = path.Path.MOVETO
+ #codes[1:] = path.Path.LINETO
+ for pt in range(nx):
+    batpts[pt+2,0] = pt
+    batpts[pt+2,1] = bat[0,pt]
+    sshpts[pt,0] = pt
+    sshpts[pt,1] = ssh[t,0,pt]
+    votpts[pt,0] = pt
+    votpts[pt,1] = np.minimum(36.,vot[t,0,pt])
+    votpts[pt,1] = np.maximum(30.0,votpts[pt,1])
+    votpts[pt,1] = batmin +0.2*brange + (votpts[pt,1]-30.)*brange/6.0
+ batpts[nx+1,1] = batmax
+ batpts[nx+2,0] = nx-1
+ batpts[nx+2,1] = batmax
+ batpts[nx+3,0] = nx-1
+ batpts[nx+3,1] = batmin
+ batpts[0,0] = 0.0
+ batpts[0,1] = batmin
+ batpts[1,0] = 0.0
+ batpts[1,1] = batmax
+ batpts[2,1] = batmax
+ sshpts[nx-1,0] = nx-1
+ sshpts[nx-1,1] = sshpts[nx-2,1]
+ sshpts[0,0] = 0.0
+ #sshpts[0,1] = batmin
+ votpts[nx-2,0] = nx-1
+ votpts[nx-1,0] = nx-1
+ votpts[0,0] = 0.0
+ votpts[nx-1,1] = batmax + tol
+ votpts[0,1] = batmax + tol
+ sshpts[0,1] = sshpts[1,1]
+ #for pt in range(nx):
+ #  print pt,votpts[pt,0],votpts[pt,1]
+ for pt in range(nx):
+    sshpts[pt+nx,0]=batpts[nx+1-pt,0]
+    sshpts[pt+nx,1]=batpts[nx+1-pt,1]
+ 
+
+ xs, ys = zip(*votpts)
+ fig, ax = plt.subplots()
+ patches = []
+
+ polygon = Polygon(batpts, True)
+ patches.append(polygon)
+ polygon2 = Polygon(sshpts, True)
+ patches.append(polygon2)
+
+ p = PatchCollection(patches, cmap=matplotlib.cm.jet, alpha=0.4)
+ 
+ #colors = 100*np.random.rand(len(patches))
+ colors = (4,3)
+ p.set_array(np.array(colors))
+
+ ax.add_collection(p)
+ ax.plot(xs,ys, '--', color='black', ms=10)
+
+ plt.annotate(hour,xy=(2,batmin+0.1*brange))
+ plt.annotate(hour2,xy=(2,batmin+0.05*brange))
+ plt.savefig(wadfr)
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/namelist_cfg
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/namelist_cfg	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/namelist_cfg	(revision 7339)
@@ -0,0 +1,482 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  : GYRE_PISCES Configuration namelist to overwrite reference dynamical namelist
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =  "WAD"    !  experience name
+   nn_it000    =       1   !  first time step
+   nn_itend    =      5760  !  last  time step
+   nn_leapy    =      30   !  Leap year calendar (1) or not (0)
+   nn_stock    =    48000  !  frequency of creation of a restart file (modulo referenced to 1)
+
+   ln_clobber  = .true.    !  clobber (overwrite) an existing file
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+
+/
+!-----------------------------------------------------------------------
+&namcfg     !   parameters of the configuration   
+!-----------------------------------------------------------------------
+   cp_cfg      =  "wad"                  !  name of the configuration
+   jp_cfg      =       1                 !  resolution of the configuration
+   jpidta      =      51                 !  1st lateral dimension ( >= jpi ) = 30*jp_cfg+2
+   jpjdta      =      34                 !  2nd    "         "    ( >= jpj ) = 20*jp_cfg+2 
+   jpkdta      =      10                 !  number of levels      ( >= jpk )
+   jpiglo      =      51                 !  1st dimension of global domain --> i  = jpidta
+   jpjglo      =      34                 !  2nd    -                  -    --> j  = jpjdta
+   jpizoom     =       1                 !  left bottom (i,j) indices of the zoom
+   jpjzoom     =       1                 !  in data domain indices
+   jperio      =       0                 !  lateral cond. type (between 0 and 6)
+/
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_sco      = .true.    !  s- or hybrid z-s-coordinate
+   ln_linssh   = .false.   !  linear free surface
+/
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   ln_s_sh94   = .false.   !  Song & Haidvogel 1994 hybrid S-sigma   (T)|
+   ln_s_sf12   = .true.    !  Siddorn & Furner 2012 hybrid S-z-sigma (T)| if both are false the NEMO tanh stretching is applied
+   ln_sigcrit  = .true.    !  use sigma coordinates below critical depth (T) or Z coordinates (F) for Siddorn & Furner stretch
+                           !  stretching coefficients for all functions
+   rn_sbot_min =   0.01     !  minimum depth of s-bottom surface (>0) (m)
+   rn_sbot_max =   15.0    !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   rn_hc       =    3.0    !  critical depth for transition to stretched coordinates
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_msh      =    1      !  create (=1) a mesh file or not (=0)
+   nn_bathy    =    0      !  compute (=0) or read (=1) the bathymetry file
+   rn_bathy    =    10.    !  value of the bathymetry. if (=0) bottom flat at jpkm1
+   rn_rdt      =    12.    !  time step for the dynamics 
+   jphgr_msh   =       1                 !  type of horizontal mesh
+   ppglam0     =       0.0               !  longitude of first raw and column T-point (jphgr_msh = 1)
+   ppgphi0     =       10.0               ! latitude  of first raw and column T-point (jphgr_msh = 1)
+   ppe1_deg    =       0.01              !  zonal      grid-spacing (degrees)
+   ppe2_deg    =       0.01              !  meridional grid-spacing (degrees)
+   ppe1_m      =  999999.0               !  zonal      grid-spacing (degrees)
+   ppe2_m      =  999999.0               !  meridional grid-spacing (degrees)
+   ppsur       =  999999.0               !  ORCA r4, r2 and r05 coefficients
+   ppa0        =  999999.0               ! (default coefficients)
+   ppa1        =  999999.0               !
+   ppkth       =  999999.0               !
+   ppacr       =  999999.0               !
+   ppdzmin     =  0.2                    !  Minimum vertical spacing
+   pphmax      =  10.0                   !  Maximum depth
+   ldbletanh   =  .FALSE.                !  Use/do not use double tanf function for vertical coordinates
+   ppa2        =  999999.0               !  Double tanh function parameters
+   ppkth2      =  999999.0               !
+   ppacr2      =  999999.0               !
+/
+!-----------------------------------------------------------------------
+&namcrs        !   Grid coarsening for dynamics output and/or
+               !   passive tracer coarsened online simulations
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtsd    !   data : Temperature  & Salinity
+!-----------------------------------------------------------------------
+   cn_dir        = './'      !  root directory for the location of the runoff files
+   ln_tsd_init   = .false.   !  Initialisation of ocean T & S with T &S input data (T) or not (F)
+   ln_tsd_tradmp = .false.   !  damping of ocean T & S toward T &S input data (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 1         !  frequency of surface boundary condition computation
+   !                       !     (also = the frequency of sea-ice model call)
+   ln_ana      = .true.    !  analytical formulation                    (T => fill namsbc_ana )
+   ln_blk_core = .false.   !  CORE bulk formulation                     (T => fill namsbc_core)
+   nn_ice      = 0         !  =0 no ice boundary condition   ,
+   ln_rnf      = .false.   !  runoffs                                   (T => fill namsbc_rnf)
+   ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked
+/
+!-----------------------------------------------------------------------
+&namsbc_ana    !   analytical surface boundary condition
+!-----------------------------------------------------------------------
+   nn_tau000   =   100     !  gently increase the stress over the first ntau_rst time-steps
+   rn_utau0    =   0.0e0   !  uniform value for the i-stress
+/
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_clio   !   namsbc_clio  CLIO bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_mfs   !   namsbc_mfs  MFS bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                       ("key_oasis3")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+   ln_qsr_rgb  = .false.   !  RGB (Red-Green-Blue) light penetration
+   ln_qsr_2bd  = .true.    !  2 bands              light penetration
+   nn_chldta   =      0    !  RGB : Chl data (=1) or cst value (=0)
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+   ln_rnf_mouth = .false.   !  specific treatment at rivers mouths
+/
+!-----------------------------------------------------------------------
+&namsbc_apr    !   Atmospheric pressure used as ocean forcing or in bulk
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+   nn_sssr     =     0     !  add a damping     term in the surface freshwater flux (=2)
+   rn_deds     =   -27.7   !  magnitude of the damping on salinity   [mm/day]
+   ln_sssr_bnd =   .false. !  flag to bound erp term (associated with nn_sssr=2)
+/
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namberg       !   iceberg parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =    0.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_tide      !    tide parameters (#ifdef key_tide)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          ("key_bdy")
+!-----------------------------------------------------------------------
+    nb_bdy         = 0                    !  number of open boundary sets
+    ln_coords_file = .false.              !  =T : read bdy coordinates from file
+    cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
+    ln_mask_file   = .false.              !  =T : read mask from file
+    cn_mask_file   = ''                   !  name of mask file (if ln_mask_file=.TRUE.)
+    cn_dyn2d       = 'flather'            !
+    nn_dyn2d_dta   =  1                   !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+                                          !  = 2, use tidal harmonic forcing data from files
+                                          !  = 3, use external data AND tidal harmonic forcing
+    cn_dyn3d      =  'none'               !
+    nn_dyn3d_dta  =  0                    !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    cn_tra        =  'frs'                !
+    nn_tra_dta    =  0                    !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    cn_ice_lim      =  'none'             !
+    nn_ice_lim_dta  =  0                  !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    rn_ice_tem      = 270.                !  lim3 only: arbitrary temperature of incoming sea ice
+    rn_ice_sal      = 10.                 !  lim3 only:      --   salinity           --
+    rn_ice_age      = 30.                 !  lim3 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
+    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
+/
+!-----------------------------------------------------------------------
+&nambdy_index
+!-----------------------------------------------------------------------
+    ctypebdy = 'E'
+    nbdyind  = 49
+    nbdybeg  = 1
+    nbdyend  = 34
+    !ctypebdy = 'W'
+    !nbdyind  = 2
+    !nbdybeg  = 1
+    !nbdyend  = 34
+/
+!-----------------------------------------------------------------------
+&nambdy_dta      !  open boundaries - external data           ("key_bdy")
+!-----------------------------------------------------------------------
+!              !  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_2.5_slow_stop' ,         1        , 'sshbdy',       .true.   , .true.  ,  'daily'  ,    ''    ,   ''     , ''
+   bn_u2d =     'bdyuv_2.5_slow'  ,         1        , 'ubdy'  ,     .true.     , .true.  ,  'daily'  ,    ''    ,   ''     , ''
+   bn_v2d =     'bdyuv_2.5_slow'  ,         1        , 'vbdy'  ,     .true.     , .true.  ,  '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'  ,    ''    ,   ''     , ''
+   cn_dir      =    './'   !  root directory for the location of the bulk files
+   ln_full_vel = .false.        !
+/
+!-----------------------------------------------------------------------
+&nambdy_tide     ! tidal forcing at open boundaries
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    2      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+   !rn_bfri2    =    1.e-5  !  bottom drag coefficient (non linear case). Minimum coeft if ln_loglayer=T
+   !rn_bfri2_max =   1.e-4  !  max. bottom drag coefficient (non linear case and ln_loglayer=T)
+   rn_bfri2    =    1.e-5  !  bottom drag coefficient (non linear case). Minimum coeft if ln_loglayer=T
+   rn_bfri2_max =   1.e-4  !  max. bottom drag coefficient (non linear case and ln_loglayer=T)
+   !rn_bfeb2    =    2.5e-3 !  bottom turbulent kinetic energy background  (m2/s2)
+   !rn_bfrz0    =    3.e-3  !  bottom roughness [m] if ln_loglayer=T
+   ln_loglayer = .true.    !  logarithmic formulation (non linear case)
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   ln_trabbc   = .false.   !  Apply a geothermal heating at the ocean bottom
+   nn_geoflx   =    0      !  geothermal heat flux: = 0 no flux
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   nn_eos      =  0       !  type of equation of state and Brunt-Vaisala frequency
+                                 !  =-1, TEOS-10 
+                                 !  = 0, EOS-80 
+                                 !  = 1, S-EOS   (simplified eos)
+   ln_useCT    = .false.  ! use of Conservative Temp. ==> surface CT converted in Pot. Temp. in sbcssm
+   !                             !
+   !                      ! S-EOS coefficients :
+   !                             !  rd(T,S,Z)*rau0 = -a0*(1+.5*lambda*dT+mu*Z+nu*dS)*dT+b0*dS
+   rn_a0       =  1.6550e-1      !  thermal expension coefficient (nn_eos= 1)
+   rn_b0       =  7.6554e-1      !  saline  expension coefficient (nn_eos= 1)
+   rn_lambda1  =  5.9520e-2      !  cabbeling coeff in T^2  (=0 for linear eos)
+   rn_lambda2  =  7.4914e-4      !  cabbeling coeff in S^2  (=0 for linear eos)
+   rn_mu1      =  1.4970e-4      !  thermobaric coeff. in T (=0 for linear eos)
+   rn_mu2      =  1.1090e-5      !  thermobaric coeff. in S (=0 for linear eos)
+   rn_nu       =  2.4341e-3      !  cabbeling coeff in T*S  (=0 for linear eos)
+!!org GYRE   rn_alpha    =   2.0e-4  !  thermal expension coefficient (nn_eos= 1 or 2)
+!!org GYRE   rn_beta     =   7.7e-4  !  saline  expension coefficient (nn_eos= 2)
+!!org  caution  now a0 = alpha / rau0   with rau0 = 1026
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+   ln_traadv_cen =  .false.  !  2nd order centered scheme
+   ln_traadv_mus =  .false.  !  MUSCL scheme
+   ln_traadv_fct =  .true.   !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!----------------------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers
+!----------------------------------------------------------------------------------
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral
+   ln_traldf_triad =  .false.  !  iso-neutral using Griffies triads
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .false.  !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML     (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom         (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0         !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 1000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.false.   ! use eddy induced velocity parameterization
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping
+!-----------------------------------------------------------------------
+   ln_tradmp   =  .false.  !  add a damping termn (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .true.  !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .false. !  energy & enstrophy scheme
+      nn_een_e3f = 1             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zco  = .false.   !  z-coordinate - full steps
+   ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .true.    !  s-coordinate
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient 
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .true.     !    laplacian operator
+   ln_dynldf_blp =  .false.    !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 0           !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      = 1000.        !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      =      0.     !  horizontal bilaplacian eddy viscosity [m4/s]
+/
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   nn_evdm     =    1      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+   nn_etau     =   0       !  penetration of tke below the mixed layer (ML) due to internal & intertial waves
+/
+!-----------------------------------------------------------------------
+&namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   ln_tmx_itf  = .false.   !  ITF specific parameterisation
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namnc4        !   netcdf4 chunking and compression settings            ("key_netcdf4")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
+!              !       or mixed-layer trends or barotropic vorticity    ("key_trdmld" or     "key_trdvor")
+!-----------------------------------------------------------------------
+   ln_glo_trd  = .false.   ! (T) global domain averaged diag for T, T^2, KE, and PE
+   ln_dyn_trd  = .false.   ! (T) 3D momentum trend output
+   ln_dyn_mxl  = .FALSE.   ! (T) 2D momentum trends averaged over the mixed layer (not coded yet)
+   ln_vor_trd  = .FALSE.   ! (T) 2D barotropic vorticity trends (not coded yet)
+   ln_KE_trd   = .false.   ! (T) 3D Kinetic   Energy     trends
+   ln_PE_trd   = .false.   ! (T) 3D Potential Energy     trends
+   ln_tra_trd  = .false.    ! (T) 3D tracer trend output
+   ln_tra_mxl  = .false.   ! (T) 2D tracer trends averaged over the mixed layer (not coded yet)
+   nn_trd      = 365       !  print frequency (ln_glo_trd=T) (unit=time step)
+/
+!!gm   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+!!gm   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+!!gm   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
+!!gm   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
+!!gm   ln_trdmld_restart = .false.         !  restart for ML diagnostics
+!!gm   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+!!gm
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namhsb       !  Heat and salt budgets
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdct        ! transports through sections
+!-----------------------------------------------------------------------
+    nn_dct      = 60       !  time step frequency for transports computing
+    nn_dctwri   = 60       !  time step frequency for transports writing
+    nn_secdebug = 0        !      0 : no section to debug
+/
+!-----------------------------------------------------------------------
+&namobs       !  observation usage switch                               ('key_diaobs')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_asminc   !   assimilation increments                               ('key_asminc')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_wave   ! External fields from wave model
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namwad  !   Wetting and drying
+!-----------------------------------------------------------------------
+   ln_wd             = .true.   ! T/F activation of wetting and drying
+   !rn_wdmin1         =  0.25    ! Minimum wet depth on dried cells
+   rn_wdmin1         =  0.4     ! Minimum wet depth on dried cells
+   rn_wdmin2         =  0.00001    ! Tolerance of min wet depth on dried cells
+   rn_wdld           =  10.0    ! Land elevation below which wetting/drying is allowed
+   nn_wdit           =  50      ! Max iterations for W/D limiter
+/
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/namelist_ref
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/namelist_ref	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/EXP00/namelist_ref	(revision 7339)
@@ -0,0 +1,1 @@
+link ../../SHARED/namelist_ref
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/domwri.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/domwri.F90	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/domwri.F90	(revision 7339)
@@ -0,0 +1,409 @@
+MODULE domwri
+   !!======================================================================
+   !!                       ***  MODULE domwri  ***
+   !! Ocean initialization : write the ocean domain mesh file(s)
+   !!======================================================================
+   !! History :  OPA  ! 1997-02  (G. Madec)  Original code
+   !!            8.1  ! 1999-11  (M. Imbard)  NetCDF FORMAT with IOIPSL
+   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90 and several file
+   !!            3.0  ! 2008-01  (S. Masson)  add dom_uniq 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dom_wri        : create and write mesh and mask file(s)
+   !!   dom_uniq       : identify unique point of a grid (TUVF)
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O library
+   USE lbclnk          ! lateral boundary conditions - mpp exchanges
+   USE lib_mpp         ! MPP library
+   USE wrk_nemo        ! Memory allocation
+   USE timing          ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dom_wri              ! routine called by inidom.F90
+   PUBLIC   dom_wri_coordinate   ! routine called by domhgr.F90
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id: domwri.F90 5836 2015-10-26 14:49:40Z cetlod $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dom_wri_coordinate
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_wri_coordinate  ***
+      !!                   
+      !! ** Purpose :   Create the NetCDF file which contains all the
+      !!              standard coordinate information plus the surface,
+      !!              e1e2u and e1e2v. By doing so, those surface will
+      !!              not be changed by the reduction of e1u or e2v scale 
+      !!              factors in some straits. 
+      !!                 NB: call just after the read of standard coordinate
+      !!              and the reduction of scale factors in some straits
+      !!
+      !! ** output file :   coordinate_e1e2u_v.nc
+      !!----------------------------------------------------------------------
+      INTEGER           ::   inum0    ! temprary units for 'coordinate_e1e2u_v.nc' file
+      CHARACTER(len=21) ::   clnam0   ! filename (mesh and mask informations)
+      !                                   !  workspaces
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zprt, zprw 
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zdepu, zdepv
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dom_wri_coordinate')
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'dom_wri_coordinate : create NetCDF coordinate file'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~~'
+      
+      clnam0 = 'coordinate_e1e2u_v'  ! filename (mesh and mask informations)
+      
+      !  create 'coordinate_e1e2u_v.nc' file
+      ! ============================
+      !
+      CALL iom_open( TRIM(clnam0), inum0, ldwrt = .TRUE., kiolib = jprstlib )
+      !
+      !                                                         ! horizontal mesh (inum3)
+      CALL iom_rstput( 0, 0, inum0, 'glamt', glamt, ktype = jp_r4 )     !    ! latitude
+      CALL iom_rstput( 0, 0, inum0, 'glamu', glamu, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum0, 'glamv', glamv, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum0, 'glamf', glamf, ktype = jp_r4 )
+      
+      CALL iom_rstput( 0, 0, inum0, 'gphit', gphit, ktype = jp_r4 )     !    ! longitude
+      CALL iom_rstput( 0, 0, inum0, 'gphiu', gphiu, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum0, 'gphiv', gphiv, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum0, 'gphif', gphif, ktype = jp_r4 )
+      
+      CALL iom_rstput( 0, 0, inum0, 'e1t', e1t, ktype = jp_r8 )         !    ! e1 scale factors
+      CALL iom_rstput( 0, 0, inum0, 'e1u', e1u, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum0, 'e1v', e1v, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum0, 'e1f', e1f, ktype = jp_r8 )
+      
+      CALL iom_rstput( 0, 0, inum0, 'e2t', e2t, ktype = jp_r8 )         !    ! e2 scale factors
+      CALL iom_rstput( 0, 0, inum0, 'e2u', e2u, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum0, 'e2v', e2v, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum0, 'e2f', e2f, ktype = jp_r8 )
+      
+      CALL iom_rstput( 0, 0, inum0, 'e1e2u', e1e2u, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum0, 'e1e2v', e1e2v, ktype = jp_r8 )
+
+      CALL iom_close( inum0 )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dom_wri_coordinate')
+      !
+   END SUBROUTINE dom_wri_coordinate
+
+
+   SUBROUTINE dom_wri
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_wri  ***
+      !!                   
+      !! ** Purpose :   Create the NetCDF file(s) which contain(s) all the
+      !!      ocean domain informations (mesh and mask arrays). This (these)
+      !!      file(s) is (are) used for visualisation (SAXO software) and
+      !!      diagnostic computation.
+      !!
+      !! ** Method  :   Write in a file all the arrays generated in routines
+      !!      domhgr, domzgr, and dommsk. Note: the file contain depends on
+      !!      the vertical coord. used (z-coord, partial steps, s-coord)
+      !!            MOD(nmsh, 3) = 1  :   'mesh_mask.nc' file
+      !!                         = 2  :   'mesh.nc' and mask.nc' files
+      !!                         = 0  :   'mesh_hgr.nc', 'mesh_zgr.nc' and
+      !!                                  'mask.nc' files
+      !!      For huge size domain, use option 2 or 3 depending on your 
+      !!      vertical coordinate.
+      !!
+      !!      if     nmsh <= 3: write full 3D arrays for e3[tuvw] and gdep[tuvw]
+      !!      if 3 < nmsh <= 6: write full 3D arrays for e3[tuvw] and 2D arrays 
+      !!                        corresponding to the depth of the bottom t- and w-points
+      !!      if 6 < nmsh <= 9: write 2D arrays corresponding to the depth and the
+      !!                        thickness (e3[tw]_ps) of the bottom points 
+      !!
+      !! ** output file :   meshmask.nc  : domain size, horizontal grid-point position,
+      !!                                   masks, depth and vertical scale factors
+      !!----------------------------------------------------------------------
+      !!
+      INTEGER           ::   inum0    ! temprary units for 'mesh_mask.nc' file
+      INTEGER           ::   inum1    ! temprary units for 'mesh.nc'      file
+      INTEGER           ::   inum2    ! temprary units for 'mask.nc'      file
+      INTEGER           ::   inum3    ! temprary units for 'mesh_hgr.nc'  file
+      INTEGER           ::   inum4    ! temprary units for 'mesh_zgr.nc'  file
+      CHARACTER(len=21) ::   clnam0   ! filename (mesh and mask informations)
+      CHARACTER(len=21) ::   clnam1   ! filename (mesh informations)
+      CHARACTER(len=21) ::   clnam2   ! filename (mask informations)
+      CHARACTER(len=21) ::   clnam3   ! filename (horizontal mesh informations)
+      CHARACTER(len=21) ::   clnam4   ! filename (vertical   mesh informations)
+      INTEGER           ::   ji, jj, jk   ! dummy loop indices
+      !                                   !  workspaces
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zprt, zprw 
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zdepu, zdepv
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dom_wri')
+      !
+      CALL wrk_alloc( jpi, jpj, zprt, zprw )
+      CALL wrk_alloc( jpi, jpj, jpk, zdepu, zdepv )
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'dom_wri : create NetCDF mesh and mask information file(s)'
+      IF(lwp) WRITE(numout,*) '~~~~~~~'
+      
+      clnam0 = 'mesh_mask'  ! filename (mesh and mask informations)
+      clnam1 = 'mesh'       ! filename (mesh informations)
+      clnam2 = 'mask'       ! filename (mask informations)
+      clnam3 = 'mesh_hgr'   ! filename (horizontal mesh informations)
+      clnam4 = 'mesh_zgr'   ! filename (vertical   mesh informations)
+      
+      SELECT CASE ( MOD(nmsh, 3) )
+         !                                  ! ============================
+      CASE ( 1 )                            !  create 'mesh_mask.nc' file
+         !                                  ! ============================
+         CALL iom_open( TRIM(clnam0), inum0, ldwrt = .TRUE., kiolib = jprstlib )
+         inum2 = inum0                                            ! put all the informations
+         inum3 = inum0                                            ! in unit inum0
+         inum4 = inum0
+         
+         !                                  ! ============================
+      CASE ( 2 )                            !  create 'mesh.nc' and 
+         !                                  !         'mask.nc' files
+         !                                  ! ============================
+         CALL iom_open( TRIM(clnam1), inum1, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_open( TRIM(clnam2), inum2, ldwrt = .TRUE., kiolib = jprstlib )
+         inum3 = inum1                                            ! put mesh informations 
+         inum4 = inum1                                            ! in unit inum1 
+         !                                  ! ============================
+      CASE ( 0 )                            !  create 'mesh_hgr.nc'
+         !                                  !         'mesh_zgr.nc' and
+         !                                  !         'mask.nc'     files
+         !                                  ! ============================
+         CALL iom_open( TRIM(clnam2), inum2, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_open( TRIM(clnam3), inum3, ldwrt = .TRUE., kiolib = jprstlib )
+         CALL iom_open( TRIM(clnam4), inum4, ldwrt = .TRUE., kiolib = jprstlib )
+         !
+      END SELECT
+      
+      !                                                         ! masks (inum2) 
+      CALL iom_rstput( 0, 0, inum2, 'tmask', tmask, ktype = jp_i1 )     !    ! land-sea mask
+      CALL iom_rstput( 0, 0, inum2, 'umask', umask, ktype = jp_i1 )
+      CALL iom_rstput( 0, 0, inum2, 'vmask', vmask, ktype = jp_i1 )
+      CALL iom_rstput( 0, 0, inum2, 'fmask', fmask, ktype = jp_i1 )
+      
+      CALL dom_uniq( zprw, 'T' )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            jk=mikt(ji,jj) 
+            zprt(ji,jj) = tmask(ji,jj,jk) * zprw(ji,jj)                        !    ! unique point mask
+         END DO
+      END DO                             !    ! unique point mask
+      CALL iom_rstput( 0, 0, inum2, 'tmaskutil', zprt, ktype = jp_i1 )  
+      CALL dom_uniq( zprw, 'U' )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            jk=miku(ji,jj) 
+            zprt(ji,jj) = umask(ji,jj,jk) * zprw(ji,jj)                        !    ! unique point mask
+         END DO
+      END DO
+      CALL iom_rstput( 0, 0, inum2, 'umaskutil', zprt, ktype = jp_i1 )  
+      CALL dom_uniq( zprw, 'V' )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            jk=mikv(ji,jj) 
+            zprt(ji,jj) = vmask(ji,jj,jk) * zprw(ji,jj)                        !    ! unique point mask
+         END DO
+      END DO
+      CALL iom_rstput( 0, 0, inum2, 'vmaskutil', zprt, ktype = jp_i1 )  
+      CALL dom_uniq( zprw, 'F' )
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            jk=mikf(ji,jj) 
+            zprt(ji,jj) = fmask(ji,jj,jk) * zprw(ji,jj)                        !    ! unique point mask
+         END DO
+      END DO
+      CALL iom_rstput( 0, 0, inum2, 'fmaskutil', zprt, ktype = jp_i1 )  
+
+      !                                                         ! horizontal mesh (inum3)
+      CALL iom_rstput( 0, 0, inum3, 'glamt', glamt, ktype = jp_r4 )     !    ! latitude
+      CALL iom_rstput( 0, 0, inum3, 'glamu', glamu, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum3, 'glamv', glamv, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum3, 'glamf', glamf, ktype = jp_r4 )
+      
+      CALL iom_rstput( 0, 0, inum3, 'gphit', gphit, ktype = jp_r4 )     !    ! longitude
+      CALL iom_rstput( 0, 0, inum3, 'gphiu', gphiu, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum3, 'gphiv', gphiv, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum3, 'gphif', gphif, ktype = jp_r4 )
+      
+      CALL iom_rstput( 0, 0, inum3, 'e1t', e1t, ktype = jp_r8 )         !    ! e1 scale factors
+      CALL iom_rstput( 0, 0, inum3, 'e1u', e1u, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum3, 'e1v', e1v, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum3, 'e1f', e1f, ktype = jp_r8 )
+      
+      CALL iom_rstput( 0, 0, inum3, 'e2t', e2t, ktype = jp_r8 )         !    ! e2 scale factors
+      CALL iom_rstput( 0, 0, inum3, 'e2u', e2u, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum3, 'e2v', e2v, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum3, 'e2f', e2f, ktype = jp_r8 )
+      
+      CALL iom_rstput( 0, 0, inum3, 'ff', ff, ktype = jp_r8 )           !    ! coriolis factor
+      
+      ! note that mbkt is set to 1 over land ==> use surface tmask
+      zprt(:,:) = ssmask(:,:) * REAL( mbkt(:,:) , wp )
+      CALL iom_rstput( 0, 0, inum4, 'mbathy', zprt, ktype = jp_i2 )     !    ! nb of ocean T-points
+      CALL iom_rstput( 0, 0, inum4, 'bathy', bathy, ktype = jp_r8 )     !    ! nb of ocean T-points
+      zprt(:,:) = ssmask(:,:) * REAL( mikt(:,:) , wp )
+      CALL iom_rstput( 0, 0, inum4, 'misf', zprt, ktype = jp_i2 )       !    ! nb of ocean T-points
+      zprt(:,:) = ssmask(:,:) * REAL( risfdep(:,:) , wp )
+      CALL iom_rstput( 0, 0, inum4, 'isfdraft', zprt, ktype = jp_r4 )       !    ! nb of ocean T-points
+            
+      IF( ln_sco ) THEN                                         ! s-coordinate
+         CALL iom_rstput( 0, 0, inum4, 'hbatt', hbatt )
+         CALL iom_rstput( 0, 0, inum4, 'hbatu', hbatu )
+         CALL iom_rstput( 0, 0, inum4, 'hbatv', hbatv )
+         CALL iom_rstput( 0, 0, inum4, 'hbatf', hbatf )
+         !
+         CALL iom_rstput( 0, 0, inum4, 'gsigt', gsigt )         !    ! scaling coef.
+         CALL iom_rstput( 0, 0, inum4, 'gsigw', gsigw )  
+         CALL iom_rstput( 0, 0, inum4, 'gsi3w', gsi3w )
+         CALL iom_rstput( 0, 0, inum4, 'esigt', esigt )
+         CALL iom_rstput( 0, 0, inum4, 'esigw', esigw )
+         !
+         CALL iom_rstput( 0, 0, inum4, 'e3t_0', e3t_0 )         !    ! scale factors
+         CALL iom_rstput( 0, 0, inum4, 'e3u_0', e3u_0 )
+         CALL iom_rstput( 0, 0, inum4, 'e3v_0', e3v_0 )
+         CALL iom_rstput( 0, 0, inum4, 'e3w_0', e3w_0 )
+         CALL iom_rstput( 0, 0, inum4, 'rx1', rx1 )             !    ! Max. grid stiffness ratio
+         !
+         CALL iom_rstput( 0, 0, inum4, 'gdept_1d' , gdept_1d )  !    ! stretched system
+         CALL iom_rstput( 0, 0, inum4, 'gdepw_1d' , gdepw_1d )
+         CALL iom_rstput( 0, 0, inum4, 'gdept_0', gdept_0, ktype = jp_r4 )     
+         CALL iom_rstput( 0, 0, inum4, 'gdepw_0', gdepw_0, ktype = jp_r4 )
+      ENDIF
+      
+      IF( ln_zps ) THEN                                         ! z-coordinate - partial steps
+         !
+         IF( nmsh <= 6 ) THEN                                   !    ! 3D vertical scale factors
+            CALL iom_rstput( 0, 0, inum4, 'e3t_0', e3t_0 )         
+            CALL iom_rstput( 0, 0, inum4, 'e3u_0', e3u_0 )
+            CALL iom_rstput( 0, 0, inum4, 'e3v_0', e3v_0 )
+            CALL iom_rstput( 0, 0, inum4, 'e3w_0', e3w_0 )
+         ELSE                                                   !    ! 2D masked bottom ocean scale factors
+            DO jj = 1,jpj   
+               DO ji = 1,jpi
+                  e3tp(ji,jj) = e3t_0(ji,jj,mbkt(ji,jj)) * ssmask(ji,jj)
+                  e3wp(ji,jj) = e3w_0(ji,jj,mbkt(ji,jj)) * ssmask(ji,jj)
+               END DO
+            END DO
+            CALL iom_rstput( 0, 0, inum4, 'e3t_ps', e3tp )      
+            CALL iom_rstput( 0, 0, inum4, 'e3w_ps', e3wp )
+         END IF
+         !
+         IF( nmsh <= 3 ) THEN                                   !    ! 3D depth
+            CALL iom_rstput( 0, 0, inum4, 'gdept_0', gdept_0, ktype = jp_r4 )     
+            DO jk = 1,jpk   
+               DO jj = 1, jpjm1   
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     zdepu(ji,jj,jk) = MIN( gdept_0(ji,jj,jk) , gdept_0(ji+1,jj  ,jk) )
+                     zdepv(ji,jj,jk) = MIN( gdept_0(ji,jj,jk) , gdept_0(ji  ,jj+1,jk) )
+                  END DO   
+               END DO   
+            END DO
+            CALL lbc_lnk( zdepu, 'U', 1. )   ;   CALL lbc_lnk( zdepv, 'V', 1. ) 
+            CALL iom_rstput( 0, 0, inum4, 'gdepu', zdepu, ktype = jp_r4 )
+            CALL iom_rstput( 0, 0, inum4, 'gdepv', zdepv, ktype = jp_r4 )
+            CALL iom_rstput( 0, 0, inum4, 'gdepw_0', gdepw_0, ktype = jp_r4 )
+         ELSE                                                   !    ! 2D bottom depth
+            DO jj = 1,jpj   
+               DO ji = 1,jpi
+                  zprt(ji,jj) = gdept_0(ji,jj,mbkt(ji,jj)  ) * ssmask(ji,jj)
+                  zprw(ji,jj) = gdepw_0(ji,jj,mbkt(ji,jj)+1) * ssmask(ji,jj)
+               END DO
+            END DO
+            CALL iom_rstput( 0, 0, inum4, 'hdept', zprt, ktype = jp_r4 )     
+            CALL iom_rstput( 0, 0, inum4, 'hdepw', zprw, ktype = jp_r4 ) 
+         ENDIF
+         !
+         CALL iom_rstput( 0, 0, inum4, 'gdept_1d', gdept_1d )   !    ! reference z-coord.
+         CALL iom_rstput( 0, 0, inum4, 'gdepw_1d', gdepw_1d )
+         CALL iom_rstput( 0, 0, inum4, 'e3t_1d'  , e3t_1d   )
+         CALL iom_rstput( 0, 0, inum4, 'e3w_1d'  , e3w_1d   )
+      ENDIF
+      
+      IF( ln_zco ) THEN
+         !                                                      ! z-coordinate - full steps
+         CALL iom_rstput( 0, 0, inum4, 'gdept_1d', gdept_1d )   !    ! depth
+         CALL iom_rstput( 0, 0, inum4, 'gdepw_1d', gdepw_1d )
+         CALL iom_rstput( 0, 0, inum4, 'e3t_1d'  , e3t_1d   )   !    ! scale factors
+         CALL iom_rstput( 0, 0, inum4, 'e3w_1d'  , e3w_1d   )
+      ENDIF
+      !                                     ! ============================
+      !                                     !        close the files 
+      !                                     ! ============================
+      SELECT CASE ( MOD(nmsh, 3) )
+      CASE ( 1 )                
+         CALL iom_close( inum0 )
+      CASE ( 2 )
+         CALL iom_close( inum1 )
+         CALL iom_close( inum2 )
+      CASE ( 0 )
+         CALL iom_close( inum2 )
+         CALL iom_close( inum3 )
+         CALL iom_close( inum4 )
+      END SELECT
+      !
+      CALL wrk_dealloc( jpi, jpj, zprt, zprw )
+      CALL wrk_dealloc( jpi, jpj, jpk, zdepu, zdepv )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dom_wri')
+      !
+   END SUBROUTINE dom_wri
+
+
+   SUBROUTINE dom_uniq( puniq, cdgrd )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_uniq  ***
+      !!                   
+      !! ** Purpose :   identify unique point of a grid (TUVF)
+      !!
+      !! ** Method  :   1) aplly lbc_lnk on an array with different values for each element
+      !!                2) check which elements have been changed
+      !!----------------------------------------------------------------------
+      !
+      CHARACTER(len=1)        , INTENT(in   ) ::   cdgrd   ! 
+      REAL(wp), DIMENSION(:,:), INTENT(inout) ::   puniq   ! 
+      !
+      REAL(wp) ::  zshift   ! shift value link to the process number
+      INTEGER  ::  ji       ! dummy loop indices
+      LOGICAL, DIMENSION(SIZE(puniq,1),SIZE(puniq,2),1) ::  lldbl  ! store whether each point is unique or not
+      REAL(wp), POINTER, DIMENSION(:,:) :: ztstref
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dom_uniq')
+      !
+      CALL wrk_alloc( jpi, jpj, ztstref )
+      !
+      ! build an array with different values for each element 
+      ! in mpp: make sure that these values are different even between process
+      ! -> apply a shift value according to the process number
+      zshift = jpi * jpj * ( narea - 1 )
+      ztstref(:,:) = RESHAPE( (/ (zshift + REAL(ji,wp), ji = 1, jpi*jpj) /), (/ jpi, jpj /) )
+      !
+      puniq(:,:) = ztstref(:,:)                   ! default definition
+      CALL lbc_lnk( puniq, cdgrd, 1. )            ! apply boundary conditions
+      lldbl(:,:,1) = puniq(:,:) == ztstref(:,:)   ! check which values have been changed 
+      !
+      puniq(:,:) = 1.                             ! default definition
+      ! fill only the inner part of the cpu with llbl converted into real 
+      puniq(nldi:nlei,nldj:nlej) = REAL( COUNT( lldbl(nldi:nlei,nldj:nlej,:), dim = 3 ) , wp )
+      !
+      CALL wrk_dealloc( jpi, jpj, ztstref )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dom_uniq')
+      !
+   END SUBROUTINE dom_uniq
+
+   !!======================================================================
+END MODULE domwri
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/dynadv_cen2.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/dynadv_cen2.F90	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/dynadv_cen2.F90	(revision 7339)
@@ -0,0 +1,157 @@
+MODULE dynadv_cen2
+   !!======================================================================
+   !!                       ***  MODULE  dynadv  ***
+   !! Ocean dynamics: Update the momentum trend with the flux form advection
+   !!                 using a 2nd order centred scheme
+   !!======================================================================
+   !! History :  2.0  ! 2006-08  (G. Madec, S. Theetten)  Original code
+   !!            3.2  ! 2009-07  (R. Benshila)  Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_adv_cen2  : flux form momentum advection (ln_dynadv_cen2=T) using a 2nd order centred scheme  
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE trd_oce        ! trends: ocean variables
+   USE trddyn         ! trend manager: dynamics
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE prtctl         ! Print control
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_adv_cen2   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! $Id: dynadv_cen2.F90 6140 2015-12-21 11:35:23Z timgraham $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dyn_adv_cen2( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_adv_cen2  ***
+      !!
+      !! ** Purpose :   Compute the now momentum advection trend in flux form
+      !!              and the general trend of the momentum equation.
+      !!
+      !! ** Method  :   Trend evaluated using now fields (centered in time) 
+      !!
+      !! ** Action  :   (ua,va) updated with the now vorticity term trend
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zfu_t, zfv_t, zfu_f, zfv_f, zfu_uw, zfv_vw, zfw
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zfu, zfv
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dyn_adv_cen2')
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,   zfu_t, zfv_t, zfu_f, zfv_f, zfu_uw, zfv_vw, zfu, zfv, zfw )
+      !
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dyn_adv_cen2 : 2nd order flux form momentum advection'
+         WRITE(numout,*) '~~~~~~~~~~~~'
+      ENDIF
+      !
+      IF( l_trddyn ) THEN           ! trends: store the input trends
+         zfu_uw(:,:,:) = ua(:,:,:)
+         zfv_vw(:,:,:) = va(:,:,:)
+      ENDIF
+      !
+      !                             !==  Horizontal advection  ==!
+      !
+      DO jk = 1, jpkm1                    ! horizontal transport
+         zfu(:,:,jk) = 0.25_wp * e2u(:,:) * e3u_n(:,:,jk) * un(:,:,jk)
+         zfv(:,:,jk) = 0.25_wp * e1v(:,:) * e3v_n(:,:,jk) * vn(:,:,jk)
+         DO jj = 1, jpjm1                 ! horizontal momentum fluxes (at T- and F-point)
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zfu_t(ji+1,jj  ,jk) = ( zfu(ji,jj,jk) + zfu(ji+1,jj,jk) ) * ( un(ji,jj,jk) + un(ji+1,jj  ,jk) )
+               zfv_f(ji  ,jj  ,jk) = ( zfv(ji,jj,jk) + zfv(ji+1,jj,jk) ) * ( un(ji,jj,jk) + un(ji  ,jj+1,jk) )
+               zfu_f(ji  ,jj  ,jk) = ( zfu(ji,jj,jk) + zfu(ji,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji+1,jj  ,jk) )
+               zfv_t(ji  ,jj+1,jk) = ( zfv(ji,jj,jk) + zfv(ji,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji  ,jj+1,jk) )
+            END DO
+         END DO
+         DO jj = 2, jpjm1                 ! divergence of horizontal momentum fluxes
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) = ua(ji,jj,jk) - (  zfu_t(ji+1,jj,jk) - zfu_t(ji,jj  ,jk)    &
+                  &                           + zfv_f(ji  ,jj,jk) - zfv_f(ji,jj-1,jk)  ) * r1_e1e2u(ji,jj) / e3u_n(ji,jj,jk)
+               va(ji,jj,jk) = va(ji,jj,jk) - (  zfu_f(ji,jj  ,jk) - zfu_f(ji-1,jj,jk)    &
+                  &                           + zfv_t(ji,jj+1,jk) - zfv_t(ji  ,jj,jk)  ) * r1_e1e2v(ji,jj) / e3v_n(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+      IF( l_trddyn ) THEN           ! trends: send trend to trddyn for diagnostic
+         zfu_uw(:,:,:) = ua(:,:,:) - zfu_uw(:,:,:)
+         zfv_vw(:,:,:) = va(:,:,:) - zfv_vw(:,:,:)
+         CALL trd_dyn( zfu_uw, zfv_vw, jpdyn_keg, kt )
+         zfu_t(:,:,:) = ua(:,:,:)
+         zfv_t(:,:,:) = va(:,:,:)
+      ENDIF
+      !
+      !                             !==  Vertical advection  ==!
+      !
+      DO jj = 2, jpjm1                    ! surface/bottom advective fluxes set to zero
+         DO ji = fs_2, fs_jpim1
+            zfu_uw(ji,jj,jpk) = 0._wp   ;   zfv_vw(jj,jj,jpk) = 0._wp
+            zfu_uw(ji,jj, 1 ) = 0._wp   ;   zfv_vw(jj,jj, 1 ) = 0._wp
+         END DO
+      END DO
+      IF( ln_linssh ) THEN                ! linear free surface: advection through the surface
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zfu_uw(ji,jj,1) = 0.5_wp * ( e1e2t(ji,jj) * wn(ji,jj,1) + e1e2t(ji+1,jj) * wn(ji+1,jj,1) ) * un(ji,jj,1)
+               zfv_vw(ji,jj,1) = 0.5_wp * ( e1e2t(ji,jj) * wn(ji,jj,1) + e1e2t(ji,jj+1) * wn(ji,jj+1,1) ) * vn(ji,jj,1)
+            END DO
+         END DO
+      ENDIF
+      DO jk = 2, jpkm1                    ! interior advective fluxes
+         DO jj = 2, jpj                       ! 1/4 * Vertical transport
+            DO ji = 2, jpi
+               zfw(ji,jj,jk) = 0.25_wp * e1e2t(ji,jj) * wn(ji,jj,jk)
+            END DO
+         END DO
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zfu_uw(ji,jj,jk) = ( zfw(ji,jj,jk) + zfw(ji+1,jj  ,jk) ) * ( un(ji,jj,jk) + un(ji,jj,jk-1) )
+               zfv_vw(ji,jj,jk) = ( zfw(ji,jj,jk) + zfw(ji  ,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji,jj,jk-1) )
+            END DO
+         END DO
+      END DO
+      DO jk = 1, jpkm1                    ! divergence of vertical momentum flux divergence
+         DO jj = 2, jpjm1 
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) = ua(ji,jj,jk) - ( zfu_uw(ji,jj,jk) - zfu_uw(ji,jj,jk+1) ) * r1_e1e2u(ji,jj) / e3u_n(ji,jj,jk)
+               va(ji,jj,jk) = va(ji,jj,jk) - ( zfv_vw(ji,jj,jk) - zfv_vw(ji,jj,jk+1) ) * r1_e1e2v(ji,jj) / e3v_n(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+      IF( l_trddyn ) THEN                 ! trends: send trend to trddyn for diagnostic
+         zfu_t(:,:,:) = ua(:,:,:) - zfu_t(:,:,:)
+         zfv_t(:,:,:) = va(:,:,:) - zfv_t(:,:,:)
+         CALL trd_dyn( zfu_t, zfv_t, jpdyn_zad, kt )
+      ENDIF
+      !                                   ! Control print
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' cen2 adv - Ua: ', mask1=umask,   &
+         &                       tab3d_2=va, clinfo2=           ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+      CALL wrk_dealloc( jpi, jpj, jpk, zfu_t, zfv_t, zfu_f, zfv_f, zfu_uw, zfv_vw, zfu, zfv, zfw )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dyn_adv_cen2')
+      !
+   END SUBROUTINE dyn_adv_cen2
+
+   !!==============================================================================
+END MODULE dynadv_cen2
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/dynadv_ubs.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/dynadv_ubs.F90	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/dynadv_ubs.F90	(revision 7339)
@@ -0,0 +1,251 @@
+MODULE dynadv_ubs
+   !!======================================================================
+   !!                       ***  MODULE  dynadv_ubs  ***
+   !! Ocean dynamics: Update the momentum trend with the flux form advection
+   !!                 trend using a 3rd order upstream biased scheme
+   !!======================================================================
+   !! History :  2.0  ! 2006-08  (R. Benshila, L. Debreu)  Original code
+   !!            3.2  ! 2009-07  (R. Benshila)  Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_adv_ubs   : flux form momentum advection using    (ln_dynadv=T)
+   !!                   an 3rd order Upstream Biased Scheme or Quick scheme
+   !!                   combined with 2nd or 4th order finite differences 
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE trd_oce        ! trends: ocean variables
+   USE trddyn         ! trend manager: dynamics
+   !
+   USE in_out_manager ! I/O manager
+   USE prtctl         ! Print control
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   REAL(wp), PARAMETER :: gamma1 = 1._wp/3._wp  ! =1/4 quick      ; =1/3  3rd order UBS
+   REAL(wp), PARAMETER :: gamma2 = 1._wp/32._wp ! =0   2nd order  ; =1/32 4th order centred
+
+   PUBLIC   dyn_adv_ubs   ! routine called by step.F90
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! $Id: dynadv_ubs.F90 6140 2015-12-21 11:35:23Z timgraham $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dyn_adv_ubs( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_adv_ubs  ***
+      !!
+      !! ** Purpose :   Compute the now momentum advection trend in flux form
+      !!              and the general trend of the momentum equation.
+      !!
+      !! ** Method  :   The scheme is the one implemeted in ROMS. It depends 
+      !!      on two parameter gamma1 and gamma2. The former control the 
+      !!      upstream baised part of the scheme and the later the centred 
+      !!      part:     gamma1 = 0    pure centered  (no diffusive part)
+      !!                       = 1/4  Quick scheme
+      !!                       = 1/3  3rd order Upstream biased scheme
+      !!                gamma2 = 0    2nd order finite differencing 
+      !!                       = 1/32 4th order finite differencing
+      !!      For stability reasons, the first term of the fluxes which cor-
+      !!      responds to a second order centered scheme is evaluated using  
+      !!      the now velocity (centered in time) while the second term which  
+      !!      is the diffusive part of the scheme, is evaluated using the 
+      !!      before velocity (forward in time). 
+      !!      Default value (hard coded in the begining of the module) are 
+      !!      gamma1=1/3 and gamma2=1/32.
+      !!
+      !! ** Action : - (ua,va) updated with the 3D advective momentum trends
+      !!
+      !! Reference : Shchepetkin & McWilliams, 2005, Ocean Modelling. 
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zui, zvj, zfuj, zfvi, zl_u, zl_v   ! local scalars
+      REAL(wp), POINTER, DIMENSION(:,:,:  ) ::  zfu, zfv
+      REAL(wp), POINTER, DIMENSION(:,:,:  ) ::  zfu_t, zfv_t, zfu_f, zfv_f, zfu_uw, zfv_vw, zfw
+      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  zlu_uu, zlv_vv, zlu_uv, zlv_vu
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dyn_adv_ubs')
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,        zfu_t , zfv_t , zfu_f , zfv_f, zfu_uw, zfv_vw, zfu, zfv, zfw )
+      CALL wrk_alloc( jpi,jpj,jpk,jpts,   zlu_uu, zlv_vv, zlu_uv, zlv_vu                               )
+      !
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_adv_ubs : UBS flux form momentum advection'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+      !
+      zfu_t(:,:,:) = 0._wp
+      zfv_t(:,:,:) = 0._wp
+      zfu_f(:,:,:) = 0._wp
+      zfv_f(:,:,:) = 0._wp
+      !
+      zlu_uu(:,:,:,:) = 0._wp
+      zlv_vv(:,:,:,:) = 0._wp 
+      zlu_uv(:,:,:,:) = 0._wp 
+      zlv_vu(:,:,:,:) = 0._wp 
+      !
+      IF( l_trddyn ) THEN           ! trends: store the input trends
+         zfu_uw(:,:,:) = ua(:,:,:)
+         zfv_vw(:,:,:) = va(:,:,:)
+      ENDIF
+      !                                      ! =========================== !
+      DO jk = 1, jpkm1                       !  Laplacian of the velocity  !
+         !                                   ! =========================== !
+         !                                         ! horizontal volume fluxes
+         zfu(:,:,jk) = e2u(:,:) * e3u_n(:,:,jk) * un(:,:,jk)
+         zfv(:,:,jk) = e1v(:,:) * e3v_n(:,:,jk) * vn(:,:,jk)
+         !            
+         DO jj = 2, jpjm1                          ! laplacian
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zlu_uu(ji,jj,jk,1) = ( ub (ji+1,jj  ,jk) - 2.*ub (ji,jj,jk) + ub (ji-1,jj  ,jk) ) * umask(ji,jj,jk)
+               zlv_vv(ji,jj,jk,1) = ( vb (ji  ,jj+1,jk) - 2.*vb (ji,jj,jk) + vb (ji  ,jj-1,jk) ) * vmask(ji,jj,jk)
+               zlu_uv(ji,jj,jk,1) = ( ub (ji  ,jj+1,jk) - ub (ji  ,jj  ,jk) ) * fmask(ji  ,jj  ,jk)   &
+                  &               - ( ub (ji  ,jj  ,jk) - ub (ji  ,jj-1,jk) ) * fmask(ji  ,jj-1,jk)
+               zlv_vu(ji,jj,jk,1) = ( vb (ji+1,jj  ,jk) - vb (ji  ,jj  ,jk) ) * fmask(ji  ,jj  ,jk)   &
+                  &               - ( vb (ji  ,jj  ,jk) - vb (ji-1,jj  ,jk) ) * fmask(ji-1,jj  ,jk)
+               !
+               zlu_uu(ji,jj,jk,2) = ( zfu(ji+1,jj  ,jk) - 2.*zfu(ji,jj,jk) + zfu(ji-1,jj  ,jk) ) * umask(ji,jj,jk)
+               zlv_vv(ji,jj,jk,2) = ( zfv(ji  ,jj+1,jk) - 2.*zfv(ji,jj,jk) + zfv(ji  ,jj-1,jk) ) * vmask(ji,jj,jk)
+               zlu_uv(ji,jj,jk,2) = ( zfu(ji  ,jj+1,jk) - zfu(ji  ,jj  ,jk) ) * fmask(ji  ,jj  ,jk)   &
+                  &               - ( zfu(ji  ,jj  ,jk) - zfu(ji  ,jj-1,jk) ) * fmask(ji  ,jj-1,jk)
+               zlv_vu(ji,jj,jk,2) = ( zfv(ji+1,jj  ,jk) - zfv(ji  ,jj  ,jk) ) * fmask(ji  ,jj  ,jk)   &
+                  &               - ( zfv(ji  ,jj  ,jk) - zfv(ji-1,jj  ,jk) ) * fmask(ji-1,jj  ,jk)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( zlu_uu(:,:,:,1), 'U', 1. )   ;   CALL lbc_lnk( zlu_uv(:,:,:,1), 'U', 1. )
+      CALL lbc_lnk( zlu_uu(:,:,:,2), 'U', 1. )   ;   CALL lbc_lnk( zlu_uv(:,:,:,2), 'U', 1. )
+      CALL lbc_lnk( zlv_vv(:,:,:,1), 'V', 1. )   ;   CALL lbc_lnk( zlv_vu(:,:,:,1), 'V', 1. )
+      CALL lbc_lnk( zlv_vv(:,:,:,2), 'V', 1. )   ;   CALL lbc_lnk( zlv_vu(:,:,:,2), 'V', 1. ) 
+      !
+      !                                      ! ====================== !
+      !                                      !  Horizontal advection  !
+      DO jk = 1, jpkm1                       ! ====================== !
+         !                                         ! horizontal volume fluxes
+         zfu(:,:,jk) = 0.25_wp * e2u(:,:) * e3u_n(:,:,jk) * un(:,:,jk)
+         zfv(:,:,jk) = 0.25_wp * e1v(:,:) * e3v_n(:,:,jk) * vn(:,:,jk)
+         !
+         DO jj = 1, jpjm1                          ! horizontal momentum fluxes at T- and F-point
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zui = ( un(ji,jj,jk) + un(ji+1,jj  ,jk) )
+               zvj = ( vn(ji,jj,jk) + vn(ji  ,jj+1,jk) )
+               !
+               IF( zui > 0 ) THEN   ;   zl_u = zlu_uu(ji  ,jj,jk,1)
+               ELSE                 ;   zl_u = zlu_uu(ji+1,jj,jk,1)
+               ENDIF
+               IF( zvj > 0 ) THEN   ;   zl_v = zlv_vv(ji,jj  ,jk,1)
+               ELSE                 ;   zl_v = zlv_vv(ji,jj+1,jk,1)
+               ENDIF
+               !
+               zfu_t(ji+1,jj  ,jk) = ( zfu(ji,jj,jk) + zfu(ji+1,jj  ,jk)                               &
+                  &                    - gamma2 * ( zlu_uu(ji,jj,jk,2) + zlu_uu(ji+1,jj  ,jk,2) )  )   &
+                  &                * ( zui - gamma1 * zl_u)
+               zfv_t(ji  ,jj+1,jk) = ( zfv(ji,jj,jk) + zfv(ji  ,jj+1,jk)                               &
+                  &                    - gamma2 * ( zlv_vv(ji,jj,jk,2) + zlv_vv(ji  ,jj+1,jk,2) )  )   &
+                  &                * ( zvj - gamma1 * zl_v)
+               !
+               zfuj = ( zfu(ji,jj,jk) + zfu(ji  ,jj+1,jk) )
+               zfvi = ( zfv(ji,jj,jk) + zfv(ji+1,jj  ,jk) )
+               IF( zfuj > 0 ) THEN   ;    zl_v = zlv_vu( ji  ,jj  ,jk,1)
+               ELSE                  ;    zl_v = zlv_vu( ji+1,jj,jk,1)
+               ENDIF
+               IF( zfvi > 0 ) THEN   ;    zl_u = zlu_uv( ji,jj  ,jk,1)
+               ELSE                  ;    zl_u = zlu_uv( ji,jj+1,jk,1)
+               ENDIF
+               !
+               zfv_f(ji  ,jj  ,jk) = ( zfvi - gamma2 * ( zlv_vu(ji,jj,jk,2) + zlv_vu(ji+1,jj  ,jk,2) )  )   &
+                  &                * ( un(ji,jj,jk) + un(ji  ,jj+1,jk) - gamma1 * zl_u )
+               zfu_f(ji  ,jj  ,jk) = ( zfuj - gamma2 * ( zlu_uv(ji,jj,jk,2) + zlu_uv(ji  ,jj+1,jk,2) )  )   &
+                  &                * ( vn(ji,jj,jk) + vn(ji+1,jj  ,jk) - gamma1 * zl_v )
+            END DO
+         END DO
+         DO jj = 2, jpjm1                          ! divergence of horizontal momentum fluxes
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) = ua(ji,jj,jk) - (  zfu_t(ji+1,jj,jk) - zfu_t(ji,jj  ,jk)    &
+                  &                           + zfv_f(ji  ,jj,jk) - zfv_f(ji,jj-1,jk)  ) * r1_e1e2u(ji,jj) / e3u_n(ji,jj,jk)
+               va(ji,jj,jk) = va(ji,jj,jk) - (  zfu_f(ji,jj  ,jk) - zfu_f(ji-1,jj,jk)    &
+                  &                           + zfv_t(ji,jj+1,jk) - zfv_t(ji  ,jj,jk)  ) * r1_e1e2v(ji,jj) / e3v_n(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      IF( l_trddyn ) THEN                          ! trends: send trends to trddyn for diagnostic
+         zfu_uw(:,:,:) = ua(:,:,:) - zfu_uw(:,:,:)
+         zfv_vw(:,:,:) = va(:,:,:) - zfv_vw(:,:,:)
+         CALL trd_dyn( zfu_uw, zfv_vw, jpdyn_keg, kt )
+         zfu_t(:,:,:) = ua(:,:,:)
+         zfv_t(:,:,:) = va(:,:,:)
+      ENDIF
+      !                                      ! ==================== !
+      !                                      !  Vertical advection  !
+      !                                      ! ==================== !
+      DO jj = 2, jpjm1                             ! surface/bottom advective fluxes set to zero                  
+         DO ji = fs_2, fs_jpim1
+            zfu_uw(ji,jj,jpk) = 0._wp
+            zfv_vw(ji,jj,jpk) = 0._wp
+            zfu_uw(ji,jj, 1 ) = 0._wp
+            zfv_vw(ji,jj, 1 ) = 0._wp
+         END DO
+      END DO
+      IF( ln_linssh ) THEN                         ! constant volume : advection through the surface
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zfu_uw(ji,jj,1) = 0.5_wp * ( e1e2t(ji,jj) * wn(ji,jj,1) + e1e2t(ji+1,jj) * wn(ji+1,jj,1) ) * un(ji,jj,1)
+               zfv_vw(ji,jj,1) = 0.5_wp * ( e1e2t(ji,jj) * wn(ji,jj,1) + e1e2t(ji,jj+1) * wn(ji,jj+1,1) ) * vn(ji,jj,1)
+            END DO
+         END DO
+      ENDIF
+      DO jk = 2, jpkm1                          ! interior fluxes
+         DO jj = 2, jpj
+            DO ji = 2, jpi
+               zfw(ji,jj,jk) = 0.25_wp * e1e2t(ji,jj) * wn(ji,jj,jk)
+            END DO
+         END DO
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zfu_uw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji+1,jj,jk) ) * ( un(ji,jj,jk) + un(ji,jj,jk-1) )
+               zfv_vw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji,jj,jk-1) )
+            END DO
+         END DO
+      END DO
+      DO jk = 1, jpkm1                          ! divergence of vertical momentum flux divergence
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ua(ji,jj,jk) =  ua(ji,jj,jk) - ( zfu_uw(ji,jj,jk) - zfu_uw(ji,jj,jk+1) ) * r1_e1e2u(ji,jj) / e3u_n(ji,jj,jk)
+               va(ji,jj,jk) =  va(ji,jj,jk) - ( zfv_vw(ji,jj,jk) - zfv_vw(ji,jj,jk+1) ) * r1_e1e2v(ji,jj) / e3v_n(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+      IF( l_trddyn ) THEN                       ! save the vertical advection trend for diagnostic
+         zfu_t(:,:,:) = ua(:,:,:) - zfu_t(:,:,:)
+         zfv_t(:,:,:) = va(:,:,:) - zfv_t(:,:,:)
+         CALL trd_dyn( zfu_t, zfv_t, jpdyn_zad, kt )
+      ENDIF
+      !                                         ! Control print
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' ubs2 adv - Ua: ', mask1=umask,   &
+         &                       tab3d_2=va, clinfo2=           ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,        zfu_t , zfv_t , zfu_f , zfv_f, zfu_uw, zfv_vw, zfu, zfv, zfw )
+      CALL wrk_dealloc( jpi,jpj,jpk,jpts,   zlu_uu, zlv_vv, zlu_uv, zlv_vu                               )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dyn_adv_ubs')
+      !
+   END SUBROUTINE dyn_adv_ubs
+
+   !!==============================================================================
+END MODULE dynadv_ubs
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/dynzdf_imp.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/dynzdf_imp.F90	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/dynzdf_imp.F90	(revision 7339)
@@ -0,0 +1,351 @@
+MODULE dynzdf_imp
+   !!======================================================================
+   !!                    ***  MODULE  dynzdf_imp  ***
+   !! Ocean dynamics:  vertical component(s) of the momentum mixing trend, implicit scheme
+   !!======================================================================
+   !! History :  OPA  !  1990-10  (B. Blanke)  Original code
+   !!            8.0  !  1997-05  (G. Madec)  vertical component of isopycnal
+   !!   NEMO     0.5  !  2002-08  (G. Madec)  F90: Free form and module
+   !!            3.3  !  2010-04  (M. Leclair, G. Madec)  Forcing averaged over 2 time steps
+   !!            3.4  !  2012-01  (H. Liu) Semi-implicit bottom friction
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_zdf_imp   : compute the vertical diffusion using a implicit scheme
+   !!                   together with the Leap-Frog time integration.
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE phycst         ! physical constants
+   USE dom_oce        ! ocean space and time domain
+   USE domvvl         ! variable volume
+   USE sbc_oce        ! surface boundary condition: ocean
+   USE dynadv   , ONLY: ln_dynadv_vec ! Momentum advection form
+   USE zdf_oce        ! ocean vertical physics
+   USE zdfbfr         ! Bottom friction setup
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_zdf_imp   ! called by step.F90
+
+   REAL(wp) ::  r_vvl     ! non-linear free surface indicator: =0 if ln_linssh=T, =1 otherwise 
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id: dynzdf_imp.F90 6140 2015-12-21 11:35:23Z timgraham $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dyn_zdf_imp( kt, p2dt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_zdf_imp  ***
+      !!                   
+      !! ** Purpose :   Compute the trend due to the vert. momentum diffusion
+      !!              together with the Leap-Frog time stepping using an 
+      !!              implicit scheme.
+      !!
+      !! ** Method  :  - Leap-Frog time stepping on all trends but the vertical mixing
+      !!         ua =         ub + 2*dt *       ua             vector form or linear free surf.
+      !!         ua = ( e3u_b*ub + 2*dt * e3u_n*ua ) / e3u_a   otherwise
+      !!               - update the after velocity with the implicit vertical mixing.
+      !!      This requires to solver the following system: 
+      !!         ua = ua + 1/e3u_a dk+1[ avmu / e3uw_a dk[ua] ]
+      !!      with the following surface/top/bottom boundary condition:
+      !!      surface: wind stress input (averaged over kt-1/2 & kt+1/2)
+      !!      top & bottom : top stress (iceshelf-ocean) & bottom stress (cf zdfbfr.F)
+      !!
+      !! ** Action :   (ua,va) after velocity 
+      !!---------------------------------------------------------------------
+      INTEGER , INTENT(in) ::  kt     ! ocean time-step index
+      REAL(wp), INTENT(in) ::  p2dt   ! vertical profile of tracer time-step
+      !
+      INTEGER  ::   ji, jj, jk    ! dummy loop indices
+      INTEGER  ::   ikbu, ikbv    ! local integers
+      REAL(wp) ::   zzwi, ze3ua   ! local scalars
+      REAL(wp) ::   zzws, ze3va   !   -      -
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zwi, zwd, zws
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dyn_zdf_imp')
+      !
+      CALL wrk_alloc( jpi,jpj,jpk, zwi, zwd, zws ) 
+      !
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_zdf_imp : vertical momentum diffusion implicit operator'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
+         !
+         If( ln_linssh ) THEN   ;    r_vvl = 0._wp    ! non-linear free surface indicator
+         ELSE                   ;    r_vvl = 1._wp
+         ENDIF
+      ENDIF
+      !
+      !              !==  Time step dynamics  ==!
+      !
+      IF( ln_dynadv_vec .OR. ln_linssh ) THEN      ! applied on velocity
+         DO jk = 1, jpkm1
+            ua(:,:,jk) = ( ub(:,:,jk) + p2dt * ua(:,:,jk) ) * umask(:,:,jk)
+            va(:,:,jk) = ( vb(:,:,jk) + p2dt * va(:,:,jk) ) * vmask(:,:,jk)
+         END DO
+      ELSE                                         ! applied on thickness weighted velocity
+         DO jk = 1, jpkm1
+            ua(:,:,jk) = (         e3u_b(:,:,jk) * ub(:,:,jk)  &
+               &          + p2dt * e3u_n(:,:,jk) * ua(:,:,jk)  ) / e3u_a(:,:,jk) * umask(:,:,jk)
+            va(:,:,jk) = (         e3v_b(:,:,jk) * vb(:,:,jk)  &
+               &          + p2dt * e3v_n(:,:,jk) * va(:,:,jk)  ) / e3v_a(:,:,jk) * vmask(:,:,jk)
+         END DO
+      ENDIF
+      !
+      !              !==  Apply semi-implicit bottom friction  ==!
+      !
+      ! Only needed for semi-implicit bottom friction setup. The explicit
+      ! bottom friction has been included in "u(v)a" which act as the R.H.S
+      ! column vector of the tri-diagonal matrix equation
+      !
+      IF( ln_bfrimp ) THEN
+         DO jj = 2, jpjm1
+            DO ji = 2, jpim1
+               ikbu = mbku(ji,jj)       ! ocean bottom level at u- and v-points 
+               ikbv = mbkv(ji,jj)       ! (deepest ocean u- and v-points)
+               avmu(ji,jj,ikbu+1) = -bfrua(ji,jj) * e3uw_n(ji,jj,ikbu+1)
+               avmv(ji,jj,ikbv+1) = -bfrva(ji,jj) * e3vw_n(ji,jj,ikbv+1)
+            END DO
+         END DO
+         IF ( ln_isfcav ) THEN
+            DO jj = 2, jpjm1
+               DO ji = 2, jpim1
+                  ikbu = miku(ji,jj)       ! ocean top level at u- and v-points 
+                  ikbv = mikv(ji,jj)       ! (first wet ocean u- and v-points)
+                  IF( ikbu >= 2 )   avmu(ji,jj,ikbu) = -tfrua(ji,jj) * e3uw_n(ji,jj,ikbu)
+                  IF( ikbv >= 2 )   avmv(ji,jj,ikbv) = -tfrva(ji,jj) * e3vw_n(ji,jj,ikbv)
+               END DO
+            END DO
+         END IF
+      ENDIF
+      !
+      ! With split-explicit free surface, barotropic stress is treated explicitly
+      ! Update velocities at the bottom.
+      ! J. Chanut: The bottom stress is computed considering after barotropic velocities, which does 
+      !            not lead to the effective stress seen over the whole barotropic loop. 
+      ! G. Madec : in linear free surface, e3u_a = e3u_n = e3u_0, so systematic use of e3u_a
+      IF( ln_bfrimp .AND. ln_dynspg_ts ) THEN
+         DO jk = 1, jpkm1        ! remove barotropic velocities
+            ua(:,:,jk) = ( ua(:,:,jk) - ua_b(:,:) ) * umask(:,:,jk)
+            va(:,:,jk) = ( va(:,:,jk) - va_b(:,:) ) * vmask(:,:,jk)
+         END DO
+         DO jj = 2, jpjm1        ! Add bottom/top stress due to barotropic component only
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ikbu = mbku(ji,jj)         ! ocean bottom level at u- and v-points 
+               ikbv = mbkv(ji,jj)         ! (deepest ocean u- and v-points)
+               ze3ua =  ( 1._wp - r_vvl ) * e3u_n(ji,jj,ikbu) + r_vvl * e3u_a(ji,jj,ikbu)
+               ze3va =  ( 1._wp - r_vvl ) * e3v_n(ji,jj,ikbv) + r_vvl * e3v_a(ji,jj,ikbv)
+               ua(ji,jj,ikbu) = ua(ji,jj,ikbu) + p2dt * bfrua(ji,jj) * ua_b(ji,jj) / ze3ua
+               va(ji,jj,ikbv) = va(ji,jj,ikbv) + p2dt * bfrva(ji,jj) * va_b(ji,jj) / ze3va
+            END DO
+         END DO
+         IF( ln_isfcav ) THEN    ! Ocean cavities (ISF)
+            DO jj = 2, jpjm1        
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ikbu = miku(ji,jj)         ! top ocean level at u- and v-points 
+                  ikbv = mikv(ji,jj)         ! (first wet ocean u- and v-points)
+                  ze3ua =  ( 1._wp - r_vvl ) * e3u_n(ji,jj,ikbu) + r_vvl * e3u_a(ji,jj,ikbu)
+                  ze3va =  ( 1._wp - r_vvl ) * e3v_n(ji,jj,ikbv) + r_vvl * e3v_a(ji,jj,ikbv)
+                  ua(ji,jj,ikbu) = ua(ji,jj,ikbu) + p2dt * tfrua(ji,jj) * ua_b(ji,jj) / ze3ua
+                  va(ji,jj,ikbv) = va(ji,jj,ikbv) + p2dt * tfrva(ji,jj) * va_b(ji,jj) / ze3va
+               END DO
+            END DO
+         END IF
+      ENDIF
+      !
+      !              !==  Vertical diffusion on u  ==!
+      !
+      ! Matrix and second member construction
+      ! bottom boundary condition: both zwi and zws must be masked as avmu can take
+      ! non zero value at the ocean bottom depending on the bottom friction used.
+      !
+      DO jk = 1, jpkm1        ! Matrix
+         DO jj = 2, jpjm1 
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ze3ua =  ( 1._wp - r_vvl ) * e3u_n(ji,jj,jk) + r_vvl * e3u_a(ji,jj,jk)   ! after scale factor at T-point
+               zzwi = - p2dt * avmu(ji,jj,jk  ) / ( ze3ua * e3uw_n(ji,jj,jk  ) )
+               zzws = - p2dt * avmu(ji,jj,jk+1) / ( ze3ua * e3uw_n(ji,jj,jk+1) )
+               zwi(ji,jj,jk) = zzwi * wumask(ji,jj,jk  )
+               zws(ji,jj,jk) = zzws * wumask(ji,jj,jk+1)
+               zwd(ji,jj,jk) = 1._wp - zzwi - zzws
+            END DO
+         END DO
+      END DO
+      DO jj = 2, jpjm1        ! Surface boundary conditions
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zwi(ji,jj,1) = 0._wp
+            zwd(ji,jj,1) = 1._wp - zws(ji,jj,1)
+         END DO
+      END DO
+
+      ! Matrix inversion starting from the first level
+      !-----------------------------------------------------------------------
+      !   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+      !
+      !        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+      !        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+      !        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+      !        (        ...               )( ...  ) ( ...  )
+      !        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+      !
+      !   m is decomposed in the product of an upper and a lower triangular matrix
+      !   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+      !   The solution (the after velocity) is in ua
+      !-----------------------------------------------------------------------
+      !
+      DO jk = 2, jpkm1        !==  First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1   (increasing k)  ==
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zwd(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) / zwd(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      !
+      DO jj = 2, jpjm1        !==  second recurrence:    SOLk = RHSk - Lk / Dk-1  Lk-1  ==!
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ze3ua =  ( 1._wp - r_vvl ) * e3u_n(ji,jj,1) + r_vvl * e3u_a(ji,jj,1) 
+            ua(ji,jj,1) = ua(ji,jj,1) + p2dt * 0.5_wp * ( utau_b(ji,jj) + utau(ji,jj) )   &
+               &                                      / ( ze3ua * rau0 ) * umask(ji,jj,1) 
+         END DO
+      END DO
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               ua(ji,jj,jk) = ua(ji,jj,jk) - zwi(ji,jj,jk) / zwd(ji,jj,jk-1) * ua(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      !
+      DO jj = 2, jpjm1        !==  thrid recurrence : SOLk = ( Lk - Uk * Ek+1 ) / Dk  ==!
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            ua(ji,jj,jpkm1) = ua(ji,jj,jpkm1) / zwd(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, 1, -1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               ua(ji,jj,jk) = ( ua(ji,jj,jk) - zws(ji,jj,jk) * ua(ji,jj,jk+1) ) / zwd(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+      !              !==  Vertical diffusion on v  ==!
+      !
+      ! Matrix and second member construction
+      ! bottom boundary condition: both zwi and zws must be masked as avmv can take
+      ! non zero value at the ocean bottom depending on the bottom friction used
+      !
+      DO jk = 1, jpkm1        ! Matrix
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               ze3va =  ( 1._wp - r_vvl ) * e3v_n(ji,jj,jk) + r_vvl * e3v_a(ji,jj,jk)   ! after scale factor at T-point
+               zzwi = - p2dt * avmv (ji,jj,jk  ) / ( ze3va * e3vw_n(ji,jj,jk  ) )
+               zzws = - p2dt * avmv (ji,jj,jk+1) / ( ze3va * e3vw_n(ji,jj,jk+1) )
+               zwi(ji,jj,jk) = zzwi * wvmask(ji,jj,jk  )
+               zws(ji,jj,jk) = zzws * wvmask(ji,jj,jk+1)
+               zwd(ji,jj,jk) = 1._wp - zzwi - zzws
+            END DO
+         END DO
+      END DO
+      DO jj = 2, jpjm1        ! Surface boundary conditions
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zwi(ji,jj,1) = 0._wp
+            zwd(ji,jj,1) = 1._wp - zws(ji,jj,1)
+         END DO
+      END DO
+
+      ! Matrix inversion
+      !-----------------------------------------------------------------------
+      !   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
+      !
+      !        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
+      !        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
+      !        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
+      !        (        ...               )( ...  ) ( ...  )
+      !        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
+      !
+      !   m is decomposed in the product of an upper and lower triangular matrix
+      !   The 3 diagonal terms are in 2d arrays: zwd, zws, zwi
+      !   The solution (after velocity) is in 2d array va
+      !-----------------------------------------------------------------------
+      !
+      DO jk = 2, jpkm1        !==  First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1   (increasing k)  ==
+         DO jj = 2, jpjm1   
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zwd(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) / zwd(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      !
+      DO jj = 2, jpjm1        !==  second recurrence:    SOLk = RHSk - Lk / Dk-1  Lk-1  ==!
+         DO ji = fs_2, fs_jpim1   ! vector opt.          
+            ze3va =  ( 1._wp - r_vvl ) * e3v_n(ji,jj,1) + r_vvl * e3v_a(ji,jj,1) 
+            va(ji,jj,1) = va(ji,jj,1) + p2dt * 0.5_wp * ( vtau_b(ji,jj) + vtau(ji,jj) )   &
+               &                                      / ( ze3va * rau0 ) * vmask(ji, jj, 1)
+         END DO
+      END DO
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               va(ji,jj,jk) = va(ji,jj,jk) - zwi(ji,jj,jk) / zwd(ji,jj,jk-1) * va(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      !
+      DO jj = 2, jpjm1        !==  third recurrence : SOLk = ( Lk - Uk * SOLk+1 ) / Dk  ==!
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            va(ji,jj,jpkm1) = va(ji,jj,jpkm1) / zwd(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, 1, -1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               va(ji,jj,jk) = ( va(ji,jj,jk) - zws(ji,jj,jk) * va(ji,jj,jk+1) ) / zwd(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      
+      ! J. Chanut: Lines below are useless ?
+      !! restore bottom layer avmu(v) 
+      !!gm  I almost sure it is !!!!
+      IF( ln_bfrimp ) THEN
+        DO jj = 2, jpjm1
+           DO ji = 2, jpim1
+              ikbu = mbku(ji,jj)         ! ocean bottom level at u- and v-points 
+              ikbv = mbkv(ji,jj)         ! (deepest ocean u- and v-points)
+              avmu(ji,jj,ikbu+1) = 0._wp
+              avmv(ji,jj,ikbv+1) = 0._wp
+           END DO
+        END DO
+        IF (ln_isfcav) THEN
+           DO jj = 2, jpjm1
+              DO ji = 2, jpim1
+                 ikbu = miku(ji,jj)         ! ocean top level at u- and v-points 
+                 ikbv = mikv(ji,jj)         ! (first wet ocean u- and v-points)
+                 IF( ikbu > 1 )   avmu(ji,jj,ikbu) = 0._wp
+                 IF( ikbv > 1 )   avmv(ji,jj,ikbv) = 0._wp
+              END DO
+           END DO
+        ENDIF
+      ENDIF
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,   zwi, zwd, zws) 
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('dyn_zdf_imp')
+      !
+   END SUBROUTINE dyn_zdf_imp
+
+   !!==============================================================================
+END MODULE dynzdf_imp
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/iom.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/iom.F90	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/MY_SRC/iom.F90	(revision 7339)
@@ -0,0 +1,1741 @@
+MODULE iom
+   !!=====================================================================
+   !!                    ***  MODULE  iom ***
+   !! Input/Output manager :  Library to read input files
+   !!====================================================================
+   !! History :  2.0  ! 2005-12  (J. Belier) Original code
+   !!            2.0  ! 2006-02  (S. Masson) Adaptation to NEMO
+   !!            3.0  ! 2007-07  (D. Storkey) Changes to iom_gettime
+   !!            3.4  ! 2012-12  (R. Bourdalle-Badie and G. Reffray)  add C1D case  
+   !!            3.6  ! 2014-15  DIMG format removed
+   !!--------------------------------------------------------------------
+
+   !!--------------------------------------------------------------------
+   !!   iom_open       : open a file read only
+   !!   iom_close      : close a file or all files opened by iom
+   !!   iom_get        : read a field (interfaced to several routines)
+   !!   iom_gettime    : read the time axis cdvar in the file
+   !!   iom_varid      : get the id of a variable in a file
+   !!   iom_rstput     : write a field in a restart file (interfaced to several routines)
+   !!--------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE c1d             ! 1D vertical configuration
+   USE flo_oce         ! floats module declarations
+   USE lbclnk          ! lateal boundary condition / mpp exchanges
+   USE iom_def         ! iom variables definitions
+   USE iom_nf90        ! NetCDF format with native NetCDF library
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp           ! MPP library
+#if defined key_iomput
+   USE sbc_oce, ONLY :   nn_fsbc         ! ocean space and time domain
+   USE trc_oce, ONLY :   nn_dttrc        !  !: frequency of step on passive tracers
+   USE icb_oce, ONLY :   nclasses, class_num       !  !: iceberg classes
+#if defined key_lim3
+   USE ice    , ONLY :   jpl
+#elif defined key_lim2
+   USE par_ice_2
+#endif
+   USE domngb          ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE dianam          ! build name of file
+   USE xios
+# endif
+   USE ioipsl, ONLY :  ju2ymds    ! for calendar
+   USE crs             ! Grid coarsening
+
+   IMPLICIT NONE
+   PUBLIC   !   must be public to be able to access iom_def through iom
+   
+#if defined key_iomput
+   LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .TRUE.        !: iom_put flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .FALSE.       !: iom_put flag
+#endif
+   PUBLIC iom_init, iom_swap, iom_open, iom_close, iom_setkt, iom_varid, iom_get, iom_gettime, iom_rstput, iom_put
+   PUBLIC iom_getatt, iom_use, iom_context_finalize
+
+   PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
+   PRIVATE iom_g0d, iom_g1d, iom_g2d, iom_g3d, iom_get_123d
+   PRIVATE iom_p1d, iom_p2d, iom_p3d
+#if defined key_iomput
+   PRIVATE iom_set_domain_attr, iom_set_axis_attr, iom_set_field_attr, iom_set_file_attr, iom_get_file_attr, iom_set_grid_attr
+   PRIVATE set_grid, set_grid_bounds, set_scalar, set_xmlatt, set_mooring, iom_update_file_name, iom_sdate
+# endif
+
+   INTERFACE iom_get
+      MODULE PROCEDURE iom_g0d, iom_g1d, iom_g2d, iom_g3d
+   END INTERFACE
+   INTERFACE iom_getatt
+      MODULE PROCEDURE iom_g0d_intatt
+   END INTERFACE
+   INTERFACE iom_rstput
+      MODULE PROCEDURE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d
+   END INTERFACE
+  INTERFACE iom_put
+     MODULE PROCEDURE iom_p0d, iom_p1d, iom_p2d, iom_p3d
+  END INTERFACE
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id: iom.F90 6140 2015-12-21 11:35:23Z timgraham $
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE iom_init( cdname ) 
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE   ***
+      !!
+      !! ** Purpose :   
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in)  :: cdname
+#if defined key_iomput
+      TYPE(xios_time)   :: dtime    = xios_time(0, 0, 0, 0, 0, 0)
+      CHARACTER(len=19) :: cldate 
+      CHARACTER(len=10) :: clname
+      INTEGER           ::   ji
+      !
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z_bnds
+      !!----------------------------------------------------------------------
+
+      ALLOCATE( z_bnds(jpk,2) )
+
+      clname = cdname
+      IF( TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(cdname)
+      CALL xios_context_initialize(TRIM(clname), mpi_comm_opa)
+      CALL iom_swap( cdname )
+
+      ! calendar parameters
+      SELECT CASE ( nleapy )        ! Choose calendar for IOIPSL
+      CASE ( 1)   ;   CALL xios_set_context_attr(TRIM(clname), calendar_type= "Gregorian")
+      CASE ( 0)   ;   CALL xios_set_context_attr(TRIM(clname), calendar_type= "NoLeap")
+      CASE (30)   ;   CALL xios_set_context_attr(TRIM(clname), calendar_type= "D360")
+      END SELECT
+      WRITE(cldate,"(i4.4,'-',i2.2,'-',i2.2,' 00:00:00')") nyear,nmonth,nday 
+      CALL xios_set_context_attr(TRIM(clname), start_date=cldate )
+
+      ! horizontal grid definition
+      CALL set_scalar
+
+      IF( TRIM(cdname) == TRIM(cxios_context) ) THEN  
+         CALL set_grid( "T", glamt, gphit ) 
+         CALL set_grid( "U", glamu, gphiu )
+         CALL set_grid( "V", glamv, gphiv )
+         CALL set_grid( "W", glamt, gphit )
+         CALL set_grid_znl( gphit )
+         !
+         IF( ln_cfmeta ) THEN   ! Add additional grid metadata
+            CALL iom_set_domain_attr("grid_T", area = e1e2t(nldi:nlei, nldj:nlej))
+            CALL iom_set_domain_attr("grid_U", area = e1e2u(nldi:nlei, nldj:nlej))
+            CALL iom_set_domain_attr("grid_V", area = e1e2v(nldi:nlei, nldj:nlej))
+            CALL iom_set_domain_attr("grid_W", area = e1e2t(nldi:nlei, nldj:nlej))
+            CALL set_grid_bounds( "T", glamf, gphif, glamt, gphit )
+            CALL set_grid_bounds( "U", glamv, gphiv, glamu, gphiu )
+            CALL set_grid_bounds( "V", glamu, gphiu, glamv, gphiv )
+            CALL set_grid_bounds( "W", glamf, gphif, glamt, gphit )
+         ENDIF
+      ENDIF
+
+      IF( TRIM(cdname) == TRIM(cxios_context)//"_crs" ) THEN  
+         CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
+         !
+         CALL set_grid( "T", glamt_crs, gphit_crs ) 
+         CALL set_grid( "U", glamu_crs, gphiu_crs ) 
+         CALL set_grid( "V", glamv_crs, gphiv_crs ) 
+         CALL set_grid( "W", glamt_crs, gphit_crs ) 
+         CALL set_grid_znl( gphit_crs )
+          !
+         CALL dom_grid_glo   ! Return to parent grid domain
+         !
+         IF( ln_cfmeta ) THEN   ! Add additional grid metadata
+            CALL iom_set_domain_attr("grid_T", area = e1e2t_crs(nldi:nlei, nldj:nlej))
+            CALL iom_set_domain_attr("grid_U", area = e1u_crs(nldi:nlei, nldj:nlej) * e2u_crs(nldi:nlei, nldj:nlej))
+            CALL iom_set_domain_attr("grid_V", area = e1v_crs(nldi:nlei, nldj:nlej) * e2v_crs(nldi:nlei, nldj:nlej))
+            CALL iom_set_domain_attr("grid_W", area = e1e2t_crs(nldi:nlei, nldj:nlej))
+            CALL set_grid_bounds( "T", glamf_crs, gphif_crs, glamt_crs, gphit_crs )
+            CALL set_grid_bounds( "U", glamv_crs, gphiv_crs, glamu_crs, gphiu_crs )
+            CALL set_grid_bounds( "V", glamu_crs, gphiu_crs, glamv_crs, gphiv_crs )
+            CALL set_grid_bounds( "W", glamf_crs, gphif_crs, glamt_crs, gphit_crs )
+         ENDIF
+      ENDIF
+
+      ! vertical grid definition
+      CALL iom_set_axis_attr( "deptht", gdept_1d )
+      CALL iom_set_axis_attr( "depthu", gdept_1d )
+      CALL iom_set_axis_attr( "depthv", gdept_1d )
+      CALL iom_set_axis_attr( "depthw", gdepw_1d )
+
+      ! Add vertical grid bounds
+      z_bnds(:      ,1) = gdepw_1d(:)
+      z_bnds(1:jpkm1,2) = gdepw_1d(2:jpk)
+      z_bnds(jpk:   ,2) = gdepw_1d(jpk) + e3t_1d(jpk)
+      !CALL iom_set_axis_attr( "deptht", bounds=z_bnds )
+      !CALL iom_set_axis_attr( "depthu", bounds=z_bnds )
+      !CALL iom_set_axis_attr( "depthv", bounds=z_bnds )
+      z_bnds(:    ,2) = gdept_1d(:)
+      z_bnds(2:jpk,1) = gdept_1d(1:jpkm1)
+      z_bnds(1    ,1) = gdept_1d(1) - e3w_1d(1)
+      !CALL iom_set_axis_attr( "depthw", bounds=z_bnds )
+
+# if defined key_floats
+      CALL iom_set_axis_attr( "nfloat", (/ (REAL(ji,wp), ji=1,nfloat) /) )
+# endif
+#if defined key_lim3 || defined key_lim2
+      CALL iom_set_axis_attr( "ncatice", (/ (REAL(ji,wp), ji=1,jpl) /) )
+#endif
+      CALL iom_set_axis_attr( "icbcla", class_num )
+      CALL iom_set_axis_attr( "iax_20C", (/ REAL(20,wp) /) )
+      CALL iom_set_axis_attr( "iax_28C", (/ REAL(28,wp) /) )
+      
+      ! automatic definitions of some of the xml attributs
+      CALL set_xmlatt
+
+      ! end file definition
+      dtime%second = rdt
+      CALL xios_set_timestep(dtime)
+      CALL xios_close_context_definition()
+      
+      CALL xios_update_calendar(0)
+
+      DEALLOCATE( z_bnds )
+
+#endif
+      
+   END SUBROUTINE iom_init
+
+
+   SUBROUTINE iom_swap( cdname )
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_swap  ***
+      !!
+      !! ** Purpose :  swap context between different agrif grid for xmlio_server
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in) :: cdname
+#if defined key_iomput
+      TYPE(xios_context) :: nemo_hdl
+
+      IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+        CALL xios_get_handle(TRIM(cdname),nemo_hdl)
+      ELSE
+        CALL xios_get_handle(TRIM(Agrif_CFixed())//"_"//TRIM(cdname),nemo_hdl)
+      ENDIF
+      !
+      CALL xios_set_current_context(nemo_hdl)
+#endif
+      !
+   END SUBROUTINE iom_swap
+
+
+   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof )
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_open  ***
+      !!
+      !! ** Purpose :  open an input file (return 0 if not found)
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in   )           ::   cdname   ! File name
+      INTEGER         , INTENT(  out)           ::   kiomid   ! iom identifier of the opened file
+      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldwrt    ! open in write modeb          (default = .FALSE.)
+      INTEGER         , INTENT(in   ), OPTIONAL ::   kdom     ! Type of domain to be written (default = jpdom_local_noovlap)
+      INTEGER         , INTENT(in   ), OPTIONAL ::   kiolib   ! library used to open the file (default = jpnf90) 
+      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.)
+      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.)
+
+      CHARACTER(LEN=256)    ::   clname    ! the name of the file based on cdname [[+clcpu]+clcpu]
+      CHARACTER(LEN=256)    ::   cltmpn    ! tempory name to store clname (in writting mode)
+      CHARACTER(LEN=10)     ::   clsuffix  ! ".nc" 
+      CHARACTER(LEN=15)     ::   clcpu     ! the cpu number (max jpmax_digits digits)
+      CHARACTER(LEN=256)    ::   clinfo    ! info character
+      LOGICAL               ::   llok      ! check the existence 
+      LOGICAL               ::   llwrt     ! local definition of ldwrt
+      LOGICAL               ::   llnoov    ! local definition to read overlap
+      LOGICAL               ::   llstop    ! local definition of ldstop
+      LOGICAL               ::   lliof     ! local definition of ldiof
+      INTEGER               ::   iolib     ! library do we use to open the file
+      INTEGER               ::   icnt      ! counter for digits in clcpu (max = jpmax_digits)
+      INTEGER               ::   iln, ils  ! lengths of character
+      INTEGER               ::   idom      ! type of domain
+      INTEGER               ::   istop     ! 
+      INTEGER, DIMENSION(2,5) ::   idompar ! domain parameters: 
+      ! local number of points for x,y dimensions
+      ! position of first local point for x,y dimensions
+      ! position of last local point for x,y dimensions
+      ! start halo size for x,y dimensions
+      ! end halo size for x,y dimensions
+      !---------------------------------------------------------------------
+      ! Initializations and control
+      ! =============
+      kiomid = -1
+      clinfo = '                    iom_open ~~~  '
+      istop = nstop
+      ! if iom_open is called for the first time: initialize iom_file(:)%nfid to 0
+      ! (could be done when defining iom_file in f95 but not in f90)
+      IF( Agrif_Root() ) THEN
+         IF( iom_open_init == 0 ) THEN
+            iom_file(:)%nfid = 0
+            iom_open_init = 1
+         ENDIF
+      ENDIF
+      ! do we read or write the file?
+      IF( PRESENT(ldwrt) ) THEN   ;   llwrt = ldwrt
+      ELSE                        ;   llwrt = .FALSE.
+      ENDIF
+      ! do we call ctl_stop if we try to open a non-existing file in read mode?
+      IF( PRESENT(ldstop) ) THEN   ;   llstop = ldstop
+      ELSE                         ;   llstop = .TRUE.
+      ENDIF
+      ! what library do we use to open the file?
+      IF( PRESENT(kiolib) ) THEN   ;   iolib = kiolib
+      ELSE                         ;   iolib = jpnf90
+      ENDIF
+      ! are we using interpolation on the fly?
+      IF( PRESENT(ldiof) ) THEN   ;   lliof = ldiof
+      ELSE                        ;   lliof = .FALSE.
+      ENDIF
+      ! do we read the overlap 
+      ! ugly patch SM+JMM+RB to overwrite global definition in some cases
+      llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif 
+      ! create the file name by added, if needed, TRIM(Agrif_CFixed()) and TRIM(clsuffix)
+      ! =============
+      clname   = trim(cdname)
+      IF ( .NOT. Agrif_Root() .AND. .NOT. lliof ) THEN
+         iln    = INDEX(clname,'/') 
+         cltmpn = clname(1:iln)
+         clname = clname(iln+1:LEN_TRIM(clname))
+         clname=TRIM(cltmpn)//TRIM(Agrif_CFixed())//'_'//TRIM(clname)
+      ENDIF
+      ! which suffix should we use?
+      SELECT CASE (iolib)
+      CASE (jpnf90   ) ;   clsuffix = '.nc'
+      CASE DEFAULT     ;   clsuffix = ''
+         CALL ctl_stop( TRIM(clinfo), 'accepted IO library is only jpnf90 (jpioipsl option has been removed) ' )
+      END SELECT
+      ! Add the suffix if needed
+      iln = LEN_TRIM(clname)
+      ils = LEN_TRIM(clsuffix)
+      IF( iln <= ils .OR. INDEX( TRIM(clname), TRIM(clsuffix), back = .TRUE. ) /= iln - ils + 1 )   &
+         &   clname = TRIM(clname)//TRIM(clsuffix)
+      cltmpn = clname   ! store this name
+      ! try to find if the file to be opened already exist
+      ! =============
+      INQUIRE( FILE = clname, EXIST = llok )
+      IF( .NOT.llok ) THEN
+         ! we try to add the cpu number to the name
+         WRITE(clcpu,*) narea-1
+
+         clcpu  = TRIM(ADJUSTL(clcpu))
+         iln = INDEX(clname,TRIM(clsuffix), back = .TRUE.)
+         clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix)
+         icnt = 0
+         INQUIRE( FILE = clname, EXIST = llok ) 
+         ! we try different formats for the cpu number by adding 0
+         DO WHILE( .NOT.llok .AND. icnt < jpmax_digits )
+            clcpu  = "0"//trim(clcpu)
+            clname = clname(1:iln-1)//'_'//TRIM(clcpu)//TRIM(clsuffix)
+            INQUIRE( FILE = clname, EXIST = llok )
+            icnt = icnt + 1
+         END DO
+      ENDIF
+      IF( llwrt ) THEN
+         ! check the domain definition
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!         idom = jpdom_local_noovlap   ! default definition
+         IF( llnoov ) THEN   ;   idom = jpdom_local_noovlap   ! default definition
+         ELSE                ;   idom = jpdom_local_full      ! default definition
+         ENDIF
+         IF( PRESENT(kdom) )   idom = kdom
+         ! create the domain informations
+         ! =============
+         SELECT CASE (idom)
+         CASE (jpdom_local_full)
+            idompar(:,1) = (/ jpi             , jpj              /)
+            idompar(:,2) = (/ nimpp           , njmpp            /)
+            idompar(:,3) = (/ nimpp + jpi - 1 , njmpp + jpj - 1  /)
+            idompar(:,4) = (/ nldi - 1        , nldj - 1         /)
+            idompar(:,5) = (/ jpi - nlei      , jpj - nlej       /)
+         CASE (jpdom_local_noextra)
+            idompar(:,1) = (/ nlci            , nlcj             /)
+            idompar(:,2) = (/ nimpp           , njmpp            /)
+            idompar(:,3) = (/ nimpp + nlci - 1, njmpp + nlcj - 1 /)
+            idompar(:,4) = (/ nldi - 1        , nldj - 1         /)
+            idompar(:,5) = (/ nlci - nlei     , nlcj - nlej      /)
+         CASE (jpdom_local_noovlap)
+            idompar(:,1) = (/ nlei  - nldi + 1, nlej  - nldj + 1 /)
+            idompar(:,2) = (/ nimpp + nldi - 1, njmpp + nldj - 1 /)
+            idompar(:,3) = (/ nimpp + nlei - 1, njmpp + nlej - 1 /)
+            idompar(:,4) = (/ 0               , 0                /)
+            idompar(:,5) = (/ 0               , 0                /)
+         CASE DEFAULT
+            CALL ctl_stop( TRIM(clinfo), 'wrong value of kdom, only jpdom_local* cases are accepted' )
+         END SELECT
+      ENDIF
+      ! Open the NetCDF file
+      ! =============
+      ! do we have some free file identifier?
+      IF( MINVAL(iom_file(:)%nfid) /= 0 )   &
+         &   CALL ctl_stop( TRIM(clinfo), 'No more free file identifier', 'increase jpmax_files in iom_def' )
+      ! if no file was found...
+      IF( .NOT. llok ) THEN
+         IF( .NOT. llwrt ) THEN   ! we are in read mode 
+            IF( llstop ) THEN   ;   CALL ctl_stop( TRIM(clinfo), 'File '//TRIM(cltmpn)//'* not found' )
+            ELSE                ;   istop = nstop + 1   ! make sure that istop /= nstop so we don't open the file
+            ENDIF
+         ELSE                     ! we are in write mode so we 
+            clname = cltmpn       ! get back the file name without the cpu number
+         ENDIF
+      ELSE
+         IF( llwrt .AND. .NOT. ln_clobber ) THEN   ! we stop as we want to write in a new file 
+            CALL ctl_stop( TRIM(clinfo), 'We want to write in a new file but '//TRIM(clname)//' already exists...' )
+            istop = nstop + 1                      ! make sure that istop /= nstop so we don't open the file
+         ELSEIF( llwrt ) THEN     ! the file exists and we are in write mode with permission to 
+            clname = cltmpn       ! overwrite so get back the file name without the cpu number
+         ENDIF
+      ENDIF
+      IF( istop == nstop ) THEN   ! no error within this routine
+         SELECT CASE (iolib)
+         CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar )
+         CASE DEFAULT
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed) ' )
+         END SELECT
+      ENDIF
+      !
+   END SUBROUTINE iom_open
+
+
+   SUBROUTINE iom_close( kiomid )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_close  ***
+      !!
+      !! ** Purpose : close an input file, or all files opened by iom
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT(inout), OPTIONAL ::   kiomid   ! iom identifier of the file to be closed
+      !                                              ! return 0 when file is properly closed
+      !                                              ! No argument: all files opened by iom are closed
+
+      INTEGER ::   jf         ! dummy loop indices
+      INTEGER ::   i_s, i_e   ! temporary integer
+      CHARACTER(LEN=100)    ::   clinfo    ! info character
+      !---------------------------------------------------------------------
+      !
+      clinfo = '                    iom_close ~~~  '
+      IF( PRESENT(kiomid) ) THEN
+         i_s = kiomid
+         i_e = kiomid
+      ELSE
+         i_s = 1
+         i_e = jpmax_files
+      ENDIF
+
+      IF( i_s > 0 ) THEN
+         DO jf = i_s, i_e
+            IF( iom_file(jf)%nfid > 0 ) THEN
+               SELECT CASE (iom_file(jf)%iolib)
+               CASE (jpnf90   )   ;   CALL iom_nf90_close(    jf )
+               CASE DEFAULT
+                  CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
+               END SELECT
+               iom_file(jf)%nfid       = 0          ! free the id 
+               IF( PRESENT(kiomid) )   kiomid = 0   ! return 0 as id to specify that the file was closed
+               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' close file: '//TRIM(iom_file(jf)%name)//' ok'
+            ELSEIF( PRESENT(kiomid) ) THEN
+               WRITE(ctmp1,*) '--->',  kiomid
+               CALL ctl_stop( TRIM(clinfo)//' Invalid file identifier', ctmp1 )
+            ENDIF
+         END DO
+      ENDIF
+      !    
+   END SUBROUTINE iom_close
+
+
+   FUNCTION iom_varid ( kiomid, cdvar, kdimsz, kndims, ldstop )  
+      !!-----------------------------------------------------------------------
+      !!                  ***  FUNCTION  iom_varid  ***
+      !!
+      !! ** Purpose : get the id of a variable in a file (return 0 if not found)
+      !!-----------------------------------------------------------------------
+      INTEGER              , INTENT(in   )           ::   kiomid   ! file Identifier
+      CHARACTER(len=*)     , INTENT(in   )           ::   cdvar    ! name of the variable
+      INTEGER, DIMENSION(:), INTENT(  out), OPTIONAL ::   kdimsz   ! size of the dimensions
+      INTEGER,               INTENT(  out), OPTIONAL ::   kndims   ! size of the dimensions
+      LOGICAL              , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if looking for non-existing variable (default = .TRUE.)
+      !
+      INTEGER                        ::   iom_varid, iiv, i_nvd
+      LOGICAL                        ::   ll_fnd
+      CHARACTER(LEN=100)             ::   clinfo                   ! info character
+      LOGICAL                        ::   llstop                   ! local definition of ldstop
+      !!-----------------------------------------------------------------------
+      iom_varid = 0                         ! default definition
+      ! do we call ctl_stop if we look for non-existing variable?
+      IF( PRESENT(ldstop) ) THEN   ;   llstop = ldstop
+      ELSE                         ;   llstop = .TRUE.
+      ENDIF
+      !
+      IF( kiomid > 0 ) THEN
+         clinfo = 'iom_varid, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(cdvar)
+         IF( iom_file(kiomid)%nfid == 0 ) THEN 
+            CALL ctl_stop( trim(clinfo), 'the file is not open' )
+         ELSE
+            ll_fnd  = .FALSE.
+            iiv = 0
+            !
+            DO WHILE ( .NOT.ll_fnd .AND. iiv < iom_file(kiomid)%nvars )
+               iiv = iiv + 1
+               ll_fnd  = ( TRIM(cdvar) == TRIM(iom_file(kiomid)%cn_var(iiv)) )
+            END DO
+            !
+            IF( .NOT.ll_fnd ) THEN
+               iiv = iiv + 1
+               IF( iiv <= jpmax_vars ) THEN
+                  SELECT CASE (iom_file(kiomid)%iolib)
+                  CASE (jpnf90   )   ;   iom_varid = iom_nf90_varid  ( kiomid, cdvar, iiv, kdimsz, kndims )
+                  CASE DEFAULT
+                     CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
+                  END SELECT
+               ELSE
+                  CALL ctl_stop( trim(clinfo), 'Too many variables in the file '//iom_file(kiomid)%name,   &
+                        &                         'increase the parameter jpmax_vars')
+               ENDIF
+               IF( llstop .AND. iom_varid == -1 )   CALL ctl_stop( TRIM(clinfo)//' not found' ) 
+            ELSE
+               iom_varid = iiv
+               IF( PRESENT(kdimsz) ) THEN 
+                  i_nvd = iom_file(kiomid)%ndims(iiv)
+                  IF( i_nvd == size(kdimsz) ) THEN
+                     kdimsz(:) = iom_file(kiomid)%dimsz(1:i_nvd,iiv)
+                  ELSE
+                     WRITE(ctmp1,*) i_nvd, size(kdimsz)
+                     CALL ctl_stop( trim(clinfo), 'error in kdimsz size'//trim(ctmp1) )
+                  ENDIF
+               ENDIF
+               IF( PRESENT(kndims) )  kndims = iom_file(kiomid)%ndims(iiv)
+            ENDIF
+         ENDIF
+      ENDIF
+      !
+   END FUNCTION iom_varid
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_get
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_g0d( kiomid, cdvar, pvar, ktime )
+      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*), INTENT(in   )                 ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out)                 ::   pvar      ! read field
+      INTEGER         , INTENT(in   ),     OPTIONAL   ::   ktime     ! record number
+      !
+      INTEGER                                         ::   idvar     ! variable id
+      INTEGER                                         ::   idmspc    ! number of spatial dimensions
+      INTEGER         , DIMENSION(1)                  ::   itime     ! record number
+      CHARACTER(LEN=100)                              ::   clinfo    ! info character
+      CHARACTER(LEN=100)                              ::   clname    ! file name
+      CHARACTER(LEN=1)                                ::   cldmspc   !
+      !
+      itime = 1
+      IF( PRESENT(ktime) ) itime = ktime
+      !
+      clname = iom_file(kiomid)%name
+      clinfo = '          iom_g0d, file: '//trim(clname)//', var: '//trim(cdvar)
+      !
+      IF( kiomid > 0 ) THEN
+         idvar = iom_varid( kiomid, cdvar )
+         IF( iom_file(kiomid)%nfid > 0 .AND. idvar > 0 ) THEN
+            idmspc = iom_file ( kiomid )%ndims( idvar )
+            IF( iom_file(kiomid)%luld(idvar) )  idmspc = idmspc - 1
+            WRITE(cldmspc , fmt='(i1)') idmspc
+            IF( idmspc > 0 )  CALL ctl_stop( TRIM(clinfo), 'When reading to a 0D array, we do not accept data', &
+                                 &                         'with 1 or more spatial dimensions: '//cldmspc//' were found.' , &
+                                 &                         'Use ncwa -a to suppress the unnecessary dimensions' )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, pvar, itime )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_g0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_g0d
+
+   SUBROUTINE iom_g1d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
+      INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                         ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out), DIMENSION(:)           ::   pvar      ! read field
+      INTEGER         , INTENT(in   )              , OPTIONAL ::   ktime     ! record number
+      INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kcount    ! number of points in each axis
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r1d=pvar,   &
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
+      ENDIF
+   END SUBROUTINE iom_g1d
+
+   SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr )
+      INTEGER         , INTENT(in   )                           ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                           ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                           ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out), DIMENSION(:,:)           ::   pvar      ! read field
+      INTEGER         , INTENT(in   )                , OPTIONAL ::   ktime     ! record number
+      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kcount    ! number of points in each axis
+      LOGICAL         , INTENT(in   )                , OPTIONAL ::   lrowattr  ! logical flag telling iom_get to
+                                                                               ! look for and use a file attribute
+                                                                               ! called open_ocean_jstart to set the start
+                                                                               ! value for the 2nd dimension (netcdf only)
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r2d=pvar,   &
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
+              &                                                     lrowattr=lrowattr )
+      ENDIF
+   END SUBROUTINE iom_g2d
+
+   SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr )
+      INTEGER         , INTENT(in   )                             ::   kiomid    ! Identifier of the file
+      INTEGER         , INTENT(in   )                             ::   kdom      ! Type of domain to be read
+      CHARACTER(len=*), INTENT(in   )                             ::   cdvar     ! Name of the variable
+      REAL(wp)        , INTENT(  out), DIMENSION(:,:,:)           ::   pvar      ! read field
+      INTEGER         , INTENT(in   )                  , OPTIONAL ::   ktime     ! record number
+      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kstart    ! start axis position of the reading 
+      INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kcount    ! number of points in each axis
+      LOGICAL         , INTENT(in   )                  , OPTIONAL ::   lrowattr  ! logical flag telling iom_get to
+                                                                                 ! look for and use a file attribute
+                                                                                 ! called open_ocean_jstart to set the start
+                                                                                 ! value for the 2nd dimension (netcdf only)
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r3d=pvar,   &
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
+              &                                                     lrowattr=lrowattr )
+      ENDIF
+   END SUBROUTINE iom_g3d
+   !!----------------------------------------------------------------------
+
+   SUBROUTINE iom_get_123d( kiomid, kdom  , cdvar ,   &
+         &                  pv_r1d, pv_r2d, pv_r3d,   &
+         &                  ktime , kstart, kcount,   &
+         &                  lrowattr                )
+      !!-----------------------------------------------------------------------
+      !!                  ***  ROUTINE  iom_get_123d  ***
+      !!
+      !! ** Purpose : read a 1D/2D/3D variable
+      !!
+      !! ** Method : read ONE record at each CALL
+      !!-----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   )           ::   kiomid     ! Identifier of the file
+      INTEGER                    , INTENT(in   )           ::   kdom       ! Type of domain to be read
+      CHARACTER(len=*)           , INTENT(in   )           ::   cdvar      ! Name of the variable
+      REAL(wp), DIMENSION(:)     , INTENT(  out), OPTIONAL ::   pv_r1d     ! read field (1D case)
+      REAL(wp), DIMENSION(:,:)   , INTENT(  out), OPTIONAL ::   pv_r2d     ! read field (2D case)
+      REAL(wp), DIMENSION(:,:,:) , INTENT(  out), OPTIONAL ::   pv_r3d     ! read field (3D case)
+      INTEGER                    , INTENT(in   ), OPTIONAL ::   ktime      ! record number
+      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kstart     ! start position of the reading in each axis 
+      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount     ! number of points to be read in each axis
+      LOGICAL                    , INTENT(in   ), OPTIONAL ::   lrowattr   ! logical flag telling iom_get to
+                                                                           ! look for and use a file attribute
+                                                                           ! called open_ocean_jstart to set the start
+                                                                           ! value for the 2nd dimension (netcdf only)
+      !
+      LOGICAL                        ::   llnoov      ! local definition to read overlap
+      LOGICAL                        ::   luse_jattr  ! local definition to read open_ocean_jstart file attribute
+      INTEGER                        ::   jstartrow   ! start point for 2nd dimension optionally set by file attribute
+      INTEGER                        ::   jl          ! loop on number of dimension 
+      INTEGER                        ::   idom        ! type of domain
+      INTEGER                        ::   idvar       ! id of the variable
+      INTEGER                        ::   inbdim      ! number of dimensions of the variable
+      INTEGER                        ::   idmspc      ! number of spatial dimensions 
+      INTEGER                        ::   itime       ! record number
+      INTEGER                        ::   istop       ! temporary value of nstop
+      INTEGER                        ::   ix1, ix2, iy1, iy2   ! subdomain indexes
+      INTEGER                        ::   ji, jj      ! loop counters
+      INTEGER                        ::   irankpv     ! 
+      INTEGER                        ::   ind1, ind2  ! substring index
+      INTEGER, DIMENSION(jpmax_dims) ::   istart      ! starting point to read for each axis
+      INTEGER, DIMENSION(jpmax_dims) ::   icnt        ! number of value to read along each axis 
+      INTEGER, DIMENSION(jpmax_dims) ::   idimsz      ! size of the dimensions of the variable
+      INTEGER, DIMENSION(jpmax_dims) ::   ishape      ! size of the dimensions of the variable
+      REAL(wp)                       ::   zscf, zofs  ! sacle_factor and add_offset
+      INTEGER                        ::   itmp        ! temporary integer
+      CHARACTER(LEN=256)             ::   clinfo      ! info character
+      CHARACTER(LEN=256)             ::   clname      ! file name
+      CHARACTER(LEN=1)               ::   clrankpv, cldmspc      ! 
+      LOGICAL                        ::   ll_depth_spec ! T => if kstart, kcount present then *only* use values for 3rd spatial dimension.
+      !---------------------------------------------------------------------
+      !
+      clname = iom_file(kiomid)%name   !   esier to read
+      clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar)
+      ! local definition of the domain ?
+      idom = kdom
+      ! do we read the overlap 
+      ! ugly patch SM+JMM+RB to overwrite global definition in some cases
+      llnoov = (jpni * jpnj ) == jpnij .AND. .NOT. lk_agrif 
+      ! check kcount and kstart optionals parameters...
+      IF( PRESENT(kcount) .AND. (.NOT. PRESENT(kstart)) ) CALL ctl_stop(trim(clinfo), 'kcount present needs kstart present')
+      IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present')
+      IF( PRESENT(kstart) .AND. idom /= jpdom_unknown .AND.  idom /= jpdom_autoglo_xy  ) &
+     &           CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown or kdom = jpdom_autoglo_xy')
+
+      luse_jattr = .false.
+      IF( PRESENT(lrowattr) ) THEN
+         IF( lrowattr .AND. idom /= jpdom_data   ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data')
+         IF( lrowattr .AND. idom == jpdom_data   ) luse_jattr = .true.
+      ENDIF
+      IF( luse_jattr ) THEN
+         SELECT CASE (iom_file(kiomid)%iolib)
+         CASE (jpnf90   )   
+             ! Ok
+         CASE DEFAULT    
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
+         END SELECT
+      ENDIF
+
+      ! Search for the variable in the data base (eventually actualize data)
+      istop = nstop
+      idvar = iom_varid( kiomid, cdvar )
+      !
+      IF( idvar > 0 ) THEN
+         ! to write iom_file(kiomid)%dimsz in a shorter way !
+         idimsz(:) = iom_file(kiomid)%dimsz(:, idvar) 
+         inbdim = iom_file(kiomid)%ndims(idvar)            ! number of dimensions in the file
+         idmspc = inbdim                                   ! number of spatial dimensions in the file
+         IF( iom_file(kiomid)%luld(idvar) )   idmspc = inbdim - 1
+         IF( idmspc > 3 )   CALL ctl_stop(trim(clinfo), 'the file has more than 3 spatial dimensions this case is not coded...') 
+         !
+         ! update idom definition...
+         ! Identify the domain in case of jpdom_auto(glo/dta) definition
+         IF( idom == jpdom_autoglo_xy ) THEN
+            ll_depth_spec = .TRUE.
+            idom = jpdom_autoglo
+         ELSE
+            ll_depth_spec = .FALSE.
+         ENDIF
+         IF( idom == jpdom_autoglo .OR. idom == jpdom_autodta ) THEN            
+            IF( idom == jpdom_autoglo ) THEN   ;   idom = jpdom_global 
+            ELSE                               ;   idom = jpdom_data
+            ENDIF
+            ind1 = INDEX( clname, '_', back = .TRUE. ) + 1
+            ind2 = INDEX( clname, '.', back = .TRUE. ) - 1
+            IF( ind2 > ind1 ) THEN   ;   IF( VERIFY( clname(ind1:ind2), '0123456789' ) == 0 )   idom = jpdom_local   ;   ENDIF
+         ENDIF
+         ! Identify the domain in case of jpdom_local definition
+         IF( idom == jpdom_local ) THEN
+            IF(     idimsz(1) == jpi               .AND. idimsz(2) == jpj               ) THEN   ;   idom = jpdom_local_full
+            ELSEIF( idimsz(1) == nlci              .AND. idimsz(2) == nlcj              ) THEN   ;   idom = jpdom_local_noextra
+            ELSEIF( idimsz(1) == (nlei - nldi + 1) .AND. idimsz(2) == (nlej - nldj + 1) ) THEN   ;   idom = jpdom_local_noovlap
+            ELSE   ;   CALL ctl_stop( trim(clinfo), 'impossible to identify the local domain' )
+            ENDIF
+         ENDIF
+         !
+         ! check the consistency between input array and data rank in the file
+         !
+         ! initializations
+         itime = 1
+         IF( PRESENT(ktime) ) itime = ktime
+
+         irankpv = 1 * COUNT( (/PRESENT(pv_r1d)/) ) + 2 * COUNT( (/PRESENT(pv_r2d)/) ) + 3 * COUNT( (/PRESENT(pv_r3d)/) )
+         WRITE(clrankpv, fmt='(i1)') irankpv
+         WRITE(cldmspc , fmt='(i1)') idmspc
+         !
+         IF(     idmspc <  irankpv ) THEN 
+            CALL ctl_stop( TRIM(clinfo), 'The file has only '//cldmspc//' spatial dimension',   &
+               &                         'it is impossible to read a '//clrankpv//'D array from this file...' )
+         ELSEIF( idmspc == irankpv ) THEN
+            IF( PRESENT(pv_r1d) .AND. idom /= jpdom_unknown )   &
+               &   CALL ctl_stop( TRIM(clinfo), 'case not coded...You must use jpdom_unknown' )
+         ELSEIF( idmspc >  irankpv ) THEN
+               IF( PRESENT(pv_r2d) .AND. itime == 1 .AND. idimsz(3) == 1 .AND. idmspc == 3 ) THEN
+                  CALL ctl_warn( trim(clinfo), '2D array but 3 spatial dimensions for the data...'              ,   &
+                        &         'As the size of the z dimension is 1 and as we try to read the first record, ',   &
+                        &         'we accept this case, even if there is a possible mix-up between z and time dimension' )   
+                  idmspc = idmspc - 1
+               ELSE
+                  CALL ctl_stop( TRIM(clinfo), 'To keep iom lisibility, when reading a '//clrankpv//'D array,'         ,   &
+                     &                         'we do not accept data with '//cldmspc//' spatial dimensions',   &
+                     &                         'Use ncwa -a to suppress the unnecessary dimensions' )
+               ENDIF
+         ENDIF
+
+         !
+         ! definition of istart and icnt
+         !
+         icnt  (:) = 1
+         istart(:) = 1
+         istart(idmspc+1) = itime
+
+         IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN ; istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc)
+         ELSE
+            IF(           idom == jpdom_unknown ) THEN                                                ; icnt(1:idmspc) = idimsz(1:idmspc)
+            ELSE 
+               IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array
+                  IF(     idom == jpdom_data    ) THEN
+                     jstartrow = 1
+                     IF( luse_jattr ) THEN
+                        CALL iom_getatt(kiomid, 'open_ocean_jstart', jstartrow ) ! -999 is returned if the attribute is not found
+                        jstartrow = MAX(1,jstartrow)
+                     ENDIF
+                     istart(1:2) = (/ mig(1), mjg(1) + jstartrow - 1 /)  ! icnt(1:2) done below
+                  ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done below
+                  ENDIF
+                  ! we do not read the overlap                     -> we start to read at nldi, nldj
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!                  IF( idom /= jpdom_local_noovlap )   istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
+                  IF( llnoov .AND. idom /= jpdom_local_noovlap ) istart(1:2) = istart(1:2) + (/ nldi - 1, nldj - 1 /)
+                  ! we do not read the overlap and the extra-halos -> from nldi to nlei and from nldj to nlej 
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!                  icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
+                  IF( llnoov ) THEN   ;   icnt(1:2) = (/ nlei - nldi + 1, nlej - nldj + 1 /)
+                  ELSE                ;   icnt(1:2) = (/ nlci           , nlcj            /)
+                  ENDIF
+                  IF( PRESENT(pv_r3d) ) THEN
+                     IF( idom == jpdom_data ) THEN                                  ; icnt(3) = jpkdta
+                     ELSE IF( ll_depth_spec .AND. PRESENT(kstart) ) THEN            ; istart(3) = kstart(3); icnt(3) = kcount(3)
+                     ELSE                                                           ; icnt(3) = jpk
+                     ENDIF
+                  ENDIF
+               ENDIF
+            ENDIF
+         ENDIF
+
+         ! check that istart and icnt can be used with this file
+         !-
+         DO jl = 1, jpmax_dims
+            itmp = istart(jl)+icnt(jl)-1
+            IF( itmp > idimsz(jl) .AND. idimsz(jl) /= 0 ) THEN
+               WRITE( ctmp1, FMT="('(istart(', i1, ') + icnt(', i1, ') - 1) = ', i5)" ) jl, jl, itmp
+               WRITE( ctmp2, FMT="(' is larger than idimsz(', i1,') = ', i5)"         ) jl, idimsz(jl)
+               CALL ctl_stop( trim(clinfo), 'start and count too big regarding to the size of the data, ', ctmp1, ctmp2 )     
+            ENDIF
+         END DO
+
+         ! check that icnt matches the input array
+         !-     
+         IF( idom == jpdom_unknown ) THEN
+            IF( irankpv == 1 )        ishape(1:1) = SHAPE(pv_r1d)
+            IF( irankpv == 2 )        ishape(1:2) = SHAPE(pv_r2d)
+            IF( irankpv == 3 )        ishape(1:3) = SHAPE(pv_r3d)
+            ctmp1 = 'd'
+         ELSE
+            IF( irankpv == 2 ) THEN
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!               ishape(1:2) = SHAPE(pv_r2d(nldi:nlei,nldj:nlej  ))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej)'
+               IF( llnoov ) THEN ; ishape(1:2)=SHAPE(pv_r2d(nldi:nlei,nldj:nlej  )) ; ctmp1='d(nldi:nlei,nldj:nlej)'
+               ELSE              ; ishape(1:2)=SHAPE(pv_r2d(1   :nlci,1   :nlcj  )) ; ctmp1='d(1:nlci,1:nlcj)'
+               ENDIF
+            ENDIF
+            IF( irankpv == 3 ) THEN 
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!               ishape(1:3) = SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:))   ;   ctmp1 = 'd(nldi:nlei,nldj:nlej,:)'
+               IF( llnoov ) THEN ; ishape(1:3)=SHAPE(pv_r3d(nldi:nlei,nldj:nlej,:)) ; ctmp1='d(nldi:nlei,nldj:nlej,:)'
+               ELSE              ; ishape(1:3)=SHAPE(pv_r3d(1   :nlci,1   :nlcj,:)) ; ctmp1='d(1:nlci,1:nlcj,:)'
+               ENDIF
+            ENDIF
+         ENDIF
+         
+         DO jl = 1, irankpv
+            WRITE( ctmp2, FMT="(', ', i1,'): ', i5,' /= icnt(', i1,'):', i5)" ) jl, ishape(jl), jl, icnt(jl)
+            IF( ishape(jl) /= icnt(jl) )   CALL ctl_stop( TRIM(clinfo), 'size(pv_r'//clrankpv//TRIM(ctmp1)//TRIM(ctmp2) )
+         END DO
+
+      ENDIF
+
+      ! read the data
+      !-     
+      IF( idvar > 0 .AND. istop == nstop ) THEN   ! no additional errors until this point...
+         !
+         ! find the right index of the array to be read
+! JMM + SM: ugly patch before getting the new version of lib_mpp)
+!         IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
+!         ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+!         ENDIF
+         IF( llnoov ) THEN
+            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = nldi   ;   ix2 = nlei      ;   iy1 = nldj   ;   iy2 = nlej
+            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+            ENDIF
+         ELSE
+            IF( idom /= jpdom_unknown ) THEN   ;   ix1 = 1      ;   ix2 = nlci      ;   iy1 = 1      ;   iy2 = nlcj
+            ELSE                               ;   ix1 = 1      ;   ix2 = icnt(1)   ;   iy1 = 1      ;   iy2 = icnt(2)
+            ENDIF
+         ENDIF
+      
+         SELECT CASE (iom_file(kiomid)%iolib)
+         CASE (jpnf90   )   ;   CALL iom_nf90_get(    kiomid, idvar, inbdim, istart, icnt, ix1, ix2, iy1, iy2,   &
+            &                                         pv_r1d, pv_r2d, pv_r3d )
+         CASE DEFAULT
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
+         END SELECT
+
+         IF( istop == nstop ) THEN   ! no additional errors until this point...
+            IF(lwp) WRITE(numout,"(10x,' read ',a,' (rec: ',i6,') in ',a,' ok')") TRIM(cdvar), itime, TRIM(iom_file(kiomid)%name)
+          
+            !--- overlap areas and extra hallows (mpp)
+            IF(     PRESENT(pv_r2d) .AND. idom /= jpdom_unknown ) THEN
+               CALL lbc_lnk( pv_r2d,'Z',-999.,'no0' )
+            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) == jpk ) THEN
+                  CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' )
+               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
+                  DO ji = nlci+1, jpi   ;   pv_r3d(ji    , : , :) = pv_r3d(nlei  , :   , :)   ;   END DO
+               ENDIF
+            ENDIF
+            
+            ! C1D case : always call lbc_lnk to replicate the central value over the whole 3X3 domain
+            IF( lk_c1d .AND. PRESENT(pv_r2d) )   CALL lbc_lnk( pv_r2d,'Z',1. )
+            IF( lk_c1d .AND. PRESENT(pv_r3d) )   CALL lbc_lnk( pv_r3d,'Z',1. )
+    
+            !--- Apply scale_factor and offset
+            zscf = iom_file(kiomid)%scf(idvar)      ! scale factor
+            zofs = iom_file(kiomid)%ofs(idvar)      ! offset
+            IF(     PRESENT(pv_r1d) ) THEN
+               IF( zscf /= 1. )   pv_r1d(:) = pv_r1d(:) * zscf 
+               IF( zofs /= 0. )   pv_r1d(:) = pv_r1d(:) + zofs
+            ELSEIF( PRESENT(pv_r2d) ) THEN
+               IF( zscf /= 1.)   pv_r2d(:,:) = pv_r2d(:,:) * zscf
+               IF( zofs /= 0.)   pv_r2d(:,:) = pv_r2d(:,:) + zofs
+            ELSEIF( PRESENT(pv_r3d) ) THEN
+               IF( zscf /= 1.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) * zscf
+               IF( zofs /= 0.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) + zofs
+            ENDIF
+            !
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE iom_get_123d
+
+
+   SUBROUTINE iom_gettime( kiomid, ptime, cdvar, kntime, cdunits, cdcalendar )
+      !!--------------------------------------------------------------------
+      !!                   ***  SUBROUTINE iom_gettime  ***
+      !!
+      !! ** Purpose : read the time axis cdvar in the file 
+      !!--------------------------------------------------------------------
+      INTEGER                    , INTENT(in   ) ::   kiomid     ! file Identifier
+      REAL(wp), DIMENSION(:)     , INTENT(  out) ::   ptime      ! the time axis
+      CHARACTER(len=*), OPTIONAL , INTENT(in   ) ::   cdvar      ! time axis name
+      INTEGER         , OPTIONAL , INTENT(  out) ::   kntime     ! number of times in file
+      CHARACTER(len=*), OPTIONAL , INTENT(  out) ::   cdunits    ! units attribute of time coordinate
+      CHARACTER(len=*), OPTIONAL , INTENT(  out) ::   cdcalendar ! calendar attribute of 
+      !
+      INTEGER, DIMENSION(1) :: kdimsz
+      INTEGER            ::   idvar    ! id of the variable
+      CHARACTER(LEN=32)  ::   tname    ! local name of time coordinate
+      CHARACTER(LEN=100) ::   clinfo   ! info character
+      !---------------------------------------------------------------------
+      !
+      IF ( PRESENT(cdvar) ) THEN
+         tname = cdvar
+      ELSE
+         tname = iom_file(kiomid)%uldname
+      ENDIF
+      IF( kiomid > 0 ) THEN
+         clinfo = 'iom_gettime, file: '//trim(iom_file(kiomid)%name)//', var: '//trim(tname)
+         IF ( PRESENT(kntime) ) THEN
+            idvar  = iom_varid( kiomid, tname, kdimsz = kdimsz )
+            kntime = kdimsz(1)
+         ELSE
+            idvar = iom_varid( kiomid, tname )
+         ENDIF
+         !
+         ptime(:) = 0. ! default definition
+         IF( idvar > 0 ) THEN
+            IF( iom_file(kiomid)%ndims(idvar) == 1 ) THEN
+               IF( iom_file(kiomid)%luld(idvar) ) THEN
+                  IF( iom_file(kiomid)%dimsz(1,idvar) <= size(ptime) ) THEN
+                     SELECT CASE (iom_file(kiomid)%iolib)
+                     CASE (jpnf90   )   ;   CALL iom_nf90_gettime(   kiomid, idvar, ptime, cdunits, cdcalendar )
+                     CASE DEFAULT
+                        CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
+                     END SELECT
+                  ELSE
+                     WRITE(ctmp1,*) 'error with the size of ptime ',size(ptime),iom_file(kiomid)%dimsz(1,idvar)
+                     CALL ctl_stop( trim(clinfo), trim(ctmp1) )
+                  ENDIF
+               ELSE
+                  CALL ctl_stop( trim(clinfo), 'variable dimension is not unlimited... use iom_get' )
+               ENDIF
+            ELSE
+               CALL ctl_stop( trim(clinfo), 'the variable has more than 1 dimension' )
+            ENDIF
+         ELSE
+            CALL ctl_stop( trim(clinfo), 'variable not found in '//iom_file(kiomid)%name )
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE iom_gettime
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_getatt
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_g0d_intatt( kiomid, cdatt, pvar )
+      INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
+      CHARACTER(len=*), INTENT(in   )                 ::   cdatt     ! Name of the attribute
+      INTEGER         , INTENT(  out)                 ::   pvar      ! read field
+      !
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpnf90   )   ;   CALL iom_nf90_getatt( kiomid, cdatt, pvar )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_g0d_att: accepted IO library is only jpnf90' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_g0d_intatt
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_rstput
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_rp0d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in)                         ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r0d = pvar )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_rp0d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp0d
+
+   SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in), DIMENSION(          :) ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r1d = pvar )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_rp1d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp1d
+
+   SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in), DIMENSION(:,    :    ) ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r2d = pvar )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_rp2d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp2d
+
+   SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype )
+      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
+      INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
+      INTEGER         , INTENT(in)                         ::   kiomid   ! Identifier of the file 
+      CHARACTER(len=*), INTENT(in)                         ::   cdvar    ! time axis name
+      REAL(wp)        , INTENT(in),       DIMENSION(:,:,:) ::   pvar     ! written field
+      INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
+      INTEGER :: ivid   ! variable id
+      IF( kiomid > 0 ) THEN
+         IF( iom_file(kiomid)%nfid > 0 ) THEN
+            ivid = iom_varid( kiomid, cdvar, ldstop = .FALSE. )
+            SELECT CASE (iom_file(kiomid)%iolib)
+            CASE (jpnf90   )   ;   CALL iom_nf90_rstput(   kt, kwrite, kiomid, cdvar, ivid, ktype, pv_r3d = pvar )
+            CASE DEFAULT
+               CALL ctl_stop( 'iom_rp3d: accepted IO library is only jpnf90 (jpioipsl option has been removed)' )
+            END SELECT
+         ENDIF
+      ENDIF
+   END SUBROUTINE iom_rp3d
+
+
+   !!----------------------------------------------------------------------
+   !!                   INTERFACE iom_put
+   !!----------------------------------------------------------------------
+   SUBROUTINE iom_p0d( cdname, pfield0d )
+      CHARACTER(LEN=*), INTENT(in) ::   cdname
+      REAL(wp)        , INTENT(in) ::   pfield0d
+      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/)) 
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pfield0d   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_p0d
+
+   SUBROUTINE iom_p1d( cdname, pfield1d )
+      CHARACTER(LEN=*)          , INTENT(in) ::   cdname
+      REAL(wp),     DIMENSION(:), INTENT(in) ::   pfield1d
+#if defined key_iomput
+      CALL xios_send_field( cdname, RESHAPE( (/pfield1d/), (/1,1,SIZE(pfield1d)/) ) )
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pfield1d   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_p1d
+
+   SUBROUTINE iom_p2d( cdname, pfield2d )
+      CHARACTER(LEN=*)            , INTENT(in) ::   cdname
+      REAL(wp),     DIMENSION(:,:), INTENT(in) ::   pfield2d
+#if defined key_iomput
+      CALL xios_send_field(cdname, pfield2d)
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pfield2d   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_p2d
+
+   SUBROUTINE iom_p3d( cdname, pfield3d )
+      CHARACTER(LEN=*)                , INTENT(in) ::   cdname
+      REAL(wp),       DIMENSION(:,:,:), INTENT(in) ::   pfield3d
+#if defined key_iomput
+      CALL xios_send_field(cdname, pfield3d)
+#else
+      IF( .FALSE. )   WRITE(numout,*) cdname, pfield3d   ! useless test to avoid compilation warnings
+#endif
+   END SUBROUTINE iom_p3d
+   !!----------------------------------------------------------------------
+
+#if defined key_iomput
+
+   SUBROUTINE iom_set_domain_attr( cdid, ni_glo, nj_glo, ibegin, jbegin, ni, nj, zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj,   &
+      &                                    data_dim, data_ibegin, data_ni, data_jbegin, data_nj, lonvalue, latvalue, mask,     &
+      &                                    nvertex, bounds_lon, bounds_lat, area )
+      CHARACTER(LEN=*)                   , INTENT(in) ::   cdid
+      INTEGER                  , OPTIONAL, INTENT(in) ::   ni_glo, nj_glo, ibegin, jbegin, ni, nj
+      INTEGER                  , OPTIONAL, INTENT(in) ::   data_dim, data_ibegin, data_ni, data_jbegin, data_nj
+      INTEGER                  , OPTIONAL, INTENT(in) ::   zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj, nvertex
+      REAL(wp), DIMENSION(:)   , OPTIONAL, INTENT(in) ::   lonvalue, latvalue
+      REAL(wp), DIMENSION(:,:) , OPTIONAL, INTENT(in) ::   bounds_lon, bounds_lat, area
+      LOGICAL,  DIMENSION(:,:) , OPTIONAL, INTENT(in) ::   mask
+
+      IF ( xios_is_valid_domain     (cdid) ) THEN
+         CALL xios_set_domain_attr     ( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj,   &
+            &    data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj ,   &
+            &    zoom_ibegin=zoom_ibegin, zoom_jbegin=zoom_jbegin, zoom_ni=zoom_ni, zoom_nj=zoom_nj,                       &
+            &    lonvalue=lonvalue, latvalue=latvalue, mask=mask, nvertex=nvertex, bounds_lon=bounds_lon,                  &
+            &    bounds_lat=bounds_lat, area=area )
+      ENDIF
+
+      IF ( xios_is_valid_domaingroup(cdid) ) THEN
+         CALL xios_set_domaingroup_attr( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj,   &
+            &    data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj ,   &
+            &    zoom_ibegin=zoom_ibegin, zoom_jbegin=zoom_jbegin, zoom_ni=zoom_ni, zoom_nj=zoom_nj,                       &
+            &    lonvalue=lonvalue, latvalue=latvalue, mask=mask, nvertex=nvertex, bounds_lon=bounds_lon,                  &
+            &    bounds_lat=bounds_lat, area=area )
+      ENDIF
+      CALL xios_solve_inheritance()
+
+   END SUBROUTINE iom_set_domain_attr
+
+
+   SUBROUTINE iom_set_axis_attr( cdid, paxis, bounds )
+      CHARACTER(LEN=*)      , INTENT(in) ::   cdid
+      REAL(wp), DIMENSION(:)  , OPTIONAL, INTENT(in) ::   paxis
+      REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) ::   bounds
+      IF ( PRESENT(paxis) ) THEN
+         IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, size=SIZE(paxis), value=paxis )
+         IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, size=SIZE(paxis), value=paxis )
+      ENDIF
+      IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, bounds=bounds )
+      IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, bounds=bounds )
+      CALL xios_solve_inheritance()
+   END SUBROUTINE iom_set_axis_attr
+
+
+   SUBROUTINE iom_set_field_attr( cdid, freq_op, freq_offset )
+      CHARACTER(LEN=*)          , INTENT(in) ::   cdid
+      CHARACTER(LEN=*),OPTIONAL , INTENT(in) ::   freq_op
+      CHARACTER(LEN=*),OPTIONAL , INTENT(in) ::   freq_offset
+      IF ( xios_is_valid_field     (cdid) )   CALL xios_set_field_attr       &
+    &     ( cdid, freq_op=freq_op, freq_offset=freq_offset )
+      IF ( xios_is_valid_fieldgroup(cdid) )   CALL xios_set_fieldgroup_attr  &
+    &                    ( cdid, freq_op=freq_op, freq_offset=freq_offset )
+      CALL xios_solve_inheritance()
+   END SUBROUTINE iom_set_field_attr
+
+
+   SUBROUTINE iom_set_file_attr( cdid, name, name_suffix )
+      CHARACTER(LEN=*)          , INTENT(in) ::   cdid
+      CHARACTER(LEN=*),OPTIONAL , INTENT(in) ::   name, name_suffix
+      IF ( xios_is_valid_file     (cdid) )   CALL xios_set_file_attr     ( cdid, name=name, name_suffix=name_suffix )
+      IF ( xios_is_valid_filegroup(cdid) )   CALL xios_set_filegroup_attr( cdid, name=name, name_suffix=name_suffix )
+      CALL xios_solve_inheritance()
+   END SUBROUTINE iom_set_file_attr
+
+
+   SUBROUTINE iom_get_file_attr( cdid, name, name_suffix, output_freq )
+      CHARACTER(LEN=*)          , INTENT(in ) ::   cdid
+      CHARACTER(LEN=*),OPTIONAL , INTENT(out) ::   name, name_suffix, output_freq
+      LOGICAL                                 ::   llexist1,llexist2,llexist3
+      !---------------------------------------------------------------------
+      IF( PRESENT( name        ) )   name = ''          ! default values
+      IF( PRESENT( name_suffix ) )   name_suffix = ''
+      IF( PRESENT( output_freq ) )   output_freq = ''
+      IF ( xios_is_valid_file     (cdid) ) THEN
+         CALL xios_solve_inheritance()
+         CALL xios_is_defined_file_attr     ( cdid, name = llexist1, name_suffix = llexist2, output_freq = llexist3)
+         IF(llexist1)   CALL xios_get_file_attr     ( cdid, name = name )
+         IF(llexist2)   CALL xios_get_file_attr     ( cdid, name_suffix = name_suffix )
+         IF(llexist3)   CALL xios_get_file_attr     ( cdid, output_freq = output_freq )
+      ENDIF
+      IF ( xios_is_valid_filegroup(cdid) ) THEN
+         CALL xios_solve_inheritance()
+         CALL xios_is_defined_filegroup_attr( cdid, name = llexist1, name_suffix = llexist2, output_freq = llexist3)
+         IF(llexist1)   CALL xios_get_filegroup_attr( cdid, name = name )
+         IF(llexist2)   CALL xios_get_filegroup_attr( cdid, name_suffix = name_suffix )
+         IF(llexist3)   CALL xios_get_filegroup_attr( cdid, output_freq = output_freq )
+      ENDIF
+   END SUBROUTINE iom_get_file_attr
+
+
+   SUBROUTINE iom_set_grid_attr( cdid, mask )
+      CHARACTER(LEN=*)                   , INTENT(in) ::   cdid
+      LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(in) ::   mask
+      IF ( xios_is_valid_grid     (cdid) )   CALL xios_set_grid_attr     ( cdid, mask=mask )
+      IF ( xios_is_valid_gridgroup(cdid) )   CALL xios_set_gridgroup_attr( cdid, mask=mask )
+      CALL xios_solve_inheritance()
+   END SUBROUTINE iom_set_grid_attr
+
+   SUBROUTINE iom_setkt( kt, cdname )
+      INTEGER         , INTENT(in) ::   kt 
+      CHARACTER(LEN=*), INTENT(in) ::   cdname
+      !     
+      CALL iom_swap( cdname )   ! swap to cdname context
+      CALL xios_update_calendar(kt)
+      IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context
+      !
+   END SUBROUTINE iom_setkt
+
+   SUBROUTINE iom_context_finalize( cdname )
+      CHARACTER(LEN=*), INTENT(in) :: cdname
+      !
+      IF( xios_is_valid_context(cdname) ) THEN
+         CALL iom_swap( cdname )   ! swap to cdname context
+         CALL xios_context_finalize() ! finalize the context
+         IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context
+      ENDIF
+      !
+   END SUBROUTINE iom_context_finalize
+
+
+   SUBROUTINE set_grid( cdgrd, plon, plat )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE set_grid  ***
+      !!
+      !! ** Purpose :   define horizontal grids
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(LEN=1)            , INTENT(in) ::   cdgrd
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plon
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat
+      !
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask
+      INTEGER  :: ni,nj
+      
+      ni=nlei-nldi+1 ; nj=nlej-nldj+1
+
+      CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-1, jbegin=njmpp+nldj-1, ni=ni, nj=nj)
+      CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj)
+      CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)),   &
+         &                                     latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))  
+
+      IF ( ln_mskland ) THEN
+         ! mask land points, keep values on coast line -> specific mask for U, V and W points
+         SELECT CASE ( cdgrd )
+         CASE('T')   ;   zmask(:,:,:)       = tmask(:,:,:)
+         CASE('U')   ;   zmask(2:jpim1,:,:) = tmask(2:jpim1,:,:) + tmask(3:jpi,:,:)   ;   CALL lbc_lnk( zmask, 'U', 1. )
+         CASE('V')   ;   zmask(:,2:jpjm1,:) = tmask(:,2:jpjm1,:) + tmask(:,3:jpj,:)   ;   CALL lbc_lnk( zmask, 'V', 1. )
+         CASE('W')   ;   zmask(:,:,2:jpk  ) = tmask(:,:,1:jpkm1) + tmask(:,:,2:jpk)   ;   zmask(:,:,1) = tmask(:,:,1)
+         END SELECT
+         !
+         CALL iom_set_domain_attr( "grid_"//cdgrd       , mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,1),(/ni,nj    /)) /= 0. )
+         CALL iom_set_grid_attr  ( "grid_"//cdgrd//"_3D", mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,:),(/ni,nj,jpk/)) /= 0. )
+      ENDIF
+      
+   END SUBROUTINE set_grid
+
+
+   SUBROUTINE set_grid_bounds( cdgrd, plon_cnr, plat_cnr, plon_pnt, plat_pnt )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE set_grid_bounds  ***
+      !!
+      !! ** Purpose :   define horizontal grid corners
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(LEN=1) , INTENT(in) :: cdgrd
+      !
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in)           :: plon_cnr, plat_cnr  ! Lat/lon coordinates of a contiguous vertex of cell (i,j)
+      REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in) :: plon_pnt, plat_pnt  ! Lat/lon coordinates of the point of cell (i,j)
+      !
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:)   :: z_bnds      ! Lat/lon coordinates of the vertices of cell (i,j)
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:)       :: z_fld       ! Working array to determine where to rotate cells
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:)       :: z_rot       ! Lat/lon working array for rotation of cells
+      !
+      INTEGER :: icnr, jcnr                                      ! Offset such that the vertex coordinate (i+icnr,j+jcnr)
+      !                                                          ! represents the bottom-left corner of cell (i,j)
+      INTEGER :: ji, jj, jn, ni, nj
+
+      ALLOCATE( z_bnds(4,jpi,jpj,2), z_fld(jpi,jpj), z_rot(4,2)  )
+
+      ! Offset of coordinate representing bottom-left corner
+      SELECT CASE ( TRIM(cdgrd) )
+         CASE ('T', 'W')
+            icnr = -1 ; jcnr = -1
+         CASE ('U')
+            icnr =  0 ; jcnr = -1
+         CASE ('V')
+            icnr = -1 ; jcnr =  0
+      END SELECT
+
+      ni = nlei-nldi+1 ; nj = nlej-nldj+1  ! Dimensions of subdomain interior
+
+      z_fld(:,:) = 1._wp
+      CALL lbc_lnk( z_fld, cdgrd, -1. )    ! Working array for location of northfold
+
+      ! Cell vertices that can be defined
+      DO jj = 2, jpjm1
+         DO ji = 2, jpim1
+            z_bnds(1,ji,jj,1) = plat_cnr(ji+icnr,  jj+jcnr  ) ! Bottom-left
+            z_bnds(2,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr  ) ! Bottom-right
+            z_bnds(3,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right
+            z_bnds(4,ji,jj,1) = plat_cnr(ji+icnr,  jj+jcnr+1) ! Top-left
+            z_bnds(1,ji,jj,2) = plon_cnr(ji+icnr,  jj+jcnr  ) ! Bottom-left
+            z_bnds(2,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr  ) ! Bottom-right
+            z_bnds(3,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right
+            z_bnds(4,ji,jj,2) = plon_cnr(ji+icnr,  jj+jcnr+1) ! Top-left
+         END DO
+      END DO
+
+      ! Cell vertices on boundries
+      DO jn = 1, 4
+         CALL lbc_lnk( z_bnds(jn,:,:,1), cdgrd, 1., pval=999._wp )
+         CALL lbc_lnk( z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp )
+      END DO
+
+      ! Zero-size cells at closed boundaries if cell points provided,
+      ! otherwise they are closed cells with unrealistic bounds
+      IF( PRESENT(plon_pnt) .AND. PRESENT(plat_pnt) ) THEN
+         IF( (nbondi == -1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN
+            DO jn = 1, 4        ! (West or jpni = 1), closed E-W
+               z_bnds(jn,1,:,1) = plat_pnt(1,:)  ;  z_bnds(jn,1,:,2) = plon_pnt(1,:)
+            END DO
+         ENDIF
+         IF( (nbondi == 1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN
+            DO jn = 1, 4        ! (East or jpni = 1), closed E-W
+               z_bnds(jn,nlci,:,1) = plat_pnt(nlci,:)  ;  z_bnds(jn,nlci,:,2) = plon_pnt(nlci,:)
+            END DO
+         ENDIF
+         IF( nbondj == -1 .OR. (nbondj == 2 .AND. jperio /= 2) ) THEN
+            DO jn = 1, 4        ! South or (jpnj = 1, not symmetric)
+               z_bnds(jn,:,1,1) = plat_pnt(:,1)  ;  z_bnds(jn,:,1,2) = plon_pnt(:,1)
+            END DO
+         ENDIF
+         IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio  < 3 ) THEN
+            DO jn = 1, 4        ! (North or jpnj = 1), no north fold
+               z_bnds(jn,:,nlcj,1) = plat_pnt(:,nlcj)  ;  z_bnds(jn,:,nlcj,2) = plon_pnt(:,nlcj)
+            END DO
+         ENDIF
+      ENDIF
+
+      ! Rotate cells at the north fold
+      IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio >= 3 ) THEN
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               IF( z_fld(ji,jj) == -1. ) THEN
+                  z_rot(1,:) = z_bnds(3,ji,jj,:) ; z_rot(2,:) = z_bnds(4,ji,jj,:)
+                  z_rot(3,:) = z_bnds(1,ji,jj,:) ; z_rot(4,:) = z_bnds(2,ji,jj,:)
+                  z_bnds(:,ji,jj,:) = z_rot(:,:)
+               ENDIF
+            END DO
+         END DO
+
+      ! Invert cells at the symmetric equator
+      ELSE IF( nbondj == 2 .AND. jperio == 2 ) THEN
+         DO ji = 1, jpi
+            z_rot(1:2,:) = z_bnds(3:4,ji,1,:)
+            z_rot(3:4,:) = z_bnds(1:2,ji,1,:)
+            z_bnds(:,ji,1,:) = z_rot(:,:)
+         END DO
+      ENDIF
+
+      CALL iom_set_domain_attr("grid_"//cdgrd, bounds_lat = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,1),(/ 4,ni*nj /)),           &
+                                               bounds_lon = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,2),(/ 4,ni*nj /)), nvertex=4 )
+
+      DEALLOCATE( z_bnds, z_fld, z_rot ) 
+
+   END SUBROUTINE set_grid_bounds
+
+
+   SUBROUTINE set_grid_znl( plat )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE set_grid_znl  ***
+      !!
+      !! ** Purpose :   define grids for zonal mean
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat
+      !
+      REAL(wp), DIMENSION(:), ALLOCATABLE  ::   zlon
+      INTEGER  :: ni,nj, ix, iy
+
+      
+      ni=nlei-nldi+1 ; nj=nlej-nldj+1            ! define zonal mean domain (jpj*jpk)
+      ALLOCATE( zlon(ni*nj) )       ;       zlon(:) = 0.
+
+      CALL iom_set_domain_attr("gznl", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-1, jbegin=njmpp+nldj-1, ni=ni, nj=nj)
+      CALL iom_set_domain_attr("gznl", data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj)
+      CALL iom_set_domain_attr("gznl", lonvalue = zlon,   &
+         &                             latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))  
+      !
+      CALL dom_ngb( 180., 90., ix, iy, 'T' ) !  i-line that passes near the North Pole : Reference latitude (used in plots)
+      CALL iom_set_domain_attr ('ptr', zoom_ibegin=ix, zoom_nj=jpjglo)
+      CALL iom_update_file_name('ptr')
+      !
+   END SUBROUTINE set_grid_znl
+
+   SUBROUTINE set_scalar
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE set_scalar  ***
+      !!
+      !! ** Purpose :   define fake grids for scalar point
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(1)   ::   zz = 1.
+      !!----------------------------------------------------------------------
+      CALL iom_set_domain_attr('scalarpoint', ni_glo=jpnij, nj_glo=1, ibegin=narea, jbegin=1, ni=1, nj=1)
+      CALL iom_set_domain_attr('scalarpoint', data_dim=2, data_ibegin = 1, data_ni = 1, data_jbegin = 1, data_nj = 1)
+      
+      zz=REAL(narea,wp)
+      CALL iom_set_domain_attr('scalarpoint', lonvalue=zz, latvalue=zz)
+
+   END SUBROUTINE set_scalar
+
+
+   SUBROUTINE set_xmlatt
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE set_xmlatt  ***
+      !!
+      !! ** Purpose :   automatic definitions of some of the xml attributs...
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=1),DIMENSION( 3) ::   clgrd                    ! suffix name
+      CHARACTER(len=256)             ::   clsuff                   ! suffix name
+      CHARACTER(len=1)               ::   cl1                      ! 1 character
+      CHARACTER(len=2)               ::   cl2                      ! 2 characters
+      CHARACTER(len=3)               ::   cl3                      ! 3 characters
+      INTEGER                        ::   ji, jg                   ! loop counters
+      INTEGER                        ::   ix, iy                   ! i-,j- index
+      REAL(wp)        ,DIMENSION(11) ::   zlontao                  ! longitudes of tao    moorings
+      REAL(wp)        ,DIMENSION( 7) ::   zlattao                  ! latitudes  of tao    moorings
+      REAL(wp)        ,DIMENSION( 4) ::   zlonrama                 ! longitudes of rama   moorings
+      REAL(wp)        ,DIMENSION(11) ::   zlatrama                 ! latitudes  of rama   moorings
+      REAL(wp)        ,DIMENSION( 3) ::   zlonpira                 ! longitudes of pirata moorings
+      REAL(wp)        ,DIMENSION( 9) ::   zlatpira                 ! latitudes  of pirata moorings
+      !!----------------------------------------------------------------------
+      ! 
+      ! frequency of the call of iom_put (attribut: freq_op)
+      WRITE(cl1,'(i1)')        1   ;   CALL iom_set_field_attr('field_definition', freq_op = cl1//'ts', freq_offset='0ts')
+      WRITE(cl1,'(i1)')  nn_fsbc   ;   CALL iom_set_field_attr('SBC'             , freq_op = cl1//'ts', freq_offset='0ts')
+      WRITE(cl1,'(i1)')  nn_fsbc   ;   CALL iom_set_field_attr('SBC_scalar'      , freq_op = cl1//'ts', freq_offset='0ts')
+      WRITE(cl1,'(i1)') nn_dttrc   ;   CALL iom_set_field_attr('ptrc_T'          , freq_op = cl1//'ts', freq_offset='0ts')
+      WRITE(cl1,'(i1)') nn_dttrc   ;   CALL iom_set_field_attr('diad_T'          , freq_op = cl1//'ts', freq_offset='0ts')
+       
+      ! output file names (attribut: name)
+      DO ji = 1, 9
+         WRITE(cl1,'(i1)') ji 
+         CALL iom_update_file_name('file'//cl1)
+      END DO
+      DO ji = 1, 99
+         WRITE(cl2,'(i2.2)') ji 
+         CALL iom_update_file_name('file'//cl2)
+      END DO
+      DO ji = 1, 999
+         WRITE(cl3,'(i3.3)') ji 
+         CALL iom_update_file_name('file'//cl3)
+      END DO
+
+      ! Zooms...
+      clgrd = (/ 'T', 'U', 'W' /) 
+      DO jg = 1, SIZE(clgrd)                                                                   ! grid type
+         cl1 = clgrd(jg)
+         ! Equatorial section (attributs: jbegin, ni, name_suffix)
+         CALL dom_ngb( 0., 0., ix, iy, cl1 )
+         CALL iom_set_domain_attr ('Eq'//cl1, zoom_jbegin=iy, zoom_ni=jpiglo)
+         CALL iom_get_file_attr   ('Eq'//cl1, name_suffix = clsuff             )
+         CALL iom_set_file_attr   ('Eq'//cl1, name_suffix = TRIM(clsuff)//'_Eq')
+         CALL iom_update_file_name('Eq'//cl1)
+      END DO
+      ! TAO moorings (attributs: ibegin, jbegin, name_suffix)
+      zlontao = (/ 137.0, 147.0, 156.0, 165.0, -180.0, -170.0, -155.0, -140.0, -125.0, -110.0, -95.0 /)
+      zlattao = (/  -8.0,  -5.0,  -2.0,   0.0,    2.0,    5.0,    8.0 /)
+      CALL set_mooring( zlontao, zlattao )
+      ! RAMA moorings (attributs: ibegin, jbegin, name_suffix)
+      zlonrama = (/  55.0,  67.0, 80.5, 90.0 /)
+      zlatrama = (/ -16.0, -12.0, -8.0, -4.0, -1.5, 0.0, 1.5, 4.0, 8.0, 12.0, 15.0 /)
+      CALL set_mooring( zlonrama, zlatrama )
+      ! PIRATA moorings (attributs: ibegin, jbegin, name_suffix)
+      zlonpira = (/ -38.0, -23.0, -10.0 /)
+      zlatpira = (/ -19.0, -14.0,  -8.0, 0.0, 4.0, 8.0, 12.0, 15.0, 20.0 /)
+      CALL set_mooring( zlonpira, zlatpira )
+
+      
+   END SUBROUTINE set_xmlatt
+
+
+   SUBROUTINE set_mooring( plon, plat)
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE set_mooring  ***
+      !!
+      !! ** Purpose :   automatic definitions of moorings xml attributs...
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:), INTENT(in) ::  plon, plat           ! longitudes/latitudes oft the mooring
+      !
+!!$      CHARACTER(len=1),DIMENSION(4) ::   clgrd = (/ 'T', 'U', 'V', 'W' /)   ! suffix name
+      CHARACTER(len=1),DIMENSION(1) ::   clgrd = (/ 'T' /)        ! suffix name
+      CHARACTER(len=256)            ::   clname                   ! file name
+      CHARACTER(len=256)            ::   clsuff                   ! suffix name
+      CHARACTER(len=1)              ::   cl1                      ! 1 character
+      CHARACTER(len=6)              ::   clon,clat                ! name of longitude, latitude
+      INTEGER                       ::   ji, jj, jg               ! loop counters
+      INTEGER                       ::   ix, iy                   ! i-,j- index
+      REAL(wp)                      ::   zlon, zlat
+      !!----------------------------------------------------------------------
+      DO jg = 1, SIZE(clgrd)
+         cl1 = clgrd(jg)
+         DO ji = 1, SIZE(plon)
+            DO jj = 1, SIZE(plat)
+               zlon = plon(ji)
+               zlat = plat(jj)
+               ! modifications for RAMA moorings
+               IF( zlon ==  67. .AND. zlat ==  15. )   zlon =  65.
+               IF( zlon ==  90. .AND. zlat <=  -4. )   zlon =  95.
+               IF( zlon ==  95. .AND. zlat ==  -4. )   zlat =  -5.
+               ! modifications for PIRATA moorings
+               IF( zlon == -38. .AND. zlat == -19. )   zlon = -34.
+               IF( zlon == -38. .AND. zlat == -14. )   zlon = -32.
+               IF( zlon == -38. .AND. zlat ==  -8. )   zlon = -30.
+               IF( zlon == -38. .AND. zlat ==   0. )   zlon = -35.
+               IF( zlon == -23. .AND. zlat ==  20. )   zlat =  21.
+               IF( zlon == -10. .AND. zlat == -14. )   zlat = -10.
+               IF( zlon == -10. .AND. zlat ==  -8. )   zlat =  -6.
+               IF( zlon == -10. .AND. zlat ==   4. ) THEN   ;   zlon = 0.   ;   zlat = 0.   ;   ENDIF
+               CALL dom_ngb( zlon, zlat, ix, iy, cl1 )
+               IF( zlon >= 0. ) THEN  
+                  IF( zlon == REAL(NINT(zlon), wp) ) THEN   ;   WRITE(clon, '(i3,  a)') NINT( zlon), 'e'
+                  ELSE                                      ;   WRITE(clon, '(f5.1,a)')       zlon , 'e'
+                  ENDIF
+               ELSE             
+                  IF( zlon == REAL(NINT(zlon), wp) ) THEN   ;   WRITE(clon, '(i3,  a)') NINT(-zlon), 'w'
+                  ELSE                                      ;   WRITE(clon, '(f5.1,a)')      -zlon , 'w'
+                  ENDIF
+               ENDIF
+               IF( zlat >= 0. ) THEN  
+                  IF( zlat == REAL(NINT(zlat), wp) ) THEN   ;   WRITE(clat, '(i2,  a)') NINT( zlat), 'n'
+                  ELSE                                      ;   WRITE(clat, '(f4.1,a)')       zlat , 'n'
+                  ENDIF
+               ELSE             
+                  IF( zlat == REAL(NINT(zlat), wp) ) THEN   ;   WRITE(clat, '(i2,  a)') NINT(-zlat), 's'
+                  ELSE                                      ;   WRITE(clat, '(f4.1,a)')      -zlat , 's'
+                  ENDIF
+               ENDIF
+               clname = TRIM(ADJUSTL(clat))//TRIM(ADJUSTL(clon))
+               CALL iom_set_domain_attr (TRIM(clname)//cl1, zoom_ibegin= ix, zoom_jbegin= iy)
+               CALL iom_get_file_attr   (TRIM(clname)//cl1, name_suffix = clsuff                         )
+               CALL iom_set_file_attr   (TRIM(clname)//cl1, name_suffix = TRIM(clsuff)//'_'//TRIM(clname))
+               CALL iom_update_file_name(TRIM(clname)//cl1)
+            END DO
+         END DO
+      END DO
+      
+   END SUBROUTINE set_mooring
+
+   
+   SUBROUTINE iom_update_file_name( cdid )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE iom_update_file_name  ***
+      !!
+      !! ** Purpose :   
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(LEN=*)          , INTENT(in) ::   cdid
+      !
+      CHARACTER(LEN=256) ::   clname
+      CHARACTER(LEN=20)  ::   clfreq
+      CHARACTER(LEN=20)  ::   cldate
+      INTEGER            ::   idx
+      INTEGER            ::   jn
+      INTEGER            ::   itrlen
+      INTEGER            ::   iyear, imonth, iday, isec
+      REAL(wp)           ::   zsec
+      LOGICAL            ::   llexist
+      !!----------------------------------------------------------------------
+
+      DO jn = 1,2
+
+         IF( jn == 1 )   CALL iom_get_file_attr( cdid, name        = clname, output_freq = clfreq )
+         IF( jn == 2 )   CALL iom_get_file_attr( cdid, name_suffix = clname )
+
+         IF ( TRIM(clname) /= '' ) THEN 
+
+            idx = INDEX(clname,'@expname@') + INDEX(clname,'@EXPNAME@')
+            DO WHILE ( idx /= 0 ) 
+               clname = clname(1:idx-1)//TRIM(cexper)//clname(idx+9:LEN_TRIM(clname))
+               idx = INDEX(clname,'@expname@') + INDEX(clname,'@EXPNAME@')
+            END DO
+
+            idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@')
+            DO WHILE ( idx /= 0 ) 
+               IF ( TRIM(clfreq) /= '' ) THEN
+                  itrlen = LEN_TRIM(clfreq)
+                  IF ( clfreq(itrlen-1:itrlen) == 'mo' ) clfreq = clfreq(1:itrlen-1)
+                  clname = clname(1:idx-1)//TRIM(clfreq)//clname(idx+6:LEN_TRIM(clname))
+               ELSE
+                  CALL ctl_stop('error in the name of file id '//TRIM(cdid),   &
+                     & ' attribute output_freq is undefined -> cannot replace @freq@ in '//TRIM(clname) )
+               ENDIF
+               idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@')
+            END DO
+
+            idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@')
+            DO WHILE ( idx /= 0 ) 
+               cldate = iom_sdate( fjulday - rdt / rday )
+               clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+11:LEN_TRIM(clname))
+               idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@')
+            END DO
+
+            idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@')
+            DO WHILE ( idx /= 0 ) 
+               cldate = iom_sdate( fjulday - rdt / rday, ldfull = .TRUE. )
+               clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+15:LEN_TRIM(clname))
+               idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@')
+            END DO
+
+            idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@')
+            DO WHILE ( idx /= 0 ) 
+               cldate = iom_sdate( fjulday + rdt / rday * REAL( nitend - nit000, wp ), ld24 = .TRUE. )
+               clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+9:LEN_TRIM(clname))
+               idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@')
+            END DO
+
+            idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@')
+            DO WHILE ( idx /= 0 ) 
+               cldate = iom_sdate( fjulday + rdt / rday * REAL( nitend - nit000, wp ), ld24 = .TRUE., ldfull = .TRUE. )
+               clname = clname(1:idx-1)//TRIM(cldate)//clname(idx+13:LEN_TRIM(clname))
+               idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@')
+            END DO
+
+            IF( jn == 1 .AND. TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname)
+            IF( jn == 1 )   CALL iom_set_file_attr( cdid, name        = clname )
+            IF( jn == 2 )   CALL iom_set_file_attr( cdid, name_suffix = clname )
+
+         ENDIF
+
+      END DO
+
+   END SUBROUTINE iom_update_file_name
+
+
+   FUNCTION iom_sdate( pjday, ld24, ldfull )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE iom_sdate  ***
+      !!
+      !! ** Purpose :   send back the date corresponding to the given julian day
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in   )           ::   pjday         ! julian day
+      LOGICAL , INTENT(in   ), OPTIONAL ::   ld24          ! true to force 24:00 instead of 00:00
+      LOGICAL , INTENT(in   ), OPTIONAL ::   ldfull        ! true to get the compleate date: yyyymmdd_hh:mm:ss
+      !
+      CHARACTER(LEN=20) ::   iom_sdate
+      CHARACTER(LEN=50) ::   clfmt                         !  format used to write the date 
+      INTEGER           ::   iyear, imonth, iday, ihour, iminute, isec
+      REAL(wp)          ::   zsec
+      LOGICAL           ::   ll24, llfull
+      !
+      IF( PRESENT(ld24) ) THEN   ;   ll24 = ld24
+      ELSE                       ;   ll24 = .FALSE.
+      ENDIF
+
+      IF( PRESENT(ldfull) ) THEN   ;   llfull = ldfull
+      ELSE                         ;   llfull = .FALSE.
+      ENDIF
+
+      CALL ju2ymds( pjday, iyear, imonth, iday, zsec )
+      isec = NINT(zsec)
+
+      IF ( ll24 .AND. isec == 0 ) THEN   ! 00:00 of the next day -> move to 24:00 of the current day
+         CALL ju2ymds( pjday - 1., iyear, imonth, iday, zsec )
+         isec = 86400
+      ENDIF
+
+      IF( iyear < 10000 ) THEN   ;   clfmt = "i4.4,2i2.2"                ! format used to write the date 
+      ELSE                       ;   WRITE(clfmt, "('i',i1,',2i2.2')") INT(LOG10(REAL(iyear,wp))) + 1
+      ENDIF
+      
+!$AGRIF_DO_NOT_TREAT      
+! Should be fixed in the conv
+      IF( llfull ) THEN 
+         clfmt = TRIM(clfmt)//",'_',i2.2,':',i2.2,':',i2.2"
+         ihour   = isec / 3600
+         isec    = MOD(isec, 3600)
+         iminute = isec / 60
+         isec    = MOD(isec, 60)
+         WRITE(iom_sdate, '('//TRIM(clfmt)//')') iyear, imonth, iday, ihour, iminute, isec    ! date of the end of run
+      ELSE
+         WRITE(iom_sdate, '('//TRIM(clfmt)//')') iyear, imonth, iday                          ! date of the end of run
+      ENDIF
+!$AGRIF_END_DO_NOT_TREAT      
+
+   END FUNCTION iom_sdate
+
+#else
+
+
+   SUBROUTINE iom_setkt( kt, cdname )
+      INTEGER         , INTENT(in)::   kt 
+      CHARACTER(LEN=*), INTENT(in) ::   cdname
+      IF( .FALSE. )   WRITE(numout,*) kt, cdname   ! useless test to avoid compilation warnings
+   END SUBROUTINE iom_setkt
+
+   SUBROUTINE iom_context_finalize( cdname )
+      CHARACTER(LEN=*), INTENT(in) ::   cdname
+      IF( .FALSE. )   WRITE(numout,*)  cdname   ! useless test to avoid compilation warnings
+   END SUBROUTINE iom_context_finalize
+
+#endif
+
+   LOGICAL FUNCTION iom_use( cdname )
+      CHARACTER(LEN=*), INTENT(in) ::   cdname
+#if defined key_iomput
+      iom_use = xios_field_is_active( cdname )
+#else
+      iom_use = .FALSE.
+#endif
+   END FUNCTION iom_use
+   
+   !!======================================================================
+END MODULE iom
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/cpp_WAD_TEST_CASES.fcm
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/cpp_WAD_TEST_CASES.fcm	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/WAD_TEST_CASES/cpp_WAD_TEST_CASES.fcm	(revision 7339)
@@ -0,0 +1,1 @@
+ bld::tool::fppkeys key_zdftke key_iomput key_mpp_mpi key_bdy key_nosignedzero key_mpp_rep
Index: branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/cfg.txt
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/cfg.txt	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/CONFIG/cfg.txt	(revision 7339)
@@ -11,2 +11,3 @@
 ORCA2_OFF_PISCES OPA_SRC OFF_SRC TOP_SRC
 GYRE OPA_SRC
+WAD_TEST_CASES OPA_SRC
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 7339)
@@ -145,10 +145,10 @@
       CALL iom_put("e3v_0", e3t_0(:,:,:) )
       !
-      CALL iom_put( "e3t" , fse3t_n(:,:,:) )
-      CALL iom_put( "e3u" , fse3u_n(:,:,:) )
-      CALL iom_put( "e3v" , fse3v_n(:,:,:) )
-      CALL iom_put( "e3w" , fse3w_n(:,:,:) )
+      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"  , ( ( fse3t_n(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2 )
+         CALL iom_put( "e3tdef"  , ( ( e3t_n(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2 )
 
       CALL iom_put( "ssh" , sshn )                 ! sea surface height
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 7339)
@@ -105,15 +105,15 @@
       IF( ln_linssh ) THEN          ! Fix in time : set to the reference one for all
          !       before        !          now          !       after         !
-         ;  gdept_b = gdept_0  ;   gdept_n = gdept_0   !        ---          ! depth of grid-points
-         ;  gdepw_b = gdepw_0  ;   gdepw_n = gdepw_0   !        ---          !
-         ;                     ;   gde3w_n = gde3w_0   !        ---          !
+            gdept_b = gdept_0  ;   gdept_n = gdept_0   !        ---          ! depth of grid-points
+            gdepw_b = gdepw_0  ;   gdepw_n = gdepw_0   !        ---          !
+                                   gde3w_n = gde3w_0   !        ---          !
          !                                                                  
-         ;    e3t_b =   e3t_0  ;     e3t_n =   e3t_0   ;   e3t_a =  e3t_0    ! scale factors
-         ;    e3u_b =   e3u_0  ;     e3u_n =   e3u_0   ;   e3u_a =  e3u_0    !
-         ;    e3v_b =   e3v_0  ;     e3v_n =   e3v_0   ;   e3v_a =  e3v_0    !
-         ;                     ;     e3f_n =   e3f_0   !        ---          !
-         ;    e3w_b =   e3w_0  ;     e3w_n =   e3w_0   !        ---          !
-         ;   e3uw_b =  e3uw_0  ;    e3uw_n =  e3uw_0   !        ---          !
-         ;   e3vw_b =  e3vw_0  ;    e3vw_n =  e3vw_0   !        ---          !
+              e3t_b =   e3t_0  ;     e3t_n =   e3t_0   ;   e3t_a =  e3t_0    ! scale factors
+              e3u_b =   e3u_0  ;     e3u_n =   e3u_0   ;   e3u_a =  e3u_0    !
+              e3v_b =   e3v_0  ;     e3v_n =   e3v_0   ;   e3v_a =  e3v_0    !
+                                     e3f_n =   e3f_0   !        ---          !
+              e3w_b =   e3w_0  ;     e3w_n =   e3w_0   !        ---          !
+             e3uw_b =  e3uw_0  ;    e3uw_n =  e3uw_0   !        ---          !
+             e3vw_b =  e3vw_0  ;    e3vw_n =  e3vw_0   !        ---          !
          !
          CALL wrk_alloc( jpi,jpj,   z1_hu_0, z1_hv_0 )
@@ -123,9 +123,9 @@
          !
          !        before       !          now          !       after         !
-         ;                     ;      ht_n =    ht_0   !                     ! water column thickness
-         ;     hu_b =    hu_0  ;      hu_n =    hu_0   ;    hu_a =    hu_0   ! 
-         ;     hv_b =    hv_0  ;      hv_n =    hv_0   ;    hv_a =    hv_0   !
-         ;  r1_hu_b = z1_hu_0  ;   r1_hu_n = z1_hu_0   ; r1_hu_a = z1_hu_0   ! inverse of water column thickness
-         ;  r1_hv_b = z1_hv_0  ;   r1_hv_n = z1_hv_0   ; r1_hv_a = z1_hv_0   !
+                                      ht_n =    ht_0   !                     ! water column thickness
+               hu_b =    hu_0  ;      hu_n =    hu_0   ;    hu_a =    hu_0   ! 
+               hv_b =    hv_0  ;      hv_n =    hv_0   ;    hv_a =    hv_0   !
+            r1_hu_b = z1_hu_0  ;   r1_hu_n = z1_hu_0   ; r1_hu_a = z1_hu_0   ! inverse of water column thickness
+            r1_hv_b = z1_hv_0  ;   r1_hv_n = z1_hv_0   ; r1_hv_a = z1_hv_0   !
          !
          CALL wrk_dealloc( jpi,jpj,   z1_hu_0, z1_hv_0 )
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 7339)
@@ -874,15 +874,26 @@
             !
          ELSE                                   !* Initialize at "rest"
-            e3t_b(:,:,:) = e3t_0(:,:,:)
-            e3t_n(:,:,:) = e3t_0(:,:,:)
-            sshn(:,:) = 0.0_wp
-
-            IF( ln_wd ) THEN
+            !
+            IF( ln_wd .AND. ( cp_cfg == 'wad' ) ) THEN
+               !
+               CALL wad_istate                  ! WAD test configuration : start from 
+                                                ! uniform T-S fields and initial ssh slope
+               ! needs to be called here and in istate which is called later.
+               ! Adjust vertical metrics
+               DO jk = 1, jpk
+                  e3t_n(:,:,jk) =  e3t_0(:,:,jk) * ( ht_0(:,:) + sshn(:,:) ) &
+                    &                            / ( ht_0(:,:) + 1._wp - ssmask(:,:) ) * tmask(:,:,jk)   &
+                    &            + e3t_0(:,:,jk)                               * (1._wp -tmask(:,:,jk))
+               END DO
+               e3t_b(:,:,:) = e3t_n(:,:,:)
+               !
+            ELSEIF( ln_wd ) THEN
+               !
               DO jj = 1, jpj
                 DO ji = 1, jpi
                   IF( e3t_0(ji,jj,1) <= 0.5_wp * rn_wdmin1 ) THEN
-                     e3t_b(ji,jj,:) = 0.5_wp * rn_wdmin1 
-                     e3t_n(ji,jj,:) = 0.5_wp * rn_wdmin1 
-                     e3t_a(ji,jj,:) = 0.5_wp * rn_wdmin1 
+                     e3t_b(ji,jj,:) = 0.5_wp * rn_wdmin1
+                     e3t_n(ji,jj,:) = 0.5_wp * rn_wdmin1
+                     e3t_a(ji,jj,:) = 0.5_wp * rn_wdmin1
                      sshb(ji,jj) = rn_wdmin1 - bathy(ji,jj)
                      sshn(ji,jj) = rn_wdmin1 - bathy(ji,jj)
@@ -891,4 +902,11 @@
                 ENDDO
               ENDDO
+               !
+            ELSE
+               !
+               e3t_b(:,:,:) = e3t_0(:,:,:)
+               e3t_n(:,:,:) = e3t_0(:,:,:)
+               sshn(:,:) = 0.0_wp
+               !
             END IF
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 7339)
@@ -416,4 +416,146 @@
                IF(lwp) WRITE(numout,*) '         Depth = rn_bathy read in namelist'
                zdta(:,:) = rn_bathy
+!
+               IF( cp_cfg == 'wad' ) THEN
+                  SELECT CASE ( jp_cfg )
+                     !                                        ! ====================
+                     CASE ( 1 )                               ! WAD 1 configuration
+                        !                                     ! ====================
+                        !
+                        IF(lwp) WRITE(numout,*)
+                        IF(lwp) WRITE(numout,*) 'zgr_bat : Closed box with EW linear bottom slope'
+                        IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+                        !
+                        zdta = 1.5_wp
+                        DO ji = 10, jpidta
+                          zi = MIN(FLOAT(ji - 10)/FLOAT(jpidta - 10), 1.0 )
+                          zdta(ji,:) = MAX(rn_bathy*zi, 1.5) 
+                          IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        END DO
+                        !!DO ji = 1, jpidta 
+                        !!  zi = 1.0-EXP(-0.045*(ji-25.0)**2)
+                        !!  zdta(ji,:) = MAX(rn_bathy*zi, 1.5)
+                        !!  IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        !!END DO
+                        zdta(1:2,:) = -2._wp
+                        zdta(jpidta-1:jpidta,:) = -2._wp
+                        zdta(:,1) = -2._wp
+                        zdta(:,jpjdta) = -2._wp
+                        zdta(:,1:3) = -2._wp
+                        zdta(:,jpjdta-2:jpjdta) = -2._wp
+                        !                                     ! ====================
+                     CASE ( 2, 3 )                            ! WAD 2 or 3  configuration
+                        !                                     ! ====================
+                        !
+                        IF(lwp) WRITE(numout,*)
+                        IF(lwp) WRITE(numout,*) 'zgr_bat : Parobolic EW channel'
+                        IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+                        !
+                        DO ji = 1, jpidta
+                          zi = MAX(1.0-FLOAT((ji-25)**2)/484.0, 0.0 )
+                          zi = MAX(1.0-FLOAT((ji-25)**2)/484.0, -2.0 )
+                          zdta(ji,:) = MAX(rn_bathy*zi, -20.0)
+                          IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        END DO
+                        zdta(1:2,:) = -2._wp
+                        zdta(jpidta-1:jpidta,:) = -2._wp
+                        zdta(:,1) = -2._wp
+                        zdta(:,jpjdta) = -2._wp
+                        zdta(:,1:3) = -2._wp
+                        zdta(:,jpjdta-2:jpjdta) = -2._wp
+                        !                                     ! ====================
+                     CASE ( 4 )                               ! WAD 4 configuration
+                        !                                     ! ====================
+                        !
+                        IF(lwp) WRITE(numout,*)
+                        IF(lwp) WRITE(numout,*) 'zgr_bat : Parobolic bowl'
+                        IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+                        !
+                        DO ji = 1, jpidta
+                          zi = MAX(1.0-FLOAT((ji-25)**2)/484.0, -2.0 )
+                        DO jj = 1, jpjdta
+                          zj = MAX(1.0-FLOAT((jj-17)**2)/196.0, -2.0 )
+                          zdta(ji,jj) = MAX(rn_bathy*zi*zj, -2.0)
+                        END DO
+                          IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        END DO
+                        zdta(1:2,:) = -2._wp
+                        zdta(jpidta-1:jpidta,:) = -2._wp
+                        zdta(:,1) = -2._wp
+                        zdta(:,jpjdta) = -2._wp
+                        zdta(:,1:3) = -2._wp
+                        zdta(:,jpjdta-2:jpjdta) = -2._wp
+                        !                                    ! ===========================
+                     CASE ( 5 )                              ! WAD 5 configuration
+                        !                                    ! ====================
+                        !
+                        IF(lwp) WRITE(numout,*)
+                        IF(lwp) WRITE(numout,*) 'zgr_bat : Double slope with shelf'
+                        IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+                        !
+                        DO ji = 1, jpidta
+                          zi = MIN(FLOAT(ji)/FLOAT(jpidta - 5), 1.0 )
+                          zdta(ji,:) = MAX(rn_bathy*zi, 0.5)
+                          IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        END DO
+                        DO ji = jpidta,46,-1
+                          zdta(ji,:) = 10.0
+                          IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        END DO
+                        DO ji = 46,20,-1
+                          zi = 7.5/25.
+                          zdta(ji,:) = MAX(10. - zi*(47.-ji),2.5)
+                          IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        END DO
+                        DO ji = 19,15,-1
+                          zdta(ji,:) = 2.5
+                          IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        END DO
+                        DO ji = 15,4,-1
+                          zi = 2.0/11.0
+                          zdta(ji,:) = MAX(2.5 - zi*(16-ji), 0.5)
+                          IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        END DO
+                        DO ji = 4,1,-1
+                          zdta(ji,:) = 0.5
+                          IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        END DO
+                        !                                    ! ===========================
+                        zdta(1:2,:) = -4._wp
+                        zdta(jpidta-1:jpidta,:) = -4._wp
+                        zdta(:,1) = -4._wp
+                        zdta(:,jpjdta) = -4._wp
+                        zdta(:,1:3) = -4._wp
+                        zdta(:,jpjdta-2:jpjdta) = -4._wp
+                        !                                    ! ===========================
+                     CASE ( 6 )                              ! WAD 6 configuration
+                        !                                    ! ====================
+                        !
+                        IF(lwp) WRITE(numout,*)
+                        IF(lwp) WRITE(numout,*) 'zgr_bat : Parabolic channel with gaussian ridge'
+                        IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+                        !
+                        DO ji = 1, jpidta
+                          zi = MAX(1.0-FLOAT((ji-25)**2)/484.0, -2.0 )
+                          zj = 0.95*MAX(EXP(-1.0*FLOAT((ji-25)**2)/32.0) , 0.0 )
+                          zdta(ji,:) = MAX(rn_bathy*(zi-zj), -2.0)
+                          IF(lwp)write(numout,*) 'ZDTA ',ji,zi,zdta(ji,1)
+                        END DO
+                        zdta(1:2,:) = -4._wp
+                        zdta(jpidta-1:jpidta,:) = -4._wp
+                        zdta(:,1) = -4._wp
+                        zdta(:,jpjdta) = -4._wp
+                        zdta(:,1:3) = -4._wp
+                        zdta(:,jpjdta-2:jpjdta) = -4._wp
+                        !                                    ! ===========================
+                     CASE DEFAULT
+                        !                                    ! ===========================
+                        WRITE(ctmp1,*) 'WAD test with a ', jp_cfg,' option is not coded'
+                        !
+                        CALL ctl_stop( ctmp1 )
+                        !
+                  END SELECT
+               END IF
+               !
                IF( ln_sco ) THEN                                   ! s-coordinate (zsc       ): idta()=jpk
                   idta(:,:) = jpkm1
@@ -2185,13 +2327,11 @@
       CALL lbc_lnk( e3vw_0, 'V', 1._wp )
       !
-      IF( .NOT.ln_wd ) THEN
-        WHERE( e3t_0 (:,:,:) == 0._wp )   e3t_0 (:,:,:) = 1._wp
-        WHERE( e3u_0 (:,:,:) == 0._wp )   e3u_0 (:,:,:) = 1._wp
-        WHERE( e3v_0 (:,:,:) == 0._wp )   e3v_0 (:,:,:) = 1._wp
-        WHERE( e3f_0 (:,:,:) == 0._wp )   e3f_0 (:,:,:) = 1._wp
-        WHERE( e3w_0 (:,:,:) == 0._wp )   e3w_0 (:,:,:) = 1._wp
-        WHERE( e3uw_0(:,:,:) == 0._wp )   e3uw_0(:,:,:) = 1._wp
-        WHERE( e3vw_0(:,:,:) == 0._wp )   e3vw_0(:,:,:) = 1._wp
-      END IF
+      WHERE( e3t_0 (:,:,:) == 0._wp )   e3t_0 (:,:,:) = 1._wp
+      WHERE( e3u_0 (:,:,:) == 0._wp )   e3u_0 (:,:,:) = 1._wp
+      WHERE( e3v_0 (:,:,:) == 0._wp )   e3v_0 (:,:,:) = 1._wp
+      WHERE( e3f_0 (:,:,:) == 0._wp )   e3f_0 (:,:,:) = 1._wp
+      WHERE( e3w_0 (:,:,:) == 0._wp )   e3w_0 (:,:,:) = 1._wp
+      WHERE( e3uw_0(:,:,:) == 0._wp )   e3uw_0(:,:,:) = 1._wp
+      WHERE( e3vw_0(:,:,:) == 0._wp )   e3vw_0(:,:,:) = 1._wp
 
 #if defined key_agrif
@@ -2295,24 +2435,24 @@
                DO jk = 1, mbathy(ji,jj)
                  ! check coordinate is monotonically increasing
-                 IF (e3w_n(ji,jj,jk) <= 0._wp .OR. e3t_n(ji,jj,jk) <= 0._wp ) THEN
+                 IF (e3w_0(ji,jj,jk) <= 0._wp .OR. e3t_0(ji,jj,jk) <= 0._wp ) THEN
                     WRITE(ctmp1,*) 'ERROR zgr_sco :   e3w   or e3t   =< 0  at point (i,j,k)= ', ji, jj, jk
                     WRITE(numout,*) 'ERROR zgr_sco :   e3w   or e3t   =< 0  at point (i,j,k)= ', ji, jj, jk
-                    WRITE(numout,*) 'e3w',e3w_n(ji,jj,:)
-                    WRITE(numout,*) 'e3t',e3t_n(ji,jj,:)
+                    WRITE(numout,*) 'e3w',e3w_0(ji,jj,:)
+                    WRITE(numout,*) 'e3t',e3t_0(ji,jj,:)
                     CALL ctl_stop( ctmp1 )
                  ENDIF
                  ! and check it has never gone negative
-                 IF( gdepw_n(ji,jj,jk) < 0._wp .OR. gdept_n(ji,jj,jk) < 0._wp ) THEN
+                 IF( gdepw_0(ji,jj,jk) < 0._wp .OR. gdept_0(ji,jj,jk) < 0._wp ) THEN
                     WRITE(ctmp1,*) 'ERROR zgr_sco :   gdepw or gdept =< 0  at point (i,j,k)= ', ji, jj, jk
                     WRITE(numout,*) 'ERROR zgr_sco :   gdepw   or gdept   =< 0  at point (i,j,k)= ', ji, jj, jk
-                    WRITE(numout,*) 'gdepw',gdepw_n(ji,jj,:)
-                    WRITE(numout,*) 'gdept',gdept_n(ji,jj,:)
+                    WRITE(numout,*) 'gdepw',gdepw_0(ji,jj,:)
+                    WRITE(numout,*) 'gdept',gdept_0(ji,jj,:)
                     CALL ctl_stop( ctmp1 )
                  ENDIF
                  ! and check it never exceeds the total depth
-                 IF( gdepw_n(ji,jj,jk) > hbatt(ji,jj) ) THEN
+                 IF( gdepw_0(ji,jj,jk) > hbatt(ji,jj) ) THEN
                     WRITE(ctmp1,*) 'ERROR zgr_sco :   gdepw > hbatt  at point (i,j,k)= ', ji, jj, jk
                     WRITE(numout,*) 'ERROR zgr_sco :   gdepw > hbatt  at point (i,j,k)= ', ji, jj, jk
-                    WRITE(numout,*) 'gdepw',gdepw_n(ji,jj,:)
+                    WRITE(numout,*) 'gdepw',gdepw_0(ji,jj,:)
                     CALL ctl_stop( ctmp1 )
                  ENDIF
@@ -2321,8 +2461,8 @@
                DO jk = 1, mbathy(ji,jj)-1
                  ! and check it never exceeds the total depth
-                IF( gdept_n(ji,jj,jk) > hbatt(ji,jj) ) THEN
+                IF( gdept_0(ji,jj,jk) > hbatt(ji,jj) ) THEN
                     WRITE(ctmp1,*) 'ERROR zgr_sco :   gdept > hbatt  at point (i,j,k)= ', ji, jj, jk
                     WRITE(numout,*) 'ERROR zgr_sco :   gdept > hbatt  at point (i,j,k)= ', ji, jj, jk
-                    WRITE(numout,*) 'gdept',gdept_n(ji,jj,:)
+                    WRITE(numout,*) 'gdept',gdept_0(ji,jj,:)
                     CALL ctl_stop( ctmp1 )
                  ENDIF
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90	(revision 7339)
@@ -36,4 +36,5 @@
    USE domvvl          ! varying vertical mesh
    USE iscplrst        ! ice sheet coupling
+   USE wet_dry         ! wetting and drying (needed for wad_istate)
    !
    USE in_out_manager  ! I/O manager
@@ -105,4 +106,6 @@
          ELSEIF( cp_cfg == 'gyre' ) THEN         
             CALL istate_gyre                     ! GYRE  configuration : start from pre-defined T-S fields
+         ELSEIF( cp_cfg == 'wad' ) THEN         
+            CALL wad_istate                      ! WAD test configuration : start from pre-defined T-S fields and initial ssh slope
          ELSE                                    ! Initial T-S, U-V fields read in files
             IF ( ln_tsd_init ) THEN              ! read 3D T and S data at nit000
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 7339)
@@ -432,5 +432,5 @@
       INTEGER  ::   ji, jj, jk, jii, jjj                 ! dummy loop indices
       REAL(wp) ::   zcoef0, zuap, zvap, znad, ztmp       ! temporary scalars
-      LOGICAL  ::   ll_tmp1, ll_tmp2, ll_tmp3            ! local logical variables
+      LOGICAL  ::   ll_tmp1, ll_tmp2                     ! local logical variables
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  zhpi, zhpj
       REAL(wp), POINTER, DIMENSION(:,:)   ::  zcpx, zcpy !W/D pressure filter
@@ -438,5 +438,5 @@
       !
       CALL wrk_alloc( jpi,jpj,jpk, zhpi, zhpj )
-      IF(ln_wd) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
+      IF( ln_wd ) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
       !
       IF( kt == nit000 ) THEN
@@ -451,47 +451,44 @@
       ENDIF
       !
-      IF(ln_wd) THEN
+      IF( ln_wd ) THEN
         DO jj = 2, jpjm1
            DO ji = 2, jpim1 
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) 
-             ll_tmp2 = MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji+1,jj) + bathy(ji+1,jj)) > rn_wdmin1 + rn_wdmin2
-             ll_tmp3 = MAX(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) + &
-                                                       & rn_wdmin1 + rn_wdmin2
-
-             IF(ll_tmp1.AND.ll_tmp2) THEN
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji+1,jj) + bathy(ji+1,jj) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2
+
+             IF(ll_tmp1) THEN
                zcpx(ji,jj) = 1.0_wp
-               wduflt(ji,jj) = 1.0_wp
-             ELSE IF(ll_tmp3) 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) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) / &
-                           &     (sshn(ji+1,jj) - sshn(ji,jj)))
-               wduflt(ji,jj) = 1.0_wp
+             ELSE IF(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) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji+1,jj) -  sshn(ji  ,jj)) )
              ELSE
                zcpx(ji,jj) = 0._wp
-               wduflt(ji,jj) = 0.0_wp
              END IF
       
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) 
-             ll_tmp2 = MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji,jj+1) + bathy(ji,jj+1)) > rn_wdmin1 + rn_wdmin2
-             ll_tmp3 = MAX(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) + &
-                                                       & rn_wdmin1 + rn_wdmin2
-
-             IF(ll_tmp1.AND.ll_tmp2) THEN
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji,jj+1) + bathy(ji,jj+1) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2
+
+             IF(ll_tmp1) THEN
                zcpy(ji,jj) = 1.0_wp
-               wdvflt(ji,jj) = 1.0_wp
-             ELSE IF(ll_tmp3) 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) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) / &
-                           &     (sshn(ji,jj+1) - sshn(ji,jj)))
-               wdvflt(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) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji,jj+1) -  sshn(ji,jj  )) )
              ELSE
                zcpy(ji,jj) = 0._wp
-               wdvflt(ji,jj) = 0.0_wp
              END IF
            END DO
         END DO
         CALL lbc_lnk( zcpx, 'U', 1._wp )    ;   CALL lbc_lnk( zcpy, 'V', 1._wp )
-      ENDIF
-
+      END IF
 
       ! Surface value
@@ -510,5 +507,5 @@
 
 
-            IF(ln_wd) THEN
+            IF( ln_wd ) THEN
 
               zhpi(ji,jj,1) = zhpi(ji,jj,1) * zcpx(ji,jj)
@@ -541,5 +538,5 @@
                   &           * ( gde3w_n(ji  ,jj+1,jk) - gde3w_n(ji,jj,jk) ) * r1_e2v(ji,jj)
 
-               IF(ln_wd) THEN
+               IF( ln_wd ) THEN
                  zhpi(ji,jj,jk) = zhpi(ji,jj,jk) * zcpx(ji,jj)
                  zhpj(ji,jj,jk) = zhpj(ji,jj,jk) * zcpy(ji,jj) 
@@ -556,5 +553,5 @@
       !
       CALL wrk_dealloc( jpi,jpj,jpk, zhpi, zhpj )
-      IF(ln_wd) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
+      IF( ln_wd ) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
       !
    END SUBROUTINE hpg_sco
@@ -701,38 +698,40 @@
       CALL wrk_alloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow )
       CALL wrk_alloc( jpi, jpj, jpk, rho_i, rho_j, rho_k,  zhpi,  zhpj        )
-      IF(ln_wd) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
-      !
-      !
-      IF(ln_wd) THEN
+      IF( ln_wd ) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
+      !
+      !
+      IF( ln_wd ) THEN
         DO jj = 2, jpjm1
            DO ji = 2, jpim1 
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) &
-                     & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji+1,jj) + bathy(ji+1,jj)) &
-                     &  > rn_wdmin1 + rn_wdmin2
-             ll_tmp2 = MAX(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) +&
-                                                       & rn_wdmin1 + rn_wdmin2
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji+1,jj) + bathy(ji+1,jj) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(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 sshn(ji+1,jj)-sshn(ji,jj) = 0, it won't happen ! here
-               zcpx(ji,jj) = ABS((sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) /&
-                           &     (sshn(ji+1,jj) - sshn(ji,jj)))
+               ! no worries about  sshn(ji+1,jj) -  sshn(ji  ,jj) = 0, it won't happen ! here
+               zcpx(ji,jj) = ABS( (sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji+1,jj) -  sshn(ji  ,jj)) )
              ELSE
                zcpx(ji,jj) = 0._wp
              END IF
       
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) &
-                     & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji,jj+1) + bathy(ji,jj+1)) &
-                     &  > rn_wdmin1 + rn_wdmin2
-             ll_tmp2 = MAX(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) +&
-                                                       & rn_wdmin1 + rn_wdmin2
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji,jj+1) + bathy(ji,jj+1) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(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) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) /&
-                           &     (sshn(ji,jj+1) - sshn(ji,jj)))
+               ! no worries about  sshn(ji,jj+1) -  sshn(ji,jj  ) = 0, it won't happen ! here
+               zcpy(ji,jj) = ABS( (sshn(ji,jj+1) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji,jj+1) -  sshn(ji,jj  )) )
              ELSE
                zcpy(ji,jj) = 0._wp
@@ -741,6 +740,5 @@
         END DO
         CALL lbc_lnk( zcpx, 'U', 1._wp )    ;   CALL lbc_lnk( zcpy, 'V', 1._wp )
-      ENDIF
-
+      END IF
 
       IF( kt == nit000 ) THEN
@@ -913,5 +911,5 @@
             zhpi(ji,jj,1) = ( rho_k(ji+1,jj  ,1) - rho_k(ji,jj,1) - rho_i(ji,jj,1) ) * r1_e1u(ji,jj)
             zhpj(ji,jj,1) = ( rho_k(ji  ,jj+1,1) - rho_k(ji,jj,1) - rho_j(ji,jj,1) ) * r1_e2v(ji,jj)
-            IF(ln_wd) THEN
+            IF( ln_wd ) THEN
               zhpi(ji,jj,1) = zhpi(ji,jj,1) * zcpx(ji,jj)
               zhpj(ji,jj,1) = zhpj(ji,jj,1) * zcpy(ji,jj) 
@@ -936,5 +934,5 @@
                   &           + (  ( rho_k(ji,jj+1,jk) - rho_k(ji,jj,jk  ) )    &
                   &               -( rho_j(ji,jj  ,jk) - rho_j(ji,jj,jk-1) )  ) * r1_e2v(ji,jj)
-               IF(ln_wd) THEN
+               IF( ln_wd ) THEN
                  zhpi(ji,jj,jk) = zhpi(ji,jj,jk) * zcpx(ji,jj)
                  zhpj(ji,jj,jk) = zhpj(ji,jj,jk) * zcpy(ji,jj) 
@@ -950,5 +948,5 @@
       CALL wrk_dealloc( jpi, jpj, jpk, drhox, drhoy, drhoz, drhou, drhov, drhow )
       CALL wrk_dealloc( jpi, jpj, jpk, rho_i, rho_j, rho_k,  zhpi,  zhpj        )
-      IF(ln_wd) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
+      IF( ln_wd ) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
       !
    END SUBROUTINE hpg_djc
@@ -987,5 +985,5 @@
       CALL wrk_alloc( jpi,jpj,jpk,   zdept, zrhh )
       CALL wrk_alloc( jpi,jpj,       zsshu_n, zsshv_n )
-      IF(ln_wd) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
+      IF( ln_wd ) CALL wrk_alloc( jpi,jpj, zcpx, zcpy )
       !
       IF( kt == nit000 ) THEN
@@ -1000,35 +998,37 @@
       IF( ln_linssh )   znad = 0._wp
 
-      IF(ln_wd) THEN
+      IF( ln_wd ) THEN
         DO jj = 2, jpjm1
            DO ji = 2, jpim1 
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) &
-                     & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji+1,jj) + bathy(ji+1,jj)) &
-                     &  > rn_wdmin1 + rn_wdmin2
-             ll_tmp2 = MAX(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj)) +&
-                                                       & rn_wdmin1 + rn_wdmin2
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji+1,jj) + bathy(ji+1,jj) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(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 sshn(ji+1,jj)-sshn(ji,jj) = 0, it won't happen ! here
-               zcpx(ji,jj) = ABS((sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) /&
-                           &     (sshn(ji+1,jj) - sshn(ji,jj)))
+               ! no worries about  sshn(ji+1,jj) -  sshn(ji  ,jj) = 0, it won't happen ! here
+               zcpx(ji,jj) = ABS( (sshn(ji+1,jj) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji+1,jj) -  sshn(ji  ,jj)) )
              ELSE
                zcpx(ji,jj) = 0._wp
              END IF
       
-             ll_tmp1 = MIN(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) &
-                     & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji,jj+1) + bathy(ji,jj+1)) &
-                     &  > rn_wdmin1 + rn_wdmin2
-             ll_tmp2 = MAX(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1)) +&
-                                                       & rn_wdmin1 + rn_wdmin2
-
-             IF(ll_tmp1.OR.ll_tmp2) THEN
+             ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) .AND.            &
+                  &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji,jj+1) + bathy(ji,jj+1) ) &
+                  &                                                         > rn_wdmin1 + rn_wdmin2
+             ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                  &    MAX( -bathy(ji,jj)               , -bathy(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) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) /&
-                           &     (sshn(ji,jj+1) - sshn(ji,jj)))
+               ! no worries about  sshn(ji,jj+1) -  sshn(ji,jj  ) = 0, it won't happen ! here
+               zcpy(ji,jj) = ABS( (sshn(ji,jj+1) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) &
+                           &    / (sshn(ji,jj+1) -  sshn(ji,jj  )) )
              ELSE
                zcpy(ji,jj) = 0._wp
@@ -1037,5 +1037,5 @@
         END DO
         CALL lbc_lnk( zcpx, 'U', 1._wp )    ;   CALL lbc_lnk( zcpy, 'V', 1._wp )
-      ENDIF
+      END IF
 
       ! Clean 3-D work arrays
@@ -1221,5 +1221,5 @@
                  zdpdx2 = zcoef0 * r1_e1u(ji,jj) * REAL(jis-jid, wp) * (zpwes + zpwed)
                ENDIF
-               IF(ln_wd) THEN
+               IF( ln_wd ) THEN
                   zdpdx1 = zdpdx1 * zcpx(ji,jj)
                   zdpdx2 = zdpdx2 * zcpx(ji,jj)
@@ -1280,5 +1280,5 @@
                   zdpdy2 = zcoef0 * r1_e2v(ji,jj) * REAL(jjs-jjd, wp) * (zpnss + zpnsd )
                ENDIF
-               IF(ln_wd) THEN
+               IF( ln_wd ) THEN
                   zdpdy1 = zdpdy1 * zcpy(ji,jj)
                   zdpdy2 = zdpdy2 * zcpy(ji,jj)
@@ -1295,5 +1295,5 @@
       CALL wrk_dealloc( jpi,jpj,jpk,   zdept, zrhh )
       CALL wrk_dealloc( jpi,jpj,       zsshu_n, zsshv_n )
-      IF(ln_wd) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
+      IF( ln_wd ) CALL wrk_dealloc( jpi,jpj, zcpx, zcpy )
       !
    END SUBROUTINE hpg_prj
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90	(revision 7339)
@@ -205,5 +205,5 @@
       ENDIF
       !                          ! Control of surface pressure gradient scheme options
-      ;                              nspg =  np_NO    ;   ioptio = 0
+                                     nspg =  np_NO    ;   ioptio = 0
       IF( ln_dynspg_exp ) THEN   ;   nspg =  np_EXP   ;   ioptio = ioptio + 1   ;   ENDIF
       IF( ln_dynspg_ts  ) THEN   ;   nspg =  np_TS    ;   ioptio = ioptio + 1   ;   ENDIF
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 7339)
@@ -156,5 +156,4 @@
       REAL(wp), POINTER, DIMENSION(:,:) :: zhf
       REAL(wp), POINTER, DIMENSION(:,:) :: zcpx, zcpy                 ! Wetting/Dying gravity filter coef.
-      REAL(wp), POINTER, DIMENSION(:,:) :: wduflt1, wdvflt1           ! Wetting/Dying velocity filter coef.
       !!----------------------------------------------------------------------
       !
@@ -168,5 +167,5 @@
       CALL wrk_alloc( jpi,jpj,   zsshu_a, zsshv_a                  )
       CALL wrk_alloc( jpi,jpj,   zhf )
-      IF( ln_wd ) CALL wrk_alloc( jpi, jpj, zcpx, zcpy, wduflt1, wdvflt1 )
+      IF( ln_wd ) CALL wrk_alloc( jpi, jpj, zcpx, zcpy )
       !
       zmdi=1.e+20                               !  missing data indicator for masking
@@ -374,51 +373,48 @@
       IF( .NOT.ln_linssh ) THEN                 ! Variable volume : remove surface pressure gradient
         IF( ln_wd ) THEN                        ! Calculating and applying W/D gravity filters
-          wduflt1(:,:) = 1.0_wp
-          wdvflt1(:,:) = 1.0_wp
-          DO jj = 2, jpjm1
-             DO ji = 2, jpim1
-                ll_tmp1 = MIN(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj))   &
-                        & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji+1,jj) + bathy(ji+1,jj))   &
-                        &  > rn_wdmin1 + rn_wdmin2
-                ll_tmp2 = MAX(sshn(ji,jj), sshn(ji+1,jj)) > MAX(-bathy(ji,jj), -bathy(ji+1,jj))   &
-                        &                                   + rn_wdmin1 + rn_wdmin2
+           DO jj = 2, jpjm1
+              DO ji = 2, jpim1 
+                ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                     &    MAX( -bathy(ji,jj)               , -bathy(ji+1,jj) ) .AND.            &
+                     &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji+1,jj) + bathy(ji+1,jj) ) &
+                     &                                                         > rn_wdmin1 + rn_wdmin2
+                ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji+1,jj) ) >                &
+                     &    MAX( -bathy(ji,jj)               , -bathy(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) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) &
-                        &          /(sshn(ji+1,jj) - sshn(ji,jj)))
+                  zcpx(ji,jj) = 1.0_wp
+                ELSE IF(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) + bathy(ji+1,jj) - sshn(ji,jj) - bathy(ji,jj)) &
+                              &    / (sshn(ji+1,jj) -  sshn(ji  ,jj)) )
                 ELSE
-                  zcpx(ji,jj)    = 0._wp
-                  wduflt1(ji,jj) = 0.0_wp
+                  zcpx(ji,jj) = 0._wp
                 END IF
-
-                ll_tmp1 = MIN(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1))   &
-                        & .and. MAX(sshn(ji,jj) + bathy(ji,jj), sshn(ji,jj+1) + bathy(ji,jj+1))   &
-                        &  > rn_wdmin1 + rn_wdmin2
-                ll_tmp2 = MAX(sshn(ji,jj), sshn(ji,jj+1)) > MAX(-bathy(ji,jj), -bathy(ji,jj+1))   &
-                        &                                   + rn_wdmin1 + rn_wdmin2
+         
+                ll_tmp1 = MIN(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                     &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) .AND.            &
+                     &    MAX(   sshn(ji,jj) + bathy(ji,jj),   sshn(ji,jj+1) + bathy(ji,jj+1) ) &
+                     &                                                         > rn_wdmin1 + rn_wdmin2
+                ll_tmp2 = MAX(   sshn(ji,jj)               ,   sshn(ji,jj+1) ) >                &
+                     &    MAX( -bathy(ji,jj)               , -bathy(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2
+   
                 IF(ll_tmp1) THEN
-                   zcpy(ji,jj)    = 1.0_wp
-                ELSEIF(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) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) &
-                        &          /(sshn(ji,jj+1) - sshn(ji,jj)))
+                  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) + bathy(ji,jj+1) - sshn(ji,jj) - bathy(ji,jj)) &
+                              &    / (sshn(ji,jj+1) -  sshn(ji,jj  )) )
                 ELSE
-                  zcpy(ji,jj)    = 0._wp
-                  wdvflt1(ji,jj) = 0.0_wp
-                ENDIF
-
-             END DO
+                  zcpy(ji,jj) = 0._wp
+                END IF
+              END DO
            END DO
-
-           CALL lbc_lnk( zcpx, 'U', 1._wp )    ;   CALL lbc_lnk( zcpy, 'V', 1._wp )
-
+ 
            DO jj = 2, jpjm1
               DO ji = 2, jpim1
-                 zu_trd(ji,jj) = ( zu_trd(ji,jj) - grav * ( sshn(ji+1,jj  ) - sshn(ji  ,jj ) )   &
-                        &                        * r1_e1u(ji,jj) ) * zcpx(ji,jj) * wduflt1(ji,jj)
-                 zv_trd(ji,jj) = ( zv_trd(ji,jj) - grav * ( sshn(ji  ,jj+1) - sshn(ji  ,jj ) )   &
-                        &                        * r1_e2v(ji,jj) ) * zcpy(ji,jj) * wdvflt1(ji,jj)
+                 zu_trd(ji,jj) = zu_trd(ji,jj) - grav * ( sshn(ji+1,jj  ) - sshn(ji  ,jj ) )   &
+                        &                        * r1_e1u(ji,jj) * zcpx(ji,jj)
+                 zv_trd(ji,jj) = zv_trd(ji,jj) - grav * ( sshn(ji  ,jj+1) - sshn(ji  ,jj ) )   &
+                        &                        * r1_e2v(ji,jj) * zcpy(ji,jj)
               END DO
            END DO
@@ -567,9 +563,4 @@
       ENDIF
 
-      IF( ln_wd ) THEN      !preserve the positivity of water depth
-                          !ssh[b,n,a] should have already been processed for this
-         sshbb_e(:,:) = MAX(sshbb_e(:,:), rn_wdmin1 - bathy(:,:))
-         sshb_e(:,:)  = MAX(sshb_e(:,:) , rn_wdmin1 - bathy(:,:))
-      ENDIF
       !
       IF (ln_bt_fw) THEN                  ! FORWARD integration: start from NOW fields                    
@@ -646,8 +637,4 @@
             zhup2_e (:,:) = hu_0(:,:) + zwx(:,:)                ! Ocean depth at U- and V-points
             zhvp2_e (:,:) = hv_0(:,:) + zwy(:,:)
-            IF( ln_wd ) THEN
-              zhup2_e(:,:) = MAX(zhup2_e (:,:), rn_wdmin1)
-              zhvp2_e(:,:) = MAX(zhvp2_e (:,:), rn_wdmin1)
-            END IF
          ELSE
             zhup2_e (:,:) = hu_n(:,:)
@@ -701,6 +688,7 @@
             END DO
          END DO
+
          ssha_e(:,:) = (  sshn_e(:,:) - rdtbt * ( zssh_frc(:,:) + zhdiv(:,:) )  ) * ssmask(:,:)
-         IF( ln_wd ) ssha_e(:,:) = MAX(ssha_e(:,:), rn_wdmin1 - bathy(:,:)) 
+         
          CALL lbc_lnk( ssha_e, 'T',  1._wp )
 
@@ -749,44 +737,44 @@
          zsshp2_e(:,:) = za0 *  ssha_e(:,:) + za1 *  sshn_e (:,:) &
           &            + za2 *  sshb_e(:,:) + za3 *  sshbb_e(:,:)
+
          IF( ln_wd ) THEN                   ! Calculating and applying W/D gravity filters
-           wduflt1(:,:) = 1._wp
-           wdvflt1(:,:) = 1._wp
            DO jj = 2, jpjm1
-              DO ji = 2, jpim1
-                 ll_tmp1 = MIN( zsshp2_e(ji,jj), zsshp2_e(ji+1,jj) ) > MAX( -bathy(ji,jj), -bathy(ji+1,jj) ) &
-                        & .AND. MAX( zsshp2_e(ji,jj) + bathy(ji,jj), zsshp2_e(ji+1,jj) + bathy(ji+1,jj) )    &
-                        &                                  > rn_wdmin1 + rn_wdmin2
-                 ll_tmp2 = MAX( zsshp2_e(ji,jj), zsshp2_e(ji+1,jj) ) > MAX( -bathy(ji,jj), -bathy(ji+1,jj) ) &
-                        &                                  + rn_wdmin1 + rn_wdmin2
-                 IF(ll_tmp1) THEN
-                    zcpx(ji,jj) = 1._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) + bathy(ji+1,jj) - zsshp2_e(ji,jj) - bathy(ji,jj)) &
-                        &             / (zsshp2_e(ji+1,jj) - zsshp2_e(ji,jj)) )
-                 ELSE
-                    zcpx(ji,jj)    = 0._wp
-                    wduflt1(ji,jj) = 0._wp
-                 END IF
-
-                 ll_tmp1 = MIN( zsshp2_e(ji,jj), zsshp2_e(ji,jj+1) ) > MAX( -bathy(ji,jj), -bathy(ji,jj+1) ) &
-                        & .AND. MAX( zsshp2_e(ji,jj) + bathy(ji,jj), zsshp2_e(ji,jj+1) + bathy(ji,jj+1) )    &
-                        &                                  > rn_wdmin1 + rn_wdmin2
-                 ll_tmp2 = MAX( zsshp2_e(ji,jj), zsshp2_e(ji,jj+1) ) > MAX( -bathy(ji,jj), -bathy(ji,jj+1) ) &
-                        &                                  + rn_wdmin1 + rn_wdmin2
-                 IF(ll_tmp1) THEN
-                    zcpy(ji,jj) = 1._wp
-                 ELSE IF(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) + bathy(ji,jj+1) - zsshp2_e(ji,jj) - bathy(ji,jj)) &
-                        &             / (zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj)) )
-                 ELSE
-                    zcpy(ji,jj)    = 0._wp
-                    wdvflt1(ji,jj) = 0._wp
-                 END IF
+              DO ji = 2, jpim1 
+                ll_tmp1 = MIN( zsshp2_e(ji,jj)               , zsshp2_e(ji+1,jj) ) >                &
+                     &    MAX(   -bathy(ji,jj)               ,   -bathy(ji+1,jj) ) .AND.            &
+                     &    MAX( zsshp2_e(ji,jj) + bathy(ji,jj), zsshp2_e(ji+1,jj) + bathy(ji+1,jj) ) &
+                     &                                                             > rn_wdmin1 + rn_wdmin2
+                ll_tmp2 = MAX( zsshp2_e(ji,jj)               , zsshp2_e(ji+1,jj) ) >                &
+                     &    MAX(   -bathy(ji,jj)               ,   -bathy(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) +    bathy(ji+1,jj) - zsshp2_e(ji,jj) - bathy(ji,jj)) &
+                              &    / (zsshp2_e(ji+1,jj) - zsshp2_e(ji  ,jj)) )
+                ELSE
+                  zcpx(ji,jj) = 0._wp
+                END IF
+         
+                ll_tmp1 = MIN( zsshp2_e(ji,jj)               , zsshp2_e(ji,jj+1) ) >                &
+                     &    MAX(   -bathy(ji,jj)               ,   -bathy(ji,jj+1) ) .AND.            &
+                     &    MAX( zsshp2_e(ji,jj) + bathy(ji,jj), zsshp2_e(ji,jj+1) + bathy(ji,jj+1) ) &
+                     &                                                             > rn_wdmin1 + rn_wdmin2
+                ll_tmp2 = MAX( zsshp2_e(ji,jj)               , zsshp2_e(ji,jj+1) ) >                &
+                     &    MAX(   -bathy(ji,jj)               ,   -bathy(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  zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj  ) = 0, it won't happen ! here
+                  zcpy(ji,jj) = ABS( (zsshp2_e(ji,jj+1) +    bathy(ji,jj+1) - zsshp2_e(ji,jj) - bathy(ji,jj)) &
+                              &    / (zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj  )) )
+                ELSE
+                  zcpy(ji,jj) = 0._wp
+                END IF
               END DO
-            END DO
-            CALL lbc_lnk( zcpx, 'U', 1._wp )    ;   CALL lbc_lnk( zcpy, 'V', 1._wp )
-         ENDIF
+           END DO
+         END IF
          !
          ! Compute associated depths at U and V points:
@@ -806,9 +794,4 @@
             END DO
 
-            IF( ln_wd ) THEN
-              zhust_e(:,:) = MAX(zhust_e (:,:), rn_wdmin1 )
-              zhvst_e(:,:) = MAX(zhvst_e (:,:), rn_wdmin1 )
-            END IF
-
          ENDIF
          !
@@ -888,6 +871,6 @@
                  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) = zu_spg * zcpx(ji,jj) 
-                 zwy(ji,jj) = zv_spg * zcpy(ji,jj)
+                 zwx(ji,jj) = zu_spg * zcpx(ji,jj) * wdmask(ji,jj) * wdmask(ji+1, jj) 
+                 zwy(ji,jj) = zv_spg * zcpy(ji,jj) * wdmask(ji,jj) * wdmask(ji, jj+1)
               END DO
            END DO
@@ -927,11 +910,6 @@
                DO ji = fs_2, fs_jpim1   ! vector opt.
 
-                  IF( ln_wd ) THEN
-                    zhura = MAX(hu_0(ji,jj) + zsshu_a(ji,jj), rn_wdmin1)
-                    zhvra = MAX(hv_0(ji,jj) + zsshv_a(ji,jj), rn_wdmin1)
-                  ELSE
-                    zhura = hu_0(ji,jj) + zsshu_a(ji,jj)
-                    zhvra = hv_0(ji,jj) + zsshv_a(ji,jj)
-                  END IF
+                  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))
@@ -953,11 +931,6 @@
          !
          IF( .NOT.ln_linssh ) THEN                     !* Update ocean depth (variable volume case only)
-            IF( ln_wd ) THEN
-              hu_e (:,:) = MAX(hu_0(:,:) + zsshu_a(:,:), rn_wdmin1)
-              hv_e (:,:) = MAX(hv_0(:,:) + zsshv_a(:,:), rn_wdmin1)
-            ELSE
-              hu_e (:,:) = hu_0(:,:) + zsshu_a(:,:)
-              hv_e (:,:) = hv_0(:,:) + zsshv_a(:,:)
-            END IF
+            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(:,:) )
@@ -1024,31 +997,62 @@
       !
       ! Update barotropic trend:
-      IF( ln_dynadv_vec .OR. ln_linssh ) THEN
-         DO jk=1,jpkm1
-            ua(:,:,jk) = ua(:,:,jk) + ( ua_b(:,:) - ub_b(:,:) ) * z1_2dt_b
-            va(:,:,jk) = va(:,:,jk) + ( va_b(:,:) - vb_b(:,:) ) * z1_2dt_b
-         END DO
+      IF(ln_wd) THEN
+        IF( ln_dynadv_vec .OR. ln_linssh ) THEN
+           DO jk=1,jpkm1
+              ua(:,:,jk) = ua(:,:,jk) + ( ua_b(:,:) - ub_b(:,:) ) * z1_2dt_b * wdmask(:,:)
+              va(:,:,jk) = va(:,:,jk) + ( va_b(:,:) - vb_b(:,:) ) * z1_2dt_b * wdmask(:,:)
+           END DO
+        ELSE
+           ! At this stage, ssha has been corrected: compute new depths at velocity points
+           DO jj = 1, jpjm1
+              DO ji = 1, jpim1      ! NO Vector Opt.
+                 zsshu_a(ji,jj) = z1_2 * umask(ji,jj,1)  * r1_e1e2u(ji,jj) &
+                    &              * ( e1e2t(ji  ,jj) * ssha(ji  ,jj)    &
+                    &              +   e1e2t(ji+1,jj) * ssha(ji+1,jj) )
+                 zsshv_a(ji,jj) = z1_2 * vmask(ji,jj,1)  * r1_e1e2v(ji,jj) &
+                    &              * ( e1e2t(ji,jj  ) * ssha(ji,jj  )    &
+                    &              +   e1e2t(ji,jj+1) * ssha(ji,jj+1) )
+              END DO
+           END DO
+           CALL lbc_lnk_multi( zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp ) ! Boundary conditions
+           !
+           DO jk=1,jpkm1
+              ua(:,:,jk) = ua(:,:,jk) + r1_hu_n(:,:) * ( ua_b(:,:) - ub_b(:,:) * hu_b(:,:) ) * z1_2dt_b * wdmask(:,:)
+              va(:,:,jk) = va(:,:,jk) + r1_hv_n(:,:) * ( va_b(:,:) - vb_b(:,:) * hv_b(:,:) ) * z1_2dt_b * wdmask(:,:)
+           END DO
+           ! Save barotropic velocities not transport:
+           ua_b(:,:) =  ua_b(:,:) / ( hu_0(:,:) + zsshu_a(:,:) + 1._wp - ssumask(:,:) )
+           va_b(:,:) =  va_b(:,:) / ( hv_0(:,:) + zsshv_a(:,:) + 1._wp - ssvmask(:,:) )
+        ENDIF
       ELSE
-         ! At this stage, ssha has been corrected: compute new depths at velocity points
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1      ! NO Vector Opt.
-               zsshu_a(ji,jj) = z1_2 * umask(ji,jj,1)  * r1_e1e2u(ji,jj) &
-                  &              * ( e1e2t(ji  ,jj) * ssha(ji  ,jj)    &
-                  &              +   e1e2t(ji+1,jj) * ssha(ji+1,jj) )
-               zsshv_a(ji,jj) = z1_2 * vmask(ji,jj,1)  * r1_e1e2v(ji,jj) &
-                  &              * ( e1e2t(ji,jj  ) * ssha(ji,jj  )    &
-                  &              +   e1e2t(ji,jj+1) * ssha(ji,jj+1) )
-            END DO
-         END DO
-         CALL lbc_lnk_multi( zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp ) ! Boundary conditions
-         !
-         DO jk=1,jpkm1
-            ua(:,:,jk) = ua(:,:,jk) + r1_hu_n(:,:) * ( ua_b(:,:) - ub_b(:,:) * hu_b(:,:) ) * z1_2dt_b
-            va(:,:,jk) = va(:,:,jk) + r1_hv_n(:,:) * ( va_b(:,:) - vb_b(:,:) * hv_b(:,:) ) * z1_2dt_b
-         END DO
-         ! Save barotropic velocities not transport:
-         ua_b(:,:) =  ua_b(:,:) / ( hu_0(:,:) + zsshu_a(:,:) + 1._wp - ssumask(:,:) )
-         va_b(:,:) =  va_b(:,:) / ( hv_0(:,:) + zsshv_a(:,:) + 1._wp - ssvmask(:,:) )
-      ENDIF
+        IF( ln_dynadv_vec .OR. ln_linssh ) THEN
+           DO jk=1,jpkm1
+              ua(:,:,jk) = ua(:,:,jk) + ( ua_b(:,:) - ub_b(:,:) ) * z1_2dt_b
+              va(:,:,jk) = va(:,:,jk) + ( va_b(:,:) - vb_b(:,:) ) * z1_2dt_b
+           END DO
+        ELSE
+           ! At this stage, ssha has been corrected: compute new depths at velocity points
+           DO jj = 1, jpjm1
+              DO ji = 1, jpim1      ! NO Vector Opt.
+                 zsshu_a(ji,jj) = z1_2 * umask(ji,jj,1)  * r1_e1e2u(ji,jj) &
+                    &              * ( e1e2t(ji  ,jj) * ssha(ji  ,jj)    &
+                    &              +   e1e2t(ji+1,jj) * ssha(ji+1,jj) )
+                 zsshv_a(ji,jj) = z1_2 * vmask(ji,jj,1)  * r1_e1e2v(ji,jj) &
+                    &              * ( e1e2t(ji,jj  ) * ssha(ji,jj  )    &
+                    &              +   e1e2t(ji,jj+1) * ssha(ji,jj+1) )
+              END DO
+           END DO
+           CALL lbc_lnk_multi( zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp ) ! Boundary conditions
+           !
+           DO jk=1,jpkm1
+              ua(:,:,jk) = ua(:,:,jk) + r1_hu_n(:,:) * ( ua_b(:,:) - ub_b(:,:) * hu_b(:,:) ) * z1_2dt_b
+              va(:,:,jk) = va(:,:,jk) + r1_hv_n(:,:) * ( va_b(:,:) - vb_b(:,:) * hv_b(:,:) ) * z1_2dt_b
+           END DO
+           ! Save barotropic velocities not transport:
+           ua_b(:,:) =  ua_b(:,:) / ( hu_0(:,:) + zsshu_a(:,:) + 1._wp - ssumask(:,:) )
+           va_b(:,:) =  va_b(:,:) / ( hv_0(:,:) + zsshv_a(:,:) + 1._wp - ssvmask(:,:) )
+        ENDIF
+
+      END IF
       !
       DO jk = 1, jpkm1
@@ -1086,5 +1090,5 @@
       CALL wrk_dealloc( jpi,jpj,   zsshu_a, zsshv_a                                   )
       CALL wrk_dealloc( jpi,jpj,   zhf )
-      IF( ln_wd ) CALL wrk_dealloc( jpi, jpj, zcpx, zcpy, wduflt1, wdvflt1 )
+      IF( ln_wd ) CALL wrk_dealloc( jpi, jpj, zcpx, zcpy )
       !
       IF ( ln_diatmb ) THEN
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 7339)
@@ -88,12 +88,17 @@
       ENDIF
       !
-      CALL div_hor( kt )                              ! Horizontal divergence
-      !
-      z2dt = 2._wp * rdt                              ! set time step size (Euler/Leapfrog)
+      z2dt = 2._wp * rdt                          ! set time step size (Euler/Leapfrog)
       IF( neuler == 0 .AND. kt == nit000 )   z2dt = rdt
+      zcoef = 0.5_wp * r1_rau0
 
       !                                           !------------------------------!
       !                                           !   After Sea Surface Height   !
       !                                           !------------------------------!
+      IF(ln_wd) THEN
+         CALL wad_lmt(sshb, zcoef * (emp_b(:,:) + emp(:,:)), z2dt)
+      ENDIF
+
+      CALL div_hor( kt )                               ! Horizontal divergence
+      !
       zhdiv(:,:) = 0._wp
       DO jk = 1, jpkm1                                 ! Horizontal divergence of barotropic transports
@@ -104,8 +109,4 @@
       ! compute the vertical velocity which can be used to compute the non-linear terms of the momentum equations.
       ! 
-      zcoef = 0.5_wp * r1_rau0
-
-      IF(ln_wd) CALL wad_lmt(sshb, zcoef * (emp_b(:,:) + emp(:,:)), z2dt)
-
       ssha(:,:) = (  sshb(:,:) - z2dt * ( zcoef * ( emp_b(:,:) + emp(:,:) ) + zhdiv(:,:) )  ) * ssmask(:,:)
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/wet_dry.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/wet_dry.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/DYN/wet_dry.F90	(revision 7339)
@@ -33,5 +33,4 @@
    !! ---------------------------------------------------------------------
 
-   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) ::   wduflt, wdvflt !: u- and v- filter
    REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) ::   wdmask         !: u- and v- limiter 
 
@@ -46,4 +45,5 @@
    PUBLIC   wad_lmt                   ! routine called by sshwzv.F90
    PUBLIC   wad_lmt_bt                ! routine called by dynspg_ts.F90
+   PUBLIC   wad_istate                ! routine called by istate.F90 and domvvl.F90
 
    !! * Substitutions
@@ -87,5 +87,5 @@
 
       IF(ln_wd) THEN
-         ALLOCATE( wduflt(jpi,jpj), wdvflt(jpi,jpj), wdmask(jpi,jpj), STAT=ierr )
+         ALLOCATE( wdmask(jpi,jpj), STAT=ierr )
          IF( ierr /= 0 ) CALL ctl_stop('STOP', 'wad_init : Array allocation error')
       ENDIF
@@ -145,6 +145,6 @@
         ! Horizontal Flux in u and v direction
         DO jk = 1, jpkm1  
-           DO jj = 1, jpjm1
-              DO ji = 1, jpim1
+           DO jj = 1, jpj
+              DO ji = 1, jpi
                  zflxu(ji,jj) = zflxu(ji,jj) + e3u_n(ji,jj,jk) * un(ji,jj,jk) * umask(ji,jj,jk)
                  zflxv(ji,jj) = zflxv(ji,jj) + e3v_n(ji,jj,jk) * vn(ji,jj,jk) * vmask(ji,jj,jk)
@@ -156,6 +156,7 @@
         zflxv(:,:) = zflxv(:,:) * e1v(:,:)
        
-        DO jj = 2, jpjm1
-           DO ji = 2, jpim1 
+        wdmask(:,:) = 1
+        DO jj = 2, jpj
+           DO ji = 2, jpi 
 
              IF(tmask(ji, jj, 1) < 0.5_wp) CYCLE   ! we don't care about land cells
@@ -168,7 +169,8 @@
 
               zdep2 = bathy(ji,jj) + sshb1(ji,jj) - rn_wdmin1
-              IF(zdep2 < 0._wp) THEN  !add more safty, but not necessary
+              IF(zdep2 .le. 0._wp) THEN  !add more safty, but not necessary
                 !zdep2 = 0._wp
                 sshb1(ji,jj) = rn_wdmin1 - bathy(ji,jj)
+                wdmask(ji,jj) = 0._wp
               END IF
            ENDDO
@@ -183,8 +185,7 @@
            zflxv1(:,:) = zflxv(:,:) * zwdlmtv(:,:)
           
-           DO jj = 2, jpjm1
-              DO ji = 2, jpim1 
+           DO jj = 2, jpj
+              DO ji = 2, jpi 
         
-                 wdmask(ji,jj) = 0
                  IF(tmask(ji, jj, 1) < 0.5_wp) CYCLE 
                  IF(bathy(ji,jj) > zdepwd) CYCLE
@@ -202,5 +203,5 @@
                  IF(zdep1 > zdep2) THEN
                    zflag = 1
-                   wdmask(ji, jj) = 1
+                   wdmask(ji, jj) = 0
                    zcoef = ( ( zdep2 - rn_wdmin2 ) * ztmp - zzflxn * z2dt ) / ( zflxp(ji,jj) * z2dt )
                    zcoef = max(zcoef, 0._wp)
@@ -209,5 +210,5 @@
                    IF(zflxu1(ji-1,jj) < 0._wp) zwdlmtu(ji-1,jj) = zcoef
                    IF(zflxv1(ji,  jj) > 0._wp) zwdlmtv(ji  ,jj) = zcoef
-                   IF(zflxv1(ji,jj-1) < 0._wp) zwdlmtv(ji-1,jj) = zcoef
+                   IF(zflxv1(ji,jj-1) < 0._wp) zwdlmtv(ji,jj-1) = zcoef
                  END IF
               END DO ! ji loop
@@ -231,4 +232,9 @@
         CALL lbc_lnk( un, 'U', -1. )
         CALL lbc_lnk( vn, 'V', -1. )
+      !
+        un_b(:,:) = un_b(:,:) * zwdlmtu(:, :)
+        vn_b(:,:) = vn_b(:,:) * zwdlmtv(:, :)
+        CALL lbc_lnk( un_b, 'U', -1. )
+        CALL lbc_lnk( vn_b, 'V', -1. )
        
         IF(zflag == 1 .AND. lwp) WRITE(numout,*) 'Need more iterations in wad_lmt!!!'
@@ -291,6 +297,4 @@
         zflxp(:,:)   = 0._wp
         zflxn(:,:)   = 0._wp
-        !zflxu(:,:)   = 0._wp
-        !zflxv(:,:)   = 0._wp
 
         zwdlmtu(:,:)  = 1._wp
@@ -299,9 +303,6 @@
         ! Horizontal Flux in u and v direction
        
-        !zflxu(:,:) = zflxu(:,:) * e2u(:,:)
-        !zflxv(:,:) = zflxv(:,:) * e1v(:,:)
-       
-        DO jj = 2, jpjm1
-           DO ji = 2, jpim1 
+        DO jj = 2, jpj
+           DO ji = 2, jpi 
 
              IF(tmask(ji, jj, 1) < 0.5_wp) CYCLE   ! we don't care about land cells
@@ -314,8 +315,4 @@
 
               zdep2 = bathy(ji,jj) + sshn_e(ji,jj) - rn_wdmin1
-              IF(zdep2 < 0._wp) THEN  !add more safty, but not necessary
-                !zdep2 = 0._wp
-               sshn_e(ji,jj) = rn_wdmin1 - bathy(ji,jj)
-              END IF
            ENDDO
         END DO
@@ -329,8 +326,7 @@
            zflxv1(:,:) = zflxv(:,:) * zwdlmtv(:,:)
           
-           DO jj = 2, jpjm1
-              DO ji = 2, jpim1 
+           DO jj = 2, jpj
+              DO ji = 2, jpi 
         
-                 wdmask(ji,jj) = 0
                  IF(tmask(ji, jj, 1) < 0.5_wp) CYCLE 
                  IF(bathy(ji,jj) > zdepwd) CYCLE
@@ -349,5 +345,4 @@
                  IF(zdep1 > zdep2) THEN
                    zflag = 1
-                   !wdmask(ji, jj) = 1
                    zcoef = ( ( zdep2 - rn_wdmin2 ) * ztmp - zzflxn * z2dt ) / ( zflxp(ji,jj) * z2dt )
                    zcoef = max(zcoef, 0._wp)
@@ -356,5 +351,5 @@
                    IF(zflxu1(ji-1,jj) < 0._wp) zwdlmtu(ji-1,jj) = zcoef
                    IF(zflxv1(ji,  jj) > 0._wp) zwdlmtv(ji  ,jj) = zcoef
-                   IF(zflxv1(ji,jj-1) < 0._wp) zwdlmtv(ji-1,jj) = zcoef
+                   IF(zflxv1(ji,jj-1) < 0._wp) zwdlmtv(ji,jj-1) = zcoef
                  END IF
               END DO ! ji loop
@@ -379,6 +374,4 @@
         IF(zflag == 1 .AND. lwp) WRITE(numout,*) 'Need more iterations in wad_lmt_bt!!!'
        
-        !IF( ln_rnf      )   CALL sbc_rnf_div( hdivn )          ! runoffs (update hdivn field)
-        !IF( nn_cla == 1 )   CALL cla_div    ( kt )             ! Cross Land Advection (update hdivn field)
         !
         !
@@ -390,3 +383,138 @@
       IF( nn_timing == 1 )  CALL timing_stop('wad_lmt')
    END SUBROUTINE wad_lmt_bt
+
+   SUBROUTINE wad_istate
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE wad_istate  ***
+      !! 
+      !! ** Purpose :   Initialization of the dynamics and tracers for WAD test
+      !!      configurations (channels or bowls with initial ssh gradients)
+      !!
+      !! ** Method  : - set temperature field
+      !!              - set salinity field
+      !!              - set ssh slope (needs to be repeated in domvvl_rst_init to
+      !!                               set vertical metrics )
+      !!----------------------------------------------------------------------
+      !
+      INTEGER  ::   ji, jj            ! dummy loop indices
+      REAL(wp) ::   zi, zj
+      !!----------------------------------------------------------------------
+      !
+      ! Uniform T & S in all test cases
+      tsn(:,:,:,jp_tem) = 10._wp
+      tsb(:,:,:,jp_tem) = 10._wp
+      tsn(:,:,:,jp_sal) = 35._wp
+      tsb(:,:,:,jp_sal) = 35._wp
+      SELECT CASE ( jp_cfg ) 
+         !                                        ! ====================
+         CASE ( 1 )                               ! WAD 1 configuration
+            !                                     ! ====================
+            !
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'istate_wad : Closed box with EW linear bottom slope'
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+            !
+            do ji = 1,jpi
+             sshn(ji,:) = ( -5.5_wp + 5.5_wp*FLOAT(mig(ji))/FLOAT(jpidta-1))*tmask(ji,:,1)
+            end do
+            !                                     ! ====================
+         CASE ( 2 )                               ! WAD 2 configuration
+            !                                     ! ====================
+            !
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'istate_wad : Parobolic EW channel, mid-range initial ssh slope'
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+            !
+            do ji = 1,jpi
+             sshn(ji,:) = ( -5.5_wp + 3.9_wp*FLOAT(jpidta - mig(ji))/FLOAT(jpidta-1))*tmask(ji,:,1)
+            end do
+            !                                     ! ====================
+         CASE ( 3 )                               ! WAD 3 configuration
+            !                                     ! ====================
+            !
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'istate_wad : Parobolic EW channel, extreme initial ssh slope' 
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+            !
+            do ji = 1,jpi
+             sshn(ji,:) = ( -7.5_wp + 6.9_wp*FLOAT(jpidta - mig(ji))/FLOAT(jpidta-1))*tmask(ji,:,1)
+            end do
+
+            !
+            !                                     ! ====================
+         CASE ( 4 )                               ! WAD 4 configuration
+            !                                     ! ====================
+            !
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'istate_wad : Parobolic bowl, mid-range initial ssh slope' 
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+            !
+            DO ji = 1, jpi
+               zi = MAX(1.0-FLOAT((mig(ji)-25)**2)/400.0, 0.0 )
+               DO jj = 1, jpj
+                  zj = MAX(1.0-FLOAT((mjg(jj)-17)**2)/144.0, 0.0 )
+                  sshn(ji,jj) = -8.5_wp + 8.5_wp*zi*zj
+               END DO
+            END DO
+
+            !
+            !                                    ! ===========================
+         CASE ( 5 )                              ! WAD 5 configuration
+            !                                    ! ====================
+            !
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'istate_wad : Double slope with shelf'
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+            !
+            ! Needed rn_wdmin2 increased to 0.01 for this case?
+            do ji = 1,jpi
+             sshn(ji,:) = ( -5.5_wp + 9.0_wp*FLOAT(mig(ji))/FLOAT(jpidta-1))*tmask(ji,:,1)
+            end do
+
+            !
+            !                                     ! ===========================
+         CASE ( 6 )                               ! WAD 6 configuration
+            !                                     ! ====================
+            !
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'istate_wad : Parobolic EW channel with gaussian ridge' 
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
+            !
+            do ji = 1,jpi
+             !6a
+             sshn(ji,:) = ( -5.5_wp + 9.0_wp*FLOAT(jpidta - mig(ji))/FLOAT(jpidta-1))*tmask(ji,:,1)
+             !Some variations in initial slope that have been tested
+             !6b
+             !sshn(ji,:) = ( -5.5_wp + 6.5_wp*FLOAT(jpidta - mig(ji))/FLOAT(jpidta-1))*tmask(ji,:,1)
+             !6c
+             !sshn(ji,:) = ( -5.5_wp + 7.5_wp*FLOAT(jpidta - mig(ji))/FLOAT(jpidta-1))*tmask(ji,:,1)
+             !6d
+             !sshn(ji,:) = ( -4.5_wp + 8.0_wp*FLOAT(jpidta - mig(ji))/FLOAT(jpidta-1))*tmask(ji,:,1)
+            end do
+
+            !
+            !                                    ! ===========================
+         CASE DEFAULT                            ! NONE existing configuration
+            !                                    ! ===========================
+            WRITE(ctmp1,*) 'WAD test with a ', jp_cfg,' option is not coded'
+            !
+            CALL ctl_stop( ctmp1 )
+            !
+      END SELECT
+      !
+      ! Apply minimum wetdepth criterion
+      !
+      do jj = 1,jpj
+         do ji = 1,jpi
+            IF( bathy(ji,jj) + sshn(ji,jj) < rn_wdmin1 ) THEN
+               sshn(ji,jj) = tmask(ji,jj,1)*( rn_wdmin1 - bathy(ji,jj) )
+            ENDIF
+         end do
+      end do
+      sshb = sshn
+      ssha = sshn
+      !
+   END SUBROUTINE wad_istate
+
+   !!=====================================================================
 END MODULE wet_dry
Index: branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_fct.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_fct.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_fct.F90	(revision 7339)
@@ -149,12 +149,11 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  ! total intermediate advective trends
+                  !                             ! 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) / e3t_n(ji,jj,jk)
-                  ! update and guess with monotonic sheme
-!!gm why tmask added in the two following lines ???    the mask is done in tranxt !
-                  pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn)         + ztra   * tmask(ji,jj,jk)
-                  zwi(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + p2dt * ztra ) * tmask(ji,jj,jk)
+                     &      + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) ) * r1_e1e2t(ji,jj)
+                  !                             ! update and guess with monotonic sheme
+                  pta(ji,jj,jk,jn) =                     pta(ji,jj,jk,jn) +        ztra   / e3t_n(ji,jj,jk) * tmask(ji,jj,jk)
+                  zwi(ji,jj,jk)    = ( e3t_b(ji,jj,jk) * ptb(ji,jj,jk,jn) + p2dt * ztra ) / e3t_a(ji,jj,jk) * tmask(ji,jj,jk)
                END DO
             END DO
@@ -163,5 +162,5 @@
          !                
          IF( l_trd )  THEN             ! trend diagnostics (contribution of upstream fluxes)
-            ztrdx(:,:,:) = zwx(:,:,:)   ;    ztrdy(:,:,:) = zwy(:,:,:)  ;   ztrdz(:,:,:) = zwz(:,:,:)
+            ztrdx(:,:,:) = zwx(:,:,:)   ;   ztrdy(:,:,:) = zwy(:,:,:)   ;   ztrdz(:,:,:) = zwz(:,:,:)
          END IF
          !                             ! "Poleward" heat and salt transports (contribution of upstream fluxes)
@@ -364,5 +363,5 @@
       !
       CALL wrk_alloc( jpi,jpj,             zwx_sav, zwy_sav )
-      CALL wrk_alloc( jpi,jpj, jpk,        zwx, zwy, zwz, zwi, zhdiv, zwzts, zwz_sav )
+      CALL wrk_alloc( jpi,jpj,jpk,         zwx, zwy, zwz, zwi, zhdiv, zwzts, zwz_sav )
       CALL wrk_alloc( jpi,jpj,jpk,kjpt+1,  ztrs )
       !
@@ -436,8 +435,8 @@
                   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) / e3t_n(ji,jj,jk)
+                     &      + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1)   ) * r1_e1e2t(ji,jj)
                   !                             ! update and guess with monotonic sheme
-                  pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn)         + ztra
-                  zwi(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + p2dt * ztra ) * tmask(ji,jj,jk)
+                  pta(ji,jj,jk,jn) =                     pta(ji,jj,jk,jn) +        ztra   / e3t_n(ji,jj,jk) * tmask(ji,jj,jk)
+                  zwi(ji,jj,jk)    = ( e3t_b(ji,jj,jk) * ptb(ji,jj,jk,jn) + p2dt * ztra ) / e3t_a(ji,jj,jk) * tmask(ji,jj,jk)
                END DO
             END DO
@@ -488,4 +487,6 @@
          zwz_sav(:,:,:)   = zwz(:,:,:)
          ztrs   (:,:,:,1) = ptb(:,:,:,jn)
+         ztrs   (:,:,1,2) = ptb(:,:,1,jn)
+         ztrs   (:,:,1,3) = ptb(:,:,1,jn)
          zwzts  (:,:,:)   = 0._wp
          !
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/DMP_TOOLS/src/zoom.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/DMP_TOOLS/src/zoom.F90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/DMP_TOOLS/src/zoom.F90	(revision 7339)
@@ -29,8 +29,5 @@
       NAMELIST/nam_zoom_dmp/lzoom_n,lzoom_e,lzoom_w,lzoom_s
       !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start( 'dtacof_zoom')
-      !
-      
+
       ! Read namelist
       OPEN( UNIT=numnam, FILE='namelist', FORM='FORMATTED', STATUS='OLD' )
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/MISCELLANEOUS/README_uspcfg
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/MISCELLANEOUS/README_uspcfg	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/MISCELLANEOUS/README_uspcfg	(revision 7339)
@@ -0,0 +1,134 @@
+Instructions for using unsupported configurations on systems without wget access to
+the internet
+
+The unsupported configurations in NEMO are provided as a way for users to provide
+alternative configurations to the wider community without having to rely on system team
+sponsership and support. The idea is to provide minimal but sufficient information
+with the standard distribution to allow ancillary files to be fetched from remote
+servers at compile time. Thus a makenemo command such as:
+
+./makenemo -n MYISOMIP -u ISOMIP -m some_arch
+
+will create a new configuration called MYISOMIP with MY_SRC and EXP00 directories
+populated from a remote server. It does this by first using the wget command to fetch a
+list of remote files and then using wget repeatedly to fetch each of the files listed
+therein. The location of the remote list is contained in one line of information held
+in the uspcfg.txt file (in CONFIG).
+
+These instructions provide a work-around for systems without direct access to the
+internet or on which wget has been disabled/not installed. On these systems it is
+possible to create local copies of the remote files and replace the wget function
+with a local copy command. It will be the user's responsibility to ensure that the
+local copies reflect any changes made in the remote sources.
+
+The procedure requires the following steps:
+
+1. From the target NEMOGCM directory on your target system copy the following
+   files into a working directory on a system that does have internet access
+   and a working wget command:
+
+      a. TOOLS/MISCELLANEOUS/make_usp_tar.sh
+      b. CONFIG/uspcfg.txt
+
+2. On that alternative system and in the working directory containing the newly
+   copied files, run the make_usp_tar.sh script. The script takes three arguments:
+
+      a. The name of the uspcfg.txt file
+      b. The name of the unsupported configuration you wish to use
+      c. The name of a directory that will be created and filled with the remote
+         files in the current working directory. This directory will be tarred and
+         eventually transferred to the target system. There it will be unpacked and
+         will form the local archive for this configuration. A meaningful name is
+         therefore recommended.
+
+   For example:
+
+   ./make_usp_tar.sh uspcfg.txt ISOMIP ISOMIP_ARCHIVE
+
+3. Copy the resulting tarball (in this case: ISOMIP_ARCHIVE.tar) to the target 
+   system and unpack (tar xvf ISOMIP_ARCHIVE.tar) in a location that is visible to 
+   the node on which you intend to compile nemo. The unpacked directory will contain
+   the files retrieved from the remote server, modified versions of the file list and
+   uspcfg.txt files and two new scripts. For example:
+
+   ls -1R ISOMIP_ARCHIVE
+   cpp_ISOMIP.fcm             - downloaded from remote server
+   def_wget                   - newly constructed script
+   local_template.ctl         - file list modified for local copy
+   uspcfg_local_template.txt  - a copy of uspcfg.txt with modification for local copy
+   remote_file.list           - downloaded from remote server
+   set_local_uspcfg           - newly constructed script
+   EXP00                      - new subdirectory
+   MY_SRC                     - new subdirectory
+
+   ./EXP00:
+   iodef.xml                  - downloaded from remote server
+   namelist_cfg               - downloaded from remote server
+
+   ./MY_SRC:
+   domzgr.F90                 - downloaded from remote server
+   istate.F90                 - downloaded from remote server
+
+4. The final stage is to enter the directory and execute the set_local_uspcfg script.
+   This script will prompt for a full path to the target CONFIG directory and then:
+
+   a. Edit the templates and create local.ctl and uspcfg_local.txt files by inserting 
+      the full path to the archive directory (i.e. the current working directory)
+   b. move uspcfg_local.txt to the named CONFIG directory
+   c. rename any existing uspcfg.txt file in the CONFIG directory to uspcfg_remote.txt
+   d. insert symbolic link (uspcfg.txt) to uspcfg_local.txt in the CONFIG directory
+   e. redefine/define wget as an exported bash function to simply copy
+
+   This last action is needed so that subsequent use of makenemo with the -u argument
+   will not invoke wget. For this to be effective the set_local_usp script should be run
+   within the same bash shell as makenemo will be run in. I.e.:
+
+   . ./set_local_usp
+
+   If this is not possible or the makenemo command is run at a later date, then the
+   def_wget script should be run in the bash shell before any attempt to use the -u
+   option of makenemo. I.e.:
+
+   . ./def_wget
+
+   [ Tip: check that the definition/re-definition of wget has worked correctly by
+     issuing this command:
+
+     wget a b c
+
+     If you get messages such as:
+
+       wget a b c
+       --2016-10-27 10:14:52--  http://a/
+       Resolving a... failed: Name or service not known.
+       wget: unable to resolve host address `a'
+       .
+       .
+
+     then the re-definition of wget has not been retained by the current shell. Run
+     . ./def_wget and try again. You should get a response such as:
+
+     wget a b c
+     Expected wget usage: wget src -O dest
+     -O not found. No action taken
+
+     if the environment is set correctly
+   ]
+
+5. The setup is now complete and moving to the CONFIG directory and issuing a command
+   such as:
+
+    ./makenemo -n MYISOMIP -u ISOMIP -m target_arch
+
+   should correctly configure from local archives only.   
+
+   [ Tip: the -u argument ( and hence the need to switch wget to local copies on isolated
+     systems ) is only required when compiling for the first time. Subsequent compilations
+     following code changes in the MYISOMIP directories can be carried out in your
+     default nemo environment. I.e.:
+
+     ./makenemo -n MYISOMIP -m target_arch
+
+     will not require any of the preceeding steps in future sessions.
+   ]
+
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/MISCELLANEOUS/make_usp_tar.sh
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/MISCELLANEOUS/make_usp_tar.sh	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/MISCELLANEOUS/make_usp_tar.sh	(revision 7339)
@@ -0,0 +1,235 @@
+#!/bin/bash
+#set -x
+set -o posix
+#set -u
+#set -e
+#+
+# ===============
+# make_usp_tar.sh
+# ===============
+# ---------------
+# Fetch and tar a unsupported configuration setup.
+# This script is only needed when target systems do
+# not have wget access to the internet. To configure
+# unsupported conigurations on these systems it will
+# first be necessary to run this script on a system that
+# does have access. Then copy access the resulting tar file,
+# unpack and run the enclosed set_local_uspcfg script in a 
+# bash shell to complete the process. That script redefines/
+# defines wget as a bash function to perform local copies 
+# from this unpacked tarball. If you wish to create a new 
+# configuration based on this local copy of an unsupported 
+# configuration in future sessions then you may need to 
+# redefine wget again before running makenemo with the 
+# appropriate -u setting. A simple script: def_wget is included
+# for such situations.
+# ---------------
+# SYNOPSIS
+# ========
+#  $ make_usp_tar.sh uspcfg.txt target_conf target_dir
+# Note target_dir.tar will be created
+#
+# DESCRIPTION
+# ===========
+# - Extract target configuration details from uspcfg.txt
+# - Create target directory
+# - Recursively use wget to retrieve remote configuration files
+#   into target directory
+# - Copy uspcfg.txt into target directory and alter remote paths
+#   to local (relative) versions
+# - tar target_directory and remove originals
+#----------------------------------------------------------------
+#
+#----------------------------------------------------------------
+# Check the correct number of arguments have been provided
+#----------------------------------------------------------------
+#
+   if [ "$#" != "3" ]; then
+    echo "Expected usage: make_usp_tar.sh uspcfg.txt target_conf target_dir"
+    exit
+   fi
+#
+#----------------------------------------------------------------
+# Check the named uspcfg.txt file exists
+#----------------------------------------------------------------
+#
+   if [ ! -f $1 ]; then
+    echo "named uspcfg.txt file does not exist ($1); attempt abandoned"
+    exit
+   fi
+#
+#----------------------------------------------------------------
+# Check the requested configuration is listed in the named uspcfg.txt file
+#----------------------------------------------------------------
+#
+   inthere=$( grep -c "$2" $1 )
+   if [ "$inthere" -lt 1 ]; then
+    echo "requested configuration is not in named uspcfg.txt file ($2); attempt abandoned"
+    exit
+   fi
+#
+#----------------------------------------------------------------
+# Create the target directory if it does not already exist
+# and cd into it
+#----------------------------------------------------------------
+#
+   if [ ! -d $3 ]; then
+    mkdir $3
+   else
+    echo "target directory already exists; attempt abandoned"
+    exit
+   fi
+   basedir=$(pwd)
+#
+   cd ${3}
+#
+#----------------------------------------------------------------
+# Copy named uspcfg.txt file into target directory
+#----------------------------------------------------------------
+#
+   cp $basedir/$1 .
+#
+#----------------------------------------------------------------
+# Extract information on target configuration and
+# retrieve full file list from remote server
+#----------------------------------------------------------------
+#
+   grep "$2 " $1 > ./cfg.tmp
+#
+   LOCAL_REF=$(cat cfg.tmp | awk 'BEGIN {FS = "#" }{print $2}')
+   TAB=$(cat cfg.tmp | awk 'BEGIN {FS = "#" }{print $3}')
+   REMOTE_CTL=$(cat cfg.tmp | awk 'BEGIN {FS = "#" }{print $4}')
+   wget ${REMOTE_CTL} -O remote_file.list
+#
+#----------------------------------------------------------------
+# Retrieve each remote file and create local directory structure
+# At the same time prepare a local version of the control file
+# by replacing http links with a string that will be replaced later
+# with a local directory path
+#----------------------------------------------------------------
+#
+   if [ -f remote_file.list ] ; then
+    cat remote_file.list | grep -v '^#' |
+     while
+      read remfile locfile
+      do
+       if [ $remfile == 'create_directory' ] ;then
+         mkdir $locfile
+         echo $remfile "                 " $locfile >> local_template.ctl
+       else
+         wget $remfile -O $locfile
+         remfile=$(echo $remfile | sed -e "s;.*$locfile;SET_LOCAL_DIRECTORY_HERE/$locfile;")
+         echo $remfile "  " $locfile >> local_template.ctl
+       fi
+      done
+   else
+    echo "Unable to find remote_file.list. Attempt abandoned"
+    echo "Files may be left in "$(pwd)
+    exit
+   fi
+#
+#----------------------------------------------------------------
+# Construct a modified version of the named uspcfg.txt file
+# First copy across all the other untouched configuration listed
+#----------------------------------------------------------------
+#
+   grep -v "$2 " $1 >  uspcfg_local_template.txt
+#
+#----------------------------------------------------------------
+# Now append the modified entry, replacing http links as before
+#----------------------------------------------------------------
+#
+   cat cfg.tmp | sed -e "s;http.*$;SET_LOCAL_DIRECTORY_HERE/local.ctl;" >> uspcfg_local_template.txt
+#
+#
+#----------------------------------------------------------------
+# Construct a script that can be used later to complete a local installation
+#----------------------------------------------------------------
+#
+cat > set_local_uspcfg << EOF
+#!/bin/bash
+   if [ "\$( echo $SHELL | grep -c bash )" -lt 1 ]; then
+    echo "WARNING: This is only going to be effective in a bash shell"
+    echo "since it redefines the wget command as a bash function."
+    echo "(ignore this comment if you are in a bash shell)"
+   fi
+   basedir=\$(pwd)
+#
+   echo "Enter full path to the CONFIG directory on your target system: "
+   read confdir
+#
+# Edit the local.ctl file to set the local directory path
+#
+   sed -e "s;SET_LOCAL_DIRECTORY_HERE;\$basedir;" local_template.ctl > local.ctl
+#
+# Edit the uspcfg_local.txt file to set the local directory path
+#
+   sed -e "s;SET_LOCAL_DIRECTORY_HERE;\$basedir;" uspcfg_local_template.txt > uspcfg_local.txt
+#
+# Install local versions in the named CONFIG directory
+#
+   if [ -f \$confdir/uspcfg.txt ] && [ ! -L \$confdir/uspcfg.txt ]; then
+    mv \$confdir/uspcfg.txt \$confdir/uspcfg_remote.txt
+    echo "\$confdir/uspcfg.txt moved to \$confdir/uspcfg_remote.txt"
+   fi
+   if [ -f \$confdir/uspcfg_local.txt ]; then
+    echo "Existing uspcfg_local.txt file found in \$confdir"
+    echo "This has been moved to: "\$confdir/uspcfg_local.txt\$\$
+    mv \$confdir/uspcfg_local.txt \$confdir/uspcfg_local.txt\$\$
+   fi
+   mv uspcfg_local.txt \$confdir/uspcfg_local.txt
+   ln -s \$confdir/uspcfg_local.txt \$confdir/uspcfg.txt
+#
+# define/redefine the wget command
+#
+function wget {
+   if [ "\$2" != "-O" ]; then
+    echo "Expected wget usage: wget src -O dest"
+    echo "-O not found. No action taken"
+   else
+    cp \$1 \$3
+   fi
+}
+export -f wget
+EOF
+#----------------------------------------------------------------
+# Construct a script that can be used later to just redefine wget 
+# in bash shell sessions
+#----------------------------------------------------------------
+#
+cat > def_wget << EOFC
+#!/bin/bash
+   if [ "\$( echo $SHELL | grep -c bash )" -lt 1 ]; then
+    echo "WARNING: This is only going to be effective in a bash shell"
+    echo "since it redefines the wget command as a bash function."
+    echo "(ignore this comment if you are in a bash shell)"
+   fi
+function wget {
+   if [ "\$2" != "-O" ]; then
+    echo "Expected wget usage: wget src -O dest"
+    echo "-O not found. No action taken"
+   else
+    cp \$1 \$3
+   fi
+}
+export -f wget
+EOFC
+#----------------------------------------------------------------
+# Make sure these scripts have execute permission
+#----------------------------------------------------------------
+   chmod 755 set_local_uspcfg
+   chmod 755 def_wget
+#
+#----------------------------------------------------------------
+# Tidy up and tar the contents of the downloaded configuration
+#----------------------------------------------------------------
+   rm cfg.tmp
+   cd $basedir
+   tar cvf ${3}.tar $3
+   echo ${3}.tar " file successfully created and prepared for local references. Move this"
+   echo "tar file to your target system, unpack and run the set_local_uspcfg script in a "
+   echo "bash shell to complete the process. This script redefines/defines wget as a bash"
+   echo "function to perform local copies from this unpacked tarball. If you wish to create"
+   echo "a new configuration based on this local copy of an unsupported configuration in "
+   echo "future sessions then you may need to rerun the def_wget script"
+exit
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/cfg/dummy.cfg
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/cfg/dummy.cfg	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/cfg/dummy.cfg	(revision 7339)
@@ -0,0 +1,5 @@
+&namdum
+   cn_dumvar=""
+   cn_dumdim=""
+   cn_dumatt="history"
+/
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg	(revision 7339)
@@ -1,7 +1,7 @@
 # name       | units          | axis | pt| interpolation   | long name                             | standard name                                  
-X            | 1              | X    |   |                 |                                       | projection_x_coordinate               
-Y            | 1              | Y    |   |                 |                                       | projection_y_coordinate               
-Z            | 1              | Z    |   |                 |                                       | projection_z_coordinate               
-T            | 1              | T    |   |                 |                                       | projection_t_coordinate               
+X            | unitless       | X    |   |                 |                                       | projection_x_coordinate               
+Y            | unitless       | Y    |   |                 |                                       | projection_y_coordinate               
+Z            | unitless       | Z    |   |                 |                                       | projection_z_coordinate               
+T            | unitless       | T    |   |                 |                                       | projection_t_coordinate               
 nav_lon      | degrees_east   | XY   | T | cubic           | Longitude                             | longitude                                   
 nav_lat      | degrees_north  | XY   | T | cubic           | Latitude                              | latitude                         
@@ -43,4 +43,5 @@
 kt           |                |      |   |                 |                                       |                                  
 rdt          |                |      |   |                 |                                       |                                  
+rdttra1      |                |      |   |                 |                                       |                                  
 utau_b       |                | XY   | U |                 |                                       |surface_downward_eastward_stress  
 vtau_b       |                | XY   | V |                 |                                       |surface_downward_northward_stress 
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/Doxyfile
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/Doxyfile	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/Doxyfile	(revision 7339)
@@ -45,5 +45,5 @@
 # quick idea about the purpose of the project. Keep the description short.
 
-PROJECT_BRIEF          = "System and Interface for oceanic RElocable Nesting"
+PROJECT_BRIEF          = "System and Interface for oceanic RElocatable Nesting"
 
 # With the PROJECT_LOGO tag one can specify an logo or icon that is included in
@@ -2069,5 +2069,5 @@
 # The default value is: NO.
 
-HAVE_DOT               = YES
+HAVE_DOT               = NO
 
 # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/attribute.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/attribute.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/attribute.f90	(revision 7339)
@@ -83,4 +83,6 @@
 !> @date November, 2014 
 !> - Fix memory leaks bug
+!> @date September, 2015
+!> - manage useless (dummy) attributes
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -98,4 +100,6 @@
    PUBLIC :: TATT       !< attribute structure
 
+   PRIVATE :: cm_dumatt !< dummy attribute array
+
    ! function and subroutine
    PUBLIC :: att_init       !< initialize attribute structure
@@ -105,4 +109,6 @@
    PUBLIC :: att_get_index  !< get attribute index, in an array of attribute structure
    PUBLIC :: att_get_id     !< get attribute id, read from file
+   PUBLIC :: att_get_dummy  !< fill dummy attribute array
+   PUBLIC :: att_is_dummy   !< check if attribute is defined as dummy attribute
 
    PRIVATE :: att__clean_unit ! clean attribute strcuture
@@ -135,4 +141,6 @@
    END TYPE TATT
 
+   CHARACTER(LEN=lc), DIMENSION(ip_maxdum), SAVE :: cm_dumatt !< dummy attribute
+
    INTERFACE att_init
       MODULE PROCEDURE att__init_c    
@@ -1251,4 +1259,98 @@
 
    END SUBROUTINE att__clean_arr
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill dummy attribute array
+   !
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !> @date Marsh, 2016
+   !> - close file (bugfix)
+   !
+   !> @param[in] cd_dummy dummy configuration file
+   !-------------------------------------------------------------------
+   SUBROUTINE att_get_dummy( cd_dummy )
+      IMPLICIT NONE
+      ! Argument
+      CHARACTER(LEN=*), INTENT(IN) :: cd_dummy
+
+      ! local variable
+      INTEGER(i4)   :: il_fileid
+      INTEGER(i4)   :: il_status
+
+      LOGICAL       :: ll_exist
+
+      ! loop indices
+      ! namelist
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumvar
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumdim
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumatt
+
+      !----------------------------------------------------------------
+      NAMELIST /namdum/ &   !< dummy namelist
+      &  cn_dumvar, &       !< variable  name
+      &  cn_dumdim, &       !< dimension name
+      &  cn_dumatt          !< attribute name
+      !----------------------------------------------------------------
+
+      ! init
+      cm_dumatt(:)=''
+
+      ! read namelist
+      INQUIRE(FILE=TRIM(cd_dummy), EXIST=ll_exist)
+      IF( ll_exist )THEN
+    
+         il_fileid=fct_getunit()
+   
+         OPEN( il_fileid, FILE=TRIM(cd_dummy), &
+         &                FORM='FORMATTED',       &
+         &                ACCESS='SEQUENTIAL',    &
+         &                STATUS='OLD',           &
+         &                ACTION='READ',          &
+         &                IOSTAT=il_status)
+         CALL fct_err(il_status)
+         IF( il_status /= 0 )THEN
+            CALL logger_fatal("DIM GET DUMMY: opening "//TRIM(cd_dummy))
+         ENDIF
+   
+         READ( il_fileid, NML = namdum )
+         cm_dumatt(:)=cn_dumatt(:)
+
+         CLOSE( il_fileid )
+
+      ENDIF
+   
+   END SUBROUTINE att_get_dummy
+   !-------------------------------------------------------------------
+   !> @brief This function check if attribute is defined as dummy attribute
+   !> in configuraton file
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !
+   !> @param[in] td_att attribute structure
+   !> @return true if attribute is dummy attribute
+   !-------------------------------------------------------------------
+   FUNCTION att_is_dummy(td_att)
+      IMPLICIT NONE
+
+      ! Argument      
+      TYPE(TATT), INTENT(IN) :: td_att
+      
+      ! function
+      LOGICAL :: att_is_dummy
+      
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      att_is_dummy=.FALSE.
+      DO ji=1,ip_maxdum
+         IF( fct_lower(td_att%c_name) == fct_lower(cm_dumatt(ji)) )THEN
+            att_is_dummy=.TRUE.
+            EXIT
+         ENDIF
+      ENDDO
+
+   END FUNCTION att_is_dummy
 END MODULE att
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/boundary.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/boundary.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/boundary.f90	(revision 7339)
@@ -482,5 +482,5 @@
    !> ex : cn_north='index1,first1,last1(width)|index2,first2,last2'
    !>
-   !> @note Boundaries are compute on T point, but expressed on U,V point.
+   !> @warn Boundaries are compute on T point, but expressed on U,V point.
    !> change will be done to get data on other point when need be. 
    !>
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_bathy.f90	(revision 7339)
@@ -8,5 +8,5 @@
 !> @file
 !> @brief 
-!> This program create fine grid bathymetry file.
+!> This program creates fine grid bathymetry file.
 !>
 !> @details
@@ -27,5 +27,5 @@
 !>    you could find a template of the namelist in templates directory.
 !>
-!>    create_bathy.nam comprise 7 namelists:<br/>
+!>    create_bathy.nam contains 7 namelists:<br/>
 !>       - logger namelist (namlog)
 !>       - config namelist (namcfg)
@@ -36,8 +36,4 @@
 !>       - output namelist (namout)
 !>    
-!>    @note 
-!>       All namelists have to be in file create_bathy.nam, however variables of
-!>       those namelists are all optional.
-!>
 !>    * _logger namelist (namlog)_:<br/>
 !>       - cn_logfile   : log filename
@@ -49,4 +45,6 @@
 !>       - cn_varcfg : variable configuration file 
 !> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
 !>
 !>    * _coarse grid namelist (namcrs)_:<br/>
@@ -61,30 +59,4 @@
 !>
 !>    * _variable namelist (namvar)_:<br/>
-!>       - cn_varinfo : list of variable and extra information about request(s) 
-!>       to be used.<br/>
-!>          each elements of *cn_varinfo* is a string character
-!>          (separated by ',').<br/>
-!>          it is composed of the variable name follow by ':', 
-!>          then request(s) to be used on this variable.<br/> 
-!>          request could be:
-!>             - int = interpolation method
-!>             - ext = extrapolation method
-!>             - flt = filter method
-!>             - min = minimum value
-!>             - max = maximum value
-!>             - unt = new units
-!>             - unf = unit scale factor (linked to new units)
-!>
-!>                requests must be separated by ';'.<br/>
-!>                order of requests does not matter.<br/>
-!>
-!>          informations about available method could be find in @ref interp,
-!>          @ref extrap and @ref filter modules.<br/>
-!>          Example: 'Bathymetry: flt=2*hamming(2,3); min=0'
-!>          @note 
-!>             If you do not specify a method which is required, 
-!>             default one is apply.
-!>          @warning 
-!>             variable name must be __Bathymetry__ here.
 !>       - cn_varfile : list of variable, and corresponding file.<br/> 
 !>          *cn_varfile* is the path and filename of the file where find
@@ -108,4 +80,31 @@
 !>             - 'Bathymetry:5000,5000,5000/5000,3000,5000/5000,5000,5000'
 !>
+!>       - cn_varinfo : list of variable and extra information about request(s) 
+!>       to be used.<br/>
+!>          each elements of *cn_varinfo* is a string character
+!>          (separated by ',').<br/>
+!>          it is composed of the variable name follow by ':', 
+!>          then request(s) to be used on this variable.<br/> 
+!>          request could be:
+!>             - int = interpolation method
+!>             - ext = extrapolation method
+!>             - flt = filter method
+!>             - min = minimum value
+!>             - max = maximum value
+!>             - unt = new units
+!>             - unf = unit scale factor (linked to new units)
+!>
+!>                requests must be separated by ';'.<br/>
+!>                order of requests does not matter.<br/>
+!>
+!>          informations about available method could be find in @ref interp,
+!>          @ref extrap and @ref filter modules.<br/>
+!>          Example: 'Bathymetry: flt=2*hamming(2,3); min=0'
+!>          @note 
+!>             If you do not specify a method which is required, 
+!>             default one is apply.
+!>          @warning 
+!>             variable name must be __Bathymetry__ here.
+!>
 !>    * _nesting namelist (namnst)_:<br/>
 !>       - in_rhoi  : refinement factor in i-direction
@@ -127,8 +126,13 @@
 !> - extrapolate all land points.
 !> - allow to change unit.
+!> @date September, 2015
+!> - manage useless (dummy) variable, attributes, and dimension
+!> @date January,2016
+!> - add create_bathy_check_depth as in create_boundary
+!> - add create_bathy_check_time  as in create_boundary
+!> @date February, 2016
+!> - do not closed sea for east-west cyclic domain
 !
 !> @todo
-!> - use create_bathy_check_depth as in create_boundary
-!> - use create_bathy_check_time  as in create_boundary
 !> - check tl_multi is not empty
 !>
@@ -167,5 +171,4 @@
    INTEGER(i4)                                        :: il_status
    INTEGER(i4)                                        :: il_fileid
-   INTEGER(i4)                                        :: il_varid
    INTEGER(i4)                                        :: il_attid
    INTEGER(i4)                                        :: il_imin0
@@ -179,4 +182,5 @@
 
    LOGICAL                                            :: ll_exist
+   LOGICAL                                            :: ll_fillclosed
 
    TYPE(TMPP)                                         :: tl_coord0
@@ -208,30 +212,31 @@
    ! namelist variable
    ! namlog
-   CHARACTER(LEN=lc) :: cn_logfile = 'create_bathy.log' 
-   CHARACTER(LEN=lc) :: cn_verbosity = 'warning' 
-   INTEGER(i4)       :: in_maxerror = 5
+   CHARACTER(LEN=lc)                       :: cn_logfile = 'create_bathy.log' 
+   CHARACTER(LEN=lc)                       :: cn_verbosity = 'warning' 
+   INTEGER(i4)                             :: in_maxerror = 5
 
    ! namcfg
-   CHARACTER(LEN=lc) :: cn_varcfg = 'variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_varcfg = './cfg/variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_dumcfg = './cfg/dummy.cfg' 
 
    ! namcrs
-   CHARACTER(LEN=lc) :: cn_coord0 = '' 
-   INTEGER(i4)       :: in_perio0 = -1
+   CHARACTER(LEN=lc)                       :: cn_coord0 = '' 
+   INTEGER(i4)                             :: in_perio0 = -1
 
    ! namfin
-   CHARACTER(LEN=lc) :: cn_coord1 = ''
-   INTEGER(i4)       :: in_perio1 = -1
-   LOGICAL           :: ln_fillclosed = .TRUE.
+   CHARACTER(LEN=lc)                       :: cn_coord1 = ''
+   INTEGER(i4)                             :: in_perio1 = -1
+   LOGICAL                                 :: ln_fillclosed = .TRUE.
 
    ! namvar
+   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
    CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
-   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
 
    ! namnst
-   INTEGER(i4)       :: in_rhoi  = 1
-   INTEGER(i4)       :: in_rhoj  = 1
+   INTEGER(i4)                             :: in_rhoi  = 1
+   INTEGER(i4)                             :: in_rhoj  = 1
 
    ! namout
-   CHARACTER(LEN=lc) :: cn_fileout = 'bathy_fine.nc' 
+   CHARACTER(LEN=lc)                       :: cn_fileout = 'bathy_fine.nc' 
    !-------------------------------------------------------------------
 
@@ -242,5 +247,6 @@
 
    NAMELIST /namcfg/ &   !< configuration namelist
-   &  cn_varcfg          !< variable configuration file
+   &  cn_varcfg, &       !< variable configuration file
+   &  cn_dumcfg          !< dummy configuration file
 
    NAMELIST /namcrs/ &   !< coarse grid namelist
@@ -254,6 +260,6 @@
  
    NAMELIST /namvar/ &   !< variable namelist
-   &  cn_varinfo, &      !< list of variable and interpolation method to be used. (ex: 'votemper:linear','vosaline:cubic' )
-   &  cn_varfile         !< list of variable file
+   &  cn_varfile, &      !< list of variable file
+   &  cn_varinfo         !< list of variable and interpolation method to be used. (ex: 'votemper:linear','vosaline:cubic' )
    
    NAMELIST /namnst/ &   !< nesting namelist
@@ -302,4 +308,11 @@
       CALL var_def_extra(TRIM(cn_varcfg))
 
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
+
       READ( il_fileid, NML = namcrs )
       READ( il_fileid, NML = namfin )
@@ -309,5 +322,5 @@
       ! match variable with file
       tl_multi=multi_init(cn_varfile)
-      
+ 
       READ( il_fileid, NML = namnst )
       READ( il_fileid, NML = namout )
@@ -322,4 +335,5 @@
 
       PRINT *,"ERROR in create_bathy: can't find "//TRIM(cl_namelist)
+      STOP
 
    ENDIF
@@ -343,4 +357,8 @@
       &     "check namelist")
    ENDIF
+
+   ! do not closed sea for east-west cyclic domain
+   ll_fillclosed=ln_fillclosed
+   IF( tl_coord1%i_perio == 1 ) ll_fillclosed=.FALSE.
 
    ! check
@@ -417,42 +435,14 @@
 
             ! get or check depth value
-            IF( tl_multi%t_mpp(ji)%t_proc(1)%i_depthid /= 0 )THEN
-               il_varid=tl_multi%t_mpp(ji)%t_proc(1)%i_depthid
-               IF( ASSOCIATED(tl_depth%d_value) )THEN
-                  tl_tmp=iom_mpp_read_var(tl_mpp,il_varid)
-                  IF( ANY( tl_depth%d_value(:,:,:,:) /= &
-                  &        tl_tmp%d_value(:,:,:,:) ) )THEN
-                     CALL logger_fatal("CREATE BATHY: depth value from "//&
-                     &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
-                     &  " to those from former file(s).")
-                  ENDIF
-                  CALL var_clean(tl_tmp)
-               ELSE
-                  tl_depth=iom_mpp_read_var(tl_mpp,il_varid)
-               ENDIF
-            ENDIF
+            CALL create_bathy_check_depth( tl_mpp, tl_depth )
 
             ! get or check time value
-            IF( tl_multi%t_mpp(ji)%t_proc(1)%i_timeid /= 0 )THEN
-               il_varid=tl_multi%t_mpp(ji)%t_proc(1)%i_timeid
-               IF( ASSOCIATED(tl_time%d_value) )THEN
-                  tl_tmp=iom_mpp_read_var(tl_mpp,il_varid)
-                  IF( ANY( tl_time%d_value(:,:,:,:) /= &
-                  &        tl_tmp%d_value(:,:,:,:) ) )THEN
-                     CALL logger_fatal("CREATE BATHY: time value from "//&
-                     &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
-                     &  " to those from former file(s).")
-                  ENDIF
-                  CALL var_clean(tl_tmp)
-               ELSE
-                  tl_time=iom_mpp_read_var(tl_mpp,il_varid)
-               ENDIF
-            ENDIF
+            CALL create_bathy_check_time( tl_mpp, tl_time )
 
             ! close mpp file
             CALL iom_mpp_close(tl_mpp)
 
-            IF( ANY( tl_mpp%t_dim(1:2)%i_len /= &
-            &        tl_coord0%t_dim(1:2)%i_len) )THEN
+            IF( ANY(tl_mpp%t_dim(1:2)%i_len /= tl_coord0%t_dim(1:2)%i_len).OR.&
+            &   ALL(il_rho(:)==1) )THEN
                !- extract bathymetry from fine grid bathymetry 
                DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
@@ -505,5 +495,5 @@
 
          ! fill closed sea
-         IF( ln_fillclosed )THEN
+         IF( ll_fillclosed )THEN
             ALLOCATE( il_mask(tl_var(jk)%t_dim(1)%i_len, &
             &                 tl_var(jk)%t_dim(2)%i_len) )
@@ -526,5 +516,5 @@
          &   dl_minbat <= 0._dp  )THEN
             CALL logger_debug("CREATE BATHY: min value "//TRIM(fct_str(dl_minbat)))
-            CALL logger_error("CREATE BATHY: Bathymetry has value <= 0")
+            CALL logger_fatal("CREATE BATHY: Bathymetry has value <= 0")
          ENDIF
 
@@ -973,4 +963,6 @@
       CALL dom_del_extra( tl_var, tl_dom, il_rho(:) )
 
+      CALL dom_clean_extra( tl_dom )
+
       !- add ghost cell
       CALL grid_add_ghost(tl_var,tl_dom%i_ghost(:,:))
@@ -1109,3 +1101,111 @@
 
    END SUBROUTINE create_bathy_interp
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine get depth variable value in an open mpp structure
+   !> and check if agree with already input depth variable.
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !>
+   !> @param[in] td_mpp       mpp structure
+   !> @param[inout] td_depth  depth variable structure 
+   !-------------------------------------------------------------------
+   SUBROUTINE create_bathy_check_depth( td_mpp, td_depth )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TMPP) , INTENT(IN   ) :: td_mpp
+      TYPE(TVAR) , INTENT(INOUT) :: td_depth
+
+      ! local variable
+      INTEGER(i4) :: il_varid
+      TYPE(TVAR)  :: tl_depth
+      ! loop indices
+      !----------------------------------------------------------------
+
+      ! get or check depth value
+      IF( td_mpp%t_proc(1)%i_depthid /= 0 )THEN
+
+         il_varid=td_mpp%t_proc(1)%i_depthid
+         IF( ASSOCIATED(td_depth%d_value) )THEN
+
+            tl_depth=iom_mpp_read_var(td_mpp, il_varid)
+
+            IF( ANY( td_depth%d_value(:,:,:,:) /= &
+            &        tl_depth%d_value(:,:,:,:) ) )THEN
+
+               CALL logger_warn("CREATE BATHY: depth value from "//&
+               &  TRIM(td_mpp%c_name)//" not conform "//&
+               &  " to those from former file(s).")
+
+            ENDIF
+            CALL var_clean(tl_depth)
+
+         ELSE
+            td_depth=iom_mpp_read_var(td_mpp,il_varid)
+         ENDIF
+
+      ENDIF
+      
+   END SUBROUTINE create_bathy_check_depth
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine get date and time in an open mpp structure
+   !> and check if agree with date and time already read.
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !>
+   !> @param[in] td_mpp      mpp structure
+   !> @param[inout] td_time  time variable structure 
+   !-------------------------------------------------------------------
+   SUBROUTINE create_bathy_check_time( td_mpp, td_time )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TMPP), INTENT(IN   ) :: td_mpp
+      TYPE(TVAR), INTENT(INOUT) :: td_time
+
+      ! local variable
+      INTEGER(i4) :: il_varid
+      TYPE(TVAR)  :: tl_time
+
+      TYPE(TDATE) :: tl_date1
+      TYPE(TDATE) :: tl_date2
+      ! loop indices
+      !----------------------------------------------------------------
+
+      ! get or check depth value
+      IF( td_mpp%t_proc(1)%i_timeid /= 0 )THEN
+
+         il_varid=td_mpp%t_proc(1)%i_timeid
+         IF( ASSOCIATED(td_time%d_value) )THEN
+
+            tl_time=iom_mpp_read_var(td_mpp, il_varid)
+
+            tl_date1=var_to_date(td_time)
+            tl_date2=var_to_date(tl_time)
+            IF( tl_date1 - tl_date2 /= 0 )THEN
+
+               CALL logger_warn("CREATE BATHY: date from "//&
+               &  TRIM(td_mpp%c_name)//" not conform "//&
+               &  " to those from former file(s).")
+
+            ENDIF
+            CALL var_clean(tl_time)
+
+         ELSE
+            td_time=iom_mpp_read_var(td_mpp,il_varid)
+         ENDIF
+
+      ENDIF
+      
+   END SUBROUTINE create_bathy_check_time
 END PROGRAM create_bathy
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_boundary.F90	(revision 7339)
@@ -0,0 +1,1764 @@
+!----------------------------------------------------------------------
+! NEMO system team, System and Interface for oceanic RElocable Nesting
+!----------------------------------------------------------------------
+!
+!
+! PROGRAM: create_boundary
+!
+! DESCRIPTION:
+!> @file
+!> @brief 
+!> This program creates boundary files.
+!>
+!> @details
+!> @section sec1 method
+!> Variables are read from coarse grid standard output, 
+!> extracted or interpolated on fine grid. 
+!> Variables could also be manually written.<br/>
+!> @note 
+!>    method could be different for each variable.
+!>
+!> @section sec2 how to 
+!>    to create boundaries files:<br/>
+!> @code{.sh}
+!>    ./SIREN/bin/create_boundary create_boundary.nam
+!> @endcode
+!>  <br/> 
+!> \image html  boundary_NEATL36_70.png 
+!> \image latex boundary_NEATL36_70.png
+!>
+!> @note 
+!>    you could find a template of the namelist in templates directory.
+!>
+!>    create_boundary.nam contains 9 namelists:<br/>
+!>       - logger namelist (namlog)
+!>       - config namelist (namcfg)
+!>       - coarse grid namelist (namcrs)
+!>       - fine grid namelist (namfin)
+!>       - variable namelist (namvar)
+!>       - nesting namelist (namnst)
+!>       - boundary namelist (nambdy)
+!>       - vertical grid namelist (namzgr)
+!>       - output namelist (namout)
+!>    
+!>    * _logger namelist (namlog)_:<br/>
+!>       - cn_logfile   : log filename
+!>       - cn_verbosity : verbosity ('trace','debug','info',
+!> 'warning','error','fatal','none')
+!>       - in_maxerror  : maximum number of error allowed
+!>
+!>    * _config namelist (namcfg)_:<br/>
+!>       - cn_varcfg : variable configuration file
+!> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
+!>
+!>    * _coarse grid namelist (namcrs)_:<br/>
+!>       - cn_coord0 : coordinate file
+!>       - in_perio0 : NEMO periodicity index (see Model Boundary Condition in
+!> [NEMO documentation](http://www.nemo-ocean.eu/About-NEMO/Reference-manuals))
+!>
+!>    * _fine grid namelist (namfin)_:<br/>
+!>       - cn_coord1 : coordinate file
+!>       - cn_bathy1 : bathymetry file
+!>       - in_perio1 : periodicity index
+!>
+!>    * _vertical grid namelist (namzgr)_:<br/>
+!>       - dn_pp_to_be_computed  :
+!>       - dn_ppsur              :
+!>       - dn_ppa0               :
+!>       - dn_ppa1               :
+!>       - dn_ppa2               : 
+!>       - dn_ppkth              :
+!>       - dn_ppkth2             :
+!>       - dn_ppacr              :
+!>       - dn_ppacr2             :
+!>       - dn_ppdzmin            :
+!>       - dn_pphmax             :
+!>       - in_nlevel             : number of vertical level
+!>
+!>    * _partial step namelist (namzps)_:<br/>
+!>       - dn_e3zps_min          :
+!>       - dn_e3zps_rat          : 
+!>
+!>    * _variable namelist (namvar)_:<br/>
+!>       - cn_varfile : list of variable, and associated file<br/> 
+!>          *cn_varfile* is the path and filename of the file where find
+!>          variable.<br/> 
+!>          @note 
+!>             *cn_varfile* could be a matrix of value, if you want to filled
+!>             manually variable value.<br/>
+!>             the variable array of value is split into equal subdomain.<br/>
+!>             Each subdomain is filled with the corresponding value 
+!>             of the matrix.<br/>          
+!>             separators used to defined matrix are:
+!>                - ',' for line
+!>                - '/' for row
+!>                - '\' for level<br/>
+!>                Example:<br/>
+!>                   3,2,3/1,4,5  =>  @f$ \left( \begin{array}{ccc}
+!>                                         3 & 2 & 3 \\\\
+!>                                         1 & 4 & 5 \end{array} \right) @f$
+!>          @warning 
+!>             the same matrix is used for all boundaries.
+!>
+!>       Examples: 
+!>          - 'votemper:gridT.nc', 'vozocrtx:gridU.nc'
+!>          - 'votemper:10\25', 'vozocrtx:gridU.nc'
+!>
+!>       - cn_varinfo : list of variable and extra information about request(s)
+!>          to be used (separated by ',').<br/>
+!>          each elements of *cn_varinfo* is a string character.<br/>
+!>          it is composed of the variable name follow by ':', 
+!>          then request(s) to be used on this variable.<br/> 
+!>          request could be:
+!>             - int = interpolation method
+!>             - ext = extrapolation method
+!>             - flt = filter method
+!>             - min = minimum value
+!>             - max = maximum value
+!>             - unt = new units
+!>             - unf = unit scale factor (linked to new units)
+!>
+!>                requests must be separated by ';'.<br/>
+!>                order of requests does not matter.
+!>
+!>          informations about available method could be find in @ref interp,
+!>          @ref extrap and @ref filter.<br/>
+!>
+!>          Example: 'votemper:int=linear;flt=hann;ext=dist_weight', 
+!>                   'vosaline:int=cubic'
+!>          @note 
+!>             If you do not specify a method which is required, 
+!>             default one is apply.
+!>
+!>    * _nesting namelist (namnst)_:<br/>
+!>       - in_rhoi  : refinement factor in i-direction
+!>       - in_rhoj  : refinement factor in j-direction
+!>
+!>    * _boundary namelist (nambdy)_:<br/>
+!>       - ln_north  : use north boundary
+!>       - ln_south  : use south boundary
+!>       - ln_east   : use east  boundary
+!>       - ln_west   : use west  boundary
+!>       - cn_north  : north boundary indices on fine grid
+!>          *cn_north* is a string character defining boundary
+!>          segmentation.<br/>
+!>          segments are separated by '|'.<br/>
+!>          each segments of the boundary is composed of:
+!>             - indice of velocity (orthogonal to boundary .ie. 
+!>                for north boundary, J-indice). 
+!>             - indice of segment start (I-indice for north boundary) 
+!>             - indice of segment end   (I-indice for north boundary)<br/>
+!>                indices must be separated by ':' .<br/>
+!>             - optionally, boundary size could be added between '(' and ')' 
+!>             in the definition of the first segment.
+!>                @note 
+!>                   boundary width is the same for all segments of one boundary.
+!>
+!>          Examples:
+!>             - cn_north='index1,first1:last1(width)'
+!>             - cn_north='index1(width),first1:last1|index2,first2:last2'
+!>             \image html  boundary_50.png 
+!>             \image latex boundary_50.png
+!>       - cn_south  : south boundary indices on fine grid
+!>       - cn_east   : east  boundary indices on fine grid
+!>       - cn_west   : west  boundary indices on fine grid
+!>       - ln_oneseg : force to use only one segment for each boundary or not
+!>
+!>    * _output namelist (namout)_:<br/>
+!>       - cn_fileout : fine grid boundary basename
+!>         (cardinal point and segment number will be automatically added)
+!>       - dn_dayofs  : date offset in day (change only ouput file name)
+!>       - ln_extrap  : extrapolate land point or not
+!>
+!>          Examples: 
+!>             - cn_fileout='boundary.nc'<br/>
+!>                if time_counter (16/07/2015 00h) is read on input file (see varfile), 
+!>                west boundary will be named boundary_west_y2015m07d16
+!>             - dn_dayofs=-2.<br/>
+!>                if you use day offset you get boundary_west_y2015m07d14
+!>       
+!>
+!> @author J.Paul
+! REVISION HISTORY:
+!> @date November, 2013 - Initial Version
+!> @date September, 2014
+!> - add header for user
+!> - take into account grid point to compue boundaries
+!> - reorder output dimension for north and south boundaries
+!> @date June, 2015
+!> - extrapolate all land points, and add ln_extrap in namelist.
+!> - allow to change unit.
+!> @date July, 2015
+!> - add namelist parameter to shift date of output file name.
+!> @date September, 2015
+!> - manage useless (dummy) variable, attributes, and dimension
+!> - allow to run on multi processors with key_mpp_mpi
+!> @date January, 2016
+!> - same process use for variable extracted or interpolated from input file.
+!>
+!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+!----------------------------------------------------------------------
+PROGRAM create_boundary
+
+   USE netcdf                          ! nf90 library
+   USE global                          ! global variable
+   USE phycst                          ! physical constant
+   USE kind                            ! F90 kind parameter
+   USE fct                             ! basic useful function
+   USE date                            ! date manager
+   USE att                             ! attribute manager
+   USE dim                             ! dimension manager
+   USE var                             ! variable manager
+   USE file                            ! file manager
+   USE multi                           ! multi file manager
+   USE boundary                        ! boundary manager
+   USE iom                             ! I/O manager
+   USE dom                             ! domain manager
+   USE grid                            ! grid manager
+   USE vgrid                           ! vertical grid manager
+   USE extrap                          ! extrapolation manager
+   USE interp                          ! interpolation manager
+   USE filter                          ! filter manager
+   USE mpp                             ! MPP manager
+   USE iom_mpp                         ! MPP I/O manager
+
+   IMPLICIT NONE
+
+   ! local variable
+   INTEGER(i4)                                        :: il_narg
+
+#if defined key_mpp_mpi
+   ! mpp variable
+   CHARACTER(LEN=lc), DIMENSION(:)      , ALLOCATABLE :: cl_namelist
+   INTEGER(i4)                                        :: ierror
+   INTEGER(i4)                                        :: iproc
+   INTEGER(i4)                                        :: nproc
+   INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_nprog
+
+   ! loop indices
+   INTEGER(i4) :: jm
+#else
+   CHARACTER(LEN=lc)                                  :: cl_namelist
+#endif
+   !-------------------------------------------------------------------
+#if defined key_mpp_mpi
+   INCLUDE 'mpif.h'
+#endif
+   !-------------------------------------------------------------------
+
+   il_narg=COMMAND_ARGUMENT_COUNT() !f03 intrinsec
+#if ! defined key_mpp_mpi
+
+   IF( il_narg/=1 )THEN
+      PRINT *,"CREATE BOUNDARY: ERROR. need one namelist"
+      STOP
+   ELSE
+      CALL GET_COMMAND_ARGUMENT(1,cl_namelist) !f03 intrinsec
+   ENDIF
+
+   CALL create__boundary(cl_namelist)
+
+#else
+
+   ! Initialize MPI
+   CALL mpi_init(ierror)
+   CALL mpi_comm_rank(mpi_comm_world,iproc,ierror)
+   CALL mpi_comm_size(mpi_comm_world,nproc,ierror)
+
+   IF( il_narg==0 )THEN
+      PRINT *,"CREATE BOUNDARY: ERROR. need at least one namelist"
+      STOP
+   ELSE
+      ALLOCATE(cl_namelist(il_narg))
+      DO jm=1,il_narg
+         CALL GET_COMMAND_ARGUMENT(jm,cl_namelist(jm))
+      ENDDO
+   ENDIF
+
+   ALLOCATE(il_nprog(il_narg))
+   DO jm=1, il_narg
+      il_nprog(jm)= MOD(jm,nproc)
+   ENDDO
+
+   DO jm=1, il_narg
+      IF ( il_nprog(jm) .eq. iproc ) THEN
+         CALL create__boundary(cl_namelist(jm))
+      ENDIF
+   ENDDO
+
+   CALL mpi_finalize(ierror)
+
+   DEALLOCATE(cl_namelist)
+   DEALLOCATE(il_nprog)
+#endif
+
+CONTAINS
+SUBROUTINE create__boundary(cd_namelist)
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine create boundary files.
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !>
+   !> @param[in] cd_namelist namelist file 
+   !-------------------------------------------------------------------
+
+   USE logger                          ! log file manager
+
+   IMPLICIT NONE
+   ! Argument
+   CHARACTER(LEN=lc), INTENT(IN) :: cd_namelist 
+
+   ! local variable
+   CHARACTER(LEN=lc)                                  :: cl_date
+   CHARACTER(LEN=lc)                                  :: cl_name
+   CHARACTER(LEN=lc)                                  :: cl_bdyout
+   CHARACTER(LEN=lc)                                  :: cl_data
+   CHARACTER(LEN=lc)                                  :: cl_dimorder
+   CHARACTER(LEN=lc)                                  :: cl_fmt
+
+   INTEGER(i4)                                        :: il_status
+   INTEGER(i4)                                        :: il_fileid
+   INTEGER(i4)                                        :: il_imin0
+   INTEGER(i4)                                        :: il_imax0
+   INTEGER(i4)                                        :: il_jmin0
+   INTEGER(i4)                                        :: il_jmax0
+   INTEGER(i4)                                        :: il_shift
+   INTEGER(i4)      , DIMENSION(ip_maxdim)            :: il_rho
+   INTEGER(i4)      , DIMENSION(2,2)                  :: il_offset
+   INTEGER(i4)      , DIMENSION(2,2)                  :: il_ind
+
+   LOGICAL                                            :: ll_exist
+
+   TYPE(TATT)                                         :: tl_att
+   
+   TYPE(TVAR)                                         :: tl_depth   
+   TYPE(TVAR)                                         :: tl_time
+   TYPE(TVAR)                                         :: tl_var1
+   TYPE(TVAR)                                         :: tl_var0
+   TYPE(TVAR)                                         :: tl_lon1
+   TYPE(TVAR)                                         :: tl_lat1
+   TYPE(TVAR)                                         :: tl_lvl1  
+   TYPE(TVAR)       , DIMENSION(:)      , ALLOCATABLE :: tl_level
+   TYPE(TVAR)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_seglvl1
+   TYPE(TVAR)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_segvar1
+
+   TYPE(TDIM)       , DIMENSION(ip_maxdim)            :: tl_dim
+
+   TYPE(TDATE)                                        :: tl_date
+   
+   TYPE(TBDY)       , DIMENSION(ip_ncard)             :: tl_bdy
+   
+   TYPE(TDOM)                                         :: tl_dom0
+   TYPE(TDOM)                                         :: tl_dom1
+   TYPE(TDOM)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_segdom1
+
+   TYPE(TFILE)                                        :: tl_fileout
+   
+   TYPE(TMPP)                                         :: tl_coord0
+   TYPE(TMPP)                                         :: tl_coord1
+   TYPE(TMPP)                                         :: tl_bathy1
+   TYPE(TMPP)                                         :: tl_mpp
+
+   TYPE(TMULTI)                                       :: tl_multi
+
+   ! loop indices
+   INTEGER(i4) :: jvar
+   INTEGER(i4) :: jpoint
+   INTEGER(i4) :: ji
+   INTEGER(i4) :: jj
+   INTEGER(i4) :: jk
+   INTEGER(i4) :: jl
+
+   ! namelist variable
+   ! namlog
+   CHARACTER(LEN=lc)                       :: cn_logfile = 'create_boundary.log' 
+   CHARACTER(LEN=lc)                       :: cn_verbosity = 'warning' 
+   INTEGER(i4)                             :: in_maxerror = 5
+
+   ! namcfg
+   CHARACTER(LEN=lc)                       :: cn_varcfg = 'variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_dumcfg = 'dummy.cfg'
+
+   ! namcrs
+   CHARACTER(LEN=lc)                       :: cn_coord0 = '' 
+   INTEGER(i4)                             :: in_perio0 = -1
+
+   ! namfin
+   CHARACTER(LEN=lc)                       :: cn_coord1 = '' 
+   CHARACTER(LEN=lc)                       :: cn_bathy1 = '' 
+   INTEGER(i4)                             :: in_perio1 = -1
+
+   !namzgr
+   REAL(dp)                                :: dn_pp_to_be_computed = 0._dp
+   REAL(dp)                                :: dn_ppsur   = -3958.951371276829_dp
+   REAL(dp)                                :: dn_ppa0    =   103.953009600000_dp
+   REAL(dp)                                :: dn_ppa1    =     2.415951269000_dp
+   REAL(dp)                                :: dn_ppa2    =   100.760928500000_dp
+   REAL(dp)                                :: dn_ppkth   =    15.351013700000_dp
+   REAL(dp)                                :: dn_ppkth2  =    48.029893720000_dp
+   REAL(dp)                                :: dn_ppacr   =     7.000000000000_dp
+   REAL(dp)                                :: dn_ppacr2  =    13.000000000000_dp
+   REAL(dp)                                :: dn_ppdzmin = 6._dp
+   REAL(dp)                                :: dn_pphmax  = 5750._dp
+   INTEGER(i4)                             :: in_nlevel  = 75
+
+   !namzps
+   REAL(dp)                                :: dn_e3zps_min = 25._dp
+   REAL(dp)                                :: dn_e3zps_rat = 0.2_dp
+
+   ! namvar
+   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
+   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
+
+   ! namnst
+   INTEGER(i4)                             :: in_rhoi  = 0
+   INTEGER(i4)                             :: in_rhoj  = 0
+
+   ! nambdy
+   LOGICAL                                 :: ln_north   = .TRUE.
+   LOGICAL                                 :: ln_south   = .TRUE.
+   LOGICAL                                 :: ln_east    = .TRUE.
+   LOGICAL                                 :: ln_west    = .TRUE.
+   LOGICAL                                 :: ln_oneseg  = .TRUE.
+   CHARACTER(LEN=lc)                       :: cn_north   = ''
+   CHARACTER(LEN=lc)                       :: cn_south   = ''
+   CHARACTER(LEN=lc)                       :: cn_east    = ''
+   CHARACTER(LEN=lc)                       :: cn_west    = ''
+
+   ! namout
+   CHARACTER(LEN=lc)                       :: cn_fileout = 'boundary.nc' 
+   REAL(dp)                                :: dn_dayofs  = 0._dp
+   LOGICAL                                 :: ln_extrap  = .FALSE.
+   !-------------------------------------------------------------------
+
+   NAMELIST /namlog/ &  !< logger namelist
+   &  cn_logfile,    &  !< log file
+   &  cn_verbosity,  &  !< log verbosity
+   &  in_maxerror
+
+   NAMELIST /namcfg/ &  !< config namelist
+   &  cn_varcfg, &       !< variable configuration file
+   &  cn_dumcfg          !< dummy configuration file
+
+   NAMELIST /namcrs/ &  !< coarse grid namelist
+   &  cn_coord0,     &  !< coordinate file
+   &  in_perio0         !< periodicity index
+ 
+   NAMELIST /namfin/ &  !< fine grid namelist
+   &  cn_coord1,     &  !< coordinate file
+   &  cn_bathy1,     &  !< bathymetry file
+   &  in_perio1         !< periodicity index
+ 
+   NAMELIST /namzgr/ &
+   &  dn_pp_to_be_computed, &
+   &  dn_ppsur,     &
+   &  dn_ppa0,      &
+   &  dn_ppa1,      &
+   &  dn_ppa2,      &
+   &  dn_ppkth,     &
+   &  dn_ppkth2,    &
+   &  dn_ppacr,     &
+   &  dn_ppacr2,    &
+   &  dn_ppdzmin,   &
+   &  dn_pphmax,    &
+   &  in_nlevel         !< number of vertical level
+
+   NAMELIST /namzps/ &
+   &  dn_e3zps_min, &
+   &  dn_e3zps_rat
+
+   NAMELIST /namvar/ &  !< variable namelist
+   &  cn_varfile, &     !< list of variable and file where find it. (ex: 'votemper:GLORYS_gridT.nc' ) 
+   &  cn_varinfo        !< list of variable and method to apply on. (ex: 'votemper:linear','vosaline:cubic' )
+ 
+   NAMELIST /namnst/ &  !< nesting namelist
+   &  in_rhoi,       &  !< refinement factor in i-direction
+   &  in_rhoj           !< refinement factor in j-direction
+
+   NAMELIST /nambdy/ &  !< boundary namelist
+   &  ln_north,      &  !< use north boundary
+   &  ln_south,      &  !< use south boundary
+   &  ln_east ,      &  !< use east  boundary
+   &  ln_west ,      &  !< use west  boundary
+   &  cn_north,      &  !< north boundary indices on fine grid
+   &  cn_south,      &  !< south boundary indices on fine grid
+   &  cn_east ,      &  !< east  boundary indices on fine grid
+   &  cn_west ,      &  !< west  boundary indices on fine grid
+   &  ln_oneseg         !< use only one segment for each boundary or not
+
+   NAMELIST /namout/ &  !< output namelist
+   &  cn_fileout,    &  !< fine grid boundary file basename   
+   &  dn_dayofs,     &  !< date offset in day (change only ouput file name)
+   &  ln_extrap         !< extrapolate or not
+   !-------------------------------------------------------------------
+
+   ! read namelist
+   INQUIRE(FILE=TRIM(cd_namelist), EXIST=ll_exist)
+
+   IF( ll_exist )THEN
+      
+      il_fileid=fct_getunit()
+
+      OPEN( il_fileid, FILE=TRIM(cd_namelist), &
+      &                FORM='FORMATTED',       &
+      &                ACCESS='SEQUENTIAL',    &
+      &                STATUS='OLD',           &
+      &                ACTION='READ',          &
+      &                IOSTAT=il_status)
+      CALL fct_err(il_status)
+      IF( il_status /= 0 )THEN
+         PRINT *,"CREATE BOUNDARY: ERROR opening "//TRIM(cd_namelist)
+         STOP
+      ENDIF
+
+      READ( il_fileid, NML = namlog )
+      ! define log file
+      CALL logger_open(TRIM(cn_logfile),TRIM(cn_verbosity),in_maxerror)
+      CALL logger_header()
+
+      READ( il_fileid, NML = namcfg )
+      ! get variable extra information
+      CALL var_def_extra(TRIM(cn_varcfg))
+
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
+
+      READ( il_fileid, NML = namcrs )
+      READ( il_fileid, NML = namfin )
+      READ( il_fileid, NML = namzgr )
+      READ( il_fileid, NML = namvar )
+      ! add user change in extra information
+      CALL var_chg_extra(cn_varinfo)
+      ! match variable with file
+      tl_multi=multi_init(cn_varfile)
+
+      READ( il_fileid, NML = namnst )
+      READ( il_fileid, NML = nambdy )
+      READ( il_fileid, NML = namout )
+
+      CLOSE( il_fileid, IOSTAT=il_status )
+      CALL fct_err(il_status)
+      IF( il_status /= 0 )THEN
+         CALL logger_error("CREATE BOUNDARY: ERROR closing "//TRIM(cd_namelist))
+      ENDIF
+
+   ELSE
+
+      PRINT *,"CREATE BOUNDARY: ERROR. can not find "//TRIM(cd_namelist)
+      STOP
+
+   ENDIF
+
+   CALL multi_print(tl_multi)
+   IF( tl_multi%i_nvar <= 0 )THEN
+      CALL logger_fatal("CREATE BOUNDARY: no variable to be used."//&
+      &  " check namelist.")
+   ENDIF
+
+   ! open files
+   IF( TRIM(cn_coord0) /= '' )THEN
+      tl_coord0=mpp_init( file_init(TRIM(cn_coord0)), id_perio=in_perio0)
+      CALL grid_get_info(tl_coord0)
+   ELSE
+      CALL logger_fatal("CREATE BOUNDARY: can not find coarse grid "//&
+      &  "coordinate file. check namelist")
+   ENDIF
+
+   IF( TRIM(cn_coord1) /= '' )THEN
+      tl_coord1=mpp_init( file_init(TRIM(cn_coord1)), id_perio=in_perio1)
+      CALL grid_get_info(tl_coord1)
+   ELSE
+      CALL logger_fatal("CREATE BOUNDARY: can not find fine grid coordinate "//&
+      &  "file. check namelist")
+   ENDIF
+
+   IF( TRIM(cn_bathy1) /= '' )THEN
+      tl_bathy1=mpp_init( file_init(TRIM(cn_bathy1)), id_perio=in_perio1)
+      CALL grid_get_info(tl_bathy1)
+   ELSE
+      CALL logger_fatal("CREATE BOUNDARY: can not find fine grid bathymetry "//&
+      &  "file. check namelist")
+   ENDIF
+
+   ! check
+   ! check output file do not already exist
+   ! WARNING: do not work when use time to create output file name
+   DO jk=1,ip_ncard
+      cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+      &                                TRIM(cp_card(jk)), 1 )
+      INQUIRE(FILE=TRIM(cl_bdyout), EXIST=ll_exist)
+      IF( ll_exist )THEN
+         CALL logger_fatal("CREATE BOUNDARY: output file "//TRIM(cl_bdyout)//&
+         &  " already exist.")
+      ENDIF
+
+      cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+      &                                TRIM(cp_card(jk)) )
+      INQUIRE(FILE=TRIM(cl_bdyout), EXIST=ll_exist)
+      IF( ll_exist )THEN
+         CALL logger_fatal("CREATE BOUNDARY: output file "//TRIM(cl_bdyout)//&
+         &  " already exist.")
+      ENDIF
+   ENDDO
+
+   ! check namelist
+   ! check refinement factor
+   il_rho(:)=1
+   IF( in_rhoi < 1 .OR. in_rhoj < 1 )THEN
+      CALL logger_error("CREATE BOUNDARY: invalid refinement factor."//&
+      &  " check namelist "//TRIM(cd_namelist))
+   ELSE
+      il_rho(jp_I)=in_rhoi
+      il_rho(jp_J)=in_rhoj
+   ENDIF
+
+   !
+   ! compute coarse grid indices around fine grid
+   il_ind(:,:)=grid_get_coarse_index(tl_coord0, tl_coord1, &
+   &                                 id_rho=il_rho(:))
+
+   il_imin0=il_ind(1,1) ; il_imax0=il_ind(1,2)
+   il_jmin0=il_ind(2,1) ; il_jmax0=il_ind(2,2)
+
+   ! check domain validity
+   CALL grid_check_dom(tl_coord0, il_imin0, il_imax0, il_jmin0, il_jmax0)
+
+   ! check coordinate file
+   CALL grid_check_coincidence( tl_coord0, tl_coord1, &
+   &                            il_imin0, il_imax0, &
+   &                            il_jmin0, il_jmax0, &
+   &                            il_rho(:) )      
+
+   ! read or compute boundary
+   CALL mpp_get_contour(tl_bathy1)
+
+   CALL iom_mpp_open(tl_bathy1)
+ 
+   tl_var1=iom_mpp_read_var(tl_bathy1,'Bathymetry')
+ 
+   CALL iom_mpp_close(tl_bathy1)
+
+   ! get boundaries indices
+   tl_bdy(:)=boundary_init(tl_var1, ln_north, ln_south, ln_east, ln_west, &
+   &                                cn_north, cn_south, cn_east, cn_west, &
+   &                                ln_oneseg ) 
+
+
+   CALL var_clean(tl_var1)
+
+   ! compute level
+   ALLOCATE(tl_level(ip_npoint))
+   tl_level(:)=vgrid_get_level(tl_bathy1, cd_namelist )
+
+   ! get coordinate for each segment of each boundary
+   ALLOCATE( tl_segdom1(ip_npoint,ip_maxseg,ip_ncard) )
+   ALLOCATE( tl_seglvl1(ip_npoint,ip_maxseg,ip_ncard) )
+ 
+   DO jl=1,ip_ncard
+      IF( tl_bdy(jl)%l_use )THEN
+         DO jk=1,tl_bdy(jl)%i_nseg
+
+            ! get fine grid segment domain
+            tl_segdom1(:,jk,jl)=create_boundary_get_dom( tl_bathy1, &
+            &                                            tl_bdy(jl), jk )
+
+            IF( .NOT. ln_extrap )THEN
+               ! get fine grid level
+               tl_seglvl1(:,jk,jl)= &
+                  & create_boundary_get_level( tl_level(:), &
+                  &                            tl_segdom1(:,jk,jl))
+            ENDIF
+
+            ! add extra band to fine grid domain (if possible)
+            ! to avoid dimension of one and so be able to compute offset
+            DO jj=1,ip_npoint
+               CALL dom_add_extra(tl_segdom1(jj,jk,jl), &
+               &                  il_rho(jp_I), il_rho(jp_J))
+            ENDDO
+
+         ENDDO
+      ENDIF
+   ENDDO
+
+   ! clean
+   CALL var_clean(tl_level(:))
+   DEALLOCATE(tl_level)
+
+   ! clean bathy
+   CALL mpp_clean(tl_bathy1)
+
+   ALLOCATE( tl_segvar1(tl_multi%i_nvar,ip_maxseg,ip_ncard) )
+   ! compute boundary for variable to be used (see namelist)
+   IF( .NOT. ASSOCIATED(tl_multi%t_mpp) )THEN
+      CALL logger_error("CREATE BOUNDARY: no file to work on. "//&
+      &                 "check cn_varfile in namelist.")
+   ELSE
+
+      jvar=0
+      ! for each file
+      DO ji=1,tl_multi%i_nmpp
+
+         WRITE(cl_data,'(a,i2.2)') 'data-',jvar+1
+
+         IF( .NOT. ASSOCIATED(tl_multi%t_mpp(ji)%t_proc(1)%t_var) )THEN
+
+            CALL logger_error("CREATE BOUNDARY: no variable to work on for "//&
+            &                 "mpp "//TRIM(tl_multi%t_mpp(ji)%c_name)//&
+            &                 ". check cn_varfile in namelist.")
+
+         ELSEIF( TRIM(tl_multi%t_mpp(ji)%c_name) == TRIM(cl_data) )THEN
+         !- use input matrix to fill variable
+
+            WRITE(*,'(a)') "work on data"
+            ! for each variable initialise from matrix
+            DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
+
+               jvar=jvar+1
+               WRITE(*,'(2x,a,a)') "work on variable "//&
+               &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name)
+
+               tl_var1=var_copy(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj))
+
+               SELECT CASE(TRIM(tl_var1%c_point))
+               CASE DEFAULT !'T'
+                  jpoint=jp_T
+               CASE('U')
+                  jpoint=jp_U
+               CASE('V')
+                  jpoint=jp_V
+               CASE('F')
+                  jpoint=jp_F
+               END SELECT
+
+               WRITE(*,'(4x,a,a)') 'work on '//TRIM(tl_var1%c_name)
+               DO jl=1,ip_ncard
+                  IF( tl_bdy(jl)%l_use )THEN
+
+                     DO jk=1,tl_bdy(jl)%i_nseg
+
+                        ! fill value with matrix data
+                        tl_segvar1(jvar,jk,jl)=create_boundary_matrix( &
+                        &                          tl_var1, &
+                        &                          tl_segdom1(jpoint,jk,jl), &
+                        &                          in_nlevel )
+
+                        !del extra
+                        CALL dom_del_extra( tl_segvar1(jvar,jk,jl), &
+                        &                   tl_segdom1(jpoint,jk,jl) )
+
+                     ENDDO
+
+                  ENDIF
+               ENDDO
+               
+               ! clean
+               CALL var_clean(tl_var1)
+
+            ENDDO
+
+         !- end of use input matrix to fill variable
+         ELSE
+         !- use mpp file to fill variable
+
+            WRITE(*,'(a)') "work on file "//TRIM(tl_multi%t_mpp(ji)%c_name)
+            ! 
+            tl_mpp=mpp_init(file_init(TRIM(tl_multi%t_mpp(ji)%t_proc(1)%c_name)))
+            CALL grid_get_info(tl_mpp)
+
+            DO jl=1,ip_ncard
+               IF( tl_bdy(jl)%l_use )THEN
+
+                  WRITE(*,'(2x,a,a)') 'work on '//TRIM(tl_bdy(jl)%c_card)//&
+                     &  ' boundary'
+                  DO jk=1,tl_bdy(jl)%i_nseg
+
+                     ! for each variable of this file
+                     DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
+ 
+                        WRITE(*,'(4x,a,a)') "work on variable "//&
+                        &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name)
+
+                        tl_var0=var_copy(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj))
+
+                        ! open mpp file
+                        CALL iom_mpp_open(tl_mpp)
+
+                        ! get or check depth value
+                        CALL create_boundary_check_depth( tl_var0, tl_mpp, &
+                        &                                 in_nlevel, tl_depth )
+
+                        ! get or check time value
+                        CALL create_boundary_check_time( tl_var0, tl_mpp, &
+                        &                                tl_time )
+
+                        ! close mpp file
+                        CALL iom_mpp_close(tl_mpp)
+
+                        ! open mpp file on domain
+                        SELECT CASE(TRIM(tl_var0%c_point))
+                           CASE DEFAULT !'T'
+                              jpoint=jp_T
+                           CASE('U')
+                              jpoint=jp_U
+                           CASE('V')
+                              jpoint=jp_V
+                           CASE('F')
+                              jpoint=jp_F
+                        END SELECT
+
+                        tl_dom1=dom_copy(tl_segdom1(jpoint,jk,jl))
+
+                        CALL create_boundary_get_coord( tl_coord1, tl_dom1, &
+                        &                               tl_var0%c_point,    &
+                        &                               tl_lon1, tl_lat1 )
+
+                        ! get coarse grid indices of this segment
+                        il_ind(:,:)=grid_get_coarse_index(tl_coord0, &
+                        &                                 tl_lon1, tl_lat1, &
+                        &                                 id_rho=il_rho(:) )
+
+                        IF( ANY(il_ind(:,:)==0) )THEN
+                           CALL logger_error("CREATE BOUNDARY: error "//&
+                           &  "computing coarse grid indices")
+                        ELSE
+                           il_imin0=il_ind(1,1)
+                           il_imax0=il_ind(1,2)
+
+                           il_jmin0=il_ind(2,1)
+                           il_jmax0=il_ind(2,2)
+                        ENDIF
+
+                        il_offset(:,:)= grid_get_fine_offset( &
+                        &                    tl_coord0, &
+                        &                    il_imin0, il_jmin0,&
+                        &                    il_imax0, il_jmax0,&
+                        &                    tl_lon1%d_value(:,:,1,1),&
+                        &                    tl_lat1%d_value(:,:,1,1),&
+                        &                    il_rho(:),&
+                        &                    TRIM(tl_var0%c_point) )
+
+                        ! compute coarse grid segment domain
+                        tl_dom0=dom_init( tl_coord0,         &
+                        &                 il_imin0, il_imax0,&
+                        &                 il_jmin0, il_jmax0 )
+
+                        ! add extra band (if possible) to compute interpolation
+                        CALL dom_add_extra(tl_dom0)
+
+                        ! open mpp files
+                        CALL iom_dom_open(tl_mpp, tl_dom0)
+
+                        cl_name=tl_var0%c_name
+                        ! read variable value on domain
+                        tl_segvar1(jvar+jj,jk,jl)= &
+                        &    iom_dom_read_var(tl_mpp, TRIM(cl_name), tl_dom0)
+
+                        IF( ANY(il_rho(:)/=1) )THEN
+                           WRITE(*,'(4x,a,a)') "interp variable "//TRIM(cl_name)
+                           ! work on variable
+                           CALL create_boundary_interp( &
+                           &                 tl_segvar1(jvar+jj,jk,jl),&
+                           &                 il_rho(:), il_offset(:,:) )
+                        ENDIF
+
+                        ! remove extraband added to domain
+                        CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), &
+                        &                   tl_dom0, il_rho(:) )
+
+                        ! del extra point on fine grid
+                        CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), &
+                        &                   tl_dom1 )
+                        ! clean extra point information on coarse grid domain
+                        CALL dom_clean_extra( tl_dom0 )
+
+                        ! add attribute to variable
+                        tl_att=att_init('src_file',&
+                        &  TRIM(fct_basename(tl_mpp%c_name)))
+                        CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
+                        &                 tl_att)
+
+                        ! 
+                        tl_att=att_init('src_i_indices',&
+                        &  (/tl_dom0%i_imin, tl_dom0%i_imax/))
+                        CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
+                        &                 tl_att)
+
+                        tl_att=att_init('src_j_indices', &
+                        &  (/tl_dom0%i_jmin, tl_dom0%i_jmax/))
+                        CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
+                        &                 tl_att)
+
+                        IF( ANY(il_rho(:)/=1) )THEN
+                           tl_att=att_init("refinment_factor", &
+                           &               (/il_rho(jp_I),il_rho(jp_J)/))
+                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
+                           &                 tl_att)
+                        ENDIF
+
+                        ! clean structure
+                        CALL att_clean(tl_att)
+
+                        ! clean
+                        CALL dom_clean(tl_dom0)
+                        CALL dom_clean(tl_dom1)
+
+                        ! close mpp files
+                        CALL iom_dom_close(tl_mpp)
+
+                        ! clean structure
+                        CALL var_clean(tl_lon1)
+                        CALL var_clean(tl_lat1)
+                        CALL var_clean(tl_lvl1)
+
+                     ENDDO ! jj
+
+                     ! clean
+                     CALL var_clean(tl_var0)
+
+                  ENDDO ! jk
+            
+               ENDIF
+            ENDDO ! jl
+
+            jvar=jvar+tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
+
+            ! clean
+            CALL mpp_clean(tl_mpp)
+
+         !- end of use file to fill variable
+         ENDIF
+      ENDDO ! ji
+   ENDIF
+
+   IF( jvar /= tl_multi%i_nvar )THEN
+      CALL logger_error("CREATE BOUNDARY: it seems some variable "//&
+         &  "can not be read")
+   ENDIF
+
+   ! write file for each segment of each boundary
+   DO jl=1,ip_ncard
+      IF( tl_bdy(jl)%l_use )THEN
+
+         DO jk=1,tl_bdy(jl)%i_nseg
+            !- 
+            CALL create_boundary_get_coord( tl_coord1, tl_segdom1(jp_T,jk,jl),&
+            &                               'T', tl_lon1, tl_lat1 )
+
+            ! force to use nav_lon, nav_lat as variable name
+            tl_lon1%c_name='nav_lon'
+            tl_lat1%c_name='nav_lat'
+
+            ! del extra point on fine grid
+            CALL dom_del_extra( tl_lon1, tl_segdom1(jp_T,jk,jl) )
+            CALL dom_del_extra( tl_lat1, tl_segdom1(jp_T,jk,jl) )
+
+            ! clean
+            DO jpoint=1,ip_npoint
+               CALL dom_clean(tl_segdom1(jpoint,jk,jl))
+            ENDDO
+
+            ! swap array
+            CALL boundary_swap(tl_lon1, tl_bdy(jl))
+            CALL boundary_swap(tl_lat1, tl_bdy(jl))
+            DO jvar=1,tl_multi%i_nvar
+
+               ! use additional request
+               ! change unit and apply factor
+               CALL var_chg_unit(tl_segvar1(jvar,jk,jl))
+
+               ! forced min and max value
+               CALL var_limit_value(tl_segvar1(jvar,jk,jl))
+
+               ! filter
+               CALL filter_fill_value(tl_segvar1(jvar,jk,jl))
+
+               IF( .NOT. ln_extrap )THEN
+                  ! use mask
+                  SELECT CASE(TRIM(tl_segvar1(jvar,jk,jl)%c_point))
+                  CASE DEFAULT !'T'
+                     jpoint=jp_T
+                  CASE('U')
+                     jpoint=jp_U
+                  CASE('V')
+                     jpoint=jp_V
+                  CASE('F')
+                     jpoint=jp_F
+                  END SELECT
+
+                  CALL create_boundary_use_mask(tl_segvar1(jvar,jk,jl), &
+                  &                             tl_seglvl1(jpoint,jk,jl))
+               ENDIF
+
+               ! swap dimension order
+               CALL boundary_swap(tl_segvar1(jvar,jk,jl), tl_bdy(jl))
+
+            ENDDO
+
+            ! create file
+            ! create file structure
+            ! set file namearray of level variable structure
+            IF( tl_bdy(jl)%i_nseg > 1 )THEN
+               IF( ASSOCIATED(tl_time%d_value) )THEN
+                  cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)"
+                  tl_date=var_to_date(tl_time)
+                  tl_date=tl_date+dn_dayofs
+                  cl_date=date_print( tl_date, cl_fmt ) 
+
+                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+                  &                                TRIM(tl_bdy(jl)%c_card), jk,&
+                  &                                cd_date=TRIM(cl_date) )
+               ELSE
+                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+                  &                                TRIM(tl_bdy(jl)%c_card), jk )
+               ENDIF
+            ELSE
+               IF( ASSOCIATED(tl_time%d_value) )THEN
+                  cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)"
+                  tl_date=var_to_date(tl_time)
+                  tl_date=tl_date+dn_dayofs
+                  cl_date=date_print( tl_date, cl_fmt )
+
+                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+                  &                                TRIM(tl_bdy(jl)%c_card), &
+                  &                                cd_date=TRIM(cl_date) )
+               ELSE
+                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
+                  &                                TRIM(tl_bdy(jl)%c_card) )
+               ENDIF
+            ENDIF
+            ! 
+            tl_fileout=file_init(TRIM(cl_bdyout),id_perio=in_perio1)
+
+            ! add dimension
+            tl_dim(:)=var_max_dim(tl_segvar1(:,jk,jl))
+
+            SELECT CASE(TRIM(tl_bdy(jl)%c_card))
+               CASE DEFAULT ! 'north','south'
+                  cl_dimorder='xyzt'
+               CASE('east','west')
+                  cl_dimorder='yxzt'
+            END SELECT
+
+            DO ji=1,ip_maxdim
+               IF( tl_dim(ji)%l_use ) CALL file_add_dim(tl_fileout, tl_dim(ji))
+            ENDDO
+
+            ! add variables
+            IF( ALL( tl_dim(1:2)%l_use ) )THEN
+               ! add longitude
+               CALL file_add_var(tl_fileout, tl_lon1)
+               CALL var_clean(tl_lon1)
+
+               ! add latitude
+               CALL file_add_var(tl_fileout, tl_lat1)
+               CALL var_clean(tl_lat1)
+            ENDIF
+            
+
+
+            IF( tl_dim(3)%l_use )THEN
+               IF( ASSOCIATED(tl_depth%d_value) )THEN
+                  ! add depth
+                  CALL file_add_var(tl_fileout, tl_depth)
+               ENDIF
+            ENDIF
+
+            IF( tl_dim(4)%l_use )THEN
+               IF( ASSOCIATED(tl_time%d_value) )THEN
+                  ! add time
+                  CALL file_add_var(tl_fileout, tl_time)
+               ENDIF
+            ENDIF
+
+            ! add other variable
+            DO jvar=tl_multi%i_nvar,1,-1
+               CALL file_add_var(tl_fileout, tl_segvar1(jvar,jk,jl))
+               CALL var_clean(tl_segvar1(jvar,jk,jl))
+            ENDDO
+
+            ! add some attribute
+            tl_att=att_init("Created_by","SIREN create_boundary")
+            CALL file_add_att(tl_fileout, tl_att)
+
+            cl_date=date_print(date_now())
+            tl_att=att_init("Creation_date",cl_date)
+            CALL file_add_att(tl_fileout, tl_att)
+
+            ! add shift on north and east boundary
+            ! boundary compute on T point but express on U or V point
+            SELECT CASE(TRIM(tl_bdy(jl)%c_card))
+            CASE DEFAULT ! 'south','west'
+               il_shift=0
+            CASE('north','east')
+               il_shift=1
+            END SELECT
+
+            ! add indice of velocity row or column
+            tl_att=att_init('bdy_ind',tl_bdy(jl)%t_seg(jk)%i_index-il_shift)
+            CALL file_move_att(tl_fileout, tl_att)
+
+            ! add width of the relaxation zone
+            tl_att=att_init('bdy_width',tl_bdy(jl)%t_seg(jk)%i_width)
+            CALL file_move_att(tl_fileout, tl_att)
+            
+            ! add indice of segment start 
+            tl_att=att_init('bdy_deb',tl_bdy(jl)%t_seg(jk)%i_first)
+            CALL file_move_att(tl_fileout, tl_att)
+            
+            ! add indice of segment end 
+            tl_att=att_init('bdy_end',tl_bdy(jl)%t_seg(jk)%i_last)
+            CALL file_move_att(tl_fileout, tl_att)
+                           
+            ! clean
+            CALL att_clean(tl_att)
+
+            ! create file
+            CALL iom_create(tl_fileout)
+
+            ! write file
+            CALL iom_write_file(tl_fileout, cl_dimorder)
+
+            ! close file
+            CALL iom_close(tl_fileout)
+            CALL file_clean(tl_fileout)
+
+         ENDDO ! jk
+
+      ENDIF
+      ! clean
+      CALL boundary_clean(tl_bdy(jl))
+   ENDDO !jl
+
+   ! clean
+   IF( ASSOCIATED(tl_depth%d_value) ) CALL var_clean(tl_depth)
+   IF( ASSOCIATED(tl_time%d_value) ) CALL var_clean(tl_time)
+   DEALLOCATE( tl_segdom1 )
+   DEALLOCATE( tl_segvar1 )
+   CALL var_clean(tl_seglvl1(:,:,:))
+   DEALLOCATE( tl_seglvl1 )
+
+
+   CALL mpp_clean(tl_coord1)
+   CALL mpp_clean(tl_coord0)
+
+   CALL multi_clean(tl_multi)
+
+   ! close log file
+   CALL logger_footer()
+   CALL logger_close()
+   CALL logger_clean()
+
+END SUBROUTINE create__boundary
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine compute boundary domain for each grid point (T,U,V,F) 
+   !> 
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !> @date September, 2014
+   !> - take into account grid point to compute boundary indices
+   !>
+   !> @param[in] td_bathy1 file structure 
+   !> @param[in] td_bdy    boundary structure
+   !> @param[in] id_seg    segment indice 
+   !> @return array of domain structure 
+   !-------------------------------------------------------------------
+   FUNCTION create_boundary_get_dom( td_bathy1, td_bdy, id_seg )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TMPP) , INTENT(IN   ) :: td_bathy1
+      TYPE(TBDY) , INTENT(IN   ) :: td_bdy
+      INTEGER(i4), INTENT(IN   ) :: id_seg
+
+      ! function
+      TYPE(TDOM), DIMENSION(ip_npoint) :: create_boundary_get_dom
+
+      ! local variable
+      INTEGER(i4) :: il_imin1
+      INTEGER(i4) :: il_imax1
+      INTEGER(i4) :: il_jmin1
+      INTEGER(i4) :: il_jmax1
+
+      INTEGER(i4) :: il_imin
+      INTEGER(i4) :: il_imax
+      INTEGER(i4) :: il_jmin
+      INTEGER(i4) :: il_jmax
+
+      INTEGER(i4), DIMENSION(ip_npoint) :: il_ishift
+      INTEGER(i4), DIMENSION(ip_npoint) :: il_jshift
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+      ! init
+      jk=id_seg
+
+      il_ishift(:)=0
+      il_jshift(:)=0
+
+      ! get boundary definition
+      SELECT CASE(TRIM(td_bdy%c_card))
+         CASE('north')
+
+            il_imin1=td_bdy%t_seg(jk)%i_first
+            il_imax1=td_bdy%t_seg(jk)%i_last 
+            il_jmin1=td_bdy%t_seg(jk)%i_index-(td_bdy%t_seg(jk)%i_width-1)
+            il_jmax1=td_bdy%t_seg(jk)%i_index
+
+            il_jshift(jp_V)=-1
+            il_jshift(jp_F)=-1
+
+         CASE('south')
+
+            il_imin1=td_bdy%t_seg(jk)%i_first
+            il_imax1=td_bdy%t_seg(jk)%i_last 
+            il_jmin1=td_bdy%t_seg(jk)%i_index
+            il_jmax1=td_bdy%t_seg(jk)%i_index+(td_bdy%t_seg(jk)%i_width-1)
+
+         CASE('east')
+
+            il_imin1=td_bdy%t_seg(jk)%i_index-(td_bdy%t_seg(jk)%i_width-1)
+            il_imax1=td_bdy%t_seg(jk)%i_index
+            il_jmin1=td_bdy%t_seg(jk)%i_first
+            il_jmax1=td_bdy%t_seg(jk)%i_last 
+
+            il_ishift(jp_U)=-1
+            il_ishift(jp_F)=-1
+
+         CASE('west')
+
+            il_imin1=td_bdy%t_seg(jk)%i_index
+            il_imax1=td_bdy%t_seg(jk)%i_index+(td_bdy%t_seg(jk)%i_width-1)
+            il_jmin1=td_bdy%t_seg(jk)%i_first
+            il_jmax1=td_bdy%t_seg(jk)%i_last 
+
+      END SELECT         
+
+      !-read fine grid domain
+      DO ji=1,ip_npoint
+
+         ! shift domain
+         il_imin=il_imin1+il_ishift(ji)
+         il_imax=il_imax1+il_ishift(ji)
+
+         il_jmin=il_jmin1+il_jshift(ji)
+         il_jmax=il_jmax1+il_jshift(ji)
+
+         ! compute domain
+         create_boundary_get_dom(ji)=dom_init( td_bathy1,       &
+         &                                     il_imin, il_imax,&
+         &                                     il_jmin, il_jmax,&
+         &                                     TRIM(td_bdy%c_card) )
+
+      ENDDO
+
+   END FUNCTION create_boundary_get_dom
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine get coordinates over boundary domain
+   !> 
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !> @date September, 2014 
+   !> - take into account grid point
+   !>
+   !> @param[in] td_coord1 coordinates file structure
+   !> @param[in] td_dom1   boundary domain structure
+   !> @param[in] cd_point  grid point
+   !> @param[out] td_lon1  longitude variable structure
+   !> @param[out] td_lat1  latitude variable structure
+   !-------------------------------------------------------------------
+   SUBROUTINE create_boundary_get_coord( td_coord1, td_dom1, cd_point, &
+   &                                     td_lon1, td_lat1 )
+
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TMPP)      , INTENT(IN   ) :: td_coord1
+      TYPE(TDOM)      , INTENT(IN   ) :: td_dom1
+      CHARACTER(LEN=*), INTENT(IN   ) :: cd_point
+      TYPE(TVAR)      , INTENT(  OUT) :: td_lon1
+      TYPE(TVAR)      , INTENT(  OUT) :: td_lat1 
+
+      ! local variable
+      TYPE(TMPP)        :: tl_coord1
+      
+      CHARACTER(LEN=lc) :: cl_name
+      ! loop indices
+      !----------------------------------------------------------------
+      !read variables on domain (ugly way to do it, have to work on it)
+      ! init mpp structure
+      tl_coord1=mpp_copy(td_coord1)
+      
+      ! open mpp files
+      CALL iom_dom_open(tl_coord1, td_dom1)
+
+      ! read variable value on domain
+      WRITE(cl_name,*) 'longitude_'//TRIM(cd_point)
+      td_lon1=iom_dom_read_var( tl_coord1, TRIM(cl_name), td_dom1)
+      WRITE(cl_name,*) 'latitude_'//TRIM(cd_point)
+      td_lat1=iom_dom_read_var( tl_coord1, TRIM(cl_name), td_dom1)
+
+      ! close mpp files
+      CALL iom_dom_close(tl_coord1)
+
+      ! clean structure
+      CALL mpp_clean(tl_coord1)
+
+   END SUBROUTINE create_boundary_get_coord
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine interpolate variable on boundary
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !>
+   !> @param[inout] td_var variable structure 
+   !> @param[in] id_rho    array of refinment factor
+   !> @param[in] id_offset array of offset between fine and coarse grid
+   !> @param[in] id_iext   i-direction size of extra bands (default=im_minext)
+   !> @param[in] id_jext   j-direction size of extra bands (default=im_minext)
+   !-------------------------------------------------------------------
+   SUBROUTINE create_boundary_interp( td_var,           &
+   &                                  id_rho,           &
+   &                                  id_offset,        &
+   &                                  id_iext, id_jext )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TVAR) ,                 INTENT(INOUT) :: td_var
+      INTEGER(I4), DIMENSION(:)  , INTENT(IN   ) :: id_rho
+      INTEGER(i4), DIMENSION(:,:), INTENT(IN   ) :: id_offset
+
+      INTEGER(i4),                 INTENT(IN   ), OPTIONAL :: id_iext
+      INTEGER(i4),                 INTENT(IN   ), OPTIONAL :: id_jext
+
+
+      ! local variable
+      INTEGER(i4) :: il_iext
+      INTEGER(i4) :: il_jext
+      ! loop indices
+      !----------------------------------------------------------------
+
+      !WARNING: at least two extrabands are required for cubic interpolation
+      il_iext=2
+      IF( PRESENT(id_iext) ) il_iext=id_iext
+
+      il_jext=2
+      IF( PRESENT(id_jext) ) il_jext=id_jext
+
+      IF( il_iext < 2 .AND. td_var%c_interp(1) == 'cubic' )THEN
+         CALL logger_warn("CREATE BOUNDARY INTERP: at least extrapolation "//&
+         &  "on two points are required with cubic interpolation ")
+         il_iext=2
+      ENDIF
+
+      IF( il_jext < 2 .AND. td_var%c_interp(1) == 'cubic' )THEN
+         CALL logger_warn("CREATE BOUNDARY INTERP: at least extrapolation "//&
+         &  "on two points are required with cubic interpolation ")
+         il_jext=2
+      ENDIF
+
+      ! work on variable
+      ! add extraband
+      CALL extrap_add_extrabands(td_var, il_iext, il_jext)
+
+      ! extrapolate variable
+      CALL extrap_fill_value( td_var )
+
+      ! interpolate Bathymetry
+      CALL interp_fill_value( td_var, id_rho(:), &
+      &                       id_offset=id_offset(:,:) )
+
+      ! remove extraband
+      CALL extrap_del_extrabands(td_var, il_iext*id_rho(jp_I), &
+         &                               il_jext*id_rho(jp_J))
+
+   END SUBROUTINE create_boundary_interp
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This function create variable, filled with matrix value
+   !> 
+   !> @details 
+   !> A variable is create with the same name that the input variable, 
+   !> and with dimension of the coordinate file. 
+   !> Then the variable array of value is split into equal subdomain.
+   !> Each subdomain is fill with the associated value of the matrix.
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !>
+   !> @param[in] td_var    variable structure 
+   !> @param[in] td_dom    domain structure 
+   !> @param[in] id_nlevel number of levels 
+   !> @return variable structure 
+   !-------------------------------------------------------------------
+   FUNCTION create_boundary_matrix(td_var, td_dom, id_nlevel)
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TVAR) , INTENT(IN) :: td_var
+      TYPE(TDOM) , INTENT(IN) :: td_dom
+      INTEGER(i4), INTENT(IN) :: id_nlevel
+
+      ! function
+      TYPE(TVAR) :: create_boundary_matrix
+
+      ! local variable
+      INTEGER(i4)      , DIMENSION(3)                    :: il_dim
+      INTEGER(i4)      , DIMENSION(3)                    :: il_size
+      INTEGER(i4)      , DIMENSION(3)                    :: il_rest
+
+      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_ishape
+      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_jshape
+      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_kshape
+
+      REAL(dp)         , DIMENSION(:,:,:,:), ALLOCATABLE :: dl_value
+
+      TYPE(TDIM)       , DIMENSION(ip_maxdim)            :: tl_dim
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      INTEGER(i4) :: jk
+      !----------------------------------------------------------------
+
+      ! write value on grid
+      ! get matrix dimension
+      il_dim(:)=td_var%t_dim(1:3)%i_len
+
+      tl_dim(jp_I:jp_J)=dim_copy(td_dom%t_dim(jp_I:jp_J))
+      tl_dim(jp_K)%i_len=id_nlevel
+
+      ! split output domain in N subdomain depending of matrix dimension 
+      il_size(:) = tl_dim(1:3)%i_len / il_dim(:)
+      il_rest(:) = MOD(tl_dim(1:3)%i_len, il_dim(:))
+
+      ALLOCATE( il_ishape(il_dim(1)+1) )
+      il_ishape(:)=0
+      DO ji=2,il_dim(1)+1
+         il_ishape(ji)=il_ishape(ji-1)+il_size(1)
+      ENDDO
+      ! add rest to last cell
+      il_ishape(il_dim(1)+1)=il_ishape(il_dim(1)+1)+il_rest(1)
+      
+      ALLOCATE( il_jshape(il_dim(2)+1) )
+      il_jshape(:)=0
+      DO jj=2,il_dim(2)+1
+         il_jshape(jj)=il_jshape(jj-1)+il_size(2)
+      ENDDO
+      ! add rest to last cell
+      il_jshape(il_dim(2)+1)=il_jshape(il_dim(2)+1)+il_rest(2)
+
+      ALLOCATE( il_kshape(il_dim(3)+1) )
+      il_kshape(:)=0
+      DO jk=2,il_dim(3)+1
+         il_kshape(jk)=il_kshape(jk-1)+il_size(3)
+      ENDDO
+      ! add rest to last cell
+      il_kshape(il_dim(3)+1)=il_kshape(il_dim(3)+1)+il_rest(3)
+
+      ! write ouput array of value 
+      ALLOCATE(dl_value( tl_dim(1)%i_len, &
+      &                  tl_dim(2)%i_len, &
+      &                  tl_dim(3)%i_len, &
+      &                  tl_dim(4)%i_len) )
+
+      dl_value(:,:,:,:)=0
+
+      DO jk=2,il_dim(3)+1
+         DO jj=2,il_dim(2)+1
+            DO ji=2,il_dim(1)+1
+               
+               dl_value( 1+il_ishape(ji-1):il_ishape(ji), &
+               &         1+il_jshape(jj-1):il_jshape(jj), &
+               &         1+il_kshape(jk-1):il_kshape(jk), &
+               &         1 ) = td_var%d_value(ji-1,jj-1,jk-1,1)
+
+            ENDDO
+         ENDDO
+      ENDDO
+
+      ! initialise variable with value
+      create_boundary_matrix=var_init(TRIM(td_var%c_name),dl_value(:,:,:,:))
+
+      DEALLOCATE(dl_value)
+
+   END FUNCTION create_boundary_matrix
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine use mask to filled land point with _FillValue
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !>
+   !> @param[inout] td_var variable structure 
+   !> @param[in] td_mask   mask variable structure
+   !-------------------------------------------------------------------
+   SUBROUTINE create_boundary_use_mask( td_var, td_mask )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TVAR), INTENT(INOUT) :: td_var
+      TYPE(TVAR), INTENT(IN   ) :: td_mask
+
+      ! local variable
+      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_mask
+
+      ! loop indices
+      INTEGER(i4) :: jk
+      INTEGER(i4) :: jl
+      !----------------------------------------------------------------
+
+      IF( ANY(td_var%t_dim(1:2)%i_len /= &
+      &       td_mask%t_dim(1:2)%i_len) )THEN
+         CALL logger_debug("     mask dimension ( "//&
+         &              TRIM(fct_str(td_mask%t_dim(1)%i_len))//","//&
+         &              TRIM(fct_str(td_mask%t_dim(2)%i_len))//")" )
+         CALL logger_debug(" variable dimension ( "//&
+         &              TRIM(fct_str(td_var%t_dim(1)%i_len))//","//&
+         &              TRIM(fct_str(td_var%t_dim(2)%i_len))//")" )
+         CALL logger_fatal("CREATE BOUNDARY USE MASK: mask and "//&
+         &                 "variable dimension differ."   )
+      ENDIF
+
+      ALLOCATE( il_mask(td_var%t_dim(1)%i_len, &
+      &                 td_var%t_dim(2)%i_len) )
+
+      il_mask(:,:)=INT(td_mask%d_value(:,:,1,1))
+
+      DO jl=1,td_var%t_dim(4)%i_len
+         DO jk=1,td_var%t_dim(3)%i_len
+            WHERE( il_mask(:,:) < jk ) td_var%d_value(:,:,jk,jl)=td_var%d_fill
+         ENDDO
+      ENDDO
+
+      DEALLOCATE( il_mask )
+
+   END SUBROUTINE create_boundary_use_mask
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This function extract level over domain on each grid point, and return
+   !> array of variable structure
+   !>
+   !> @author J.Paul
+   !> @date November, 2013 - Initial Version
+   !>
+   !> @param[in] td_level  array of level variable structure
+   !> @param[in] td_dom    array of domain structure
+   !> @return array of variable structure
+   !-------------------------------------------------------------------
+   FUNCTION create_boundary_get_level(td_level, td_dom)
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TVAR), DIMENSION(:), INTENT(IN) :: td_level
+      TYPE(TDOM), DIMENSION(:), INTENT(IN) :: td_dom
+
+      ! function
+      TYPE(TVAR), DIMENSION(ip_npoint) :: create_boundary_get_level
+
+      ! local variable
+      TYPE(TVAR), DIMENSION(ip_npoint) :: tl_var
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      IF( SIZE(td_level(:)) /= ip_npoint .OR. &
+      &   SIZE(td_dom(:)) /= ip_npoint )THEN
+         CALL logger_error("CREATE BDY GET LEVEL: invalid dimension. "//&
+         &  "check input array of level and domain.")
+      ELSE
+
+         DO ji=1,ip_npoint
+
+            tl_var(ji)=var_copy(td_level(ji))
+
+            IF( ASSOCIATED(tl_var(ji)%d_value) ) DEALLOCATE(tl_var(ji)%d_value)
+
+            tl_var(ji)%t_dim(1)%i_len=td_dom(ji)%t_dim(1)%i_len
+            tl_var(ji)%t_dim(2)%i_len=td_dom(ji)%t_dim(2)%i_len
+            ALLOCATE(tl_var(ji)%d_value(tl_var(ji)%t_dim(1)%i_len, &
+            &                           tl_var(ji)%t_dim(2)%i_len, &
+            &                           tl_var(ji)%t_dim(3)%i_len, &
+            &                           tl_var(ji)%t_dim(4)%i_len) )
+
+            tl_var(ji)%d_value(:,:,:,:) = &
+            &  td_level(ji)%d_value( td_dom(ji)%i_imin:td_dom(ji)%i_imax, &
+            &                        td_dom(ji)%i_jmin:td_dom(ji)%i_jmax, :, : )
+
+         ENDDO
+         ! save result
+         create_boundary_get_level(:)=var_copy(tl_var(:))
+
+         ! clean
+         CALL var_clean(tl_var(:))
+
+      ENDIF
+   END FUNCTION create_boundary_get_level
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine check if variable need depth dimension, 
+   !> get depth variable value in an open mpp structure
+   !> and check if agree with already input depth variable.
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date November, 2014 - Initial Version
+   !> @date January, 2016
+   !> - check if variable need/use depth dimension
+   !>
+   !> @param[in] td_var       variable structure
+   !> @param[in] td_mpp       mpp structure
+   !> @param[in] id_nlevel    mpp structure
+   !> @param[inout] td_depth  depth variable structure 
+   !-------------------------------------------------------------------
+   SUBROUTINE create_boundary_check_depth( td_var, td_mpp, id_nlevel, td_depth )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TVAR) , INTENT(IN   ) :: td_var
+      TYPE(TMPP) , INTENT(IN   ) :: td_mpp
+      INTEGER(i4), INTENT(IN   ) :: id_nlevel
+      TYPE(TVAR) , INTENT(INOUT) :: td_depth
+
+      ! local variable
+      INTEGER(i4) :: il_varid
+      TYPE(TVAR)  :: tl_depth
+      ! loop indices
+      !----------------------------------------------------------------
+
+      IF( td_var%t_dim(jp_K)%l_use .AND. &
+      &   ( TRIM(td_var%c_axis) == '' .OR. &
+      &     INDEX(TRIM(td_var%c_axis),'Z') /= 0 )&
+      & )THEN
+
+         ! check vertical dimension
+         IF( td_mpp%t_dim(jp_K)%l_use )THEN
+            IF( td_mpp%t_dim(jp_K)%i_len /= id_nlevel .AND. &
+              & td_mpp%t_dim(jp_K)%i_len /= 1 )THEN
+               CALL logger_error("CREATE BOUNDARY: dimension in file "//&
+               &  TRIM(td_mpp%c_name)//" not agree with namelist in_nlevel ")
+            ENDIF
+         ENDIF
+
+         ! get or check depth value
+         IF( td_mpp%t_proc(1)%i_depthid /= 0 )THEN
+
+            il_varid=td_mpp%t_proc(1)%i_depthid
+            IF( ASSOCIATED(td_depth%d_value) )THEN
+
+               tl_depth=iom_mpp_read_var(td_mpp, il_varid)
+
+               IF( ANY( td_depth%d_value(:,:,:,:) /= &
+               &        tl_depth%d_value(:,:,:,:) ) )THEN
+
+                  CALL logger_error("CREATE BOUNDARY: depth value "//&
+                  &  "for variable "//TRIM(td_var%c_name)//&
+                  &  "from "//TRIM(td_mpp%c_name)//" not conform "//&
+                  &  " to those from former file(s).")
+
+               ENDIF
+               CALL var_clean(tl_depth)
+
+            ELSE
+               td_depth=iom_mpp_read_var(td_mpp,il_varid)
+            ENDIF
+
+         ENDIF
+      ELSE
+         CALL logger_debug("CREATE BOUNDARY: no depth dimension use"//&
+         &                 " for variable "//TRIM(td_var%c_name))
+      ENDIF
+      
+   END SUBROUTINE create_boundary_check_depth
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine check if variable need time dimension, 
+   !> get date and time in an open mpp structure
+   !> and check if agree with date and time already read.
+   !> 
+   !> @details 
+   !>
+   !> @author J.Paul
+   !> @date November, 2014 - Initial Version
+   !> @date January, 2016
+   !> - check if variable need/use time dimension
+   !>
+   !> @param[in] td_var       variable structure
+   !> @param[in] td_mpp      mpp structure
+   !> @param[inout] td_time  time variable structure 
+   !-------------------------------------------------------------------
+   SUBROUTINE create_boundary_check_time( td_var, td_mpp, td_time )
+
+      IMPLICIT NONE
+
+      ! Argument
+      TYPE(TVAR), INTENT(IN   ) :: td_var
+      TYPE(TMPP), INTENT(IN   ) :: td_mpp
+      TYPE(TVAR), INTENT(INOUT) :: td_time
+
+      ! local variable
+      INTEGER(i4) :: il_varid
+      TYPE(TVAR)  :: tl_time
+
+      TYPE(TDATE) :: tl_date1
+      TYPE(TDATE) :: tl_date2
+      ! loop indices
+      !----------------------------------------------------------------
+      IF( td_var%t_dim(jp_L)%l_use .AND. &
+      &   ( TRIM(td_var%c_axis) == '' .OR. &
+      &     INDEX(TRIM(td_var%c_axis),'T') /= 0 )&
+      & )THEN
+
+         ! get or check depth value
+         IF( td_mpp%t_proc(1)%i_timeid /= 0 )THEN
+
+            il_varid=td_mpp%t_proc(1)%i_timeid
+            IF( ASSOCIATED(td_time%d_value) )THEN
+
+               tl_time=iom_mpp_read_var(td_mpp, il_varid)
+
+               tl_date1=var_to_date(td_time)
+               tl_date2=var_to_date(tl_time)
+               IF( tl_date1 - tl_date2 /= 0 )THEN
+
+                  CALL logger_warn("CREATE BOUNDARY: date from "//&
+                  &  TRIM(td_mpp%c_name)//" not conform "//&
+                  &  " to those from former file(s).")
+
+               ENDIF
+               CALL var_clean(tl_time)
+
+            ELSE
+               td_time=iom_mpp_read_var(td_mpp,il_varid)
+            ENDIF
+
+         ENDIF
+
+      ELSE
+         CALL logger_debug("CREATE BOUNDARY: no time dimension use"//&
+         &                 " for variable "//TRIM(td_var%c_name))
+      ENDIF
+
+   END SUBROUTINE create_boundary_check_time
+END PROGRAM create_boundary
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_boundary.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_boundary.f90	(revision 7338)
+++ 	(revision )
@@ -1,1728 +1,0 @@
-!----------------------------------------------------------------------
-! NEMO system team, System and Interface for oceanic RElocable Nesting
-!----------------------------------------------------------------------
-!
-!
-! PROGRAM: create_boundary
-!
-! DESCRIPTION:
-!> @file
-!> @brief 
-!> This program create boundary files.
-!>
-!> @details
-!> @section sec1 method
-!> Variables are read from coarse grid standard output 
-!> and interpolated on fine grid or manually written.<br/>
-!> @note 
-!>    method could be different for each variable.
-!>
-!> @section sec2 how to 
-!>    to create boundaries files:<br/>
-!> @code{.sh}
-!>    ./SIREN/bin/create_boundary create_boundary.nam
-!> @endcode
-!>  <br/> 
-!> \image html  boundary_NEATL36_70.png 
-!> \image latex boundary_NEATL36_70.png
-!>
-!> @note 
-!>    you could find a template of the namelist in templates directory.
-!>
-!>    create_boundary.nam comprise 9 namelists:<br/>
-!>       - logger namelist (namlog)
-!>       - config namelist (namcfg)
-!>       - coarse grid namelist (namcrs)
-!>       - fine grid namelist (namfin)
-!>       - variable namelist (namvar)
-!>       - nesting namelist (namnst)
-!>       - boundary namelist (nambdy)
-!>       - vertical grid namelist (namzgr)
-!>       - output namelist (namout)
-!>    
-!>    @note 
-!>       All namelists have to be in file create_boundary.nam, 
-!>       however variables of those namelists are all optional.
-!>
-!>    * _logger namelist (namlog)_:<br/>
-!>       - cn_logfile   : log filename
-!>       - cn_verbosity : verbosity ('trace','debug','info',
-!> 'warning','error','fatal','none')
-!>       - in_maxerror  : maximum number of error allowed
-!>
-!>    * _config namelist (namcfg)_:<br/>
-!>       - cn_varcfg : variable configuration file
-!> (see ./SIREN/cfg/variable.cfg)
-!>
-!>    * _coarse grid namelist (namcrs)_:<br/>
-!>       - cn_coord0 : coordinate file
-!>       - in_perio0 : NEMO periodicity index (see Model Boundary Condition in
-!> [NEMO documentation](http://www.nemo-ocean.eu/About-NEMO/Reference-manuals))
-!>
-!>    * _fine grid namelist (namfin)_:<br/>
-!>       - cn_coord1 : coordinate file
-!>       - cn_bathy1 : bathymetry file
-!>       - in_perio1 : periodicity index
-!>
-!>    * _vertical grid namelist (namzgr)_:<br/>
-!>       - dn_pp_to_be_computed  :
-!>       - dn_ppsur              :
-!>       - dn_ppa0               :
-!>       - dn_ppa1               :
-!>       - dn_ppa2               : 
-!>       - dn_ppkth              :
-!>       - dn_ppkth2             :
-!>       - dn_ppacr              :
-!>       - dn_ppacr2             :
-!>       - dn_ppdzmin            :
-!>       - dn_pphmax             :
-!>       - in_nlevel             : number of vertical level
-!>
-!>    * _partial step namelist (namzps)_:<br/>
-!>       - dn_e3zps_mi           :
-!>       - dn_e3zps_rat          : 
-!>
-!>    * _variable namelist (namvar)_:<br/>
-!>       - cn_varinfo : list of variable and extra information about request(s)
-!>          to be used (separated by ',').<br/>
-!>          each elements of *cn_varinfo* is a string character.<br/>
-!>          it is composed of the variable name follow by ':', 
-!>          then request(s) to be used on this variable.<br/> 
-!>          request could be:
-!>             - int = interpolation method
-!>             - ext = extrapolation method
-!>             - flt = filter method
-!>             - unt = new units
-!>             - unf = unit scale factor (linked to new units)
-!>
-!>                requests must be separated by ';'.<br/>
-!>                order of requests does not matter.
-!>
-!>          informations about available method could be find in @ref interp,
-!>          @ref extrap and @ref filter.<br/>
-!>
-!>          Example: 'votemper:int=linear;flt=hann;ext=dist_weight', 'vosaline:int=cubic'
-!>          @note 
-!>             If you do not specify a method which is required, 
-!>             default one is apply.
-!>       - cn_varfile : list of variable, and corresponding file<br/> 
-!>          *cn_varfile* is the path and filename of the file where find
-!>          variable.<br/> 
-!>          @note 
-!>             *cn_varfile* could be a matrix of value, if you want to filled
-!>             manually variable value.<br/>
-!>             the variable array of value is split into equal subdomain.<br/>
-!>             Each subdomain is filled with the corresponding value 
-!>             of the matrix.<br/>          
-!>             separators used to defined matrix are:
-!>                - ',' for line
-!>                - '/' for row
-!>                - '\' for level<br/>
-!>                Example:<br/>
-!>                   3,2,3/1,4,5  =>  @f$ \left( \begin{array}{ccc}
-!>                                         3 & 2 & 3 \\
-!>                                         1 & 4 & 5 \end{array} \right) @f$
-!>          @warning 
-!>             the same matrix is used for all boundaries.
-!>
-!>       Examples: 
-!>          - 'votemper:gridT.nc', 'vozocrtx:gridU.nc'
-!>          - 'votemper:10\25', 'vozocrtx:gridU.nc'
-!>
-!>    * _nesting namelist (namnst)_:<br/>
-!>       - in_rhoi  : refinement factor in i-direction
-!>       - in_rhoj  : refinement factor in j-direction
-!>
-!>    * _boundary namelist (nambdy)_:<br/>
-!>       - ln_north  : use north boundary
-!>       - ln_south  : use south boundary
-!>       - ln_east   : use east  boundary
-!>       - ln_west   : use west  boundary
-!>       - cn_north  : north boundary indices on fine grid
-!>          *cn_north* is a string character defining boundary
-!>          segmentation.<br/>
-!>          segments are separated by '|'.<br/>
-!>          each segments of the boundary is composed of:
-!>             - indice of velocity (orthogonal to boundary .ie. 
-!>                for north boundary, J-indice). 
-!>             - indice of segemnt start (I-indice for north boundary) 
-!>             - indice of segment end   (I-indice for north boundary)<br/>
-!>                indices must be separated by ':' .<br/>
-!>             - optionally, boundary size could be added between '(' and ')' 
-!>             in the first segment defined.
-!>                @note 
-!>                   boundary width is the same for all segments of one boundary.
-!>
-!>          Examples:
-!>             - cn_north='index1,first1:last1(width)'
-!>             - cn_north='index1(width),first1:last1|index2,first2:last2'
-!>             \image html  boundary_50.png 
-!>             \image latex boundary_50.png
-!>       - cn_south  : south boundary indices on fine grid
-!>       - cn_east   : east  boundary indices on fine grid
-!>       - cn_west   : west  boundary indices on fine grid
-!>       - ln_oneseg : use only one segment for each boundary or not
-!>
-!>    * _output namelist (namout)_:<br/>
-!>       - cn_fileout : fine grid boundary basename
-!>         (cardinal and segment number will be automatically added)
-!>       - dn_dayofs  : date offset in day (change only ouput file name)
-!>       - ln_extrap  : extrapolate land point or not
-!>
-!>          Examples: 
-!>             - cn_fileout=boundary.nc<br/>
-!>                if time_counter (16/07/2015 00h) is read on input file (see varfile), 
-!>                west boundary will be named boundary_west_y2015m07d16
-!>             - dn_dayofs=-2.<br/>
-!>                if you use day offset you get boundary_west_y2015m07d14
-!>       
-!>
-!> @author J.Paul
-! REVISION HISTORY:
-!> @date November, 2013 - Initial Version
-!> @date September, 2014
-!> - add header for user
-!> - take into account grid point to compue boundaries
-!> - reorder output dimension for north and south boundaries
-!> @date June, 2015
-!> - extrapolate all land points, and add ln_extrap in namelist.
-!> - allow to change unit.
-!> @date July, 2015
-!> - add namelist parameter to shift date of output file name.  
-!>
-!> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-!----------------------------------------------------------------------
-PROGRAM create_boundary
-
-   USE netcdf                          ! nf90 library
-   USE global                          ! global variable
-   USE phycst                          ! physical constant
-   USE kind                            ! F90 kind parameter
-   USE logger                          ! log file manager
-   USE fct                             ! basic useful function
-   USE date                            ! date manager
-   USE att                             ! attribute manager
-   USE dim                             ! dimension manager
-   USE var                             ! variable manager
-   USE file                            ! file manager
-   USE multi                           ! multi file manager
-   USE boundary                        ! boundary manager
-   USE iom                             ! I/O manager
-   USE dom                             ! domain manager
-   USE grid                            ! grid manager
-   USE vgrid                           ! vertical grid manager
-   USE extrap                          ! extrapolation manager
-   USE interp                          ! interpolation manager
-   USE filter                          ! filter manager
-   USE mpp                             ! MPP manager
-   USE iom_mpp                         ! MPP I/O manager
-
-   IMPLICIT NONE
-
-   ! local variable
-   CHARACTER(LEN=lc)                                  :: cl_namelist
-   CHARACTER(LEN=lc)                                  :: cl_date
-   CHARACTER(LEN=lc)                                  :: cl_name
-   CHARACTER(LEN=lc)                                  :: cl_bdyout
-   CHARACTER(LEN=lc)                                  :: cl_data
-   CHARACTER(LEN=lc)                                  :: cl_dimorder
-   CHARACTER(LEN=lc)                                  :: cl_point
-   CHARACTER(LEN=lc)                                  :: cl_fmt
-
-   INTEGER(i4)                                        :: il_narg
-   INTEGER(i4)                                        :: il_status
-   INTEGER(i4)                                        :: il_fileid
-   INTEGER(i4)                                        :: il_imin0
-   INTEGER(i4)                                        :: il_imax0
-   INTEGER(i4)                                        :: il_jmin0
-   INTEGER(i4)                                        :: il_jmax0
-   INTEGER(i4)                                        :: il_shift
-   INTEGER(i4)      , DIMENSION(ip_maxdim)            :: il_rho
-   INTEGER(i4)      , DIMENSION(2,2)                  :: il_offset
-   INTEGER(i4)      , DIMENSION(2,2)                  :: il_ind
-
-   LOGICAL                                            :: ll_exist
-
-   TYPE(TATT)                                         :: tl_att
-   
-   TYPE(TVAR)                                         :: tl_depth   
-   TYPE(TVAR)                                         :: tl_time
-   TYPE(TVAR)                                         :: tl_var1
-   TYPE(TVAR)                                         :: tl_var0
-   TYPE(TVAR)                                         :: tl_lon1
-   TYPE(TVAR)                                         :: tl_lat1
-   TYPE(TVAR)                                         :: tl_lvl1  
-   TYPE(TVAR)       , DIMENSION(:)      , ALLOCATABLE :: tl_level
-   TYPE(TVAR)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_seglvl1
-   TYPE(TVAR)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_segvar1
-
-   TYPE(TDIM)       , DIMENSION(ip_maxdim)            :: tl_dim
-
-   TYPE(TDATE)                                        :: tl_date
-   
-   TYPE(TBDY)       , DIMENSION(ip_ncard)             :: tl_bdy
-   
-   TYPE(TDOM)                                         :: tl_dom0
-   TYPE(TDOM)                                         :: tl_dom1
-   TYPE(TDOM)       , DIMENSION(:,:,:)  , ALLOCATABLE :: tl_segdom1
-
-   TYPE(TFILE)                                        :: tl_fileout
-   
-   TYPE(TMPP)                                         :: tl_coord0
-   TYPE(TMPP)                                         :: tl_coord1
-   TYPE(TMPP)                                         :: tl_bathy1
-   TYPE(TMPP)                                         :: tl_mpp
-
-   TYPE(TMULTI)                                       :: tl_multi
-
-   ! loop indices
-   INTEGER(i4) :: jvar
-   INTEGER(i4) :: jpoint
-   INTEGER(i4) :: ji
-   INTEGER(i4) :: jj
-   INTEGER(i4) :: jk
-   INTEGER(i4) :: jl
-
-   ! namelist variable
-   ! namlog
-   CHARACTER(LEN=lc)  :: cn_logfile = 'create_boundary.log' 
-   CHARACTER(LEN=lc)  :: cn_verbosity = 'warning' 
-   INTEGER(i4)        :: in_maxerror = 5
-
-   ! namcfg
-   CHARACTER(LEN=lc)  :: cn_varcfg = 'variable.cfg' 
-
-   ! namcrs
-   CHARACTER(LEN=lc)  :: cn_coord0 = '' 
-   INTEGER(i4)        :: in_perio0 = -1
-
-   ! namfin
-   CHARACTER(LEN=lc)  :: cn_coord1 = '' 
-   CHARACTER(LEN=lc)  :: cn_bathy1 = '' 
-   INTEGER(i4)        :: in_perio1 = -1
-
-   !namzgr
-   REAL(dp)          :: dn_pp_to_be_computed = 0._dp
-   REAL(dp)          :: dn_ppsur     = -3958.951371276829_dp
-   REAL(dp)          :: dn_ppa0      =   103.9530096000000_dp
-   REAL(dp)          :: dn_ppa1      =     2.4159512690000_dp
-   REAL(dp)          :: dn_ppa2      =   100.7609285000000_dp
-   REAL(dp)          :: dn_ppkth     =    15.3510137000000_dp
-   REAL(dp)          :: dn_ppkth2    =    48.0298937200000_dp
-   REAL(dp)          :: dn_ppacr     =     7.0000000000000_dp
-   REAL(dp)          :: dn_ppacr2    =    13.000000000000_dp
-   REAL(dp)          :: dn_ppdzmin   = 6._dp
-   REAL(dp)          :: dn_pphmax    = 5750._dp
-   INTEGER(i4)       :: in_nlevel    = 75
-
-   !namzps
-   REAL(dp)          :: dn_e3zps_min = 25._dp
-   REAL(dp)          :: dn_e3zps_rat = 0.2_dp
-
-   ! namvar
-   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
-   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
-
-   ! namnst
-   INTEGER(i4)       :: in_rhoi  = 0
-   INTEGER(i4)       :: in_rhoj  = 0
-
-   ! nambdy
-   LOGICAL           :: ln_north   = .TRUE.
-   LOGICAL           :: ln_south   = .TRUE.
-   LOGICAL           :: ln_east    = .TRUE.
-   LOGICAL           :: ln_west    = .TRUE.
-   CHARACTER(LEN=lc) :: cn_north   = ''
-   CHARACTER(LEN=lc) :: cn_south   = ''
-   CHARACTER(LEN=lc) :: cn_east    = ''
-   CHARACTER(LEN=lc) :: cn_west    = ''
-   LOGICAL           :: ln_oneseg  = .TRUE.
-
-   ! namout
-   CHARACTER(LEN=lc) :: cn_fileout = 'boundary.nc' 
-   REAL(dp)          :: dn_dayofs  = 0._dp
-   LOGICAL           :: ln_extrap  = .FALSE.
-   !-------------------------------------------------------------------
-
-   NAMELIST /namlog/ &  !< logger namelist
-   &  cn_logfile,    &  !< log file
-   &  cn_verbosity,  &  !< log verbosity
-   &  in_maxerror
-
-   NAMELIST /namcfg/ &  !< config namelist
-   &  cn_varcfg         !< variable configuration file
-
-   NAMELIST /namcrs/ &  !< coarse grid namelist
-   &  cn_coord0,     &  !< coordinate file
-   &  in_perio0         !< periodicity index
- 
-   NAMELIST /namfin/ &  !< fine grid namelist
-   &  cn_coord1,     &  !< coordinate file
-   &  cn_bathy1,     &  !< bathymetry file
-   &  in_perio1         !< periodicity index
- 
-   NAMELIST /namzgr/ &
-   &  dn_pp_to_be_computed, &
-   &  dn_ppsur,     &
-   &  dn_ppa0,      &
-   &  dn_ppa1,      &
-   &  dn_ppa2,      &
-   &  dn_ppkth,     &
-   &  dn_ppkth2,    &
-   &  dn_ppacr,     &
-   &  dn_ppacr2,    &
-   &  dn_ppdzmin,   &
-   &  dn_pphmax,    &
-   &  in_nlevel         !< number of vertical level
-
-   NAMELIST /namzps/ &
-   &  dn_e3zps_min, &
-   &  dn_e3zps_rat
-
-   NAMELIST /namvar/ &  !< variable namelist
-   &  cn_varinfo,    &  !< list of variable and method to apply on. (ex: 'votemper:linear','vosaline:cubic' )
-   &  cn_varfile        !< list of variable and file where find it. (ex: 'votemper:GLORYS_gridT.nc' ) 
- 
-   NAMELIST /namnst/ &  !< nesting namelist
-   &  in_rhoi,       &  !< refinement factor in i-direction
-   &  in_rhoj           !< refinement factor in j-direction
-
-   NAMELIST /nambdy/ &  !< boundary namelist
-   &  ln_north,      &  !< use north boundary
-   &  ln_south,      &  !< use south boundary
-   &  ln_east ,      &  !< use east  boundary
-   &  ln_west ,      &  !< use west  boundary
-   &  cn_north,      &  !< north boundary indices on fine grid
-   &  cn_south,      &  !< south boundary indices on fine grid
-   &  cn_east ,      &  !< east  boundary indices on fine grid
-   &  cn_west ,      &  !< west  boundary indices on fine grid
-   &  ln_oneseg         !< use only one segment for each boundary or not
-
-   NAMELIST /namout/ &  !< output namelist
-   &  cn_fileout,    &  !< fine grid boundary file basename   
-   &  dn_dayofs,     &  !< date offset in day (change only ouput file name)
-   &  ln_extrap         !< extrapolate or not
-   !-------------------------------------------------------------------
-
-   ! namelist
-   ! get namelist
-   il_narg=COMMAND_ARGUMENT_COUNT() !f03 intrinsec
-   IF( il_narg/=1 )THEN
-      PRINT *,"CREATE BOUNDARY: ERROR. need a namelist"
-      STOP
-   ELSE
-      CALL GET_COMMAND_ARGUMENT(1,cl_namelist) !f03 intrinsec
-   ENDIF
-   
-   ! read namelist
-   INQUIRE(FILE=TRIM(cl_namelist), EXIST=ll_exist)
-   IF( ll_exist )THEN
-      
-      il_fileid=fct_getunit()
-
-      OPEN( il_fileid, FILE=TRIM(cl_namelist), &
-      &                FORM='FORMATTED',       &
-      &                ACCESS='SEQUENTIAL',    &
-      &                STATUS='OLD',           &
-      &                ACTION='READ',          &
-      &                IOSTAT=il_status)
-      CALL fct_err(il_status)
-      IF( il_status /= 0 )THEN
-         PRINT *,"CREATE BOUNDARY: ERROR opening "//TRIM(cl_namelist)
-         STOP
-      ENDIF
-
-      READ( il_fileid, NML = namlog )
-      ! define log file
-      CALL logger_open(TRIM(cn_logfile),TRIM(cn_verbosity),in_maxerror)
-      CALL logger_header()
-
-      READ( il_fileid, NML = namcfg )
-      ! get variable extra information
-      CALL var_def_extra(TRIM(cn_varcfg))
-
-      READ( il_fileid, NML = namcrs )
-      READ( il_fileid, NML = namfin )
-      READ( il_fileid, NML = namzgr )
-      READ( il_fileid, NML = namvar )
-      ! add user change in extra information
-      CALL var_chg_extra(cn_varinfo)
-      ! match variable with file
-      tl_multi=multi_init(cn_varfile)
-
-      READ( il_fileid, NML = namnst )
-      READ( il_fileid, NML = nambdy )
-      READ( il_fileid, NML = namout )
-
-      CLOSE( il_fileid, IOSTAT=il_status )
-      CALL fct_err(il_status)
-      IF( il_status /= 0 )THEN
-         CALL logger_error("CREATE BOUNDARY: ERROR closing "//TRIM(cl_namelist))
-      ENDIF
-
-   ELSE
-
-      PRINT *,"CREATE BOUNDARY: ERROR. can not find "//TRIM(cl_namelist)
-      STOP
-
-   ENDIF
-
-   CALL multi_print(tl_multi)
-   IF( tl_multi%i_nvar <= 0 )THEN
-      CALL logger_fatal("CREATE BOUNDARY: no variable to be used."//&
-      &  " check namelist.")
-   ENDIF
-
-   ! open files
-   IF( TRIM(cn_coord0) /= '' )THEN
-      tl_coord0=mpp_init( file_init(TRIM(cn_coord0)), id_perio=in_perio0)
-      CALL grid_get_info(tl_coord0)
-   ELSE
-      CALL logger_fatal("CREATE BOUNDARY: can not find coarse grid "//&
-      &  "coordinate file. check namelist")
-   ENDIF
-
-   IF( TRIM(cn_coord1) /= '' )THEN
-      tl_coord1=mpp_init( file_init(TRIM(cn_coord1)), id_perio=in_perio1)
-      CALL grid_get_info(tl_coord1)
-   ELSE
-      CALL logger_fatal("CREATE BOUNDARY: can not find fine grid coordinate "//&
-      &  "file. check namelist")
-   ENDIF
-
-   IF( TRIM(cn_bathy1) /= '' )THEN
-      tl_bathy1=mpp_init( file_init(TRIM(cn_bathy1)), id_perio=in_perio1)
-      CALL grid_get_info(tl_bathy1)
-   ELSE
-      CALL logger_fatal("CREATE BOUNDARY: can not find fine grid bathymetry "//&
-      &  "file. check namelist")
-   ENDIF
-
-   ! check
-   ! check output file do not already exist
-   ! WARNING: do not work when use time to create output file name
-   DO jk=1,ip_ncard
-      cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-      &                                TRIM(cp_card(jk)), 1 )
-      INQUIRE(FILE=TRIM(cl_bdyout), EXIST=ll_exist)
-      IF( ll_exist )THEN
-         CALL logger_fatal("CREATE BOUNDARY: output file "//TRIM(cl_bdyout)//&
-         &  " already exist.")
-      ENDIF
-
-      cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-      &                                TRIM(cp_card(jk)) )
-      INQUIRE(FILE=TRIM(cl_bdyout), EXIST=ll_exist)
-      IF( ll_exist )THEN
-         CALL logger_fatal("CREATE BOUNDARY: output file "//TRIM(cl_bdyout)//&
-         &  " already exist.")
-      ENDIF
-   ENDDO
-
-   ! check namelist
-   ! check refinement factor
-   il_rho(:)=1
-   IF( in_rhoi < 1 .OR. in_rhoj < 1 )THEN
-      CALL logger_error("CREATE BOUNDARY: invalid refinement factor."//&
-      &  " check namelist "//TRIM(cl_namelist))
-   ELSE
-      il_rho(jp_I)=in_rhoi
-      il_rho(jp_J)=in_rhoj
-   ENDIF
-
-   !
-   ! compute coarse grid indices around fine grid
-   il_ind(:,:)=grid_get_coarse_index(tl_coord0, tl_coord1, &
-   &                                 id_rho=il_rho(:))
-
-   il_imin0=il_ind(1,1) ; il_imax0=il_ind(1,2)
-   il_jmin0=il_ind(2,1) ; il_jmax0=il_ind(2,2)
-
-   ! check domain validity
-   CALL grid_check_dom(tl_coord0, il_imin0, il_imax0, il_jmin0, il_jmax0)
-
-   ! check coordinate file
-   CALL grid_check_coincidence( tl_coord0, tl_coord1, &
-   &                            il_imin0, il_imax0, &
-   &                            il_jmin0, il_jmax0, &
-   &                            il_rho(:) )      
-
-   ! read or compute boundary
-   CALL mpp_get_contour(tl_bathy1)
-
-   CALL iom_mpp_open(tl_bathy1)
- 
-   tl_var1=iom_mpp_read_var(tl_bathy1,'Bathymetry')
- 
-   CALL iom_mpp_close(tl_bathy1)
-
-   ! get boundaries indices
-   tl_bdy(:)=boundary_init(tl_var1, ln_north, ln_south, ln_east, ln_west, &
-   &                                cn_north, cn_south, cn_east, cn_west, &
-   &                                ln_oneseg ) 
-
-   CALL var_clean(tl_var1)
-
-   ! compute level
-   ALLOCATE(tl_level(ip_npoint))
-   tl_level(:)=vgrid_get_level(tl_bathy1, cl_namelist )
-
-   ! get coordinate for each segment of each boundary
-   ALLOCATE( tl_segdom1(ip_npoint,ip_maxseg,ip_ncard) )
-   ALLOCATE( tl_seglvl1(ip_npoint,ip_maxseg,ip_ncard) )
- 
-   DO jl=1,ip_ncard
-      IF( tl_bdy(jl)%l_use )THEN
-         DO jk=1,tl_bdy(jl)%i_nseg
-
-            ! get fine grid segment domain
-            tl_segdom1(:,jk,jl)=create_boundary_get_dom( tl_bathy1, &
-            &                                            tl_bdy(jl), jk )
-
-            IF( .NOT. ln_extrap )THEN
-               ! get fine grid level
-               tl_seglvl1(:,jk,jl)= &
-                  & create_boundary_get_level( tl_level(:), &
-                  &                            tl_segdom1(:,jk,jl))
-            ENDIF
-
-            ! add extra band to fine grid domain (if possible)
-            ! to avoid dimension of one and so be able to compute offset
-            DO jj=1,ip_npoint
-               CALL dom_add_extra(tl_segdom1(jj,jk,jl), &
-               &                  il_rho(jp_I), il_rho(jp_J))
-            ENDDO
-
-         ENDDO
-      ENDIF
-   ENDDO
-
-   ! clean
-   CALL var_clean(tl_level(:))
-   DEALLOCATE(tl_level)
-
-   ! clean bathy
-   CALL mpp_clean(tl_bathy1)
-
-   ALLOCATE( tl_segvar1(tl_multi%i_nvar,ip_maxseg,ip_ncard) )
-   ! compute boundary for variable to be used (see namelist)
-   IF( .NOT. ASSOCIATED(tl_multi%t_mpp) )THEN
-      CALL logger_error("CREATE BOUNDARY: no file to work on. "//&
-      &                 "check cn_varfile in namelist.")
-   ELSE
-
-      jvar=0
-      ! for each file
-      DO ji=1,tl_multi%i_nmpp
-
-         WRITE(cl_data,'(a,i2.2)') 'data-',jvar+1
-
-         IF( .NOT. ASSOCIATED(tl_multi%t_mpp(ji)%t_proc(1)%t_var) )THEN
-
-            CALL logger_error("CREATE BOUNDARY: no variable to work on for "//&
-            &                 "mpp "//TRIM(tl_multi%t_mpp(ji)%c_name)//&
-            &                 ". check cn_varfile in namelist.")
-
-         ELSEIF( TRIM(tl_multi%t_mpp(ji)%c_name) == TRIM(cl_data) )THEN
-         !- use input matrix to fill variable
-
-            WRITE(*,'(a)') "work on data"
-            ! for each variable initialise from matrix
-            DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
-
-               jvar=jvar+1
-               WRITE(*,'(2x,a,a)') "work on variable "//&
-               &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name)
-
-               tl_var1=var_copy(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj))
-
-               SELECT CASE(TRIM(tl_var1%c_point))
-               CASE DEFAULT !'T'
-                  jpoint=jp_T
-               CASE('U')
-                  jpoint=jp_U
-               CASE('V')
-                  jpoint=jp_V
-               CASE('F')
-                  jpoint=jp_F
-               END SELECT
-
-               WRITE(*,'(4x,a,a)') 'work on '//TRIM(tl_var1%c_name)
-               DO jl=1,ip_ncard
-                  IF( tl_bdy(jl)%l_use )THEN
-
-                     DO jk=1,tl_bdy(jl)%i_nseg
-
-                        ! fill value with matrix data
-                        tl_segvar1(jvar,jk,jl)=create_boundary_matrix( &
-                        &                          tl_var1, &
-                        &                          tl_segdom1(jpoint,jk,jl), &
-                        &                          in_nlevel )
-
-                        !del extra
-                        CALL dom_del_extra( tl_segvar1(jvar,jk,jl), &
-                        &                   tl_segdom1(jpoint,jk,jl) )
-
-                     ENDDO
-
-                  ENDIF
-               ENDDO
-               
-               ! clean
-               CALL var_clean(tl_var1)
-
-            ENDDO
-
-         !- end of use input matrix to fill variable
-         ELSE
-         !- use file to fill variable
-
-            WRITE(*,'(a)') "work on file "//TRIM(tl_multi%t_mpp(ji)%c_name)
-            ! 
-            tl_mpp=mpp_init(file_init(TRIM(tl_multi%t_mpp(ji)%t_proc(1)%c_name)))
-            CALL grid_get_info(tl_mpp)
-
-            ! check vertical dimension
-            IF( tl_mpp%t_dim(jp_K)%l_use .AND. &
-            &   tl_mpp%t_dim(jp_K)%i_len /= in_nlevel  )THEN
-               CALL logger_error("CREATE BOUNDARY: dimension in file "//&
-               &  TRIM(tl_mpp%c_name)//" not agree with namelist in_nlevel ")
-            ENDIF
-
-            ! open mpp file
-            CALL iom_mpp_open(tl_mpp)
-
-            ! get or check depth value
-            CALL create_boundary_check_depth( tl_mpp, tl_depth )
-
-            ! get or check time value
-            CALL create_boundary_check_time( tl_mpp, tl_time )
-
-            ! close mpp file
-            CALL iom_mpp_close(tl_mpp)
-
-            IF( ANY( tl_mpp%t_dim(1:2)%i_len /= &
-            &        tl_coord0%t_dim(1:2)%i_len) )THEN
-            !- extract value from fine grid
-
-               IF( ANY( tl_mpp%t_dim(1:2)%i_len <= &
-               &        tl_coord1%t_dim(1:2)%i_len) )THEN
-                  CALL logger_fatal("CREATE BOUNDARY: dimension in file "//&
-                  &  TRIM(tl_mpp%c_name)//" smaller than those in fine"//&
-                  &  " grid coordinates.")
-               ENDIF
-
-               DO jl=1,ip_ncard
-                  IF( tl_bdy(jl)%l_use )THEN
-                     
-                     WRITE(*,'(2x,a,a)') 'work on '//TRIM(tl_bdy(jl)%c_card)//&
-                        &  ' boundary'
-                     DO jk=1,tl_bdy(jl)%i_nseg
-                        ! compute domain on fine grid
-                        
-                        ! for each variable of this file
-                        DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
-                           
-                           cl_name=tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name
-                           WRITE(*,'(4x,a,a)') "work on (extract) variable "//&
-                              &  TRIM(cl_name)
-
-                           cl_point=tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_point
-                           ! open mpp file on domain
-                           SELECT CASE(TRIM(cl_point))
-                              CASE DEFAULT !'T'
-                                 jpoint=jp_T
-                              CASE('U')
-                                 jpoint=jp_U
-                              CASE('V')
-                                 jpoint=jp_V
-                              CASE('F')
-                                 jpoint=jp_F
-                           END SELECT
-
-                           tl_dom1=dom_copy(tl_segdom1(jpoint,jk,jl))
-
-                           ! open mpp files
-                           CALL iom_dom_open(tl_mpp, tl_dom1)
-
-                           !7-5 read variable over domain
-                           tl_segvar1(jvar+jj,jk,jl)=iom_dom_read_var( &
-                           &                     tl_mpp, TRIM(cl_name), tl_dom1)
-
-                           ! del extra point
-                           CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), &
-                           &                   tl_dom1 )
-
-                           ! clean extra point information on fine grid domain
-                           CALL dom_clean_extra( tl_dom1 )
-
-                           ! add attribute to variable
-                           tl_att=att_init('src_file', &
-                              &  TRIM(fct_basename(tl_mpp%c_name)))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), tl_att)
-
-                           tl_att=att_init('src_i_indices', &
-                              &  (/tl_dom1%i_imin, tl_dom1%i_imax/))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), tl_att)
-
-                           tl_att=att_init('src_j_indices', &
-                              &  (/tl_dom1%i_jmin, tl_dom1%i_jmax/))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), tl_att)
-
-                           ! clean structure
-                           CALL att_clean(tl_att)
-                           CALL dom_clean(tl_dom1)
-
-                           ! close mpp files
-                           CALL iom_dom_close(tl_mpp)
-
-                           ! clean
-                           CALL var_clean(tl_lvl1)
-
-                        ENDDO ! jj
-                     ENDDO ! jk
-
-                  ENDIF
-               ENDDO ! jl
-
-               ! clean
-               CALL mpp_clean(tl_mpp)
-
-               jvar=jvar+tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
-
-            !- end of extract value from fine grid
-            ELSE
-            !- interpolate value from coarse grid
-
-               DO jl=1,ip_ncard
-                  IF( tl_bdy(jl)%l_use )THEN
-
-                     WRITE(*,'(2x,a,a)') 'work on '//TRIM(tl_bdy(jl)%c_card)//&
-                        &  ' boundary'
-                     DO jk=1,tl_bdy(jl)%i_nseg
-                        
-                        ! for each variable of this file
-                        DO jj=1,tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
- 
-                           WRITE(*,'(4x,a,a)') "work on (interp) variable "//&
-                           &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name)
-
-                           tl_var0=var_copy(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj))
-                           ! open mpp file on domain
-                           SELECT CASE(TRIM(tl_var0%c_point))
-                              CASE DEFAULT !'T'
-                                 jpoint=jp_T
-                              CASE('U')
-                                 jpoint=jp_U
-                              CASE('V')
-                                 jpoint=jp_V
-                              CASE('F')
-                                 jpoint=jp_F
-                           END SELECT
-
-                           tl_dom1=dom_copy(tl_segdom1(jpoint,jk,jl))
-
-                           CALL create_boundary_get_coord( tl_coord1, tl_dom1, &
-                           &                               tl_var0%c_point,    &
-                           &                               tl_lon1, tl_lat1 )
-
-                           ! get coarse grid indices of this segment
-                           il_ind(:,:)=grid_get_coarse_index(tl_coord0, &
-                           &                                 tl_lon1, tl_lat1, &
-                           &                                 id_rho=il_rho(:) )
-
-                           IF( ANY(il_ind(:,:)==0) )THEN
-                              CALL logger_error("CREATE BOUNDARY: error "//&
-                              &  "computing coarse grid indices")
-                           ELSE
-                              il_imin0=il_ind(1,1)
-                              il_imax0=il_ind(1,2)
-
-                              il_jmin0=il_ind(2,1)
-                              il_jmax0=il_ind(2,2)
-                           ENDIF
-
-                           il_offset(:,:)= grid_get_fine_offset( &
-                           &                    tl_coord0, &
-                           &                    il_imin0, il_jmin0,&
-                           &                    il_imax0, il_jmax0,&
-                           &                    tl_lon1%d_value(:,:,1,1),&
-                           &                    tl_lat1%d_value(:,:,1,1),&
-                           &                    il_rho(:),&
-                           &                    TRIM(tl_var0%c_point) )
-
-                           ! compute coarse grid segment domain
-                           tl_dom0=dom_init( tl_coord0,         &
-                           &                 il_imin0, il_imax0,&
-                           &                 il_jmin0, il_jmax0 )
-
-                           ! add extra band (if possible) to compute 
-                           ! interpolation
-                           CALL dom_add_extra(tl_dom0)
-
-                           ! read variables on domain 
-                           ! open mpp files
-                           CALL iom_dom_open(tl_mpp, tl_dom0)
-
-                           cl_name=tl_var0%c_name
-                           ! read variable value on domain
-                           tl_segvar1(jvar+jj,jk,jl)= &
-                           &    iom_dom_read_var(tl_mpp, TRIM(cl_name), tl_dom0)
-
-                           ! work on variable
-                           CALL create_boundary_interp( &
-                           &                 tl_segvar1(jvar+jj,jk,jl),&
-                           &                 il_rho(:), il_offset(:,:) )
-
-                           ! remove extraband added to domain
-                           CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), &
-                           &                   tl_dom0, il_rho(:) )
-
-                           ! del extra point on fine grid
-                           CALL dom_del_extra( tl_segvar1(jvar+jj,jk,jl), &
-                           &                   tl_dom1 )
-                           ! clean extra point information on coarse grid domain
-                           CALL dom_clean_extra( tl_dom0 )
-
-                           ! add attribute to variable
-                           tl_att=att_init('src_file',&
-                           &  TRIM(fct_basename(tl_mpp%c_name)))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
-                           &                 tl_att)
-
-                           ! use clean extra avt creer attribut
-                           tl_att=att_init('src_i-indices',&
-                           &  (/tl_dom0%i_imin, tl_dom0%i_imax/))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
-                           &                 tl_att)
-
-                           tl_att=att_init('src_j-indices', &
-                           &  (/tl_dom0%i_jmin, tl_dom0%i_jmax/))
-                           CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
-                           &                 tl_att)
-
-                           IF( ANY(il_rho(:)/=1) )THEN
-                              tl_att=att_init("refinment_factor", &
-                              &               (/il_rho(jp_I),il_rho(jp_J)/))
-                              CALL var_move_att(tl_segvar1(jvar+jj,jk,jl), &
-                              &                 tl_att)
-                           ENDIF
-
-                           ! clean structure
-                           CALL att_clean(tl_att)
-
-                           ! clean
-                           CALL dom_clean(tl_dom0)
-                           CALL dom_clean(tl_dom1)
-
-                           ! close mpp files
-                           CALL iom_dom_close(tl_mpp)
-
-                           ! clean structure
-                           CALL var_clean(tl_lon1)
-                           CALL var_clean(tl_lat1)
-                           CALL var_clean(tl_lvl1)
-
-                        ENDDO ! jj
-
-                        ! clean
-                        CALL var_clean(tl_var0)
-
-                     ENDDO ! jk
-               
-                  ENDIF
-               ENDDO ! jl
-
-               jvar=jvar+tl_multi%t_mpp(ji)%t_proc(1)%i_nvar
-
-            !- end of interpolate value from coarse grid
-            ENDIF
-
-            ! clean
-            CALL mpp_clean(tl_mpp)
-
-         !- end of use file to fill variable
-         ENDIF
-      ENDDO
-   ENDIF
-
-   IF( jvar /= tl_multi%i_nvar )THEN
-      CALL logger_error("CREATE BOUNDARY: it seems some variable "//&
-         &  "can not be read")
-   ENDIF
-
-   ! write file for each segment of each boundary
-   DO jl=1,ip_ncard
-      IF( tl_bdy(jl)%l_use )THEN
-
-         DO jk=1,tl_bdy(jl)%i_nseg
-            !- 
-            CALL create_boundary_get_coord( tl_coord1, tl_segdom1(jp_T,jk,jl),&
-            &                               'T', tl_lon1, tl_lat1 )
-
-            ! force to use nav_lon, nav_lat as variable name
-            tl_lon1%c_name='nav_lon'
-            tl_lat1%c_name='nav_lat'
-
-            ! del extra point on fine grid
-            CALL dom_del_extra( tl_lon1, tl_segdom1(jp_T,jk,jl) )
-            CALL dom_del_extra( tl_lat1, tl_segdom1(jp_T,jk,jl) )
-
-            ! clean
-            DO jpoint=1,ip_npoint
-               CALL dom_clean(tl_segdom1(jpoint,jk,jl))
-            ENDDO
-
-            ! swap array
-            CALL boundary_swap(tl_lon1, tl_bdy(jl))
-            CALL boundary_swap(tl_lat1, tl_bdy(jl))
-            DO jvar=1,tl_multi%i_nvar
-
-               ! use additional request
-               ! change unit and apply factor
-               CALL var_chg_unit(tl_segvar1(jvar,jk,jl))
-
-               ! forced min and max value
-               CALL var_limit_value(tl_segvar1(jvar,jk,jl))
-
-               ! filter
-               CALL filter_fill_value(tl_segvar1(jvar,jk,jl))
-
-               IF( .NOT. ln_extrap )THEN
-                  ! use mask
-                  SELECT CASE(TRIM(tl_segvar1(jvar,jk,jl)%c_point))
-                  CASE DEFAULT !'T'
-                     jpoint=jp_T
-                  CASE('U')
-                     jpoint=jp_U
-                  CASE('V')
-                     jpoint=jp_V
-                  CASE('F')
-                     jpoint=jp_F
-                  END SELECT
-
-                  CALL create_boundary_use_mask(tl_segvar1(jvar,jk,jl), &
-                  &                             tl_seglvl1(jpoint,jk,jl))
-               ENDIF
-
-               ! swap dimension order
-               CALL boundary_swap(tl_segvar1(jvar,jk,jl), tl_bdy(jl))
-
-            ENDDO
-
-            ! create file
-            ! create file structure
-            ! set file namearray of level variable structure
-            IF( tl_bdy(jl)%i_nseg > 1 )THEN
-               IF( ASSOCIATED(tl_time%d_value) )THEN
-                  cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)"
-                  tl_date=var_to_date(tl_time)
-                  tl_date=tl_date+dn_dayofs
-                  cl_date=date_print( tl_date, cl_fmt ) 
-
-                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-                  &                                TRIM(tl_bdy(jl)%c_card), jk,&
-                  &                                cd_date=TRIM(cl_date) )
-               ELSE
-                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-                  &                                TRIM(tl_bdy(jl)%c_card), jk )
-               ENDIF
-            ELSE
-               IF( ASSOCIATED(tl_time%d_value) )THEN
-                  cl_fmt="('y',i0.4,'m',i0.2,'d',i0.2)"
-                  tl_date=var_to_date(tl_time)
-                  tl_date=tl_date+dn_dayofs
-                  cl_date=date_print( tl_date, cl_fmt )
-
-                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-                  &                                TRIM(tl_bdy(jl)%c_card), &
-                  &                                cd_date=TRIM(cl_date) )
-               ELSE
-                  cl_bdyout=boundary_set_filename( TRIM(cn_fileout), &
-                  &                                TRIM(tl_bdy(jl)%c_card) )
-               ENDIF
-            ENDIF
-            ! 
-            tl_fileout=file_init(TRIM(cl_bdyout),id_perio=in_perio1)
-
-            ! add dimension
-            tl_dim(:)=var_max_dim(tl_segvar1(:,jk,jl))
-
-            SELECT CASE(TRIM(tl_bdy(jl)%c_card))
-               CASE DEFAULT ! 'north','south'
-                  cl_dimorder='xyzt'
-               CASE('east','west')
-                  cl_dimorder='yxzt'
-            END SELECT
-
-            DO ji=1,ip_maxdim
-               IF( tl_dim(ji)%l_use ) CALL file_add_dim(tl_fileout, tl_dim(ji))
-            ENDDO
-
-            ! add variables
-            IF( ALL( tl_dim(1:2)%l_use ) )THEN
-               ! add longitude
-               CALL file_add_var(tl_fileout, tl_lon1)
-               CALL var_clean(tl_lon1)
-
-               ! add latitude
-               CALL file_add_var(tl_fileout, tl_lat1)
-               CALL var_clean(tl_lat1)
-            ENDIF
-            
-
-
-            IF( tl_dim(3)%l_use )THEN
-               IF( ASSOCIATED(tl_depth%d_value) )THEN
-                  ! add depth
-                  CALL file_add_var(tl_fileout, tl_depth)
-               ENDIF
-            ENDIF
-
-            IF( tl_dim(4)%l_use )THEN
-               IF( ASSOCIATED(tl_time%d_value) )THEN
-                  ! add time
-                  CALL file_add_var(tl_fileout, tl_time)
-               ENDIF
-            ENDIF
-
-            ! add other variable
-            DO jvar=tl_multi%i_nvar,1,-1
-               CALL file_add_var(tl_fileout, tl_segvar1(jvar,jk,jl))
-               CALL var_clean(tl_segvar1(jvar,jk,jl))
-            ENDDO
-
-            ! add some attribute
-            tl_att=att_init("Created_by","SIREN create_boundary")
-            CALL file_add_att(tl_fileout, tl_att)
-
-            cl_date=date_print(date_now())
-            tl_att=att_init("Creation_date",cl_date)
-            CALL file_add_att(tl_fileout, tl_att)
-
-            ! add shift on north and east boundary
-            ! boundary compute on T point but express on U or V point
-            SELECT CASE(TRIM(tl_bdy(jl)%c_card))
-            CASE DEFAULT ! 'south','west'
-               il_shift=0
-            CASE('north','east')
-               il_shift=1
-            END SELECT
-
-            ! add indice of velocity row or column
-            tl_att=att_init('bdy_ind',tl_bdy(jl)%t_seg(jk)%i_index-il_shift)
-            CALL file_move_att(tl_fileout, tl_att)
-
-            ! add width of the relaxation zone
-            tl_att=att_init('bdy_width',tl_bdy(jl)%t_seg(jk)%i_width)
-            CALL file_move_att(tl_fileout, tl_att)
-            
-            ! add indice of segment start 
-            tl_att=att_init('bdy_deb',tl_bdy(jl)%t_seg(jk)%i_first)
-            CALL file_move_att(tl_fileout, tl_att)
-            
-            ! add indice of segment end 
-            tl_att=att_init('bdy_end',tl_bdy(jl)%t_seg(jk)%i_last)
-            CALL file_move_att(tl_fileout, tl_att)
-                           
-            ! clean
-            CALL att_clean(tl_att)
-
-            ! create file
-            CALL iom_create(tl_fileout)
-
-            ! write file
-            CALL iom_write_file(tl_fileout, cl_dimorder)
-
-            ! close file
-            CALL iom_close(tl_fileout)
-            CALL file_clean(tl_fileout)
-
-         ENDDO ! jk
-
-      ENDIF
-      ! clean
-      CALL boundary_clean(tl_bdy(jl))
-   ENDDO !jl
-
-   ! clean
-   IF( ASSOCIATED(tl_depth%d_value) ) CALL var_clean(tl_depth)
-   IF( ASSOCIATED(tl_time%d_value) )   CALL var_clean(tl_time)
-   DEALLOCATE( tl_segdom1 )
-   DEALLOCATE( tl_segvar1 )
-   CALL var_clean(tl_seglvl1(:,:,:))
-   DEALLOCATE( tl_seglvl1 )
-
-
-   CALL mpp_clean(tl_coord1)
-   CALL mpp_clean(tl_coord0)
-
-   CALL multi_clean(tl_multi)
-
-   ! close log file
-   CALL logger_footer()
-   CALL logger_close()
-
-CONTAINS
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine compute boundary domain for each grid point (T,U,V,F) 
-   !> 
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !> @date September, 2014
-   !> - take into account grid point to compute boundary indices
-   !>
-   !> @param[in] td_bathy1 file structure 
-   !> @param[in] td_bdy    boundary structure
-   !> @param[in] id_seg    segment indice 
-   !> @return array of domain structure 
-   !-------------------------------------------------------------------
-   FUNCTION create_boundary_get_dom( td_bathy1, td_bdy, id_seg )
-
-      IMPLICIT NONE
-
-      ! Argument
-      TYPE(TMPP) , INTENT(IN   ) :: td_bathy1
-      TYPE(TBDY) , INTENT(IN   ) :: td_bdy
-      INTEGER(i4), INTENT(IN   ) :: id_seg
-
-      ! function
-      TYPE(TDOM), DIMENSION(ip_npoint) :: create_boundary_get_dom
-
-      ! local variable
-      INTEGER(i4) :: il_imin1
-      INTEGER(i4) :: il_imax1
-      INTEGER(i4) :: il_jmin1
-      INTEGER(i4) :: il_jmax1
-
-      INTEGER(i4) :: il_imin
-      INTEGER(i4) :: il_imax
-      INTEGER(i4) :: il_jmin
-      INTEGER(i4) :: il_jmax
-
-      INTEGER(i4), DIMENSION(ip_npoint) :: il_ishift
-      INTEGER(i4), DIMENSION(ip_npoint) :: il_jshift
-
-      ! loop indices
-      INTEGER(i4) :: ji
-      INTEGER(i4) :: jk
-      !----------------------------------------------------------------
-      ! init
-      jk=id_seg
-
-      il_ishift(:)=0
-      il_jshift(:)=0
-
-      ! get boundary definition
-      SELECT CASE(TRIM(td_bdy%c_card))
-         CASE('north')
-
-            il_imin1=td_bdy%t_seg(jk)%i_first
-            il_imax1=td_bdy%t_seg(jk)%i_last 
-            il_jmin1=td_bdy%t_seg(jk)%i_index-(td_bdy%t_seg(jk)%i_width-1)
-            il_jmax1=td_bdy%t_seg(jk)%i_index
-
-            il_jshift(jp_V)=-1
-            il_jshift(jp_F)=-1
-
-         CASE('south')
-
-            il_imin1=td_bdy%t_seg(jk)%i_first
-            il_imax1=td_bdy%t_seg(jk)%i_last 
-            il_jmin1=td_bdy%t_seg(jk)%i_index
-            il_jmax1=td_bdy%t_seg(jk)%i_index+(td_bdy%t_seg(jk)%i_width-1)
-
-         CASE('east')
-
-            il_imin1=td_bdy%t_seg(jk)%i_index-(td_bdy%t_seg(jk)%i_width-1)
-            il_imax1=td_bdy%t_seg(jk)%i_index
-            il_jmin1=td_bdy%t_seg(jk)%i_first
-            il_jmax1=td_bdy%t_seg(jk)%i_last 
-
-            il_ishift(jp_U)=-1
-            il_ishift(jp_F)=-1
-
-         CASE('west')
-
-            il_imin1=td_bdy%t_seg(jk)%i_index
-            il_imax1=td_bdy%t_seg(jk)%i_index+(td_bdy%t_seg(jk)%i_width-1)
-            il_jmin1=td_bdy%t_seg(jk)%i_first
-            il_jmax1=td_bdy%t_seg(jk)%i_last 
-
-      END SELECT         
-
-      !-read fine grid domain
-      DO ji=1,ip_npoint
-
-         ! shift domain
-         il_imin=il_imin1+il_ishift(ji)
-         il_imax=il_imax1+il_ishift(ji)
-
-         il_jmin=il_jmin1+il_jshift(ji)
-         il_jmax=il_jmax1+il_jshift(ji)
-
-         ! compute domain
-         create_boundary_get_dom(ji)=dom_init( td_bathy1,       &
-         &                                     il_imin, il_imax,&
-         &                                     il_jmin, il_jmax,&
-         &                                     TRIM(td_bdy%c_card) )
-
-      ENDDO
-
-   END FUNCTION create_boundary_get_dom
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine get coordinates over boundary domain
-   !> 
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !> @date September, 2014 
-   !> - take into account grid point
-   !>
-   !> @param[in] td_coord1 coordinates file structure
-   !> @param[in] td_dom1   boundary domain structure
-   !> @param[in] cd_point  grid point
-   !> @param[out] td_lon1  longitude variable structure
-   !> @param[out] td_lat1  latitude variable structure
-   !-------------------------------------------------------------------
-   SUBROUTINE create_boundary_get_coord( td_coord1, td_dom1, cd_point, &
-   &                                     td_lon1, td_lat1 )
-
-      IMPLICIT NONE
-      ! Argument
-      TYPE(TMPP)      , INTENT(IN   ) :: td_coord1
-      TYPE(TDOM)      , INTENT(IN   ) :: td_dom1
-      TYPE(TVAR)      , INTENT(  OUT) :: td_lon1
-      TYPE(TVAR)      , INTENT(  OUT) :: td_lat1 
-      CHARACTER(LEN=*), INTENT(IN   ), OPTIONAL :: cd_point
-
-      ! local variable
-      TYPE(TMPP)  :: tl_coord1
-      
-      CHARACTER(LEN=lc) :: cl_name
-      ! loop indices
-      !----------------------------------------------------------------
-      !read variables on domain (ugly way to do it, have to work on it)
-      ! init mpp structure
-      tl_coord1=mpp_copy(td_coord1)
-      
-      ! open mpp files
-      CALL iom_dom_open(tl_coord1, td_dom1)
-
-      ! read variable value on domain
-      WRITE(cl_name,*) 'longitude_'//TRIM(cd_point)
-      td_lon1=iom_dom_read_var( tl_coord1, TRIM(cl_name), td_dom1)
-      WRITE(cl_name,*) 'latitude_'//TRIM(cd_point)
-      td_lat1=iom_dom_read_var( tl_coord1, TRIM(cl_name), td_dom1)
-
-      ! close mpp files
-      CALL iom_dom_close(tl_coord1)
-
-      ! clean structure
-      CALL mpp_clean(tl_coord1)
-
-   END SUBROUTINE create_boundary_get_coord
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine interpolate variable on boundary
-   !> 
-   !> @details 
-   !>
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !>
-   !> @param[inout] td_var variable structure 
-   !> @param[in] id_rho    array of refinment factor
-   !> @param[in] id_offset array of offset between fine and coarse grid
-   !> @param[in] id_iext   i-direction size of extra bands (default=im_minext)
-   !> @param[in] id_jext   j-direction size of extra bands (default=im_minext)
-   !-------------------------------------------------------------------
-   SUBROUTINE create_boundary_interp( td_var,           &
-   &                                  id_rho,           &
-   &                                  id_offset,        &
-   &                                  id_iext, id_jext )
-
-      IMPLICIT NONE
-
-      ! Argument
-      TYPE(TVAR) ,                 INTENT(INOUT) :: td_var
-      INTEGER(I4), DIMENSION(:)  , INTENT(IN   ) :: id_rho
-      INTEGER(i4), DIMENSION(:,:), INTENT(IN   ) :: id_offset
-
-      INTEGER(i4), INTENT(IN   ), OPTIONAL :: id_iext
-      INTEGER(i4), INTENT(IN   ), OPTIONAL :: id_jext
-
-
-      ! local variable
-      INTEGER(i4) :: il_iext
-      INTEGER(i4) :: il_jext
-      ! loop indices
-      !----------------------------------------------------------------
-
-      !WARNING: at least two extrabands are required for cubic interpolation
-      il_iext=2
-      IF( PRESENT(id_iext) ) il_iext=id_iext
-
-      il_jext=2
-      IF( PRESENT(id_jext) ) il_jext=id_jext
-
-      IF( il_iext < 2 .AND. td_var%c_interp(1) == 'cubic' )THEN
-         CALL logger_warn("CREATE BOUNDARY INTERP: at least extrapolation "//&
-         &  "on two points are required with cubic interpolation ")
-         il_iext=2
-      ENDIF
-
-      IF( il_jext < 2 .AND. td_var%c_interp(1) == 'cubic' )THEN
-         CALL logger_warn("CREATE BOUNDARY INTERP: at least extrapolation "//&
-         &  "on two points are required with cubic interpolation ")
-         il_jext=2
-      ENDIF
-
-      ! work on variable
-      ! add extraband
-      CALL extrap_add_extrabands(td_var, il_iext, il_jext)
-
-      ! extrapolate variable
-      CALL extrap_fill_value( td_var )
-
-      ! interpolate Bathymetry
-      CALL interp_fill_value( td_var, id_rho(:), &
-      &                       id_offset=id_offset(:,:) )
-
-      ! remove extraband
-      CALL extrap_del_extrabands(td_var, il_iext*id_rho(jp_I), &
-         &                               il_jext*id_rho(jp_J))
-
-   END SUBROUTINE create_boundary_interp
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This function create variable, filled with matrix value
-   !> 
-   !> @details 
-   !> A variable is create with the same name that the input variable, 
-   !> and with dimension of the coordinate file. 
-   !> Then the variable array of value is split into equal subdomain.
-   !> Each subdomain is fill with the linked value of the matrix.
-   !>
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !>
-   !> @param[in] td_var    variable structure 
-   !> @param[in] td_dom    domain structure 
-   !> @param[in] id_nlevel number of levels 
-   !> @return variable structure 
-   !-------------------------------------------------------------------
-   FUNCTION create_boundary_matrix(td_var, td_dom, id_nlevel)
-      IMPLICIT NONE
-      ! Argument
-      TYPE(TVAR) ,               INTENT(IN) :: td_var
-      TYPE(TDOM) ,               INTENT(IN) :: td_dom
-      INTEGER(i4),               INTENT(IN) :: id_nlevel
-
-      ! function
-      TYPE(TVAR) :: create_boundary_matrix
-
-      ! local variable
-      INTEGER(i4)      , DIMENSION(3)                    :: il_dim
-      INTEGER(i4)      , DIMENSION(3)                    :: il_size
-      INTEGER(i4)      , DIMENSION(3)                    :: il_rest
-
-      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_ishape
-      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_jshape
-      INTEGER(i4)      , DIMENSION(:)      , ALLOCATABLE :: il_kshape
-
-      REAL(dp)         , DIMENSION(:,:,:,:), ALLOCATABLE :: dl_value
-
-      TYPE(TDIM)       , DIMENSION(ip_maxdim)            :: tl_dim
-
-      ! loop indices
-      INTEGER(i4) :: ji
-      INTEGER(i4) :: jj
-      INTEGER(i4) :: jk
-      !----------------------------------------------------------------
-
-      ! write value on grid
-      ! get matrix dimension
-      il_dim(:)=td_var%t_dim(1:3)%i_len
-
-      tl_dim(jp_I:jp_J)=dim_copy(td_dom%t_dim(jp_I:jp_J))
-      tl_dim(jp_K)%i_len=id_nlevel
-
-      ! split output domain in N subdomain depending of matrix dimension 
-      il_size(:) = tl_dim(1:3)%i_len / il_dim(:)
-      il_rest(:) = MOD(tl_dim(1:3)%i_len, il_dim(:))
-
-      ALLOCATE( il_ishape(il_dim(1)+1) )
-      il_ishape(:)=0
-      DO ji=2,il_dim(1)+1
-         il_ishape(ji)=il_ishape(ji-1)+il_size(1)
-      ENDDO
-      ! add rest to last cell
-      il_ishape(il_dim(1)+1)=il_ishape(il_dim(1)+1)+il_rest(1)
-      
-      ALLOCATE( il_jshape(il_dim(2)+1) )
-      il_jshape(:)=0
-      DO jj=2,il_dim(2)+1
-         il_jshape(jj)=il_jshape(jj-1)+il_size(2)
-      ENDDO
-      ! add rest to last cell
-      il_jshape(il_dim(2)+1)=il_jshape(il_dim(2)+1)+il_rest(2)
-
-      ALLOCATE( il_kshape(il_dim(3)+1) )
-      il_kshape(:)=0
-      DO jk=2,il_dim(3)+1
-         il_kshape(jk)=il_kshape(jk-1)+il_size(3)
-      ENDDO
-      ! add rest to last cell
-      il_kshape(il_dim(3)+1)=il_kshape(il_dim(3)+1)+il_rest(3)
-
-      ! write ouput array of value 
-      ALLOCATE(dl_value( tl_dim(1)%i_len, &
-      &                  tl_dim(2)%i_len, &
-      &                  tl_dim(3)%i_len, &
-      &                  tl_dim(4)%i_len) )
-
-      dl_value(:,:,:,:)=0
-
-      DO jk=2,il_dim(3)+1
-         DO jj=2,il_dim(2)+1
-            DO ji=2,il_dim(1)+1
-               
-               dl_value( 1+il_ishape(ji-1):il_ishape(ji), &
-               &         1+il_jshape(jj-1):il_jshape(jj), &
-               &         1+il_kshape(jk-1):il_kshape(jk), &
-               &         1 ) = td_var%d_value(ji-1,jj-1,jk-1,1)
-
-            ENDDO
-         ENDDO
-      ENDDO
-
-      ! initialise variable with value
-      create_boundary_matrix=var_init(TRIM(td_var%c_name),dl_value(:,:,:,:))
-
-      DEALLOCATE(dl_value)
-
-   END FUNCTION create_boundary_matrix
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine use mask to filled land point with _FillValue
-   !> 
-   !> @details 
-   !>
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !>
-   !> @param[inout] td_var variable structure 
-   !> @param[in] td_mask   mask variable structure
-   !-------------------------------------------------------------------
-   SUBROUTINE create_boundary_use_mask( td_var, td_mask )
-
-      IMPLICIT NONE
-
-      ! Argument
-      TYPE(TVAR), INTENT(INOUT) :: td_var
-      TYPE(TVAR), INTENT(IN   ) :: td_mask
-
-      ! local variable
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_mask
-
-      ! loop indices
-      INTEGER(i4) :: jk
-      INTEGER(i4) :: jl
-      !----------------------------------------------------------------
-
-      IF( ANY(td_var%t_dim(1:2)%i_len /= &
-      &       td_mask%t_dim(1:2)%i_len) )THEN
-         CALL logger_debug("     mask dimension ( "//&
-         &              TRIM(fct_str(td_mask%t_dim(1)%i_len))//","//&
-         &              TRIM(fct_str(td_mask%t_dim(2)%i_len))//")" )
-         CALL logger_debug(" variable dimension ( "//&
-         &              TRIM(fct_str(td_var%t_dim(1)%i_len))//","//&
-         &              TRIM(fct_str(td_var%t_dim(2)%i_len))//")" )
-         CALL logger_fatal("CREATE BOUNDARY USE MASK: mask and "//&
-         &                 "variable dimension differ."   )
-      ENDIF
-
-      ALLOCATE( il_mask(td_var%t_dim(1)%i_len, &
-      &                 td_var%t_dim(2)%i_len) )
-
-      il_mask(:,:)=INT(td_mask%d_value(:,:,1,1))
-
-      DO jl=1,td_var%t_dim(4)%i_len
-         DO jk=1,td_var%t_dim(3)%i_len
-            WHERE( il_mask(:,:) < jk ) td_var%d_value(:,:,jk,jl)=td_var%d_fill
-         ENDDO
-      ENDDO
-
-      DEALLOCATE( il_mask )
-
-   END SUBROUTINE create_boundary_use_mask
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This function extract level over domain on each grid point, and return
-   !> array of variable structure
-   !>
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !>
-   !> @param[in] td_level  array of level variable structure
-   !> @param[in] td_dom    array of domain structure
-   !> @return array of variable structure
-   !-------------------------------------------------------------------
-   FUNCTION create_boundary_get_level(td_level, td_dom)
-      IMPLICIT NONE
-      ! Argument
-      TYPE(TVAR), DIMENSION(:), INTENT(IN) :: td_level
-      TYPE(TDOM), DIMENSION(:), INTENT(IN) :: td_dom
-
-      ! function
-      TYPE(TVAR), DIMENSION(ip_npoint) :: create_boundary_get_level
-
-      ! local variable
-      TYPE(TVAR), DIMENSION(ip_npoint) :: tl_var
-
-      ! loop indices
-      INTEGER(i4) :: ji
-      !----------------------------------------------------------------
-
-      IF( SIZE(td_level(:)) /= ip_npoint .OR. &
-      &   SIZE(td_dom(:)) /= ip_npoint )THEN
-         CALL logger_error("CREATE BDY GET LEVEL: invalid dimension. "//&
-         &  "check input array of level and domain.")
-      ELSE
-
-         DO ji=1,ip_npoint
-
-            tl_var(ji)=var_copy(td_level(ji))
-
-            IF( ASSOCIATED(tl_var(ji)%d_value) ) DEALLOCATE(tl_var(ji)%d_value)
-
-            tl_var(ji)%t_dim(1)%i_len=td_dom(ji)%t_dim(1)%i_len
-            tl_var(ji)%t_dim(2)%i_len=td_dom(ji)%t_dim(2)%i_len
-            ALLOCATE(tl_var(ji)%d_value(tl_var(ji)%t_dim(1)%i_len, &
-            &                           tl_var(ji)%t_dim(2)%i_len, &
-            &                           tl_var(ji)%t_dim(3)%i_len, &
-            &                           tl_var(ji)%t_dim(4)%i_len) )
-
-            tl_var(ji)%d_value(:,:,:,:) = &
-            &  td_level(ji)%d_value( td_dom(ji)%i_imin:td_dom(ji)%i_imax, &
-            &                        td_dom(ji)%i_jmin:td_dom(ji)%i_jmax, :, : )
-
-         ENDDO
-         ! save result
-         create_boundary_get_level(:)=var_copy(tl_var(:))
-
-         ! clean
-         CALL var_clean(tl_var(:))
-
-      ENDIF
-   END FUNCTION create_boundary_get_level
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine get depth variable value in an open mpp structure
-   !> and check if agree with already input depth variable.
-   !> 
-   !> @details 
-   !>
-   !> @author J.Paul
-   !> @date November, 2014 - Initial Version
-   !>
-   !> @param[in] td_mpp       mpp structure
-   !> @param[inout] td_depth  depth variable structure 
-   !-------------------------------------------------------------------
-   SUBROUTINE create_boundary_check_depth( td_mpp, td_depth )
-
-      IMPLICIT NONE
-
-      ! Argument
-      TYPE(TMPP) , INTENT(IN   ) :: td_mpp
-      TYPE(TVAR) , INTENT(INOUT) :: td_depth
-
-      ! local variable
-      INTEGER(i4) :: il_varid
-      TYPE(TVAR)  :: tl_depth
-      ! loop indices
-      !----------------------------------------------------------------
-
-      ! get or check depth value
-      IF( td_mpp%t_proc(1)%i_depthid /= 0 )THEN
-
-         il_varid=td_mpp%t_proc(1)%i_depthid
-         IF( ASSOCIATED(td_depth%d_value) )THEN
-
-            tl_depth=iom_mpp_read_var(td_mpp, il_varid)
-            IF( ANY( td_depth%d_value(:,:,:,:) /= &
-            &        tl_depth%d_value(:,:,:,:) ) )THEN
-
-               CALL logger_fatal("CREATE BOUNDARY: depth value from "//&
-               &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
-               &  " to those from former file(s).")
-
-            ENDIF
-            CALL var_clean(tl_depth)
-
-         ELSE
-            td_depth=iom_mpp_read_var(td_mpp,il_varid)
-         ENDIF
-
-      ENDIF
-      
-   END SUBROUTINE create_boundary_check_depth
-   !-------------------------------------------------------------------
-   !> @brief
-   !> This subroutine get date and time in an open mpp structure
-   !> and check if agree with date and time already read.
-   !> 
-   !> @details 
-   !>
-   !> @author J.Paul
-   !> @date November, 2014 - Initial Version
-   !>
-   !> @param[in] td_mpp      mpp structure
-   !> @param[inout] td_time  time variable structure 
-   !-------------------------------------------------------------------
-   SUBROUTINE create_boundary_check_time( td_mpp, td_time )
-
-      IMPLICIT NONE
-
-      ! Argument
-      TYPE(TMPP), INTENT(IN   ) :: td_mpp
-      TYPE(TVAR), INTENT(INOUT) :: td_time
-
-      ! local variable
-      INTEGER(i4) :: il_varid
-      TYPE(TVAR)  :: tl_time
-
-      TYPE(TDATE) :: tl_date1
-      TYPE(TDATE) :: tl_date2
-      ! loop indices
-      !----------------------------------------------------------------
-
-      ! get or check depth value
-      IF( td_mpp%t_proc(1)%i_timeid /= 0 )THEN
-
-         il_varid=td_mpp%t_proc(1)%i_timeid
-         IF( ASSOCIATED(td_time%d_value) )THEN
-
-            tl_time=iom_mpp_read_var(td_mpp, il_varid)
-
-            tl_date1=var_to_date(td_time)
-            tl_date2=var_to_date(tl_time)
-            IF( tl_date1 - tl_date2 /= 0 )THEN
-
-               CALL logger_fatal("CREATE BOUNDARY: date from "//&
-               &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
-               &  " to those from former file(s).")
-
-            ENDIF
-            CALL var_clean(tl_time)
-
-         ELSE
-            td_time=iom_mpp_read_var(td_mpp,il_varid)
-         ENDIF
-
-      ENDIF
-      
-   END SUBROUTINE create_boundary_check_time
-END PROGRAM create_boundary
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_coord.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_coord.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_coord.f90	(revision 7339)
@@ -9,5 +9,5 @@
 !> @file
 !> @brief 
-!> This program create fine grid coordinate file.
+!> This program creates fine grid coordinate file.
 !>
 !> @details
@@ -27,5 +27,5 @@
 !>    you could find a template of the namelist in templates directory.
 !>
-!>    create_coord.nam comprise 6 namelists:<br/>
+!>    create_coord.nam contains 6 namelists:<br/>
 !>       - logger namelist (namlog)
 !>       - config namelist (namcfg)
@@ -35,8 +35,4 @@
 !>       - output namelist (namout)
 !>    
-!>    @note 
-!>       All namelists have to be in file create_coord.nam, 
-!>       however variables of those namelists are all optional.
-!>
 !>    * _logger namelist (namlog)_:<br/>
 !>       - cn_logfile   : log filename
@@ -48,4 +44,6 @@
 !>       - cn_varcfg : variable configuration file 
 !> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
 !>
 !>    * _coarse grid namelist (namcrs)_:<br/>
@@ -64,5 +62,4 @@
 !>             - int = interpolation method
 !>             - ext = extrapolation method
-!>             - flt = filter method
 !> 
 !>                requests must be separated by ';' .<br/>
@@ -72,6 +69,6 @@
 !>          @ref extrap and @ref filter modules.<br/>
 !>
-!>          Example: 'votemper: int=linear; flt=hann(2,3); ext=dist_weight', 
-!>          'vosaline: int=cubic'<br/>
+!>          Example: 'glamt: int=linear; ext=dist_weight', 
+!>          'e1t: int=cubic/rhoi'<br/>
 !>          @note 
 !>             If you do not specify a method which is required, 
@@ -103,4 +100,6 @@
 !> - compute offset considering grid point
 !> - add global attributes in output file
+!> @date September, 2015
+!> - manage useless (dummy) variable, attributes, and dimension
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -167,5 +166,6 @@
 
    ! namcfg
-   CHARACTER(LEN=lc) :: cn_varcfg = '../cfg/variable.cfg' 
+   CHARACTER(LEN=lc) :: cn_varcfg = './cfg/variable.cfg' 
+   CHARACTER(LEN=lc) :: cn_dumcfg = './cfg/dummy.cfg'
 
    ! namcrs
@@ -194,5 +194,6 @@
 
    NAMELIST /namcfg/ &  !  config namelist
-   &  cn_varcfg         !< variable configuration file
+   &  cn_varcfg, &       !< variable configuration file
+   &  cn_dumcfg          !< dummy configuration file
 
    NAMELIST /namcrs/ &  !  coarse grid namelist
@@ -254,4 +255,11 @@
       CALL var_def_extra(TRIM(cn_varcfg))
 
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
+
       READ( il_fileid, NML = namcrs )
       READ( il_fileid, NML = namvar )
@@ -354,4 +362,7 @@
    ENDDO
 
+   ! clean
+   CALL dom_clean_extra( tl_dom )
+
    ! close mpp files
    CALL iom_dom_close(tl_coord0)
@@ -388,7 +399,7 @@
    CALL file_add_att(tl_fileout, tl_att)   
 
-   tl_att=att_init("src_i_indices",(/in_imin0,in_imax0/))
+   tl_att=att_init("src_i_indices",(/tl_dom%i_imin,tl_dom%i_imax/))
    CALL file_add_att(tl_fileout, tl_att)   
-   tl_att=att_init("src_j_indices",(/in_jmin0,in_jmax0/))
+   tl_att=att_init("src_j_indices",(/tl_dom%i_jmin,tl_dom%i_jmax/))
    CALL file_add_att(tl_fileout, tl_att)
    IF( .NOT. ALL(il_rho(:)==1) )THEN
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_restart.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_restart.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/create_restart.f90	(revision 7339)
@@ -9,11 +9,11 @@
 !> @file
 !> @brief 
-!> This program create restart file.
+!> This program creates restart file.
 !>
 !> @details
 !> @section sec1 method
 !> Variables could be extracted from fine grid file, interpolated from coarse
-!> grid file or restart file, or manually written.<br/> 
-!> Then they are split over new decomposition. 
+!> grid file or restart file. Variables could also be manually written.<br/> 
+!> Then they are split over new layout. 
 !> @note 
 !>    method could be different for each variable.
@@ -28,5 +28,5 @@
 !>    you could find a template of the namelist in templates directory.
 !>
-!>    create_restart.nam comprise 9 namelists:<br/>
+!>    create_restart.nam contains 9 namelists:<br/>
 !>       - logger namelist (namlog)
 !>       - config namelist (namcfg)
@@ -39,8 +39,4 @@
 !>       - output namelist (namout)
 !>    
-!>    @note 
-!>       All namelists have to be in file create_restart.nam 
-!>       however variables of those namelists are all optional.
-!>
 !>    * _logger namelist (namlog)_:<br/>
 !>       - cn_logfile   : log filename
@@ -52,4 +48,6 @@
 !>       - cn_varcfg : variable configuration file
 !> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
 !>
 !>    * _coarse grid namelist (namcrs):<br/>
@@ -82,29 +80,5 @@
 !>
 !>    * _variable namelist (namvar)_:<br/>
-!>       - cn_varinfo : list of variable and extra information about request(s) 
-!>       to be used.<br/>
-!>          each elements of *cn_varinfo* is a string character
-!>          (separated by ',').<br/>
-!>          it is composed of the variable name follow by ':', 
-!>          then request(s) to be used on this variable.<br/> 
-!>          request could be:
-!>             - int = interpolation method
-!>             - ext = extrapolation method
-!>             - flt = filter method
-!>             - min = minimum value
-!>             - max = maximum value
-!>             - unt = new units
-!>             - unf = unit scale factor (linked to new units)
-!>
-!>             requests must be separated by ';'.<br/>
-!>             order of requests does not matter.<br/>
-!>
-!>          informations about available method could be find in @ref interp,
-!>          @ref extrap and @ref filter.<br/>
-!>          Example: 'votemper: int=linear; flt=hann; ext=dist_weight','vosaline: int=cubic'
-!>          @note 
-!>             If you do not specify a method which is required, 
-!>             default one is apply.
-!>       - cn_varfile : list of variable, and corresponding file<br/> 
+!>       - cn_varfile : list of variable, and associated file<br/> 
 !>          *cn_varfile* is the path and filename of the file where find
 !>          variable.<br/>
@@ -131,9 +105,35 @@
 !>             - 'all:restart.dimg'
 !>
+!>       - cn_varinfo : list of variable and extra information about request(s) 
+!>       to be used.<br/>
+!>          each elements of *cn_varinfo* is a string character
+!>          (separated by ',').<br/>
+!>          it is composed of the variable name follow by ':', 
+!>          then request(s) to be used on this variable.<br/> 
+!>          request could be:
+!>             - int = interpolation method
+!>             - ext = extrapolation method
+!>             - flt = filter method
+!>             - min = minimum value
+!>             - max = maximum value
+!>             - unt = new units
+!>             - unf = unit scale factor (linked to new units)
+!>
+!>             requests must be separated by ';'.<br/>
+!>             order of requests does not matter.<br/>
+!>
+!>          informations about available method could be find in @ref interp,
+!>          @ref extrap and @ref filter.<br/>
+!>          Example: 'votemper: int=linear; flt=hann; ext=dist_weight',
+!>                   'vosaline: int=cubic'
+!>          @note 
+!>             If you do not specify a method which is required, 
+!>             default one is apply.
+!>
 !>    * _nesting namelist (namnst)_:<br/>
 !>       - in_rhoi  : refinement factor in i-direction
 !>       - in_rhoj  : refinement factor in j-direction
 !>       @note 
-!>          coarse grid indices will be deduced from fine grid
+!>          coarse grid indices will be computed from fine grid
 !>          coordinate file.
 !>
@@ -141,6 +141,6 @@
 !>       - cn_fileout : output file
 !>       - ln_extrap : extrapolate land point or not
-!>       - in_niproc : i-direction number of processor
-!>       - in_njproc : j-direction numebr of processor
+!>       - in_niproc : number of processor in i-direction
+!>       - in_njproc : number of processor in j-direction
 !>       - in_nproc  : total number of processor to be used
 !>       - cn_type   : output format ('dimg', 'cdf')
@@ -156,4 +156,6 @@
 !> - extrapolate all land points, and add ln_extrap in namelist.
 !> - allow to change unit.
+!> @date September, 2015
+!> - manage useless (dummy) variable, attributes, and dimension
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -173,5 +175,5 @@
    USE iom                             ! I/O manager
    USE grid                            ! grid manager
-   USE vgrid                            ! vertical grid manager
+   USE vgrid                           ! vertical grid manager
    USE extrap                          ! extrapolation manager
    USE interp                          ! interpolation manager
@@ -183,5 +185,4 @@
 
    IMPLICIT NONE
-
 
    ! local variable
@@ -212,4 +213,5 @@
 
    LOGICAL                                            :: ll_exist
+   LOGICAL                                            :: ll_sameGrid
 
    TYPE(TDOM)                                         :: tl_dom1
@@ -242,53 +244,54 @@
    ! namelist variable
    ! namlog
-   CHARACTER(LEN=lc) :: cn_logfile = 'create_restart.log' 
-   CHARACTER(LEN=lc) :: cn_verbosity = 'warning' 
-   INTEGER(i4)       :: in_maxerror = 5
+   CHARACTER(LEN=lc)                       :: cn_logfile = 'create_restart.log' 
+   CHARACTER(LEN=lc)                       :: cn_verbosity = 'warning' 
+   INTEGER(i4)                             :: in_maxerror = 5
 
    ! namcfg
-   CHARACTER(LEN=lc) :: cn_varcfg = 'variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_varcfg = 'variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_dumcfg = 'dummy.cfg'
 
    ! namcrs
-   CHARACTER(LEN=lc) :: cn_coord0 = '' 
-   INTEGER(i4)       :: in_perio0 = -1
+   CHARACTER(LEN=lc)                       :: cn_coord0 = '' 
+   INTEGER(i4)                             :: in_perio0 = -1
 
    ! namfin
-   CHARACTER(LEN=lc) :: cn_coord1 = ''
-   CHARACTER(LEN=lc) :: cn_bathy1 = ''
-   INTEGER(i4)       :: in_perio1 = -1
+   CHARACTER(LEN=lc)                       :: cn_coord1 = ''
+   CHARACTER(LEN=lc)                       :: cn_bathy1 = ''
+   INTEGER(i4)                             :: in_perio1 = -1
 
    !namzgr
-   REAL(dp)          :: dn_pp_to_be_computed = 0._dp
-   REAL(dp)          :: dn_ppsur     = -3958.951371276829_dp
-   REAL(dp)          :: dn_ppa0      =   103.9530096000000_dp
-   REAL(dp)          :: dn_ppa1      =     2.4159512690000_dp
-   REAL(dp)          :: dn_ppa2      =   100.7609285000000_dp
-   REAL(dp)          :: dn_ppkth     =    15.3510137000000_dp
-   REAL(dp)          :: dn_ppkth2    =    48.0298937200000_dp
-   REAL(dp)          :: dn_ppacr     =     7.0000000000000_dp
-   REAL(dp)          :: dn_ppacr2    =    13.000000000000_dp
-   REAL(dp)          :: dn_ppdzmin   = 6._dp
-   REAL(dp)          :: dn_pphmax    = 5750._dp
-   INTEGER(i4)       :: in_nlevel    = 75
+   REAL(dp)                                :: dn_pp_to_be_computed = 0._dp
+   REAL(dp)                                :: dn_ppsur   = -3958.951371276829_dp
+   REAL(dp)                                :: dn_ppa0    =   103.953009600000_dp
+   REAL(dp)                                :: dn_ppa1    =     2.415951269000_dp
+   REAL(dp)                                :: dn_ppa2    =   100.760928500000_dp
+   REAL(dp)                                :: dn_ppkth   =    15.351013700000_dp
+   REAL(dp)                                :: dn_ppkth2  =    48.029893720000_dp
+   REAL(dp)                                :: dn_ppacr   =     7.000000000000_dp
+   REAL(dp)                                :: dn_ppacr2  =    13.000000000000_dp
+   REAL(dp)                                :: dn_ppdzmin = 6._dp
+   REAL(dp)                                :: dn_pphmax  = 5750._dp
+   INTEGER(i4)                             :: in_nlevel  = 75
 
    !namzps
-   REAL(dp)          :: dn_e3zps_min = 25._dp
-   REAL(dp)          :: dn_e3zps_rat = 0.2_dp
+   REAL(dp)                                :: dn_e3zps_min = 25._dp
+   REAL(dp)                                :: dn_e3zps_rat = 0.2_dp
 
    ! namvar
+   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
    CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
-   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varfile = ''
 
    ! namnst
-   INTEGER(i4)       :: in_rhoi = 0
-   INTEGER(i4)       :: in_rhoj = 0
+   INTEGER(i4)                             :: in_rhoi = 0
+   INTEGER(i4)                             :: in_rhoj = 0
 
    ! namout
-   CHARACTER(LEN=lc) :: cn_fileout = 'restart.nc' 
-   LOGICAL           :: ln_extrap  = .FALSE.
-   INTEGER(i4)       :: in_nproc   = 0
-   INTEGER(i4)       :: in_niproc  = 0
-   INTEGER(i4)       :: in_njproc  = 0
-   CHARACTER(LEN=lc) :: cn_type    = ''
+   CHARACTER(LEN=lc)                       :: cn_fileout = 'restart.nc' 
+   LOGICAL                                 :: ln_extrap  = .FALSE.
+   INTEGER(i4)                             :: in_nproc   = 0
+   INTEGER(i4)                             :: in_niproc  = 0
+   INTEGER(i4)                             :: in_njproc  = 0
+   CHARACTER(LEN=lc)                       :: cn_type    = ''
 
    !-------------------------------------------------------------------
@@ -300,5 +303,6 @@
 
    NAMELIST /namcfg/ &  !< configuration namelist
-   &  cn_varcfg         !< variable configuration file
+   &  cn_varcfg, &      !< variable configuration file
+   &  cn_dumcfg         !< dummy configuration file
 
    NAMELIST /namcrs/ &  !< coarse grid namelist
@@ -330,6 +334,6 @@
 
    NAMELIST /namvar/ &  !< variable namelist
-   &  cn_varinfo, &     !< list of variable and interpolation method to be used.
-   &  cn_varfile        !< list of variable file
+   &  cn_varfile, &     !< list of variable file
+   &  cn_varinfo        !< list of variable and interpolation method to be used.
    
    NAMELIST /namnst/ &  !< nesting namelist
@@ -382,4 +386,11 @@
       ! get variable extra information
       CALL var_def_extra(TRIM(cn_varcfg))
+
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
 
       READ( il_fileid, NML = namcrs )
@@ -509,5 +520,5 @@
 
                jvar=jvar+1
-               
+
                WRITE(*,'(2x,a,a)') "work on variable "//&
                &  TRIM(tl_multi%t_mpp(ji)%t_proc(1)%t_var(jj)%c_name)
@@ -541,5 +552,4 @@
             CALL iom_mpp_open(tl_mpp)
 
-
             ! get or check depth value
             CALL create_restart_check_depth( tl_mpp, tl_depth )
@@ -551,17 +561,29 @@
             CALL iom_mpp_close(tl_mpp)
 
-            IF( ANY( tl_mpp%t_dim(1:2)%i_len /= &
-            &        tl_coord0%t_dim(1:2)%i_len) )THEN
+            IF( ANY(tl_mpp%t_dim(1:2)%i_len /= tl_coord0%t_dim(1:2)%i_len) .OR.&
+            &   ALL(il_rho(:)==1) )THEN
             !!! extract value from fine grid 
 
-               IF( ANY( tl_mpp%t_dim(1:2)%i_len <= &
+               IF( ANY( tl_mpp%t_dim(1:2)%i_len < &
                &        tl_coord1%t_dim(1:2)%i_len) )THEN
-                  CALL logger_fatal("CREATE RESTART: dimension in file "//&
+                  CALL logger_fatal("CREATE RESTART: dimensions in file "//&
                   &  TRIM(tl_mpp%c_name)//" smaller than those in fine"//&
                   &  " grid coordinates.")
                ENDIF
 
+               ! use coord0 instead of mpp for restart file case 
+               !  (without lon,lat)
+               ll_sameGrid=.FALSE.
+               IF( ALL(tl_mpp%t_dim(1:2)%i_len /= tl_coord0%t_dim(1:2)%i_len) &
+               &   )THEN
+                  ll_sameGrid=.TRUE. 
+               ENDIF
+
                ! compute domain on fine grid
-               il_ind(:,:)=grid_get_coarse_index(tl_mpp, tl_coord1 )
+               IF( ll_sameGrid )THEN
+                  il_ind(:,:)=grid_get_coarse_index(tl_mpp, tl_coord1 )
+               ELSE
+                  il_ind(:,:)=grid_get_coarse_index(tl_coord0, tl_coord1 )
+               ENDIF
 
                il_imin1=il_ind(1,1) ; il_imax1=il_ind(1,2)
@@ -569,8 +591,15 @@
 
                !- check grid coincidence
-               CALL grid_check_coincidence( tl_mpp, tl_coord1, &
-               &                            il_imin1, il_imax1, &
-               &                            il_jmin1, il_jmax1, &
-               &                            il_rho(:) )
+               IF( ll_sameGrid )THEN
+                  CALL grid_check_coincidence( tl_mpp, tl_coord1, &
+                  &                            il_imin1, il_imax1, &
+                  &                            il_jmin1, il_jmax1, &
+                  &                            il_rho(:) )
+               ELSE
+                  CALL grid_check_coincidence( tl_coord0, tl_coord1, &
+                  &                            il_imin1, il_imax1, &
+                  &                            il_jmin1, il_jmax1, &
+                  &                            il_rho(:) )
+               ENDIF
 
                ! compute domain
@@ -754,4 +783,5 @@
 
    DO ji=1,ip_maxdim
+
       IF( tl_dim(ji)%l_use )THEN
          CALL mpp_move_dim(tl_mppout, tl_dim(ji))
@@ -763,4 +793,5 @@
          END SELECT 
       ENDIF
+
    ENDDO
 
@@ -879,5 +910,5 @@
    !> and with dimension of the coordinate file.<br/> 
    !> Then the variable array of value is split into equal subdomain.
-   !> Each subdomain is filled with the corresponding value of the matrix.
+   !> Each subdomain is filled with the associated value of the matrix.
    !>
    !> @author J.Paul
@@ -1169,6 +1200,6 @@
             &        tl_depth%d_value(:,:,:,:) ) )THEN
 
-               CALL logger_fatal("CREATE BOUNDARY: depth value from "//&
-               &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
+               CALL logger_warn("CREATE BOUNDARY: depth value from "//&
+               &  TRIM(td_mpp%c_name)//" not conform "//&
                &  " to those from former file(s).")
 
@@ -1226,6 +1257,6 @@
             IF( tl_date1 - tl_date2 /= 0 )THEN
 
-               CALL logger_fatal("CREATE BOUNDARY: date from "//&
-               &  TRIM(tl_multi%t_mpp(ji)%c_name)//" not conform "//&
+               CALL logger_warn("CREATE BOUNDARY: date from "//&
+               &  TRIM(td_mpp%c_name)//" not conform "//&
                &  " to those from former file(s).")
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/dimension.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/dimension.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/dimension.f90	(revision 7339)
@@ -154,4 +154,6 @@
 ! REVISION HISTORY:
 !> @date November, 2013 - Initial Version
+!> @date Spetember, 2015
+!> - manage useless (dummy) dimension
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -167,4 +169,6 @@
    ! type and variable
    PUBLIC :: TDIM              !< dimension structure
+
+   PRIVATE :: cm_dumdim        !< dummy dimension array
 
    ! function and subroutine
@@ -182,4 +186,6 @@
    PUBLIC :: dim_get_index     !< get dimension index in array of dimension structure
    PUBLIC :: dim_get_id        !< get dimension id in array of dimension structure
+   PUBLIC :: dim_get_dummy     !< fill dummy dimension array
+   PUBLIC :: dim_is_dummy      !< check if dimension is defined as dummy dimension
 
    PRIVATE :: dim__reshape_2xyzt_dp ! reshape real(8) 4D array to ('x','y','z','t')
@@ -209,4 +215,6 @@
    END TYPE
 
+   CHARACTER(LEN=lc), DIMENSION(ip_maxdum), SAVE :: cm_dumdim !< dummy dimension
+
    INTERFACE dim_print
       MODULE PROCEDURE dim__print_unit ! print information on one dimension
@@ -518,8 +526,8 @@
    !> @param[in] ld_uld    dimension unlimited
    !> @param[in] cd_sname  dimension short name
-   !> @param[in] ld_uld    dimension use or not
+   !> @param[in] ld_use    dimension use or not
    !> @return dimension structure
    !-------------------------------------------------------------------
-   TYPE(TDIM) FUNCTION dim_init( cd_name, id_len, ld_uld, cd_sname, ld_use)
+   TYPE(TDIM) FUNCTION dim_init( cd_name, id_len, ld_uld, cd_sname, ld_use )
       IMPLICIT NONE
 
@@ -1401,4 +1409,96 @@
 
    END SUBROUTINE dim__clean_arr
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill dummy dimension array
+   !
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !
+   !> @param[in] cd_dummy dummy configuration file
+   !-------------------------------------------------------------------
+   SUBROUTINE dim_get_dummy( cd_dummy )
+      IMPLICIT NONE
+      ! Argument
+      CHARACTER(LEN=*), INTENT(IN) :: cd_dummy
+
+      ! local variable
+      INTEGER(i4)   :: il_fileid
+      INTEGER(i4)   :: il_status
+
+      LOGICAL       :: ll_exist
+
+      ! loop indices
+      ! namelist
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumvar
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumdim
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumatt
+
+      !----------------------------------------------------------------
+      NAMELIST /namdum/ &   !< dummy namelist
+      &  cn_dumvar, &       !< variable  name
+      &  cn_dumdim, &       !< dimension name
+      &  cn_dumatt          !< attribute name
+      !----------------------------------------------------------------
+
+      ! init
+      cm_dumdim(:)=''
+
+      ! read namelist
+      INQUIRE(FILE=TRIM(cd_dummy), EXIST=ll_exist)
+      IF( ll_exist )THEN
+
+         il_fileid=fct_getunit()
+
+         OPEN( il_fileid, FILE=TRIM(cd_dummy), &
+         &                FORM='FORMATTED',       &
+         &                ACCESS='SEQUENTIAL',    &
+         &                STATUS='OLD',           &
+         &                ACTION='READ',          &
+         &                IOSTAT=il_status)
+         CALL fct_err(il_status)
+         IF( il_status /= 0 )THEN
+            CALL logger_fatal("DIM GET DUMMY: opening "//TRIM(cd_dummy))
+         ENDIF
+
+         READ( il_fileid, NML = namdum )
+         cm_dumdim(:)=cn_dumdim(:)
+
+         CLOSE( il_fileid )
+
+      ENDIF
+
+   END SUBROUTINE dim_get_dummy
+   !-------------------------------------------------------------------
+   !> @brief This function check if dimension is defined as dummy dimension
+   !> in configuraton file
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !
+   !> @param[in] td_dim dimension structure
+   !> @return true if dimension is dummy dimension 
+   !-------------------------------------------------------------------
+   FUNCTION dim_is_dummy(td_dim)
+      IMPLICIT NONE
+
+      ! Argument      
+      TYPE(TDIM), INTENT(IN) :: td_dim
+      
+      ! function
+      LOGICAL :: dim_is_dummy
+      
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      dim_is_dummy=.FALSE.
+      DO ji=1,ip_maxdum
+         IF( fct_lower(td_dim%c_name) == fct_lower(cm_dumdim(ji)) )THEN
+            dim_is_dummy=.TRUE.
+            EXIT
+         ENDIF
+      ENDDO
+
+   END FUNCTION dim_is_dummy
 END MODULE dim
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/1_install.md	(revision 7339)
@@ -1,25 +1,27 @@
-# How to Install
+# Download
 
-# Install NEMO
-to install SIREN, you should first install NEMO.
-see [here](http://www.nemo-ocean.eu/Using-NEMO/User-Guides/Basics/NEMO-Quick-Start-Guide)
+# Download NEMO #
+to install SIREN, you should first download NEMO.
+see [NEMO quick start guide](http://www.nemo-ocean.eu/Using-NEMO/User-Guides/Basics/NEMO-Quick-Start-Guide)
 
-# Compile SIREN
+# Compile SIREN #
 when NEMO is installed, you just have to compile SIREN codes:
-1. go to ./NEMOGCM/TOOLS
-2. use maketools <br/>
-   to get help: maketools -h 
+   1. go to ./NEMOGCM/TOOLS
+   2. run maketools (ex: ./maketools -n SIREN -m ifort_mpi_beaufix)
 
-# Fortran Compiler
-   SIREN codes were succesfully tested with :
-   - ifort (version 15.0.1)
-   - gfortran (version 4.8.2 20140120) 
-<!--   - pgf95 (version 13.9-0) -->
+      @note to get help on maketools: ./maketools -h
 
- <HR>
-   <b>
-   - @ref index
-   - @ref md_docsrc_3_codingRules
-   - @ref md_docsrc_4_changeLog
-   - @ref todo
-   </b>
+# Fortran Compiler #
+SIREN codes were succesfully tested with :
+  - ifort (version 15.0.1)
+  - gfortran (version 4.8.2 20140120) 
+
+<HR>
+  <b>
+  - @ref index
+  - @ref md_docsrc_2_quickstart
+  - @ref md_docsrc_3_support_bug
+  - @ref md_docsrc_4_codingRules
+  - @ref md_docsrc_5_changeLog
+  - @ref todo
+  </b>
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/2_quickstart.md	(revision 7339)
@@ -0,0 +1,600 @@
+# How To Use (Quick Start)
+
+@tableofcontents
+
+SIREN is a software to set up regional configuration with
+ [NEMO](http://www.nemo-ocean.eu).<br/> 
+Actually SIREN creates all the input files you need to run a NEMO regional configuration.<br/>
+ 
+SIREN is composed of a set of 5 Fortran programs :
+<ul>
+ <li>create_coord.f90 to create regional grid coordinates.</li>
+ <li>create_bathy.f90 to create regional grid bathymetry.</li>
+ <li>merge_bathy.f90 to merge regional grid bathymetry with wider grid bathymetry
+ at boundaries. 
+ @note the goal of this step is to avoid break in Bathymetry.
+ This break may cause inconsistency between forcing fields  at boundary and regional fields.
+ </li>
+ <li>create_restart.f90 to create initial state file from coarse grid restart
+ or standard outputs.
+ @note this program could also be used to refined other input fields from a wider
+ configuations (as runoff, chlorophyll etc...)
+ </li>
+ <li>create_boundary.F90 to create boundaries conditions from wider configurations
+ output fields.
+ </li>
+</ul>
+
+@warning SIREN can not:
+<ul>
+<li>create global configuration.</li>
+<li>create configuarion around or close to North pole.</li>
+<li>change number of vertical level.</li>
+</ul>
+
+Here after we briefly describe how to use each programs,
+and so how to create your own regional configuration.
+@note A set of GLORYS files (global reanalysis on *ORCA025*
+grid), as well as examples of namelists are available in dods repository.<br/>
+You could create and forced a first release of your own regional configuration,
+with those files. 
+<!-- ######################################################################  -->
+# Create coordinates file # {#coord}
+
+To create your own configuration, you first have to create a coordinates file on your domain of study.<br/>
+SIREN allows you to create this coordinates file from a wider coordinates file.<br/>
+The coordinates file created could simply be an extraction, or a refinment of
+the wide grid.<br/>
+
+To create this new cooridnates file, you have to run :
+~~~~~~~~~~~~~~~~~~
+./SIREN/create_coord.exe create_coord.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *create_coord.exe*.<br/>
+In this example, you create a coordinates file named *coord_fine.nc*.<br/>
+This new coordinates file is refined from an extraction of *coordinates_ORCA025.nc*. 
+~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namcrs
+   cn_coord0 = "PATH/coordinates_ORCA025.nc"
+   in_perio0 = 4
+/
+
+&namvar
+/
+
+&namnst
+   in_imin0 = 1070
+   in_imax0 = 1072
+   in_jmin0 = 607
+   in_jmax0 = 609
+
+   in_rhoi = 2
+   in_rhoj = 3
+/
+
+&namout
+   cn_fileout = "PATH/coord_fine.nc"
+/
+~~~~~~~~~~~
+
+Let's get describe this namelist.<br/>
+First we have the **namlog** sub-namelist. This sub-namelist set parameters of the log
+file.<br/>
+All the parameters of this sub-namelist have default value, so you could let it
+empty, as done here.<br/> This will create a log file named *create_coord.log*
+
+The **namcfg** sub-namelist defines where found SIREN configuration file.<br/>
+This configuration file defines standard name, default interpolation method,
+axis,... to be used for some known variables.<br/>
+Obviously, you could add other variables to those already list, in this file.
+
+@note You could find the generic version of *variable.cfg* in the directory *NEMOGCM/TOOLS/SIREN/cfg*.
+
+The **namcrs** sub-namelist set parameters of the wide
+coordinates file,<br/> as path to find it, and NEMO periodicity of the wide grid.<br/>
+
+@note the NEMO periodicity could be choose between 0 to 6:
+<dl>
+<dt>in_perio=0</dt>
+<dd>standard regional model</dd>
+<dt>in_perio=1</dt>
+<dd>east-west cyclic model</dd>
+<dt>in_perio=2</dt>
+<dd>model with symmetric boundary condition across the equator</dd>
+<dt>in_perio=3</dt>
+<dd>regional model with North fold boundary and T-point pivot</dd>
+<dt>in_perio=4</dt>
+<dd>global model with a T-point pivot.<br/>
+example: ORCA2, ORCA025, ORCA12</dd>
+<dt>in_perio=5</dt>
+<dd>regional model with North fold boundary and F-point pivot</dd>
+<dt>in_perio=6</dt>
+<dd>global model with a F-point pivot<br/>
+example: ORCA05</dd>
+</dl>
+@sa For more information see @ref md_docsrc_6_perio
+</dd>
+</dl>
+
+The **namvar** sub-namelist lists variables to be used.<br/>
+By default all the variables of the wider coordinates file are used to create
+the new coordinates file.<br/> 
+The interpolation methods to be used are defined in the configuration variables file (see
+below). So you do not need to fill this sub-namelist too.
+
+The **namnst** sub-namelist defines the subdomain to be used as well as refinment factor.<br/>
+@note Subdomain is defined by indices of the coarse/wide grid.<br/>
+
+<ul>
+<li>you can select area quite every where (excepted too close from the North
+pole), and use the refinment factor you want.</li>
+
+~~~~~~~~~~~
+&namvar
+   in_imin0 = 1070
+   in_imax0 = 1072
+   in_jmin0 = 607
+   in_jmax0 = 609
+
+   in_rhoi = 2
+   in_rhoj = 3
+/
+~~~~~~~~~~~
+@image html grid_zoom_60.png
+@image latex grid_zoom_40.png
+<!-- @note ghost cells all around the grid are not shown here. -->
+
+<li>you can select area crossing the east-west overlap of the global ORCA grid.</li>
+
+~~~~~~~~~~~
+&namvar          
+   in_imin0 = 1402 
+   in_imax0 = 62
+   in_jmin0 = 490 
+   in_jmax0 = 570 
+
+   in_rhoi = 5
+   in_rhoj = 5 
+/                
+~~~~~~~~~~~
+@image html grid_glob_over_30.png
+@image latex grid_glob_over_20.png
+<!-- @note in blue, the east-west overlap band of ORCA grid. -->
+
+<li>you can select east-west cyclic area.</li>
+
+~~~~~~~~~~~
+&namvar
+   in_imin0 = 0
+   in_imax0 = 0
+   in_jmin0 = 390
+   in_jmax0 = 450
+
+   in_rhoi = 1
+   in_rhoj = 1
+/
+~~~~~~~~~~~
+@image html grid_glob_band_30.png
+@image latex grid_glob_band_20.png
+
+</ul>
+
+Finally the **namout** sub-namelist defines the output file.<br/>
+
+@note All the output files created by SIREN include information about NEMO
+periodicity, as well as source file, indices and refinment used.
+
+@sa For more information about how to create coordinates, see create_coord.f90
+
+<!-- ######################################################################  -->
+# Create bathymetry file # {#bathy}
+
+Then you need a Bathymetry file.<br/>
+SIREN allows you to create a Bathymetry extracted or refined from a wider
+Bathymetry grid.<br/>
+
+To create this new bathymetry, you have to run :
+~~~~~~~~~~~~~~~~~~
+./SIREN/create_bathy.exe create_bathy.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *create_bathy.exe*.<br/>
+In this example, you create a bathymetry file named *bathy_fine.nc*.<br/>
+This new bathymetry file is refined from an extraction of *bathy_meter_ORCA025.nc*.<br/>
+Moreover a minimum value of 5m is imposed to the output Bathymetry.
+~~~~~~~~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namcrs
+   cn_coord0 = "PATH/coordinates_ORCA025.nc"
+   in_perio0 = 4
+/
+
+&namfin
+   cn_coord1 = "PATH/coord_fine.nc"
+/
+
+&namvar
+   cn_varfile = "Bathymetry:PATH/bathy_meter_ORCA025.nc"
+   cn_varinfo = "Bathymetry: min=5"
+/
+
+&namnst
+   in_rhoi = 2
+   in_rhoj = 3
+/
+
+&namout
+   cn_fileout = "PATH/bathy_fine.nc"      
+/
+~~~~~~~~~~~~~~~~~~
+
+Let's get describe this namelist.<br/>
+
+First as previously, we have the **namlog** and **namcfg** sub-namelist (see above for more
+explanation).<br/>
+
+Then the **namcrs** sub-namelist set parameters of the wide
+coordinates file.<br/>
+@note in all SIREN namelist: <br/>
+0 referred to the coarse/wide grid.<br/>
+1 referred to the fine grid.
+
+In the same way, the **namfin** sub-namelist  set parameters of the fine
+coordinates file.<br/>
+@note in this namelist example, there is no need to set the variable *in_perio1* to define the NEMO
+periodicity of the fine grid.<br/> Indeed, if this variable is not inform, SIREN tries to read it in the attributes of the file.<br/> 
+So if you created the fine coordinates with SIREN, you do not have to
+fill it. In other case, you should add it to the namelist.
+
+The **namvar** sub-namelist lists variables to be used:
+<dl>
+   <dt>cn_varfile</dt>
+      <dd> defines the variable name ("Bathymetry" here) and the input file associated with.
+            @warning The domain of the input Bathymetry have to be larger than the output domain.
+         @note 
+         <ul>
+            <li>if the input file is at coarse grid resolution (same than *cn_coord0*), the ouptut Bathymetry will be refined on fine grid.</li>
+            <li>if the input file is a wider bathymetry (already at fine grid resolution), the output Bathymetry will be extracted from this one.</li>
+         </ul>
+      </dd>
+   <dt>cn_varinfo</dt>
+      <dd> defines user's requests for a variable.
+         @note Default interpolation method for the Bathymetry, is *cubic* interpolation.<br/>
+         So you may want to specify a minimum value to avoid negative value, or to change interpolation method.<br/>
+         example: <ul><li>cn_varinfo="Bathymetry: min=1"'</li>
+                      <li>cn_varinfo="Bathymetry: int=linear"</li></ul>
+      </dd>
+</dl>
+
+The **namnst** sub-namelist defines the subdomain refinment factor.<br/>
+Of course those refinment factors have to be convenient with refinment
+from coarse grid *cn_coord0* to fine grid *cn_coord1*.
+@note subdomain indices are automatically deduced from fine and coarse grid
+coordinates.
+
+Finally, this **namout** sub-namelist defines the output file.<br/>
+
+@note All the output files create by SIREN include information about 
+source file, indices, refinment and interpolation method used.
+
+@sa For more information about how to create bathymetry, see
+create_bathy.f90
+
+<!-- ######################################################################  -->
+# Merge bathymetry file # {#merge}
+
+The Bathymetry you build differs from the wider one.<br/>
+To avoid issue with boundaries forcing fields, you should merge fine and coarse Bathymetry on boundaries.<br/>
+SIREN allows you to do this.<br/>
+
+To create this merged bathymetry, you have to run :
+~~~~~~~~~~~~~~~~~~
+./SIREN/merge_bathy.exe merge_bathy.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *merge_bathy.exe*.<br/>
+~~~~~~~~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namcrs
+   cn_bathy0 = "PATH/bathy_meter_ORCA025.nc"
+   in_perio0 = 4
+/
+
+&namfin
+   cn_bathy1 = "PATH/bathy_fine.nc"
+/
+
+&namnst
+   in_rhoi = 3
+   in_rhoj = 3
+/
+
+&nambdy
+/
+
+&namout
+   cn_fileout = "PATH/bathy_merged.nc"      
+/
+~~~~~~~~~~~~~~~~~~
+In this namelist, you find again the **namlog**, **namcfg** describe above.
+
+Then the **namcrs** sub-namelist sets parameters of the wider grid.
+However this time, this is the coarse/wide grid Bathymetry wich have to be informed.
+
+The **namfin** sub-namelist defines parameters of the fine grid Bathymetry.
+@note here again you could add the *in_perio1* parameter if need be i.e. if your
+fine grid Bathymetry was not created by SIREN.
+
+The **namnst** sub-namelist defines the subdomain refinment factor.
+
+
+The **nambdy** sub-namelist defines the subdomain boundaries.<br/>
+By default SIREN tries to create boundaries for each side. Boundary exist if there is at least one sea point on the second row of each side.<br/>
+So you could let this namelist empty.
+
+@sa For more information about boundaries, see @ref boundary
+
+Finally, this **namout** sub-namelist defines the output file.<br/>
+
+@sa For more information about how to merge bathymetry, see
+merge_bathy.f90
+
+<!-- ######################################################################  -->
+# Create initial state # {#restart}
+
+To run your configuration you need an inital state of the ocean.<br/>
+You could start from a restart file (with all NEMO variables fields at one
+time step). Or you could start from "partial" information about ocean state (Temperature and Salinity for example).
+
+Siren allows you to create both of those initial state.<br/>
+To create the initial state, you have to run:<br/>
+~~~~~~~~~~~~~~~~~~
+./SIREN/create_restart.exe create_restart.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *create_restart.exe*.<br/>
+In this example, you create an initial state split on 81 "processors", and named restar_out.nc.<br/>
+The initial state is composed of temperature and salinity refined from an extraction of GLORYS fields.
+~~~~~~~~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namcrs
+   cn_coord0 = "PATH/coordinates_ORCA025.nc"
+   in_perio0 = 4
+/
+
+&namfin
+   cn_coord1 = "PATH/coord_fine.nc"
+   cn_bathy1 = "PATH/bathy_merged.nc"
+/
+
+&namzgr
+/
+
+&namzps
+/
+
+&namvar
+   cn_varfile = "votemper:GLORYS_gridT.nc",
+                "vosaline:GLORYS_gridS.nc"
+/
+
+&namnst
+   in_rhoi = 3
+   in_rhoj = 3
+/
+
+&namout
+   cn_fileout = "PATH/restart_out.nc"      
+   in_nproc = 81
+/
+~~~~~~~~~~~~~~~~~~
+Let's get describe this namelist more accurately.<br/>
+
+As previously, we have the **namlog** and **namcfg** sub-namelists, as well as 
+the **namcrs** sub-namelist to set parameters of the wide coordinates file (see above for more
+explanation).<br/>
+
+Then the **namfin** sub-namelist set parameters of the fine
+grid coordinates and bathymetry.<br/>
+
+The **namzgr** and **namzps** sub-namelists define respectively parameters for vertical grid
+and partial step.<br>
+By default, those parameters are defined the same way than in GLORYS (i.e. 75 vertical levels).<br/>
+So you could let it empty.
+@note If you use forcing fields other than GLORYS, you have to be sure it uses the same vertical grid. In other case, you need to get information about the parametrisation use, and to put it in those sub-namelist (see create_restart.f90).
+
+the **namvar** sub-namelist lists variables to be used.<br/>
+Here we use *votemper* (temperature) get from *GLORYS_gridT.nc* file, and *vosaline*
+(salinity) get from *GLORYS_gridS.nc* file.
+@note To get all variables of a restart file. You have to use:
+~~~~~~~~~~~~~~~~~~
+cn_varfile = "all:PATH/restart.dimg"
+~~~~~~~~~~~~~~~~~~
+
+The **namnst** sub-namelist defines the subdomain refinment factor, as seen previously.<br/>
+
+Finally, this **namout** sub-namelist defines the output files.<br/>
+Here we ask for output on 81 processors, with *restart_out.nc* as file "basename".<br/>
+So SIREN computes the optimal layout for 81 porcessors
+available,<br/>
+and split restart on output files named *restart_out_num.nc*, where *num* is the porc number.
+
+@note SIREN could also create the other fields you may need for
+your configuration.<br/>
+To do so, you just have to run *create_restart.exe* with other variable(s) from other input file(s).<br/>
+For example, to get runoff fields, you could use:
+~~~~~~~~~~~~~~~~~~
+cn_varfile = "sorunoff:PATH/runoff_GLORYS.nc"
+...
+cn_fileout = "PATH/runoff_out.nc"
+~~~~~~~~~~~~~~~~~~
+
+@sa For more information about how to create initial state or other fields, see
+create_restart.f90
+
+<!-- ######################################################################  -->
+# Create boundaries conditions # {#boundary}
+
+Finally to force your configuration, you may need boundaries conditions.<br/>
+NEMO read physical boundaries conditions from temperature, salinity, currents, and sea
+surface height.
+
+To create the boundaries condition with SIREN, you have to run:<br/>
+~~~~~~~~~~~~~~~~~~
+./SIREN/create_boundary.exe create_boundary.nam
+~~~~~~~~~~~~~~~~~~
+
+Here after is an example of namelist for *create_boundary.exe*.<br/>
+In this example, you create boundaries conditions named *boundary_out.nc* on
+each side of the domain.<br/>
+The boundaries contain information about temperature, salinity, currents and sea surface height refined from an extraction of GLORYS fields.
+~~~~~~~~~~~~~~~~~~
+&namlog
+/
+
+&namcfg
+   cn_varcfg = "PATH/NEMOGCM/TOOLS/SIREN/cfg/variable.cfg"
+/
+
+&namcrs
+   cn_coord0 = "PATH/coordinates_ORCA025.nc"
+   in_perio0 = 4
+/
+
+&namfin
+   cn_coord1 = "PATH/coord_fine.nc"
+   cn_bathy1 = "PATH/bathy_fine.nc"
+/
+
+&namzgr
+/
+
+&namzps
+/
+
+&namvar
+   cn_varfile="votemper:GLORYS_gridT.nc",
+              "vosaline:GLORYS_gridS.nc",
+              "vozocrtx:GLORYS_gridU.nc",
+              "vomecrty:GLORYS_gridV.nc",
+              "sossheig:GLORYS_grid2D.nc"
+/
+
+&namnst
+   in_rhoi = 3
+   in_rhoj = 3
+/
+
+&nambdy
+/
+
+&namout
+   cn_fileout = "PATH/boundary_out.nc"      
+/
+~~~~~~~~~~~~~~~~~~
+
+Let's get describe this namelist more accurately.<br/>
+
+As previously, we have the **namlog** and **namcfg** sub-namelists, as well as 
+the **namcrs** sub-namelist to set parameters of the wide coordinates file (see above for more
+explanation).<br/>
+
+Then the **namfin** sub-namelist set parameters of the fine
+grid coordinates and bathymetry.<br/>
+
+The **namzgr** and **namzps** sub-namelists define respectively parameters for vertical grid
+and partial step.<br>
+By default, those parameters are defined the same way than in GLORYS (i.e. 75 vertical levels).<br/>
+So you could let it empty.
+@note If you use forcing fields other than GLORYS, you have to be sure it uses the same vertical grid. In other case, you need to get information about the parametrisation use, and to put it in those sub-namelist (see create_boundary.F90).
+
+the **namvar** sub-namelist lists variables to be used.<br/>
+Here we get *votemper* (temperature) from *GLORYS_gridT.nc* file, *vosaline*
+(salinity) from *GLORYS_gridS.nc* file, *vozocrtx* (zonal velocity) from
+*GLORYS_gridU.nc*, *vomecrty* (meridional velocity) from *GLORYS_gridV.nc*, and sossheig (sea surface
+height) from *GLORYS_grid2D.nc*.
+
+The **namnst** sub-namelist defines the subdomain refinment factor.<br/>
+
+The **nambdy** sub-namelist defines the subdomain boundaries.<br/>
+By default SIREN tries to create boundaries for each side (Boundary is created if sea point exist on the second row of each side).<br/>
+So you could let this namelist empty.
+
+@note SIREN allows you to place boundaries away from the side of the domain.
+To do so you have to define your boundary.<br/>
+That means you have to give on fine
+grid the index of the boundary (how far from the border your boundary is),
+the width of your boundary, and finally first and last point of your boundary (the length of your boundary).<br/>
+So to define a north boundary, you have to add in the sub-namelist *nambdy*, the parameter:
+~~~~~~~~~~~~~~~~~~
+cn_north="index,first:last(width)"
+~~~~~~~~~~~~~~~~~~
+
+Finally, this **namout** sub-namelist defines the output files.<br/>
+Here we ask for output with *boundary_out.nc* as file "basename".<br/>
+So SIREN creates output files named *boundary_out_west.nc*,
+*boundary_out_east.nc*, *boundary_out_north.nc*, and *boundary_out_south.nc*
+depending if boundary exist or not.
+
+@sa For more information about how to create boundaries condition, see
+create_boundary.F90
+
+# Create and run NEMO configuration # {#NEMOconf}
+
+So now you created all the input files you need for your physical configuration, you have to create the "NEMO configuration".<br/>
+To do so, go to the directory *NEMOGCM/CONFIG/*, and run:
+~~~~~~~~~~~~~~~~~~
+./makenemo -n MY_CONFIG -d "OPA_SRC"
+~~~~~~~~~~~~~~~~~~
+This creates your configuration "MY_CONFIG" in the directory *NEMOGCM/CONFIG*.<br/>
+you could check the cpp_keys used in file *cpp_MY_CONFIG.fcm*, and re-run *makenemo*
+if need be.
+
+Once *makenemo* has run successfully, the *opa* executable is available in
+directory *NEMOGCM/CONFIG/MY_CONFIG/EXP00*.<br/>
+Then you just have to put all your input files in this directory, fill the namelist *namelist_cfg*, and run:
+~~~~~~~~~~~~~~~~~~
+mpirun ./opa
+~~~~~~~~~~~~~~~~~~
+
+@note no surface forcing here.
+weighted function needed to do interpolation on the fly, could be created by WEIGHT tools already inside NEMO.
+
+@sa For more information about how to create NEMO configuration see [NEMO Quick Start Guide](http://www.nemo-ocean.eu/Using-NEMO/User-Guides/Basics/NEMO-Quick-Start-Guide).
+
+ <HR>
+   <b>
+   - @ref index
+   - @ref md_docsrc_1_install
+   - @ref md_docsrc_2_quickstart
+   - @ref md_docsrc_3_support_bug
+   - @ref md_docsrc_4_codingRules
+   - @ref md_docsrc_5_changeLog
+   - @ref todo
+   </b>
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/3_codingRules.md
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/3_codingRules.md	(revision 7338)
+++ 	(revision )
@@ -1,98 +1,0 @@
-# Coding Rules
-
-The conventions used in SIREN coding are based on the NEMO coding rules
-(see [NEMO coding
-conventions](http://www.nemo-ocean.eu/content/download/15483/73221/file/NEMO_coding.conv_v3.pdf)).<br/>
-However some modifications were added to improve readibility of the code.<br/>
-Some of the NEMO coding rules are reminded here, and extensions are described.
-
-@tableofcontents
-
-# Fortran Standard {#std}
-
-SIREN software adhere to strict __FORTRAN 95__ standard.<br/>
-There is only one exception. The use of functions _COMMAND_ARGUMENT_COUNT_ and
-_GET_COMMAND_ARGUMENT_.<br/>
-There exist no equivalent for those Fortran 03 intrinsec functions in Fortran
-95.<br/> At least none convenient for compilers tested (see @ref md_docsrc_1_install). 
-
-#  Free Form Source {#free}
-Free Form Source will be used, however a self imposed limit of 80 should
-enhance readibility.
-
-#  Indentation {#indent}
-Code as well as comments lines will be indented 3 characters for readibility.<br/>
-__Indentation should be write without hard tabs__.
-
-Example for vi  :
-~~~~~~~~~~~~~~~~~~~~~
-:set expandtab tabstop=3 shiftwidth=3
-~~~~~~~~~~~~~~~~~~~~~
-
-#  Naming conventions : variable {#namvar}
-All variables should be named as explicitly as possible.<br/>
-The naming conventions concerns prefix letters of these name, in order to
-identify the variable type and status.<br/> It must be composed of two
-letters defining type and status follow by an underscore.<br/>
-table below list the starting letters to be used for variable naming,
-depending on their type and status.
-
- | Type / Status     | byte (integer(1)) <br/> __b__ | short (integer(2)) <br/> __s__ | integer(4) <br/> __i__  | integer(8) <br/> __k__ | real(4) <br/> __r__ | real(8) <br/> __d__ | logical <br/> __l__ | character <br/> __c__ | complex <br/> __y__ | structure <br/> __t__  |
- | :----:            | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: |
- |global <br/> __g__           | bg_  | sg_  | ig_  | kg_  | rg_  | dg_  | lg_  | cg_  | yg_  | tg_  |
- |global parameter <br/> __p__ | bp_  | sp_  | ip_  | kp_  | rp_  | dp_  | lp_  | cp_  | yp_  | tp_  |
- |module <br/> __m__           | bm_  | sm_  | im_  | km_  | rm_  | dm_  | lm_  | cm_  | ym_  | tm_  |
- |namelist <br/> __n__         | bn_  | sn_  | in_  | kn_  | rn_  | dn_  | ln_  | cn_  | yn_  | tn_  |
- |dummy argument <br/> __d__   | bd_  | sd_  | id_  | kd_  | rd_  | dd_  | ld_  | cd_  | yd_  | td_  |
- |local <br/> __l__            | bl_  | sl_  | il_  | kl_  | rl_  | dl_  | ll_  | cl_  | yl_  | tl_  |
- |loop control       |      |      | j?   |      |      |      |      |      |      |      |
-
-# Naming conventions : structure {#namstr}
-The structure name should be written in capital letter, and start with
-__T__<br/> Example: TTRACER <br/>
-Variables inside the structure should be named as explicitly as possible.<br/>
-For those variables, the prefix naming conventions only concern the type of variable.<br/>
-It must be composed of one letter defining type follows by an
-underscore.<br/>
-see table of variable conventions.<br/>
-
-Example: __tl\_type\%i\_year__<br/> _year_ is an integer(4) variable in a local strucure
-named _type_. <br/>
-
-# Naming conventions : function-subroutine {#namsub}
-Functions or Subroutines are defined in a module.<br/>
-Their name should start with the module name then with their "functional" name. So it will be
-easy to find it.<br/>
-Example:<br/> a function to realise addition written in a module
-__math__ should be called __math\_add__.<br/>
-
-__PUBLIC__  function or subroutine should used one undescrore: _math_add_<br/>
-__PRIVATE__ function or subroutine should used two undescrores: _math__add_<br/>
-
-# Precision {#precision}
-__All variables should make use of kinds__.<br/>
-Numerical constant need to have a suffix of __kindvalue__
-
-# Declaration for global variable and constants {#global}
-All global data must be accompanied with a comment field on the same
-line.<br/>
-_Note that using doxygen (see [header](#header)), we will use symbol !< instead of !: as separator_
-
-# Implicit none {#implicit}
-All subroutines and functions will include an IMPLICIT NONE statement.
-
-# Header {#header}
-
-SIREN use __doxigen auto documentation__ tool.<br/>
-Information could be find on
-[doxygen](http://www.stack.nl/~dimitri/doxygen/index.html) web page.<br/>
-Some basic tag are described
-[here](http://www.msg.chem.iastate.edu/gamess/DoxygenRules.oct10.pdf).
-
- <HR>
-   <b>
-   - @ref index
-   - @ref md_docsrc_1_install
-   - @ref md_docsrc_4_changeLog
-   - @ref todo
-   </b>
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/3_support_bug.md	(revision 7339)
@@ -0,0 +1,28 @@
+# Support
+
+# How to get support
+  If you have questions regarding the use of SIREN, please have a look at the [NEMO configuration manager forum](https://forge.ipsl.jussieu.fr/nemo/discussion/forum/2).<br/>
+  If you don't find an answer in the archives, feel free to register and post your question.
+
+# How to Help
+   The development of SIREN highly depends on your input!<br/>
+   If you are trying SIREN let me know what you think of it (do you miss certain features?). Even if you decide not to use it, please let me know why.
+
+# How to report a bug
+   If you believe you have found a new bug, please report it.<br/>
+   Before submitting a new bug, first search through the database if the same bug has already been submitted by others
+
+   If you send only a (vague) description of a bug, you are usually not very
+   helpful and it will cost much more time to figure out what you mean. In
+   the worst-case your bug report may even be completely ignored.
+
+ <HR>
+   <b>
+   - @ref index
+   - @ref md_docsrc_1_install
+   - @ref md_docsrc_2_quickstart
+   - @ref md_docsrc_3_support_bug
+   - @ref md_docsrc_4_codingRules
+   - @ref md_docsrc_5_changeLog
+   - @ref todo
+   </b>
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/4_changeLog.md
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/4_changeLog.md	(revision 7338)
+++ 	(revision )
@@ -1,18 +1,0 @@
-# Change log
-
-@tableofcontents
-
-# Release 3.6
-Initial release (release date )
-
-## Changes
-## New Features
-## Bug fixes
-
- <HR>
-   <b>
-   - @ref index
-   - @ref md_docsrc_1_install
-   - @ref md_docsrc_3_codingRules
-   - @ref todo
-   </b>
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/4_codingRules.md	(revision 7339)
@@ -0,0 +1,100 @@
+# Coding Rules
+
+The conventions used in SIREN coding are based on the NEMO coding rules
+(see [NEMO coding
+conventions](http://www.nemo-ocean.eu/content/download/15483/73221/file/NEMO_coding.conv_v3.pdf)).<br/>
+However some modifications were added to improve readibility of the code.<br/>
+Some of the NEMO coding rules are reminded here, and extensions are described.
+
+@tableofcontents
+
+# Fortran Standard {#std}
+
+SIREN software adhere to strict __FORTRAN 95__ standard.<br/>
+There is only one exception. The use of functions _COMMAND_ARGUMENT_COUNT_ and
+_GET_COMMAND_ARGUMENT_.<br/>
+There exist no equivalent for those Fortran 03 intrinsec functions in Fortran
+95.<br/> At least none convenient for compilers tested (see @ref md_docsrc_1_install). 
+
+#  Free Form Source {#free}
+Free Form Source will be used, however a self imposed limit of 80 should
+enhance readibility.
+
+#  Indentation {#indent}
+Code as well as comments lines will be indented 3 characters for readibility.<br/>
+__Indentation should be write without hard tabs__.
+
+Example for vi  :
+~~~~~~~~~~~~~~~~~~~~~
+:set expandtab tabstop=3 shiftwidth=3
+~~~~~~~~~~~~~~~~~~~~~
+
+#  Naming conventions : variable {#namvar}
+All variables should be named as explicitly as possible.<br/>
+The naming conventions concerns prefix letters of these name, in order to
+identify the variable type and status.<br/> It must be composed of two
+letters defining type and status follow by an underscore.<br/>
+table below list the starting letters to be used for variable naming,
+depending on their type and status.
+
+ | Type / Status     | byte (integer(1)) <br/> __b__ | short (integer(2)) <br/> __s__ | integer(4) <br/> __i__  | integer(8) <br/> __k__ | real(4) <br/> __r__ | real(8) <br/> __d__ | logical <br/> __l__ | character <br/> __c__ | complex <br/> __y__ | structure <br/> __t__  |
+ | :----:            | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: |
+ |global <br/> __g__           | bg_  | sg_  | ig_  | kg_  | rg_  | dg_  | lg_  | cg_  | yg_  | tg_  |
+ |global parameter <br/> __p__ | bp_  | sp_  | ip_  | kp_  | rp_  | dp_  | lp_  | cp_  | yp_  | tp_  |
+ |module <br/> __m__           | bm_  | sm_  | im_  | km_  | rm_  | dm_  | lm_  | cm_  | ym_  | tm_  |
+ |namelist <br/> __n__         | bn_  | sn_  | in_  | kn_  | rn_  | dn_  | ln_  | cn_  | yn_  | tn_  |
+ |dummy argument <br/> __d__   | bd_  | sd_  | id_  | kd_  | rd_  | dd_  | ld_  | cd_  | yd_  | td_  |
+ |local <br/> __l__            | bl_  | sl_  | il_  | kl_  | rl_  | dl_  | ll_  | cl_  | yl_  | tl_  |
+ |loop control       |      |      | j?   |      |      |      |      |      |      |      |
+
+# Naming conventions : structure {#namstr}
+The structure name should be written in capital letter, and start with
+__T__<br/> Example: TTRACER <br/>
+Variables inside the structure should be named as explicitly as possible.<br/>
+For those variables, the prefix naming conventions only concern the type of variable.<br/>
+It must be composed of one letter defining type follows by an
+underscore.<br/>
+see table of variable conventions.<br/>
+
+Example: __tl\_type\%i\_year__<br/> _year_ is an integer(4) variable in a local strucure
+named _type_. <br/>
+
+# Naming conventions : function-subroutine {#namsub}
+Functions or Subroutines are defined in a module.<br/>
+Their name should start with the module name then with their "functional" name. So it will be
+easy to find it.<br/>
+Example:<br/> a function to realise addition written in a module
+__math__ should be called __math\_add__.<br/>
+
+__PUBLIC__  function or subroutine should used one undescrore: _math_add_<br/>
+__PRIVATE__ function or subroutine should used two undescrores: _math__add_<br/>
+
+# Precision {#precision}
+__All variables should make use of kinds__.<br/>
+Numerical constant need to have a suffix of __kindvalue__
+
+# Declaration for global variable and constants {#global}
+All global data must be accompanied with a comment field on the same
+line.<br/>
+_Note that using doxygen (see [header](#header)), we will use symbol !< instead of !: as separator_
+
+# Implicit none {#implicit}
+All subroutines and functions will include an IMPLICIT NONE statement.
+
+# Header {#header}
+
+SIREN use __doxigen auto documentation__ tool.<br/>
+Information could be find on
+[doxygen](http://www.stack.nl/~dimitri/doxygen/index.html) web page.<br/>
+Some basic tag are described
+[here](http://www.msg.chem.iastate.edu/gamess/DoxygenRules.oct10.pdf).
+
+ <HR>
+   <b>
+   - @ref index
+   - @ref md_docsrc_1_install
+   - @ref md_docsrc_2_quickstart
+   - @ref md_docsrc_3_support_bug
+   - @ref md_docsrc_5_changeLog
+   - @ref todo
+   </b>
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/5_changeLog.md	(revision 7339)
@@ -0,0 +1,20 @@
+# Change log
+
+@tableofcontents
+
+# Release $Revision$
+Initial release (2016-03-17)
+
+## Changes
+## New Features
+## Bug fixes
+
+ <HR>
+   <b>
+   - @ref index
+   - @ref md_docsrc_1_install
+   - @ref md_docsrc_2_quickstart
+   - @ref md_docsrc_3_support_bug
+   - @ref md_docsrc_4_codingRules
+   - @ref todo
+   </b>
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md	(revision 7339)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/6_perio.md	(revision 7339)
@@ -0,0 +1,34 @@
+# NEMO periodicity
+
+NEMO periodicity is defined as follow :<br/> 
+<dl>
+<dt>closed boundary (in_perio=0)</dt>
+<dd>ghost cells (solid walls) are imposed at all model boundaries.</dd> 
+@image html perio0_20.png 
+@image latex perio0_20.png
+<dt>cyclic east-west boundary (in_perio=1)</dt>
+<dd>first and last rows are 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.</dd>  
+@image html perio1_20.png 
+@image latex perio1_20.png
+<dt>symmetric boundary condition across the equator. (in_perio=2)</dt>
+<dd>last row, and first and last columns are closed. </dd> 
+@image html perio2_20.png 
+@image latex perio2_20.png
+<dt>North fold boundary with a T -point pivot (in_perio=3)</dt>
+<dd>first row, and first and last columns are closed. </dd> 
+@image html perio3_20.png 
+@image latex perio3_20.png
+<dt>North fold boundary with a T -point pivot and cyclic east-west boundary (in_perio=4)</dt>
+<dd>first row is closed. 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. </dd> 
+@image html perio4_20.png 
+@image latex perio4_20.png
+<dt>North fold boundary with a F -point pivot (in_perio=5)</dt>
+<dd>first row, and first and last columns are closed. </dd> 
+@image html perio5_20.png 
+@image latex perio5_20.png
+<dt>North fold boundary with a F -point pivot and cyclic east-west boundary (in_perio=6)</dt>
+<dd>first row is closed. 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.</dd> 
+@image html perio6_20.png 
+@image latex perio6_20.png
+</dl>
+@sa For more information about NEMO periodicity, see _Model Boundary Condition_ chapter in [NEMO documentation](http://www.nemo-ocean.eu/About-NEMO/Reference-manuals))
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/docsrc/main.dox	(revision 7339)
@@ -1,41 +1,32 @@
 /*!
- @mainpage Main Page
- @section descr Generic Description
- SIREN is a software to create regional configuration with
- [NEMO](http://www.nemo-ocean.eu).<br/> 
+ @mainpage About 
+
+ SIREN is a software to create regional configuration with [NEMO](http://www.nemo-ocean.eu).<br/> 
  Actually SIREN create input files needed for a basic NEMO configuration.<br/>
+
+ SIREN allows you to create your own regional configuration embedded in a wider one.<br/>
+ In order to help you, a set of GLORYS files (global reanalysis on ORCA025 grid), as well as examples
+ of namelists are available in dods repository.
+
+ @note This software was created, and is maintain by the Configuration Manager Working Group, composed
+ of NEMO system team members.
  
- SIREN is composed of a set of 5 Fortran programs :
-   - create_coord.f90 to create fine grid coordinate file from coarse grid coordinate file.
-   - create_bathy.f90 to create fine grid bathymetry file over domain.
-   - merge_bathy.f90 to merge fine grid bathymetry with coarse grid bathymetry at boundaries.
-   - create_restart.f90 to create initial state file from coarse grid restart or standard outputs.
-   - create_boundary.f90 to create boundary condition from coarse grid standard outputs.
+ To know how to install SIREN see @ref md_docsrc_1_install.
 
-To install those programs see @ref md_docsrc_1_install.
-
- @note SIREN can not:
- - create global configuration
- - create configuarion around or close to north pole
- - change number of vertical level
- - change grid (horizontal or vertical)
-
- @section howto How to use
-   @subsection howto_coord to create fine grid coordinate file
-   see create_coord.f90
-   @subsection howto_bathy to create fine grid bathymetry
-   see create_bathy.f90
-   @subsection howto_merge to merge fine grid bathymetry
-   see merge_bathy.f90
-   @subsection howto_restart to create initial state file
-   see create_restart.f90
-   @subsection howto_boundary to create boundary condition
-   see create_boundary.f90
+ You could find a tutorial for a quick start with SIREN in @ref md_docsrc_2_quickstart.<br/>
+ For more information about how to use each component of SIREN
+ - see create_coord.f90 to create fine grid coordinate file
+ - see create_bathy.f90 to create fine grid bathymetry
+ - see merge_bathy.f90 to merge fine grid bathymetry
+ - see create_restart.f90 to create initial state file, or other fields.
+ - see create_boundary.F90 to create boundary condition
 
 <HR>
    <b>
    - @ref md_docsrc_1_install
-   - @ref md_docsrc_3_codingRules
-   - @ref md_docsrc_4_changeLog
+   - @ref md_docsrc_2_quickstart
+   - @ref md_docsrc_3_support_bug
+   - @ref md_docsrc_4_codingRules
+   - @ref md_docsrc_5_changeLog
    - @ref todo
    </b>
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/domain.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/domain.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/domain.f90	(revision 7339)
@@ -1297,4 +1297,6 @@
    !> @date September, 2014
    !> - take into account number of ghost cell
+   !> @date February, 2016
+   !> - number of extra point is the MAX (not the MIN) of zero and asess value. 
    !
    !> @param[inout] td_dom domain strcuture
@@ -1344,5 +1346,5 @@
                   td_dom%i_imin      = td_dom%i_imin - td_dom%i_iextra(1)
                ELSE ! td_dom%i_imin - il_iext <= td_dom%i_ghost0(jp_I,1)*ip_ghost
-                  td_dom%i_iextra(1) = MIN(0, &
+                  td_dom%i_iextra(1) = MAX(0, &
                   &                         td_dom%i_imin - &
                   &                         td_dom%i_ghost0(jp_I,1)*ip_ghost -1)
@@ -1356,5 +1358,5 @@
                ELSE ! td_dom%i_imax + il_iext >= &
                     !  td_dom%t_dim0(1)%i_len - td_dom%i_ghost0(jp_I,2)*ip_ghost
-                  td_dom%i_iextra(2) = MIN(0, &
+                  td_dom%i_iextra(2) = MAX( 0, &
                   &                         td_dom%t_dim0(1)%i_len - &
                   &                         td_dom%i_ghost0(jp_I,2)*ip_ghost - &
@@ -1364,4 +1366,5 @@
 
             ELSE ! td_dom%i_ew0 >= 0
+
                ! EW cyclic
                IF( td_dom%i_imin - il_iext > 0 )THEN
@@ -1391,9 +1394,10 @@
             ! nothing to be done
          ELSE
+
             IF( td_dom%i_jmin - il_jext > td_dom%i_ghost0(jp_J,1)*ip_ghost )THEN
                td_dom%i_jextra(1) = il_jext
                td_dom%i_jmin      = td_dom%i_jmin - td_dom%i_jextra(1)
             ELSE ! td_dom%i_jmin - il_jext <= td_dom%i_ghost0(jp_J,1)*ip_ghost
-               td_dom%i_jextra(1) = MIN(0, &
+               td_dom%i_jextra(1) = MAX( 0, &
                &                         td_dom%i_jmin - &
                &                         td_dom%i_ghost0(jp_J,1)*ip_ghost - 1)
@@ -1407,5 +1411,5 @@
             ELSE ! td_dom%i_jmax + il_jext >= &
                  !  td_dom%t_dim0(2)%i_len - td_dom%i_ghost0(jp_J,2)*ip_ghost
-               td_dom%i_jextra(2) = MIN(0, &
+               td_dom%i_jextra(2) = MAX( 0, &
                &                         td_dom%t_dim0(2)%i_len - &
                &                         td_dom%i_ghost0(jp_J,2)*ip_ghost - &
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/file.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/file.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/file.f90	(revision 7339)
@@ -694,6 +694,8 @@
    !> @date November, 2013 - Initial Version
    !> @date September, 2014
-   !> - add dimension to file if need be
+   !> - add dimension in file if need be
    !> - do not reorder dimension from variable, before put in file
+   !> @date September, 2015
+   !> - check variable dimension expected
    !
    !> @param[inout] td_file   file structure
@@ -705,5 +707,5 @@
       ! Argument      
       TYPE(TFILE), INTENT(INOUT) :: td_file
-      TYPE(TVAR) , INTENT(IN   ) :: td_var
+      TYPE(TVAR) , INTENT(INOUT) :: td_var
 
       ! local variable
@@ -761,4 +763,7 @@
                IF( file_check_var_dim(td_file, td_var) )THEN
 
+                  ! check variable dimension expected
+                  CALL var_check_dim(td_var)
+
                   ! update dimension if need be
                   DO ji=1,ip_maxdim
@@ -1050,5 +1055,4 @@
                   ! new number of variable in file
                   td_file%i_nvar=td_file%i_nvar-1
-
                   SELECT CASE(td_var%i_ndim)
                      CASE(0)
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/function.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/function.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/function.f90	(revision 7339)
@@ -363,5 +363,5 @@
       IF( id_status /= 0 )THEN
          !CALL ERRSNS() ! not F95 standard
-         PRINT *, "FORTRAN ERROR"
+         PRINT *, "FORTRAN ERROR ",id_status
          !STOP
       ENDIF
@@ -740,5 +740,5 @@
    !
    !> @param[in] cd_var character
-   !> @return character is numeric
+   !> @return character is real number
    !-------------------------------------------------------------------
    PURE LOGICAL FUNCTION fct_is_real(cd_var)
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/global.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/global.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/global.f90	(revision 7339)
@@ -12,4 +12,6 @@
 ! REVISION HISTORY:
 !> @date November, 2013 - Initial Version
+!> @date September, 2015
+!> - define fill value for each variable type
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -95,5 +97,9 @@
    &     'gauss      '/)
 
-   REAL(dp)                                , PARAMETER :: dp_fill=NF90_FILL_DOUBLE !< default fill value
+   REAL(dp)                                , PARAMETER :: dp_fill_i1=NF90_FILL_BYTE   !< byte fill value
+   REAL(dp)                                , PARAMETER :: dp_fill_i2=NF90_FILL_SHORT  !< short fill value
+   REAL(dp)                                , PARAMETER :: dp_fill_i4=NF90_FILL_INT    !< INT fill value
+   REAL(dp)                                , PARAMETER :: dp_fill_sp=NF90_FILL_FLOAT  !< real fill value
+   REAL(dp)                                , PARAMETER :: dp_fill=NF90_FILL_DOUBLE !< double fill value
 
    INTEGER(i4)                             , PARAMETER :: ip_npoint=4
@@ -125,5 +131,5 @@
    INTEGER(i4), PARAMETER :: jp_west =4
 
-
+   INTEGER(i4)                             , PARAMETER :: ip_maxdum = 10 !< maximum dummy variable, dimension, attribute
 
 END MODULE global
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/grid.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/grid.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/grid.f90	(revision 7339)
@@ -80,5 +80,6 @@
 !> point:<br/>
 !> @code
-!>    il_index(:)=grid_get_closest(dd_lon0(:,:), dd_lat0(:,:), dd_lon1, dd_lat1)
+!>    il_index(:)=grid_get_closest(dd_lon0(:,:), dd_lat0(:,:), dd_lon1, dd_lat1
+!>                                 [,dd_fill] [,cd_pos])
 !> @endcode
 !>       - il_index(:) is  coarse grid indices (/ i0, j0 /)
@@ -87,4 +88,6 @@
 !>       - dd_lon1 is fine grid longitude value (real(8))
 !>       - dd_lat1 is fine grid latitude  value (real(8))
+!>       - dd_fill
+!>       - cd_pos
 !>
 !>    to compute distance between a point A and grid points:<br/>
@@ -215,4 +218,7 @@
 !> @date February, 2015
 !> - add function grid_fill_small_msk to fill small domain inside bigger one
+!> @February, 2016
+!> - improve way to check coincidence (bug fix)
+!> - manage grid cases for T,U,V or F point, with even or odd refinment (bug fix)
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -664,5 +670,5 @@
             
             ! no pivot point found
-            CALL logger_error("GRID GET PIVOT: something wrong "//&
+            CALL logger_warn("GRID GET PIVOT: something wrong "//&
             &  "when computing pivot point with variable "//&
             &  TRIM(td_var%c_name))
@@ -685,5 +691,5 @@
 
                IF( grid__get_pivot_var /= -1 )THEN
-                  CALL logger_warn("GRID GET PIVOT: variable "//&
+                  CALL logger_info("GRID GET PIVOT: variable "//&
                   &  TRIM(td_var%c_name)//" seems to be on grid point "//&
                   &  TRIM(cp_grid_point(jj)) )
@@ -1335,7 +1341,7 @@
          il_dim(:)=td_var%t_dim(:)%i_len
 
-         CALL logger_info("GRID GET PERIO: use varibale "//TRIM(td_var%c_name))
-         CALL logger_info("GRID GET PERIO: fill value "//TRIM(fct_str(td_var%d_fill)))
-         CALL logger_info("GRID GET PERIO: fill value "//TRIM(fct_str(td_var%d_value(1,1,1,1))))
+         CALL logger_debug("GRID GET PERIO: use varibale "//TRIM(td_var%c_name))
+         CALL logger_debug("GRID GET PERIO: fill value "//TRIM(fct_str(td_var%d_fill)))
+         CALL logger_debug("GRID GET PERIO: first value "//TRIM(fct_str(td_var%d_value(1,1,1,1))))
 
          IF(ALL(td_var%d_value(    1    ,    :    ,1,1)/=td_var%d_fill).AND.&
@@ -1344,7 +1350,18 @@
          &  ALL(td_var%d_value(    :    ,il_dim(2),1,1)/=td_var%d_fill))THEN
          ! no boundary closed
-            CALL logger_warn("GRID GET PERIO: can't determined periodicity. "//&
+            CALL logger_error("GRID GET PERIO: can't determined periodicity. "//&
             &             "there is no boundary closed for variable "//&
             &              TRIM(td_var%c_name) )
+            ! check pivot
+            SELECT CASE(id_pivot)
+               CASE(0)
+                  ! F pivot
+                  CALL logger_warn("GRID GET PERIO: assume domain is global")
+                  grid__get_perio_var=6
+               CASE(1)
+                  ! T pivot
+                  CALL logger_warn("GRID GET PERIO: assume domain is global")
+                  grid__get_perio_var=4
+            END SELECT
          ELSE
             ! check periodicity
@@ -2287,5 +2304,4 @@
          &                                                    il_rho(:), cl_point )
 
-         
          CALL var_clean(tl_lon1)
          CALL var_clean(tl_lat1)         
@@ -2463,4 +2479,7 @@
    !> - check grid point
    !> - take into account EW overlap
+   !> @date February, 2016
+   !> - use delta (lon or lat)
+   !> - manage cases for T,U,V or F point, with even or odd refinment
    !>
    !> @param[in] td_lon0   coarse grid longitude
@@ -2490,54 +2509,49 @@
 
       ! local variable
-      REAL(dp)    :: dl_lon1_ll
-      REAL(dp)    :: dl_lon1_ul
-      REAL(dp)    :: dl_lon1_lr
-      REAL(dp)    :: dl_lon1_ur
-
-      REAL(dp)    :: dl_lat1_ll
-      REAL(dp)    :: dl_lat1_ul
-      REAL(dp)    :: dl_lat1_lr
-      REAL(dp)    :: dl_lat1_ur
+      CHARACTER(LEN= 1)                      :: cl_point0
+      CHARACTER(LEN= 1)                      :: cl_point1
+
+      LOGICAL    , DIMENSION(2)              :: ll_even
+
+      REAL(dp)                               :: dl_lon1
+      REAL(dp)                               :: dl_dlon
+      REAL(dp)                               :: dl_lat1
+      REAL(dp)                               :: dl_dlat
+
+      INTEGER(i4)                            :: il_ew0 
+      INTEGER(i4)                            :: il_imin0
+      INTEGER(i4)                            :: il_imax0
+      INTEGER(i4)                            :: il_jmin0
+      INTEGER(i4)                            :: il_jmax0
+
+      INTEGER(i4)                            :: il_ew1 
+      INTEGER(i4)                            :: il_imin1
+      INTEGER(i4)                            :: il_imax1
+      INTEGER(i4)                            :: il_jmin1
+      INTEGER(i4)                            :: il_jmax1
+
+      INTEGER(i4)                            :: il_imin
+      INTEGER(i4)                            :: il_imax
+      INTEGER(i4)                            :: il_jmin
+      INTEGER(i4)                            :: il_jmax      
 
       INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_rho
 
-      INTEGER(i4), DIMENSION(2) :: il_ill
-      INTEGER(i4), DIMENSION(2) :: il_ilr
-      INTEGER(i4), DIMENSION(2) :: il_iul
-      INTEGER(i4), DIMENSION(2) :: il_iur
-
-      INTEGER(i4) :: il_ew0 
-      INTEGER(i4) :: il_imin0
-      INTEGER(i4) :: il_imax0
-      INTEGER(i4) :: il_jmin0
-      INTEGER(i4) :: il_jmax0
-
-      INTEGER(i4) :: il_ew1 
-      INTEGER(i4) :: il_imin1
-      INTEGER(i4) :: il_imax1
-      INTEGER(i4) :: il_jmin1
-      INTEGER(i4) :: il_jmax1
-
-      INTEGER(i4) :: il_imin
-      INTEGER(i4) :: il_imax
-      INTEGER(i4) :: il_jmin
-      INTEGER(i4) :: il_jmax      
-
-      INTEGER(i4), DIMENSION(2,2) :: il_xghost0
-      INTEGER(i4), DIMENSION(2,2) :: il_yghost0
-      INTEGER(i4), DIMENSION(2,2) :: il_xghost1
-      INTEGER(i4), DIMENSION(2,2) :: il_yghost1
-
-      TYPE(TVAR) :: tl_lon0
-      TYPE(TVAR) :: tl_lat0
-      TYPE(TVAR) :: tl_lon1
-      TYPE(TVAR) :: tl_lat1
-
-      CHARACTER(LEN= 1) :: cl_point0
-      CHARACTER(LEN= 1) :: cl_point1
-      
+      INTEGER(i4), DIMENSION(2)              :: il_ill
+      INTEGER(i4), DIMENSION(2)              :: il_ilr
+      INTEGER(i4), DIMENSION(2)              :: il_iul
+      INTEGER(i4), DIMENSION(2)              :: il_iur
+
+      INTEGER(i4), DIMENSION(2,2)            :: il_xghost0
+      INTEGER(i4), DIMENSION(2,2)            :: il_yghost0
+      INTEGER(i4), DIMENSION(2,2)            :: il_xghost1
+      INTEGER(i4), DIMENSION(2,2)            :: il_yghost1
+
+      TYPE(TVAR)                             :: tl_lon0
+      TYPE(TVAR)                             :: tl_lat0
+      TYPE(TVAR)                             :: tl_lon1
+      TYPE(TVAR)                             :: tl_lat1
+
       ! loop indices
-      INTEGER(i4) :: ji
-      INTEGER(i4) :: jj
       !----------------------------------------------------------------
       ! init
@@ -2547,4 +2561,6 @@
       il_rho(:)=1
       IF( PRESENT(id_rho) ) il_rho(:)=id_rho(:)
+
+      ll_even(:)=(/ (MOD(id_rho(jp_I),2)==0), (MOD(id_rho(jp_J),2)==0) /)
 
       cl_point0='T'
@@ -2645,19 +2661,53 @@
             ! get indices for each corner
             !1- search lower left corner indices
-            dl_lon1_ll=tl_lon1%d_value( il_imin1, il_jmin1, 1, 1 )
-            dl_lat1_ll=tl_lat1%d_value( il_imin1, il_jmin1, 1, 1 )
-
-            IF( dl_lon1_ll == tl_lon1%d_fill .OR. &
-            &   dl_lat1_ll == tl_lat1%d_fill )THEN
-               CALL logger_debug("GRID GET COARSE INDEX: lon "//&
-               &  TRIM(fct_str(dl_lon1_ll))//" "//&
-               &  TRIM(fct_str(tl_lon1%d_fill)) )
-               CALL logger_debug("GRID GET COARSE INDEX: lat "//&
-               &  TRIM(fct_str(dl_lat1_ll))//" "//&
-               &  TRIM(fct_str(tl_lat1%d_fill)) )
+            dl_lon1=tl_lon1%d_value( il_imin1, il_jmin1, 1, 1 )
+            dl_lat1=tl_lat1%d_value( il_imin1, il_jmin1, 1, 1 )
+
+            IF( dl_lon1 == tl_lon1%d_fill .OR. &
+            &   dl_lat1 == tl_lat1%d_fill )THEN
                CALL logger_error("GRID GET COARSE INDEX: lower left corner "//&
                &                 "point is FillValue. remove ghost cell "//&
                &                 "before running grid_get_coarse_index.")
             ENDIF
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','U')
+                     dl_dlon= ( tl_lon1%d_value(il_imin1+1,il_jmin1,1,1) -   &
+                        &       tl_lon1%d_value(il_imin1  ,il_jmin1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( tl_lon1%d_value(il_imin1+1,il_jmin1,1,1) -   &
+                  &       tl_lon1%d_value(il_imin1  ,il_jmin1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','V')
+                     dl_dlat= ( tl_lat1%d_value(il_imin1,il_jmin1+1,1,1) -   &
+                        &       tl_lat1%d_value(il_imin1,il_jmin1  ,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( tl_lat1%d_value(il_imin1,il_jmin1+1,1,1) -   &
+                  &       tl_lat1%d_value(il_imin1,il_jmin1  ,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            dl_lon1 = dl_lon1 + dl_dlon
+            dl_lat1 = dl_lat1 + dl_dlat
+
             ! look for closest point on coarse grid
             il_ill(:)= grid_get_closest(tl_lon0%d_value(il_imin0:il_imax0, &
@@ -2667,45 +2717,57 @@
             &                                           il_jmin0:il_jmax0, &
             &                                           1,1), &
-            &                           dl_lon1_ll, dl_lat1_ll   )
-
-            ! coarse grid point should be south west of fine grid domain
-            ji = il_ill(1)
-            jj = il_ill(2)
-
-            IF( ABS(tl_lon0%d_value(ji,jj,1,1)-dl_lon1_ll) > dp_delta )THEN
-               IF(tl_lon0%d_value(ji,jj,1,1) > dl_lon1_ll )THEN
-                  il_ill(1)=il_ill(1)-1
-                  IF( il_ill(1) <= 0 )THEN
-                     IF( tl_lon0%i_ew >= 0 )THEN
-                        il_ill(1)=tl_lon0%t_dim(jp_I)%i_len-tl_lon0%i_ew
-                     ELSE
-                        CALL logger_error("GRID GET COARSE INDEX: error "//&
-                        &                 "computing lower left corner "//&
-                        &                 "index for longitude")
-                     ENDIF
-                  ENDIF
-               ENDIF
-            ENDIF
-            IF( ABS(tl_lat0%d_value(ji,jj,1,1)-dl_lat1_ll) > dp_delta )THEN
-               IF(tl_lat0%d_value(ji,jj,1,1) > dl_lat1_ll )THEN
-                  il_ill(2)=il_ill(2)-1
-                  IF( il_ill(2)-1 <= 0 )THEN
-                     CALL logger_error("GRID GET COARSE INDEX: error "//&
-                     &                 "computing lower left corner "//&
-                     &                 "index for latitude")
-                  ENDIF
-               ENDIF
-            ENDIF
+            &                           dl_lon1, dl_lat1, 'll'   )
+
 
             !2- search upper left corner indices
-            dl_lon1_ul=tl_lon1%d_value( il_imin1, il_jmax1, 1, 1 )
-            dl_lat1_ul=tl_lat1%d_value( il_imin1, il_jmax1, 1, 1 )
-
-            IF( dl_lon1_ul == tl_lon1%d_fill .OR. &
-            &   dl_lat1_ul == tl_lat1%d_fill )THEN
+            dl_lon1=tl_lon1%d_value( il_imin1, il_jmax1, 1, 1 )
+            dl_lat1=tl_lat1%d_value( il_imin1, il_jmax1, 1, 1 )
+
+            IF( dl_lon1 == tl_lon1%d_fill .OR. &
+            &   dl_lat1 == tl_lat1%d_fill )THEN
                CALL logger_error("GRID GET COARSE INDEX: upper left corner "//&
                &                 "point is FillValue. remove ghost cell "//&
                &                 "running grid_get_coarse_index.")
             ENDIF            
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','U')
+                     dl_dlon= ( tl_lon1%d_value(il_imin1+1,il_jmax1,1,1) -   &
+                        &       tl_lon1%d_value(il_imin1  ,il_jmax1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( tl_lon1%d_value(il_imin1+1,il_jmax1,1,1) -   &
+                  &       tl_lon1%d_value(il_imin1  ,il_jmax1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','V')
+                     dl_dlat= ( tl_lat1%d_value(il_imin1,il_jmax1  ,1,1) -   &
+                        &       tl_lat1%d_value(il_imin1,il_jmax1-1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( tl_lat1%d_value(il_imin1,il_jmax1  ,1,1) -   &
+                  &       tl_lat1%d_value(il_imin1,il_jmax1-1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            dl_lon1 = dl_lon1 + dl_dlon
+            dl_lat1 = dl_lat1 - dl_dlat
+
             ! look for closest point on coarse grid
             il_iul(:)= grid_get_closest(tl_lon0%d_value(il_imin0:il_imax0, &
@@ -2715,44 +2777,56 @@
             &                                           il_jmin0:il_jmax0, &
             &                                           1,1), &
-            &                           dl_lon1_ul, dl_lat1_ul   )
-
-            ! coarse grid point should be north west of fine grid domain
-            ji = il_iul(1)
-            jj = il_iul(2)
-            IF( ABS(tl_lon0%d_value(ji,jj,1,1)-dl_lon1_ul) > dp_delta )THEN
-               IF(tl_lon0%d_value(ji,jj,1,1) > dl_lon1_ul )THEN
-                  il_iul(1)=il_iul(1)-1
-                  IF( il_iul(1) <= 0 )THEN
-                     IF( tl_lon0%i_ew >= 0 )THEN
-                        il_iul(1)=tl_lon0%t_dim(jp_I)%i_len-tl_lon0%i_ew
-                     ELSE
-                        CALL logger_error("GRID GET COARSE INDEX: error "//&
-                        &                 "computing upper left corner "//&
-                        &                 "index for longitude")
-                     ENDIF
-                  ENDIF
-               ENDIF
-            ENDIF
-            IF( ABS(tl_lat0%d_value(ji,jj,1,1)-dl_lat1_ul) > dp_delta )THEN
-               IF(tl_lat0%d_value(ji,jj,1,1) < dl_lat1_ul )THEN
-                  il_iul(2)=il_iul(2)+1
-                  IF( il_ill(2) > tl_lat0%t_dim(jp_J)%i_len )THEN
-                     CALL logger_error("GRID GET COARSE INDEX: error "//&
-                     &                 "computing upper left corner "//&
-                     &                 "index for latitude")
-                  ENDIF
-               ENDIF
-            ENDIF
+            &                           dl_lon1, dl_lat1, 'ul' )
 
             !3- search lower right corner indices
-            dl_lon1_lr=tl_lon1%d_value( il_imax1, il_jmin1, 1, 1 )
-            dl_lat1_lr=tl_lat1%d_value( il_imax1, il_jmin1, 1, 1 )
-
-            IF( dl_lon1_lr == tl_lon1%d_fill .OR. &
-            &   dl_lat1_lr == tl_lat1%d_fill )THEN
+            dl_lon1=tl_lon1%d_value( il_imax1, il_jmin1, 1, 1 )
+            dl_lat1=tl_lat1%d_value( il_imax1, il_jmin1, 1, 1 )
+
+            IF( dl_lon1 == tl_lon1%d_fill .OR. &
+            &   dl_lat1 == tl_lat1%d_fill )THEN
                CALL logger_error("GRID GET COARSE INDEX: lower right corner "//&
                &                 "point is FillValue. remove ghost cell "//&
                &                 "running grid_get_coarse_index.")
             ENDIF            
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','U')
+                     dl_dlon= ( tl_lon1%d_value(il_imax1  ,il_jmin1,1,1) -   &
+                        &       tl_lon1%d_value(il_imax1-1,il_jmin1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( tl_lon1%d_value(il_imax1  ,il_jmin1,1,1) -   &
+                  &       tl_lon1%d_value(il_imax1-1,il_jmin1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','V')
+                     dl_dlat= ( tl_lat1%d_value(il_imax1,il_jmin1+1,1,1) -   &
+                        &       tl_lat1%d_value(il_imax1,il_jmin1  ,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( tl_lat1%d_value(il_imax1,il_jmin1+1,1,1) -   &
+                  &       tl_lat1%d_value(il_imax1,il_jmin1  ,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            dl_lon1 = dl_lon1 - dl_dlon
+            dl_lat1 = dl_lat1 + dl_dlat
+
             ! look for closest point on coarse grid
             il_ilr(:)= grid_get_closest(tl_lon0%d_value(il_imin0:il_imax0, &
@@ -2762,44 +2836,56 @@
             &                                           il_jmin0:il_jmax0, &
             &                                           1,1), &
-            &                           dl_lon1_lr, dl_lat1_lr   )
-
-            ! coarse grid point should be south east of fine grid domain
-            ji = il_ilr(1)
-            jj = il_ilr(2)
-            IF( ABS(tl_lon0%d_value(ji,jj,1,1)-dl_lon1_lr) > dp_delta )THEN
-               IF( tl_lon0%d_value(ji,jj,1,1) < dl_lon1_lr )THEN
-                  il_ilr(1)=il_ilr(1)+1
-                  IF( il_ilr(1) > tl_lon0%t_dim(jp_I)%i_len )THEN
-                     IF( tl_lon0%i_ew >= 0 )THEN
-                        il_ilr(1)=tl_lon0%i_ew+1
-                     ELSE
-                        CALL logger_error("GRID GET COARSE INDEX: error "//&
-                        &                 "computing lower right corner "//&
-                        &                 "index for longitude")
-                     ENDIF
-                  ENDIF
-               ENDIF
-            ENDIF
-            IF( ABS(tl_lat0%d_value(ji,jj,1,1)-dl_lat1_lr) > dp_delta )THEN
-               IF( tl_lat0%d_value(ji,jj,1,1) > dl_lat1_lr )THEN
-                  il_ilr(2)=il_ilr(2)-1
-                  IF( il_ilr(2) <= 0 )THEN
-                     CALL logger_error("GRID GET COARSE INDEX: error "//&
-                     &                 "computing lower right corner "//&
-                     &                 "index for latitude")
-                  ENDIF
-               ENDIF
-            ENDIF
+            &                           dl_lon1, dl_lat1, 'lr' )
 
             !4- search upper right corner indices
-            dl_lon1_ur=tl_lon1%d_value( il_imax1, il_jmax1, 1, 1 )
-            dl_lat1_ur=tl_lat1%d_value( il_imax1, il_jmax1, 1, 1 )
-
-            IF( dl_lon1_ur == tl_lon1%d_fill .OR. &
-            &   dl_lat1_ur == tl_lat1%d_fill )THEN
+            dl_lon1=tl_lon1%d_value( il_imax1, il_jmax1, 1, 1 )
+            dl_lat1=tl_lat1%d_value( il_imax1, il_jmax1, 1, 1 )
+
+            IF( dl_lon1 == tl_lon1%d_fill .OR. &
+            &   dl_lat1 == tl_lat1%d_fill )THEN
                CALL logger_error("GRID GET COARSE INDEX: upper right corner "//&
                &                 "point is FillValue. remove ghost cell "//&
-               &                 "running grid_get_coarse_index.")
+               &                 "before running grid_get_coarse_index.")
             ENDIF            
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','U')
+                     dl_dlon= ( tl_lon1%d_value(il_imax1  ,il_jmax1,1,1) -   &
+                        &       tl_lon1%d_value(il_imax1-1,il_jmax1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( tl_lon1%d_value(il_imax1  ,il_jmax1,1,1) -   &
+                  &       tl_lon1%d_value(il_imax1-1,il_jmax1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point1))
+                  CASE('F','V')
+                     dl_dlat= ( tl_lat1%d_value(il_imax1,il_jmax1  ,1,1) -   &
+                        &       tl_lat1%d_value(il_imax1,il_jmax1-1,1,1) ) / &
+                        &     2.
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( tl_lat1%d_value(il_imax1,il_jmax1  ,1,1) -   &
+                  &       tl_lat1%d_value(il_imax1,il_jmax1-1,1,1) ) / &
+                  &     2.
+            ENDIF
+
+            dl_lon1 = dl_lon1 - dl_dlon
+            dl_lat1 = dl_lat1 - dl_dlat
+
             ! look for closest point on coarse grid
             il_iur(:)= grid_get_closest(tl_lon0%d_value(il_imin0:il_imax0, &
@@ -2809,33 +2895,5 @@
             &                                           il_jmin0:il_jmax0, &
             &                                           1,1), &
-            &                           dl_lon1_ur, dl_lat1_ur   )
-
-            ! coarse grid point should be north east fine grid domain
-            ji = il_iur(1)
-            jj = il_iur(2)
-            IF( ABS(tl_lon0%d_value(ji,jj,1,1)-dl_lon1_ur) > dp_delta )THEN
-               IF( tl_lon0%d_value(ji,jj,1,1) < dl_lon1_ur )THEN
-                  il_iur(1)=il_iur(1)+1
-                  IF( il_iur(1) > tl_lon0%t_dim(jp_I)%i_len )THEN
-                     IF( tl_lon0%i_ew >= 0 )THEN
-                        il_iur(1)=tl_lon0%i_ew+1
-                     ELSE
-                        CALL logger_error("GRID GET COARSE INDEX: error "//&
-                        &                 "computing upper right corner "//&
-                        &                 "index for longitude")
-                     ENDIF
-                  ENDIF
-               ENDIF
-            ENDIF
-            IF( ABS(tl_lat0%d_value(ji,jj,1,1)-dl_lat1_ur) > dp_delta )THEN
-               IF( tl_lat0%d_value(ji,jj,1,1) < dl_lat1_ur )THEN
-                  il_iur(2)=il_iur(2)+1
-                  IF( il_iur(2) > tl_lat0%t_dim(jp_J)%i_len )THEN
-                     CALL logger_error("GRID GET COARSE INDEX: error "//&
-                     &                 "computing upper right corner "//&
-                     &                 "index for latitude")
-                  ENDIF
-               ENDIF
-            ENDIF
+            &                           dl_lon1, dl_lat1, 'ur' )
 
             ! coarse grid indices
@@ -2943,6 +3001,6 @@
    END FUNCTION grid_is_global
    !-------------------------------------------------------------------
-   !> @brief This function return coarse grid indices of the closest point
-   !> from fine grid point (lon1,lat1) 
+   !> @brief This function return grid indices of the closest point
+   !> from point (lon1,lat1) 
    !> 
    !> @details
@@ -2951,7 +3009,20 @@
    !> of longitude and latitude, before running this function
    !>
+   !> if you add cd_pos argument, you could choice to return closest point at
+   !> - lower left  (ll) of the point
+   !> - lower right (lr) of the point
+   !> - upper left  (ul) of the point
+   !> - upper right (ur) of the point
+   !> - lower       (lo) of the point
+   !> - upper       (up) of the point
+   !> -       left  (le) of the point
+   !> -       right (ri) of the point
+   !>
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !> @date February, 2015 - change dichotomy method to manage ORCA grid
+   !> @date February, 2015
+   !> - change dichotomy method to manage ORCA grid
+   !> @date February, 2016
+   !> - add optional use of relative position
    !
    !> @param[in] dd_lon0   coarse grid array of longitude
@@ -2959,8 +3030,9 @@
    !> @param[in] dd_lon1   fine   grid longitude
    !> @param[in] dd_lat1   fine   grid latitude
+   !> @param[in] cd_pos    relative position of grid point from point 
    !> @param[in] dd_fill   fill value
    !> @return coarse grid indices of closest point of fine grid point
    !-------------------------------------------------------------------
-   FUNCTION grid_get_closest( dd_lon0, dd_lat0, dd_lon1, dd_lat1, dd_fill )
+   FUNCTION grid_get_closest( dd_lon0, dd_lat0, dd_lon1, dd_lat1, cd_pos, dd_fill )
       IMPLICIT NONE
       ! Argument
@@ -2969,4 +3041,5 @@
       REAL(dp),                 INTENT(IN) :: dd_lon1
       REAL(dp),                 INTENT(IN) :: dd_lat1
+      CHARACTER(LEN=*),         INTENT(IN), OPTIONAL :: cd_pos
       REAL(dp),                 INTENT(IN), OPTIONAL :: dd_fill
 
@@ -3147,4 +3220,45 @@
       &                          dl_lon1, dd_lat1 )
 
+      IF( PRESENT(cd_pos) )THEN
+         ! 
+         SELECT CASE(TRIM(cd_pos))
+            CASE('le')
+               WHERE( dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) > dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+            CASE('ri')
+               WHERE( dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) < dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+            CASE('up')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) < dl_lon1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+            CASE('lo')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) > dl_lon1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+            CASE('ll')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) > dl_lon1 .OR. &
+                    & dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) > dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+            CASE('lr')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) < dl_lon1 .OR. &
+                    & dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) > dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE               
+            CASE('ul')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) > dl_lon1 .OR. &
+                    & dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) < dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE               
+            CASE('ur')
+               WHERE( dl_lon0(il_iinf:il_isup,il_jinf:il_jsup) < dl_lon1 .OR. &
+                    & dd_lat0(il_iinf:il_isup,il_jinf:il_jsup) < dd_lat1 )
+                  dl_dist(:,:)=NF90_FILL_DOUBLE
+               END WHERE
+         END SELECT
+      ENDIF
       grid_get_closest(:)=MINLOC(dl_dist(:,:),dl_dist(:,:)/=NF90_FILL_DOUBLE)
 
@@ -3443,5 +3557,5 @@
          &                                         il_imax0, il_jmax0, &
          &                                         dl_lon1(:,:), dl_lat1(:,:),&
-         &                                         id_rho(:) )
+         &                                         id_rho(:), cl_point )
  
          DEALLOCATE(dl_lon0, dl_lat0)
@@ -3588,5 +3702,5 @@
          &                                         id_imax0, id_jmax0, &
          &                                         dl_lon1(:,:), dl_lat1(:,:),&
-         &                                         id_rho(:) )
+         &                                         id_rho(:), cl_point )
          
          DEALLOCATE(dl_lon1, dl_lat1)
@@ -3668,5 +3782,4 @@
       ! init
       grid__get_fine_offset_fc(:,:)=-1
-
       ALLOCATE(il_rho(ip_maxdim))
       il_rho(:)=1
@@ -3690,5 +3803,5 @@
          CALL iom_mpp_open(tl_coord0)
 
-         ! read coarse longitue and latitude
+         ! read coarse longitude and latitude
          WRITE(cl_name,*) 'longitude_'//TRIM(cl_point)
          il_ind=var_get_id(tl_coord0%t_proc(1)%t_var(:), cl_name)
@@ -3710,5 +3823,5 @@
          ENDIF
          tl_lat0=iom_mpp_read_var(tl_coord0, TRIM(cl_name))
-         
+ 
          ! close mpp files
          CALL iom_mpp_close(tl_coord0)
@@ -3716,4 +3829,5 @@
          CALL grid_del_ghost(tl_lon0, il_xghost0(:,:))
          CALL grid_del_ghost(tl_lat0, il_xghost0(:,:))
+
 
          ALLOCATE(dl_lon0(tl_lon0%t_dim(jp_I)%i_len, &
@@ -3738,5 +3852,4 @@
          il_jmax0=id_jmax0-il_xghost0(jp_J,1)
 
-      
          !3- compute
          grid__get_fine_offset_fc(:,:)=grid_get_fine_offset(&
@@ -3745,5 +3858,5 @@
          &                                         il_imax0, il_jmax0, &
          &                                         dd_lon1(:,:), dd_lat1(:,:),&
-         &                                         id_rho(:) )
+         &                                         id_rho(:), cl_point )
          
          DEALLOCATE(dl_lon0, dl_lat0)
@@ -3767,4 +3880,14 @@
    !> @date May, 2015 
    !> - improve way to find offset
+   !> @date July, 2015
+   !> - manage case close to greenwich meridian
+   !> @date February, 2016
+   !> - use grid_get_closest to assess offset
+   !> - use delta (lon or lat)
+   !> - manage cases for T,U,V or F point, with even or odd refinment
+   !> - check lower left(upper right) fine grid point inside lower left(upper
+   !> right) coarse grid cell.
+   !> 
+   !> @todo check case close from North fold.
    !>
    !> @param[in] dd_lon0   coarse grid longitude array 
@@ -3777,22 +3900,24 @@
    !> @param[in] dd_lat1   fine   grid latitude  array
    !> @param[in] id_rho    array of refinement factor
+   !> @param[in] cd_point  Arakawa grid point
    !> @return offset array (/ (/i_offset_left,i_offset_right/),(/j_offset_lower,j_offset_upper/) /)
    !-------------------------------------------------------------------
    FUNCTION grid__get_fine_offset_cc( dd_lon0, dd_lat0, &
    &                                  id_imin0, id_jmin0, id_imax0, id_jmax0, &
-   &                                  dd_lon1, dd_lat1, id_rho )
+   &                                  dd_lon1, dd_lat1, id_rho, cd_point )
       IMPLICIT NONE
       ! Argument
-      REAL(dp)   , DIMENSION(:,:), INTENT(IN) :: dd_lon0
-      REAL(dp)   , DIMENSION(:,:), INTENT(IN) :: dd_lat0
-      REAL(dp)   , DIMENSION(:,:), INTENT(IN) :: dd_lon1
-      REAL(dp)   , DIMENSION(:,:), INTENT(IN) :: dd_lat1
-
-      INTEGER(i4),                 INTENT(IN) :: id_imin0
-      INTEGER(i4),                 INTENT(IN) :: id_jmin0
-      INTEGER(i4),                 INTENT(IN) :: id_imax0
-      INTEGER(i4),                 INTENT(IN) :: id_jmax0
-
-      INTEGER(i4), DIMENSION(:)  , INTENT(IN) :: id_rho
+      REAL(dp)        , DIMENSION(:,:), INTENT(IN) :: dd_lon0
+      REAL(dp)        , DIMENSION(:,:), INTENT(IN) :: dd_lat0
+      REAL(dp)        , DIMENSION(:,:), INTENT(IN) :: dd_lon1
+      REAL(dp)        , DIMENSION(:,:), INTENT(IN) :: dd_lat1
+
+      INTEGER(i4)     ,                 INTENT(IN) :: id_imin0
+      INTEGER(i4)     ,                 INTENT(IN) :: id_jmin0
+      INTEGER(i4)     ,                 INTENT(IN) :: id_imax0
+      INTEGER(i4)     ,                 INTENT(IN) :: id_jmax0
+
+      INTEGER(i4)     , DIMENSION(:)  , INTENT(IN) :: id_rho
+      CHARACTER(LEN=*)                , INTENT(IN), OPTIONAL :: cd_point
 
       ! function
@@ -3800,17 +3925,33 @@
 
       ! local variable
+      CHARACTER(LEN= 1)                        :: cl_point
+
+      INTEGER(i4)                              :: i1
+      INTEGER(i4)                              :: i2
+      INTEGER(i4)                              :: j1
+      INTEGER(i4)                              :: j2
+
       INTEGER(i4), DIMENSION(2)                :: il_shape0
       INTEGER(i4), DIMENSION(2)                :: il_shape1
 
+      INTEGER(i4), DIMENSION(2)                :: il_ind
+
       REAL(dp)   , DIMENSION(:,:), ALLOCATABLE :: dl_lon0
       REAL(dp)   , DIMENSION(:,:), ALLOCATABLE :: dl_lon1
 
-      LOGICAL                                  :: ll_ii
-      LOGICAL                                  :: ll_ij
+      REAL(dp)                                 :: dl_lonmax0
+      REAL(dp)                                 :: dl_latmax0
+      REAL(dp)                                 :: dl_lonmin0
+      REAL(dp)                                 :: dl_latmin0
+
+      REAL(dp)                                 :: dl_lon0F
+      REAL(dp)                                 :: dl_lat0F
+      REAL(dp)                                 :: dl_dlon
+      REAL(dp)                                 :: dl_dlat
+
+      LOGICAL    , DIMENSION(2)                :: ll_even
+      LOGICAL                                  :: ll_greenwich
       
       ! loop indices
-      INTEGER(i4) :: ji
-      INTEGER(i4) :: jj
-
       INTEGER(i4) :: ii
       INTEGER(i4) :: ij
@@ -3824,50 +3965,196 @@
          CALL logger_fatal("GRID GET FINE OFFSET: dimension of fine "//&
          &              "longitude and latitude differ")
-      ENDIF      
+      ENDIF
+
+      ll_even(:)=(/ (MOD(id_rho(jp_I),2)==0), (MOD(id_rho(jp_J),2)==0) /)
+
+      cl_point='T'
+      IF( PRESENT(cd_point) ) cl_point=TRIM(fct_upper(cd_point))
 
       il_shape0(:)=SHAPE(dd_lon0(:,:))
       ALLOCATE( dl_lon0(il_shape0(1),il_shape0(2)) )
 
+      il_shape1(:)=SHAPE(dd_lon1(:,:))
+      ALLOCATE( dl_lon1(il_shape1(1),il_shape1(2)) )
+
       dl_lon0(:,:)=dd_lon0(:,:)
       WHERE( dd_lon0(:,:) < 0 ) dl_lon0(:,:)=dd_lon0(:,:)+360.
 
-      il_shape1(:)=SHAPE(dd_lon1(:,:))
-      ALLOCATE( dl_lon1(il_shape1(1),il_shape1(2)) )
-
       dl_lon1(:,:)=dd_lon1(:,:)
-      WHERE( dd_lon1(:,:) < 0 ) dl_lon1(:,:)=dd_lon1(:,:)+360.         
+      WHERE( dd_lon1(:,:) < 0 ) dl_lon1(:,:)=dd_lon1(:,:)+360.
 
       ! init
       grid__get_fine_offset_cc(:,:)=-1
+      ll_greenwich=.FALSE.
 
       IF( il_shape1(jp_J) == 1 )THEN
-          
+ 
          grid__get_fine_offset_cc(jp_J,:)=((id_rho(jp_J)-1)/2)
 
-         ! work on i-direction
-         ! look for i-direction left offset
-         IF( dl_lon1(1,1) < dl_lon0(id_imin0+1,id_jmin0) )THEN
-            DO ji=1,id_rho(jp_I)+2
-               IF( dl_lon1(ji,1) > dl_lon0(id_imin0+1,id_jmin0) - dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ji
-                  EXIT
-               ENDIF
-            ENDDO
+         !!! work on i-direction
+         !!! look for i-direction left offset
+         i1=1 ; i2=MIN((id_rho(jp_I)+2),il_shape1(jp_I))
+         j1=1 ; j2=1
+
+         ! check if cross greenwich meridien
+         IF( minval(dl_lon0(id_imin0:id_imin0+1,id_jmin0))<5. .OR. &
+           & maxval(dl_lon0(id_imin0:id_imin0+1,id_jmin0))>355. )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.TRUE.
+            ! 0:360 => -180:180
+            WHERE( dl_lon0(id_imin0:id_imin0+1,id_jmin0) > 180. )
+               dl_lon0(id_imin0:id_imin0+1,id_jmin0) = &
+                  & dl_lon0(id_imin0:id_imin0+1,id_jmin0)-360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) > 180. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)-360.
+            END WHERE
+         ENDIF
+
+         ! max lognitude of the left cell
+         dl_lonmax0=dl_lon0(id_imin0+1,id_jmin0)
+         IF( dl_lon1(1,1) < dl_lonmax0 )THEN
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','U')
+                     dl_dlon= ( dl_lon0(id_imin0+1,id_jmin0) -   &
+                        &       dl_lon0(id_imin0  ,id_jmin0) ) / &
+                        &     ( 2.*id_rho(jp_I) )
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( dl_lon0(id_imin0+1,id_jmin0) -   &
+                  &       dl_lon0(id_imin0  ,id_jmin0) ) / &
+                  &     ( 2.*id_rho(jp_I) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imin0+1,id_jmin0) + dl_dlon
+            dl_lat0F= dd_lat0(id_imin0+1,id_jmin0)
+
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'le' )
+      
+            ii=il_ind(1)
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','V')
+                     grid__get_fine_offset_cc(jp_I,1)=id_rho(jp_I)-ii
+                  CASE DEFAULT !'F','U' 
+                     grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+            ENDIF
+
          ELSE
             CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
-            &                 " not match fine grid lower left corner.")
-         ENDIF
-         ! look for i-direction right offset
-         IF( dl_lon1(il_shape1(jp_I),1) > dl_lon0(id_imax0-1,id_jmin0) )THEN
-            DO ji=1,id_rho(jp_I)+2
-               ii=il_shape1(jp_I)-ji+1
-               IF( dl_lon1(ii,1) < dl_lon0(id_imax0-1,id_jmin0) + dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-ji
-                  EXIT
-               ENDIF
-            ENDDO
+            &                 " not match fine grid left corner.")
+         ENDIF
+
+         IF( ll_greenwich )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.FALSE.
+            ! -180:180 => 0:360
+            WHERE( dl_lon0(id_imin0:id_imin0+1,id_jmin0) < 0. )
+               dl_lon0(id_imin0:id_imin0+1,id_jmin0) = &
+                  & dl_lon0(id_imin0:id_imin0+1,id_jmin0)+360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) < 0. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)+360.
+            END WHERE
+         ENDIF
+
+         !!!!!! look for i-direction right offset !!!!!!
+         i1=MAX(1,il_shape1(jp_I)-(id_rho(jp_I)+2)+1) ; i2=il_shape1(jp_I)
+         j1=1                                         ; j2=1
+
+         ! check if cross greenwich meridien
+         IF( minval(dl_lon0(id_imax0-1:id_imax0,id_jmin0))<5. .OR. &
+           & maxval(dl_lon0(id_imax0-1:id_imax0,id_jmin0))>355. )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.TRUE.
+            ! 0:360 => -180:180
+            WHERE( dl_lon0(id_imax0-1:id_imax0,id_jmin0) > 180. )
+               dl_lon0(id_imax0-1:id_imax0,id_jmin0) = &
+                  & dl_lon0(id_imax0-1:id_imax0,id_jmin0)-360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) > 180. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)-360.
+            END WHERE
+         ENDIF
+
+         ! min lognitude of the right cell
+         dl_lonmin0=dl_lon0(id_imax0-1,id_jmin0)
+         IF( dl_lon1(il_shape1(jp_I),il_shape1(jp_J)) > dl_lonmin0 )THEN
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','U')
+                     dl_dlon= ( dl_lon0(id_imax0  ,id_jmin0) -   &
+                        &       dl_lon0(id_imax0-1,id_jmin0) ) / &
+                        &     ( 2.*id_rho(jp_I) )
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( dl_lon0(id_imax0  ,id_jmin0) -   &
+                  &       dl_lon0(id_imax0-1,id_jmin0) ) / &
+                  &     ( 2.*id_rho(jp_I) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imax0-1,id_jmin0) - dl_dlon
+            dl_lat0F= dd_lat0(id_imax0-1,id_jmin0)
+
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'ri' )
+
+            ii=(MIN(il_shape1(jp_I),(id_rho(jp_I)+2))-il_ind(1)+1)
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','V')
+                     grid__get_fine_offset_cc(jp_I,2)=id_rho(jp_I)-ii
+                  CASE DEFAULT !'F','U' 
+                     grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-ii
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-ii
+            ENDIF
+
          ELSE
             CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
-            &                 " not match fine grid lower right corner.")
+            &                 " not match fine grid right corner.")
+         ENDIF
+
+         IF( ll_greenwich )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.FALSE.
+            ! -180:180 => 0:360
+            WHERE( dl_lon0(id_imax0-1:id_imax0,id_jmin0) < 0. )
+               dl_lon0(id_imax0-1:id_imax0,id_jmin0) = &
+                  & dl_lon0(id_imax0-1:id_imax0,id_jmin0)+360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) < 0. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)+360.
+            END WHERE
          ENDIF
 
@@ -3876,106 +4163,348 @@
          grid__get_fine_offset_cc(jp_I,:)=((id_rho(jp_I)-1)/2)
          
-         ! work on j-direction
-
-         ! look for j-direction lower offset 
-         IF( dd_lat1(1,1) < dd_lat0(id_imin0,id_jmin0+1) )THEN
-            DO jj=1,id_rho(jp_J)+2
-               IF( dd_lat1(1,jj) > dd_lat0(id_imin0,id_jmin0+1) - dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_J,1)=(id_rho(jp_J)+1)-jj
-                  EXIT
-               ENDIF
-            ENDDO
+         !!! work on j-direction
+         !!! look for j-direction lower offset 
+         i1=1 ; i2=1
+         j1=1 ; j2=MIN((id_rho(jp_J)+2),il_shape1(jp_J))
+
+
+         ! max latitude of the lower cell
+         dl_latmax0=dd_lat0(id_imin0,id_jmin0+1)
+         IF( dd_lat1(1,1) < dl_latmax0 )THEN
+
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','V')
+                     dl_dlat= ( dd_lat0(id_imin0,id_jmin0+1) -   &
+                        &       dd_lat0(id_imin0,id_jmin0  ) ) / &
+                        &     ( 2.*id_rho(jp_J) )
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( dd_lat0(id_imin0,id_jmin0+1) -   &
+                  &       dd_lat0(id_imin0,id_jmin0  ) ) / &
+                  &     ( 2.*id_rho(jp_J) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imin0,id_jmin0+1)
+            dl_lat0F= dd_lat0(id_imin0,id_jmin0+1) + dl_dlat 
+            
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'lo' )
+
+            ij=il_ind(2)
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','V')
+                     grid__get_fine_offset_cc(jp_I,1)=id_rho(jp_I)-ii
+                  CASE DEFAULT !'F','U' 
+                     grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+            ENDIF
+
          ELSE
             CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
-            &                 " not match fine grid upper left corner.")
-         ENDIF
-
-         ! look for j-direction upper offset 
-         IF( dd_lat1(1,il_shape1(jp_J)) > dd_lat0(id_imin0,id_jmax0-1) )THEN
-            DO jj=1,id_rho(jp_J)+2
-               ij=il_shape1(jp_J)-jj+1
-               IF( dd_lat1(1,ij) < dd_lat0(id_imin0,id_jmax0-1) + dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-jj
-                  EXIT
-               ENDIF
-            ENDDO
+            &                 " not match fine grid lower corner.")
+         ENDIF
+
+         !!! look for j-direction upper offset 
+         i1=1                                         ; i2=1
+         j1=MAX(1,il_shape1(jp_J)-(id_rho(jp_J)+2)+1) ; j2=il_shape1(jp_J)
+
+         ! min latitude of the upper cell
+         dl_latmin0=dd_lat0(id_imin0,id_jmax0-1)
+         IF( dd_lat1(il_shape1(jp_I),il_shape1(jp_J)) > dl_latmin0 )THEN
+
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','V')
+                     dl_dlat= ( dd_lat0(id_imin0,id_jmax0  ) -   &
+                        &       dd_lat0(id_imin0,id_jmax0-1) ) / &
+                        &     ( 2.*id_rho(jp_J) )
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( dd_lat0(id_imin0,id_jmax0  ) -   &
+                  &       dd_lat0(id_imin0,id_jmax0-1) ) / &
+                  &     ( 2*id_rho(jp_J) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imin0,id_jmax0-1) 
+            dl_lat0F= dd_lat0(id_imin0,id_jmax0-1) - dl_dlat
+            
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'up' )
+
+            ij=(MIN(il_shape1(jp_J),(id_rho(jp_J)+2))-il_ind(2)+1)
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','U')
+                     grid__get_fine_offset_cc(jp_J,2)=id_rho(jp_J)-ij
+                  CASE DEFAULT !'F','V'
+                     grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-ij
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-ij
+            ENDIF
+
          ELSE
             CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
+            &                 " not match fine grid upper corner.")
+         ENDIF
+
+      ELSE ! il_shape1(1) > 1 .AND. il_shape1(2) > 1 
+
+         !!!!!! look for lower left offset !!!!!!
+         i1=1 ; i2=MIN((id_rho(jp_I)+2),il_shape1(jp_I))
+         j1=1 ; j2=MIN((id_rho(jp_J)+2),il_shape1(jp_J))
+
+         ! check if cross greenwich meridien
+         IF( minval(dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1))<5. .OR. &
+           & maxval(dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1))>355. )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.TRUE.
+            ! 0:360 => -180:180
+            WHERE( dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1) > 180. )
+               dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1) = &
+                  & dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1)-360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) > 180. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)-360.
+            END WHERE
+         ENDIF
+
+         ! max longitude of the lower left cell
+         dl_lonmax0=MAX(dl_lon0(id_imin0+1,id_jmin0),dl_lon0(id_imin0+1,id_jmin0+1))
+         ! max latitude of the lower left cell
+         dl_latmax0=MAX(dd_lat0(id_imin0,id_jmin0+1),dd_lat0(id_imin0+1,id_jmin0+1))
+         IF( dl_lon1(1,1) < dl_lonmax0 .AND. &
+           & dd_lat1(1,1) < dl_latmax0 )THEN
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','U')
+                     dl_dlon= ( dl_lon0(id_imin0+1,id_jmin0+1) -   &
+                        &       dl_lon0(id_imin0  ,id_jmin0+1) ) / &
+                        &     ( 2.*id_rho(jp_I) )
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlon= ( dl_lon0(id_imin0+1,id_jmin0+1) -   &
+                  &       dl_lon0(id_imin0  ,id_jmin0+1) ) / &
+                  &     ( 2.*id_rho(jp_I) )
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','V')
+                     dl_dlat= ( dd_lat0(id_imin0+1,id_jmin0+1) -   &
+                        &       dd_lat0(id_imin0+1,id_jmin0  ) ) / &
+                        &     ( 2.*id_rho(jp_J) )
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( dd_lat0(id_imin0+1,id_jmin0+1) -   &
+                  &       dd_lat0(id_imin0+1,id_jmin0  ) ) / &
+                  &     ( 2.*id_rho(jp_J) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imin0+1,id_jmin0+1) + dl_dlon
+            dl_lat0F= dd_lat0(id_imin0+1,id_jmin0+1) + dl_dlat
+
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'll' )
+
+            ii=il_ind(1)
+            ij=il_ind(2)
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','V')
+                     grid__get_fine_offset_cc(jp_I,1)=id_rho(jp_I)-ii
+                  CASE DEFAULT !'F','U' 
+                     grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','U')
+                     grid__get_fine_offset_cc(jp_J,1)=id_rho(jp_J)-ij
+                  CASE DEFAULT !'F','V'
+                     grid__get_fine_offset_cc(jp_J,1)=(id_rho(jp_J)+1)-ij
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_J,1)=(id_rho(jp_J)+1)-ij
+            ENDIF
+
+         ELSE
+            CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do"//&
+            &                 " not match fine grid lower left corner.")
+         ENDIF
+
+         IF( ll_greenwich )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.FALSE.
+            ! -180:180 => 0:360 
+            WHERE( dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1) < 0. )
+               dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1) = &
+                  & dl_lon0(id_imin0:id_imin0+1,id_jmin0:id_jmin0+1)+360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) < 0. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)+360.
+            END WHERE
+         ENDIF
+
+         !!!!!! look for upper right offset !!!!!!
+         i1=MAX(1,il_shape1(jp_I)-(id_rho(jp_I)+2)+1) ; i2=il_shape1(jp_I)
+         j1=MAX(1,il_shape1(jp_J)-(id_rho(jp_J)+2)+1) ; j2=il_shape1(jp_J)
+
+         ! check if cross greenwich meridien
+         IF( minval(dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0))<5. .OR. &
+           & maxval(dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0))>355. )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.TRUE.
+            ! 0:360 => -180:180
+            WHERE( dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0) > 180. )
+               dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0) = &
+                  & dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0)-360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) > 180. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)-360.
+            END WHERE
+         ENDIF
+
+         ! min latitude of the upper right cell
+         dl_lonmin0=MIN(dl_lon0(id_imax0-1,id_jmax0-1),dl_lon0(id_imax0-1,id_jmax0))
+         ! min latitude of the upper right cell
+         dl_latmin0=MIN(dd_lat0(id_imax0-1,id_jmax0-1),dd_lat0(id_imax0,id_jmax0-1))
+         IF( dl_lon1(il_shape1(jp_I),il_shape1(jp_J)) > dl_lonmin0 .AND. &
+           & dd_lat1(il_shape1(jp_I),il_shape1(jp_J)) > dl_latmin0 )THEN
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','U')
+                     dl_dlon= ( dl_lon0(id_imax0  ,id_jmax0-1) -   &
+                        &       dl_lon0(id_imax0-1,id_jmax0-1) ) / &
+                        &     ( 2.*id_rho(jp_I) )
+                  CASE DEFAULT
+                     dl_dlon=0
+               END SELECT               
+            ELSE
+               ! odd
+               dl_dlon= ( dl_lon0(id_imax0  ,id_jmax0-1) -   &
+                  &       dl_lon0(id_imax0-1,id_jmax0-1) ) / &
+                  &     ( 2*id_rho(jp_I) )
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('F','V')
+                     dl_dlat= ( dd_lat0(id_imax0-1,id_jmax0  ) -   &
+                        &       dd_lat0(id_imax0-1,id_jmax0-1) ) / &
+                        &     ( 2.*id_rho(jp_J) )
+                  CASE DEFAULT
+                     dl_dlat=0
+               END SELECT
+            ELSE
+               ! odd
+               dl_dlat= ( dd_lat0(id_imax0-1,id_jmax0  ) -   &
+                  &       dd_lat0(id_imax0-1,id_jmax0-1) ) / &
+                  &     ( 2*id_rho(jp_J) )
+            ENDIF
+
+            dl_lon0F= dl_lon0(id_imax0-1,id_jmax0-1) - dl_dlon
+            dl_lat0F= dd_lat0(id_imax0-1,id_jmax0-1) - dl_dlat
+
+            il_ind(:)=grid_get_closest( dl_lon1(i1:i2,j1:j2), dd_lat1(i1:i2,j1:j2), &
+            &                           dl_lon0F, dl_lat0F, 'ur' )
+
+            ii=(MIN(il_shape1(jp_I),(id_rho(jp_I)+2))-il_ind(1)+1)
+            ij=(MIN(il_shape1(jp_J),(id_rho(jp_J)+2))-il_ind(2)+1)
+
+            !!!!! i-direction !!!!!
+            IF( ll_even(jp_I) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','V')
+                     grid__get_fine_offset_cc(jp_I,2)=id_rho(jp_I)-ii
+                  CASE DEFAULT !'F','U' 
+                     grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-ii
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-ii
+            ENDIF
+
+            !!!!! j-direction !!!!!
+            IF( ll_even(jp_J) )THEN
+               ! even
+               SELECT CASE(TRIM(cl_point))
+                  CASE('T','U')
+                     grid__get_fine_offset_cc(jp_J,2)=id_rho(jp_J)-ij
+                  CASE DEFAULT !'F','V'
+                     grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-ij
+               END SELECT
+            ELSE
+               ! odd
+               grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-ij
+            ENDIF
+
+         ELSE
+            CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do"//&
             &                 " not match fine grid upper right corner.")
-         ENDIF         
-
-      ELSE ! il_shape1(1) > 1 .AND. il_shape1(2) > 1 
-
-         ! look for lower left offset
-         IF( dl_lon1(1,1) < dl_lon0(id_imin0+1,id_jmin0+1) )THEN
-
-            ii=1
-            ij=1
-            DO ji=1,(id_rho(jp_I)+2)*(id_rho(jp_J)+2)
-
-               ll_ii=.FALSE.
-               ll_ij=.FALSE.
-
-               IF( dl_lon1(ii,ij) >= dl_lon0(id_imin0+1,id_jmin0+1)-dp_delta .AND. &
-               &   dd_lat1(ii,ij) >= dd_lat0(id_imin0+1,id_jmin0+1)-dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_I,1)=(id_rho(jp_I)+1)-ii
-                  grid__get_fine_offset_cc(jp_J,1)=(id_rho(jp_J)+1)-ij
-                  EXIT
-               ENDIF
-
-               IF( dl_lon1(ii+1,ij) <= dl_lon0(id_imin0+1,id_jmin0+1)+dp_delta .AND. &
-               &   dd_lat1(ii+1,ij) <= dd_lat0(id_imin0+1,id_jmin0+1)+dp_delta )THEN
-                  ll_ii=.TRUE.
-               ENDIF
-               IF( dl_lon1(ii,ij+1) <= dl_lon0(id_imin0+1,id_jmin0+1)+dp_delta .AND. &
-               &   dd_lat1(ii,ij+1) <= dd_lat0(id_imin0+1,id_jmin0+1)+dp_delta )THEN
-                  ll_ij=.TRUE.
-               ENDIF
-
-               IF( ll_ii ) ii=ii+1
-               IF( ll_ij ) ij=ij+1
-
-            ENDDO
-
-         ELSE
-            CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
-            &                 " not match fine grid lower left corner.")
-         ENDIF
-
-         ! look for upper right offset
-         IF( dl_lon1(il_shape1(jp_I),il_shape1(jp_J)) > &
-            & dl_lon0(id_imax0-1,id_jmax0-1) )THEN
-
-            ii=il_shape1(jp_I)
-            ij=il_shape1(jp_J)
-            DO ji=1,(id_rho(jp_I)+2)*(id_rho(jp_J)+2)
-
-               ll_ii=.FALSE.
-               ll_ij=.FALSE.
-
-               IF( dl_lon1(ii,ij) <= dl_lon0(id_imax0-1,id_jmax0-1)+dp_delta .AND. &
-               &   dd_lat1(ii,ij) <= dd_lat0(id_imax0-1,id_jmax0-1)+dp_delta )THEN
-                  grid__get_fine_offset_cc(jp_I,2)=(id_rho(jp_I)+1)-(il_shape1(jp_I)+1-ii)
-                  grid__get_fine_offset_cc(jp_J,2)=(id_rho(jp_J)+1)-(il_shape1(jp_J)+1-ij)
-                  EXIT
-               ENDIF
-
-               IF( dl_lon1(ii-1,ij) >= dl_lon0(id_imax0-1,id_jmax0-1)-dp_delta .AND. &
-               &   dd_lat1(ii-1,ij) >= dd_lat0(id_imax0-1,id_jmax0-1)-dp_delta )THEN
-                  ll_ii=.TRUE.
-               ENDIF
-               IF( dl_lon1(ii,ij-1) >= dl_lon0(id_imax0-1,id_jmax0-1)-dp_delta .AND. &
-               &   dd_lat1(ii,ij-1) >= dd_lat0(id_imax0-1,id_jmax0-1)-dp_delta )THEN
-                  ll_ij=.TRUE.
-               ENDIF
-
-               IF( ll_ii ) ii=ii-1
-               IF( ll_ij ) ij=ij-1
-
-            ENDDO
-
-         ELSE
-            CALL logger_error("GRID GET FINE OFFSET: coarse grid indices do "//&
-            &                 " not match fine grid upper right corner.")
+         ENDIF
+
+         IF( ll_greenwich )THEN
+            ! close to greenwich meridien
+            ll_greenwich=.FALSE.
+            ! -180:180 => 0:360
+            WHERE( dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0) < 0. )
+               dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0) = &
+                  & dl_lon0(id_imax0-1:id_imax0,id_jmax0-1:id_jmax0)+360.
+            END WHERE
+
+            WHERE( dl_lon1(i1:i2,j1:j2) < 0. )
+               dl_lon1(i1:i2,j1:j2)=dl_lon1(i1:i2,j1:j2)+360.
+            END WHERE
          ENDIF
 
@@ -3984,4 +4513,9 @@
       DEALLOCATE( dl_lon0 )
       DEALLOCATE( dl_lon1 )
+
+      IF( ANY(grid__get_fine_offset_cc(:,:)==-1) )THEN
+         CALL logger_fatal("GRID GET FINE OFFSET: can not found "//&
+         &                 " offset between coarse and fine grid.")
+      ENDIF
 
    END FUNCTION grid__get_fine_offset_cc
@@ -3995,5 +4529,8 @@
    !> @date October, 2014
    !> - work on mpp file structure instead of file structure
-   !
+   !> @date February, 2016
+   !> - use F-point to check coincidence for even refinment
+   !> - use F-point estimation, if can not read it.
+   !>
    !> @param[in] td_coord0 coarse grid coordinate file structure 
    !> @param[in] td_coord1 fine   grid coordinate file structure 
@@ -4020,39 +4557,54 @@
 
       ! local variable
-      INTEGER(i4) :: il_imid1
-      INTEGER(i4) :: il_jmid1
+      INTEGER(i4)               :: il_imid1
+      INTEGER(i4)               :: il_jmid1
       
-      INTEGER(i4) :: il_ew0
-      INTEGER(i4) :: il_ew1
-
-      INTEGER(i4) :: il_imin1
-      INTEGER(i4) :: il_imax1
-      INTEGER(i4) :: il_jmin1
-      INTEGER(i4) :: il_jmax1
-
-      INTEGER(i4), DIMENSION(2) :: il_indC
-      INTEGER(i4), DIMENSION(2) :: il_indF
-      INTEGER(i4), DIMENSION(2) :: il_iind
-      INTEGER(i4), DIMENSION(2) :: il_jind
-
-      REAL(dp)    :: dl_lon0
-      REAL(dp)    :: dl_lat0
-      REAL(dp)    :: dl_lon1
-      REAL(dp)    :: dl_lat1
-
-      REAL(dp)    :: dl_lon1p
-      REAL(dp)    :: dl_lat1p
-
-      LOGICAL     :: ll_coincidence
-
-      TYPE(TVAR)  :: tl_lon0
-      TYPE(TVAR)  :: tl_lat0
-      TYPE(TVAR)  :: tl_lon1
-      TYPE(TVAR)  :: tl_lat1
-
-      TYPE(TMPP)  :: tl_coord0
-      TYPE(TMPP)  :: tl_coord1
-
-      TYPE(TDOM)  :: tl_dom0
+      INTEGER(i4)               :: il_ew0
+      INTEGER(i4)               :: il_ew1
+
+      INTEGER(i4)               :: il_ind
+
+      INTEGER(i4)               :: il_imin1
+      INTEGER(i4)               :: il_imax1
+      INTEGER(i4)               :: il_jmin1
+      INTEGER(i4)               :: il_jmax1
+
+      INTEGER(i4), DIMENSION(2) :: il_ind0
+      INTEGER(i4), DIMENSION(2) :: il_ind1
+
+      INTEGER(i4), DIMENSION(2) :: il_ill1
+      INTEGER(i4), DIMENSION(2) :: il_ilr1
+      INTEGER(i4), DIMENSION(2) :: il_iul1
+      INTEGER(i4), DIMENSION(2) :: il_iur1
+
+      REAL(dp)                  :: dl_lon0F
+      REAL(dp)                  :: dl_lat0F
+      REAL(dp)                  :: dl_lon0
+      REAL(dp)                  :: dl_lat0
+      REAL(dp)                  :: dl_lon1F
+      REAL(dp)                  :: dl_lat1F
+      REAL(dp)                  :: dl_lon1
+      REAL(dp)                  :: dl_lat1
+
+      REAL(dp)                  :: dl_delta
+
+      LOGICAL                   :: ll_coincidence
+      LOGICAL                   :: ll_even
+      LOGICAL                   :: ll_grid0F
+      LOGICAL                   :: ll_grid1F
+
+      TYPE(TVAR)                :: tl_lon0
+      TYPE(TVAR)                :: tl_lat0
+      TYPE(TVAR)                :: tl_lon0F
+      TYPE(TVAR)                :: tl_lat0F
+      TYPE(TVAR)                :: tl_lon1
+      TYPE(TVAR)                :: tl_lat1
+      TYPE(TVAR)                :: tl_lon1F
+      TYPE(TVAR)                :: tl_lat1F
+
+      TYPE(TMPP)                :: tl_coord0
+      TYPE(TMPP)                :: tl_coord1
+
+      TYPE(TDOM)                :: tl_dom0
 
       ! loop indices
@@ -4063,4 +4615,9 @@
       ll_coincidence=.TRUE.
 
+      ll_even=.FALSE.
+      IF( MOD(id_rho(jp_I)*id_rho(jp_J),2) == 0 )THEN
+         ll_even=.TRUE.
+      ENDIF
+
       ! copy structure
       tl_coord0=mpp_copy(td_coord0)
@@ -4075,6 +4632,37 @@
 
       ! read variable value on domain
-      tl_lon0=iom_dom_read_var(tl_coord0,'longitude',tl_dom0)
-      tl_lat0=iom_dom_read_var(tl_coord0,'latitude' ,tl_dom0)
+      il_ind=var_get_index(tl_coord0%t_proc(1)%t_var(:), 'longitude_T')
+      IF( il_ind /= 0 )THEN
+         tl_lon0=iom_dom_read_var(tl_coord0,'longitude_T',tl_dom0)
+      ELSE
+         tl_lon0=iom_dom_read_var(tl_coord0,'longitude',tl_dom0)
+      ENDIF
+
+      il_ind=var_get_index(tl_coord0%t_proc(1)%t_var(:), 'latitude_T')
+      IF( il_ind /= 0 )THEN
+         tl_lat0=iom_dom_read_var(tl_coord0,'latitude_T' ,tl_dom0)
+      ELSE
+         tl_lat0=iom_dom_read_var(tl_coord0,'latitude' ,tl_dom0)
+      ENDIF
+
+      IF( ll_even )THEN
+         ! look for variable value on domain for F point
+         il_ind=var_get_index(tl_coord0%t_proc(1)%t_var(:), 'longitude_F')
+         IF( il_ind /= 0 )THEN
+            tl_lon0F=iom_dom_read_var(tl_coord0,'longitude_F',tl_dom0)
+         ENDIF
+
+         il_ind=var_get_index(tl_coord0%t_proc(1)%t_var(:), 'latitude_F')
+         IF( il_ind /= 0 )THEN
+            tl_lat0F=iom_dom_read_var(tl_coord0,'latitude_F' ,tl_dom0)
+         ENDIF
+
+         ll_grid0F=.FALSE.
+         IF( ASSOCIATED(tl_lon0F%d_value) .AND. &
+         &   ASSOCIATED(tl_lat0F%d_value) )THEN
+            ll_grid0F=.TRUE.
+         ENDIF
+
+      ENDIF
 
       ! close mpp files
@@ -4092,9 +4680,40 @@
 
       ! read fine longitue and latitude
-      tl_lon1=iom_mpp_read_var(tl_coord1,'longitude')
-      tl_lat1=iom_mpp_read_var(tl_coord1,'latitude')
+      il_ind=var_get_index(tl_coord1%t_proc(1)%t_var(:), TRIM(tl_lon0%c_longname))
+      IF( il_ind /= 0 )THEN
+         tl_lon1=iom_mpp_read_var(tl_coord1,TRIM(tl_lon0%c_longname))
+      ELSE
+         tl_lon1=iom_mpp_read_var(tl_coord1,'longitude')
+      ENDIF
+      il_ind=var_get_index(tl_coord1%t_proc(1)%t_var(:), TRIM(tl_lat0%c_longname))
+      IF( il_ind /= 0 )THEN
+         tl_lat1=iom_mpp_read_var(tl_coord1,TRIM(tl_lat0%c_longname))
+      ELSE
+         tl_lat1=iom_mpp_read_var(tl_coord1,'latitude')
+      ENDIF
       
+      IF( ll_even )THEN
+
+         ! look for variable value on domain for F point
+         il_ind=var_get_index(tl_coord1%t_proc(1)%t_var(:), 'longitude_F')
+         IF( il_ind /= 0 )THEN
+            tl_lon1F=iom_mpp_read_var(tl_coord1,'longitude_F')
+         ENDIF
+
+         il_ind=var_get_index(tl_coord1%t_proc(1)%t_var(:), 'latitude_F')
+         IF( il_ind /= 0 )THEN
+            tl_lat1F=iom_mpp_read_var(tl_coord1,'latitude_F')
+         ENDIF
+
+         ll_grid1F=.FALSE.
+         IF( ASSOCIATED(tl_lon1F%d_value) .AND. &
+         &   ASSOCIATED(tl_lat1F%d_value) )THEN
+            ll_grid1F=.TRUE.
+         ENDIF
+
+      ENDIF
+
       ! close mpp files
-      CALL iom_dom_close(tl_coord1)
+      CALL iom_mpp_close(tl_coord1)
       ! clean structure
       CALL mpp_clean(tl_coord1)
@@ -4158,5 +4777,5 @@
          IF( .NOT. ll_coincidence )THEN
             CALL logger_fatal("GRID CHECK COINCIDENCE: no coincidence "//&
-            &              "between fine grid and coarse grid. invalid domain" )
+            &              "between fine grid and coarse grid: invalid domain." )
          ENDIF
 
@@ -4172,61 +4791,36 @@
 
       ! select closest point on coarse grid
-      il_indC(:)=grid_get_closest(tl_lon0%d_value(:,:,1,1),&
+      il_ind0(:)=grid_get_closest(tl_lon0%d_value(:,:,1,1),&
       &                           tl_lat0%d_value(:,:,1,1),&
       &                           dl_lon1, dl_lat1   )
 
-      IF( ANY(il_indC(:)==0) )THEN
+      IF( ANY(il_ind0(:)==0) )THEN
          CALL logger_fatal("GRID CHECK COINCIDENCE: can not find valid "//&
-         &              "coarse grid indices. invalid domain" )
-      ENDIF
-
-      dl_lon0=tl_lon0%d_value(il_indC(1),il_indC(2),1,1)
-      dl_lat0=tl_lat0%d_value(il_indC(1),il_indC(2),1,1)
-
-      ! look for closest fine grid point from selected coarse grid point
-      il_iind(:)=MAXLOC( tl_lon1%d_value(:,:,1,1), &
-      &                  tl_lon1%d_value(:,:,1,1) <= dl_lon0 )
-
-      il_jind(:)=MAXLOC( tl_lat1%d_value(:,:,1,1), &
-      &                  tl_lat1%d_value(:,:,1,1) <= dl_lat0 )
-
-      il_indF(1)=il_iind(1)
-      il_indF(2)=il_jind(2)
-
-      IF( ANY(il_indF(:)==0) )THEN
-         CALL logger_fatal("GRID CHECK COINCIDENCE: can not find valid "//&
-         &              "fine grid indices. invalid domain" )
-      ENDIF
-
-      dl_lon1=tl_lon1%d_value(il_indF(1),il_indF(2),1,1)
-      dl_lat1=tl_lat1%d_value(il_indF(1),il_indF(2),1,1)
-
-      ! check i-direction refinement factor
-      DO ji=1,MIN(3,il_imid1)
-
-         IF( il_indF(1)+ji*id_rho(jp_I)+1 > tl_lon1%t_dim(1)%i_len )THEN
-            CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
-            &  " to check i-direction refinement factor ")
-            EXIT
-         ELSE
-            dl_lon1=tl_lon1%d_value(il_indF(1)+ji*id_rho(jp_I),il_indF(2),1,1)
-            dl_lon0=tl_lon0%d_value(il_indC(1)+ji,il_indC(2),1,1)
-
-            dl_lon1p=tl_lon1%d_value(il_indF(1)+ji*id_rho(jp_I)+1,il_indF(2),1,1)
-
-            SELECT CASE(MOD(id_rho(jp_I),2))
-
-            CASE(0)
-
-               IF( dl_lon1 >= dl_lon0 .OR. dl_lon0 >= dl_lon1p )THEN
-                  ll_coincidence=.FALSE.
-                  CALL logger_debug("GRID CHECK COINCIDENCE: invalid "//&
-                  &  "i-direction refinement factor ("//&
-                  &   TRIM(fct_str(id_rho(jp_I)))//&
-                  &   ") between fine grid and coarse grid ")
-               ENDIF
-
-            CASE DEFAULT         
-            
+         &              "coarse grid indices: invalid domain." )
+      ENDIF
+
+      IF( .NOT. ll_even )THEN
+         ! case odd refinment in both direction
+         ! work on T-point
+
+         dl_lon0=tl_lon0%d_value(il_ind0(1),il_ind0(2),1,1)
+         dl_lat0=tl_lat0%d_value(il_ind0(1),il_ind0(2),1,1)
+
+         il_ind1(:)=grid_get_closest(tl_lon1%d_value(:,:,1,1),&
+         &                           tl_lat1%d_value(:,:,1,1),&
+         &                           dl_lon0, dl_lat0 )
+
+         ! check i-direction refinement factor
+         DO ji=0,MIN(3,il_imid1)
+
+            IF( il_ind1(1)+ji*id_rho(jp_I)+1 > tl_lon1%t_dim(1)%i_len )THEN
+               CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
+               &  " to check i-direction refinement factor ")
+               EXIT
+            ELSE
+               dl_lon0=tl_lon0%d_value(il_ind0(1)+ji             ,il_ind0(2),1,1)
+               dl_lon1=tl_lon1%d_value(il_ind1(1)+ji*id_rho(jp_I),il_ind1(2),1,1)
+
+               ! assume there could be little difference due to interpolation
                IF( ABS(dl_lon1 - dl_lon0) > dp_delta )THEN
                   ll_coincidence=.FALSE.
@@ -4236,37 +4830,20 @@
                   &  ") between fine grid and coarse grid ")
                ENDIF
-            
-            END SELECT
-         ENDIF
-
-      ENDDO
-
-      ! check j-direction refinement factor
-      DO jj=1,MIN(3,il_jmid1)
-
-         IF( il_indF(2)+jj*id_rho(jp_J)+1 > tl_lat1%t_dim(2)%i_len )THEN
-            CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
-            &  " to check j-direction refinement factor ")
-            EXIT
-         ELSE      
-            dl_lat1=tl_lat1%d_value(il_indF(1),il_indF(2)+jj*id_rho(jp_J),1,1)
-            dl_lat0=tl_lat0%d_value(il_indC(1),il_indC(2)+jj,1,1)
-
-            dl_lat1p=tl_lat1%d_value(il_indF(1),il_indF(2)+jj*id_rho(jp_J)+1,1,1)
-
-            SELECT CASE(MOD(id_rho(jp_J),2))
-
-            CASE(0)
-               
-               IF( dl_lat1 >= dl_lat0 .OR. dl_lat0 >= dl_lat1p )THEN
-                  ll_coincidence=.FALSE.
-                  CALL logger_debug("GRID CHECK COINCIDENCE: invalid "//&
-                  &  "j-direction refinement factor ("//&
-                  &   TRIM(fct_str(id_rho(jp_J)))//&
-                  &  ") between fine grid and coarse grid ")
-               ENDIF
-
-            CASE DEFAULT
-
+            ENDIF
+
+         ENDDO
+
+         ! check j-direction refinement factor
+         DO jj=0,MIN(3,il_jmid1)
+
+            IF( il_ind1(2)+jj*id_rho(jp_J)+1 > tl_lat1%t_dim(2)%i_len )THEN
+               CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
+               &  " to check j-direction refinement factor ")
+               EXIT
+            ELSE      
+               dl_lat0=tl_lat0%d_value(il_ind0(1),il_ind0(2)+jj             ,1,1)
+               dl_lat1=tl_lat1%d_value(il_ind1(1),il_ind1(2)+jj*id_rho(jp_J),1,1)
+
+               ! assume there could be little difference due to interpolation
                IF( ABS(dl_lat1-dl_lat0) > dp_delta )THEN
                   ll_coincidence=.FALSE.
@@ -4276,9 +4853,159 @@
                   &  ") between fine grid and coarse grid ")
                ENDIF
-
-            END SELECT
-         ENDIF
-
-      ENDDO
+            ENDIF
+
+         ENDDO
+
+      ELSE
+         ! case even refinment at least in one direction
+         ! work on F-point
+
+         dl_delta=dp_delta
+         ! look for lower left fine point in coarse cell.
+         IF( ll_grid0F )THEN
+      
+            ! lower left corner of coarse cell
+            dl_lon0F=tl_lon0F%d_value(il_ind0(1)-1,il_ind0(2)-1,1,1)
+            dl_lat0F=tl_lat0F%d_value(il_ind0(1)-1,il_ind0(2)-1,1,1)
+
+         ELSE
+
+            ! approximate lower left corner of coarse cell (with T point)
+            dl_lon0F=( tl_lon0%d_value(il_ind0(1)  ,il_ind0(2)  ,1,1) + &
+            &          tl_lon0%d_value(il_ind0(1)  ,il_ind0(2)-1,1,1) + &
+            &          tl_lon0%d_value(il_ind0(1)-1,il_ind0(2)  ,1,1) + &
+            &          tl_lon0%d_value(il_ind0(1)-1,il_ind0(2)-1,1,1) ) * 0.25
+
+            dl_lat0F=( tl_lat0%d_value(il_ind0(1)  ,il_ind0(2)  ,1,1) + &
+            &          tl_lat0%d_value(il_ind0(1)  ,il_ind0(2)-1,1,1) + &
+            &          tl_lat0%d_value(il_ind0(1)-1,il_ind0(2)  ,1,1) + &
+            &          tl_lat0%d_value(il_ind0(1)-1,il_ind0(2)-1,1,1) ) * 0.25
+
+            ! as we use approximation of F-point we relax condition
+            dl_delta=100*dp_delta
+
+         ENDIF
+
+         IF( ll_grid1F )THEN
+      
+            il_ind1(:)=grid_get_closest(tl_lon1F%d_value(:,:,1,1),&
+            &                           tl_lat1F%d_value(:,:,1,1),&
+            &                           dl_lon0F, dl_lat0F )
+
+         ELSE
+
+            il_ill1(:)=grid_get_closest(tl_lon1%d_value(:,:,1,1),&
+            &                           tl_lat1%d_value(:,:,1,1),&
+            &                           dl_lon0F, dl_lat0F, 'll' )
+
+            il_ilr1(:)=grid_get_closest(tl_lon1%d_value(:,:,1,1),&
+            &                           tl_lat1%d_value(:,:,1,1),&
+            &                           dl_lon0F, dl_lat0F, 'lr' )
+
+            il_iul1(:)=grid_get_closest(tl_lon1%d_value(:,:,1,1),&
+            &                           tl_lat1%d_value(:,:,1,1),&
+            &                           dl_lon0F, dl_lat0F, 'ul' )
+
+            il_iur1(:)=grid_get_closest(tl_lon1%d_value(:,:,1,1),&
+            &                           tl_lat1%d_value(:,:,1,1),&
+            &                           dl_lon0F, dl_lat0F, 'ur' )
+
+            ! as we use approximation of F-point we relax condition
+            dl_delta=100*dp_delta
+
+         ENDIF
+
+         ! check i-direction refinement factor
+         DO ji=0,MIN(3,il_imid1)
+
+            IF( il_ind1(1)+ji*id_rho(jp_I)+1 > tl_lon1%t_dim(1)%i_len )THEN
+               CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
+               &  " to check i-direction refinement factor ")
+               EXIT
+            ELSE
+               IF( ll_grid0F )THEN
+                  dl_lon0F=tl_lon0F%d_value(il_ind0(1)+ji-1, il_ind0(2)-1,1,1)
+               ELSE
+                  dl_lon0F= 0.25 * &
+                  & ( tl_lon0%d_value(il_ind0(1)+ji  , il_ind0(2)  ,1,1) + &
+                  &   tl_lon0%d_value(il_ind0(1)+ji-1, il_ind0(2)  ,1,1) + &
+                  &   tl_lon0%d_value(il_ind0(1)+ji  , il_ind0(2)-1,1,1) + &
+                  &   tl_lon0%d_value(il_ind0(1)+ji-1, il_ind0(2)-1,1,1) )
+               ENDIF
+
+               IF( ll_grid1F )THEN
+                  dl_lon1F= tl_lon1F%d_value( il_ind1(1)+ji*id_rho(jp_I), &
+                                            & il_ind1(2),1,1)
+               ELSE
+                  dl_lon1F= 0.25 * &
+                  & ( tl_lon1%d_value( il_ill1(1)+ji*id_rho(jp_I), &
+                                     & il_ill1(2),1,1) + &
+                  &   tl_lon1%d_value( il_ilr1(1)+ji*id_rho(jp_I), &
+                                     & il_ilr1(2),1,1) + &
+                  &   tl_lon1%d_value( il_iul1(1)+ji*id_rho(jp_I), &
+                                     & il_iul1(2),1,1) + &
+                  &   tl_lon1%d_value( il_iur1(1)+ji*id_rho(jp_I), &
+                                     & il_iur1(2),1,1) )
+                  
+               ENDIF
+
+               ! assume there could be little difference due to interpolation
+               IF( ABS(dl_lon1F - dl_lon0F) > dl_delta )THEN
+                  ll_coincidence=.FALSE.
+                  CALL logger_debug("GRID CHECK COINCIDENCE: invalid "//&
+                  &  "i-direction refinement factor ("//&
+                  &   TRIM(fct_str(id_rho(jp_I)))//&
+                  &  ") between fine grid and coarse grid ")
+               ENDIF
+            ENDIF
+
+         ENDDO
+
+         ! check j-direction refinement factor
+         DO jj=0,MIN(3,il_jmid1)
+
+            IF( il_ind1(2)+jj*id_rho(jp_J)+1 > tl_lat1%t_dim(2)%i_len )THEN
+               CALL logger_warn("GRID CHECK COINCIDENCE: domain to small "//&
+               &  " to check j-direction refinement factor ")
+               EXIT
+            ELSE      
+               IF( ll_grid0F )THEN
+                  dl_lat0F=tl_lat0F%d_value(il_ind0(1)-1, il_ind0(2)+jj-1,1,1)
+               ELSE
+                  dl_lat0F= 0.25 * &
+                  & ( tl_lat0%d_value(il_ind0(1)  , il_ind0(2)+jj  ,1,1) + &
+                  &   tl_lat0%d_value(il_ind0(1)-1, il_ind0(2)+jj  ,1,1) + &
+                  &   tl_lat0%d_value(il_ind0(1)  , il_ind0(2)+jj-1,1,1) + &
+                  &   tl_lat0%d_value(il_ind0(1)-1, il_ind0(2)+jj-1,1,1) )
+               ENDIF
+
+               IF( ll_grid1F )THEN
+                  dl_lat1F= tl_lat1F%d_value( il_ind1(1), &
+                                            & il_ind1(2)+jj*id_rho(jp_J),1,1)
+               ELSE
+                  dl_lat1F= 0.25 * &
+                  & ( tl_lat1%d_value( il_ill1(1), &
+                                     & il_ill1(2)+jj*id_rho(jp_J),1,1) + &
+                  &   tl_lat1%d_value( il_ilr1(1), &
+                                     & il_ilr1(2)+jj*id_rho(jp_J),1,1) + &
+                  &   tl_lat1%d_value( il_iul1(1), &
+                                     & il_iul1(2)+jj*id_rho(jp_J),1,1) + &
+                  &   tl_lat1%d_value( il_iur1(1), &
+                                     & il_iur1(2)+jj*id_rho(jp_J),1,1) )
+                  
+               ENDIF
+
+               ! assume there could be little difference due to interpolation
+               IF( ABS(dl_lat1F - dl_lat0F) > dl_delta )THEN
+                  ll_coincidence=.FALSE.
+                  CALL logger_debug("GRID CHECK COINCIDENCE: invalid "//&
+                  &  "i-direction refinement factor ("//&
+                  &   TRIM(fct_str(id_rho(jp_I)))//&
+                  &  ") between fine grid and coarse grid ")
+               ENDIF
+            ENDIF
+
+         ENDDO
+      ENDIF
 
       ! clean 
@@ -4851,11 +5578,11 @@
 
          ! copy structure
-          tl_mpp=mpp_copy(td_mpp)
-
-          CALL logger_info("GRID GET FINE GHOST perio"//TRIM(fct_str(tl_mpp%i_perio)))
-          IF( tl_mpp%i_perio < 0 )THEN
-             ! compute NEMO periodicity index
-             CALL grid_get_info(tl_mpp)
-          ENDIF
+         tl_mpp=mpp_copy(td_mpp)
+
+         CALL logger_info("GRID GET FINE GHOST perio"//TRIM(fct_str(tl_mpp%i_perio)))
+         IF( tl_mpp%i_perio < 0 )THEN
+            ! compute NEMO periodicity index
+            CALL grid_get_info(tl_mpp)
+         ENDIF
 
          SELECT CASE(tl_mpp%i_perio)
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/interp_linear.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/interp_linear.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/interp_linear.f90	(revision 7339)
@@ -627,13 +627,13 @@
       
       IF( ld_even(jp_I) )THEN
-         dl_dx=1./REAL(id_rho(jp_I)-1)
+         dl_dx=1._dp/REAL(id_rho(jp_I)-1,dp)
       ELSE ! odd refinement
-         dl_dx=1./REAL(id_rho(jp_I))
+         dl_dx=1._dp/REAL(id_rho(jp_I),dp)
       ENDIF
 
       IF( ld_even(jp_J) )THEN
-         dl_dy=1./REAL(id_rho(jp_J)-1)
+         dl_dy=1._dp/REAL(id_rho(jp_J)-1,dp)
       ELSE ! odd refinement
-         dl_dy=1./REAL(id_rho(jp_J))
+         dl_dy=1._dp/REAL(id_rho(jp_J),dp)
       ENDIF
 
@@ -642,7 +642,7 @@
 
          IF( ld_even(jp_J) )THEN
-            dl_y=(jj-1)*dl_dy - dl_dy*0.5 
+            dl_y=REAL(jj-1,dp)*dl_dy - dl_dy*0.5_dp
          ELSE ! odd refinement
-            dl_y=(jj-1)*dl_dy 
+            dl_y=REAL(jj-1,dp)*dl_dy 
          ENDIF
 
@@ -653,7 +653,7 @@
 
             IF( ld_even(jp_I) )THEN
-               dl_x=(ji-1)*dl_dx - dl_dx*0.5 
+               dl_x=REAL(ji-1,dp)*dl_dx - dl_dx*0.5_dp 
             ELSE ! odd refinement
-               dl_x=(ji-1)*dl_dx 
+               dl_x=REAL(ji-1,dp)*dl_dx 
             ENDIF
 
@@ -692,14 +692,14 @@
       
       IF( ld_even )THEN
-         dl_dx=1./REAL(id_rho-1)
+         dl_dx=1._dp/REAL(id_rho-1,dp)
       ELSE ! odd refinement
-         dl_dx=1./REAL(id_rho)
+         dl_dx=1._dp/REAL(id_rho,dp)
       ENDIF
 
       DO ji=1,id_rho+1
          IF( ld_even )THEN
-            dl_x=(ji-1)*dl_dx - dl_dx*0.5 
+            dl_x=REAL(ji-1,dp)*dl_dx - dl_dx*0.5_dp 
          ELSE ! odd refinement
-            dl_x=(ji-1)*dl_dx 
+            dl_x=REAL(ji-1,dp)*dl_dx 
          ENDIF
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 7339)
@@ -214,5 +214,4 @@
             &                       cmode=NF90_64BIT_OFFSET,&
             &                       ncid=td_file%i_id)
-         !NF90_WRITE,               &
             CALL iom_cdf__check(il_status," IOM CDF CREATE: ")
 
@@ -222,4 +221,5 @@
 
       ELSE
+
          IF( td_file%i_id /= 0 )THEN
 
@@ -239,6 +239,4 @@
                CALL iom_cdf__check(il_status," IOM CDF OPEN: ")
 
-               CALL logger_trace("IOM CDF OPEN "//TRIM(td_file%c_name)//" "//&
-                  &  TRIM(fct_str(td_file%i_id)))
             ELSE
 
@@ -363,7 +361,10 @@
       ! Argument      
       TYPE(TFILE), INTENT(INOUT) :: td_file
+      ! local variable
+      TYPE(TDIM) :: tl_dim
 
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: ii
       !----------------------------------------------------------------
 
@@ -374,7 +375,17 @@
 
       IF( td_file%i_ndim > 0 )THEN
+         ii=1
          DO ji = 1, td_file%i_ndim
             ! read dimension information
-            td_file%t_dim(ji)=iom_cdf_read_dim( td_file, ji)
+            tl_dim=iom_cdf_read_dim( td_file, ji)
+            IF( .NOT. dim_is_dummy(tl_dim) )THEN
+               IF( ii > ip_maxdim )THEN
+                  CALL logger_fatal("IOM CDF OPEN: too much dimension "//&
+                  & "to be read. you should remove dummy dimension using "//&
+                  & " configuration file")
+               ENDIF
+               td_file%t_dim(ii)=dim_copy(tl_dim)
+               ii=ii+1
+            ENDIF
          ENDDO
 
@@ -418,6 +429,9 @@
 
       ! local variable
+      TYPE(TATT) :: tl_att
+
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: ii
       !----------------------------------------------------------------
 
@@ -429,7 +443,12 @@
          ALLOCATE(td_file%t_att(td_file%i_natt))
 
+         ii=1
          DO ji = 1, td_file%i_natt
             ! read global attribute
-            td_file%t_att(ji)=iom_cdf_read_att( td_file, NF90_GLOBAL, ji)
+            tl_att=iom_cdf_read_att( td_file, NF90_GLOBAL, ji)
+            IF( .NOT. att_is_dummy(tl_att) )THEN
+               td_file%t_att(ii)=att_copy(tl_att)
+               ii=ii+1
+            ENDIF
             
          ENDDO
@@ -450,4 +469,8 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date September, 2015
+   !> - manage useless (dummy) variable
+   !> @date January, 2016
+   !> - increment n3d for 4D variable
    !
    !> @param[inout] td_file   file structure
@@ -460,66 +483,92 @@
       ! local variable
       INTEGER(i4) :: il_attid
+      INTEGER(i4) :: il_nvar
+
+      TYPE(TVAR), DIMENSION(:), ALLOCATABLE  :: tl_var
 
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: ii
       !----------------------------------------------------------------
 
       IF( td_file%i_nvar > 0 )THEN
+
          IF(ASSOCIATED(td_file%t_var))THEN
             CALL var_clean(td_file%t_var(:))
             DEALLOCATE(td_file%t_var)
          ENDIF
+
+         il_nvar=td_file%i_nvar
+         ALLOCATE(tl_var(il_nvar))
+         ii=0
+         DO ji = 1, il_nvar
+           ! read variable information
+           tl_var(ji)=iom_cdf__read_var_meta( td_file, ji) 
+           IF( .NOT. var_is_dummy(tl_var(ji)) )THEN
+              ii=ii+1
+           ENDIF
+         ENDDO
+
+         ! update number of variable used
+         td_file%i_nvar=ii
+
          ALLOCATE(td_file%t_var(td_file%i_nvar))
 
-         DO ji = 1, td_file%i_nvar
-            ! read dimension information
-            td_file%t_var(ji)=iom_cdf__read_var_meta( td_file, ji)
-            SELECT CASE(td_file%t_var(ji)%i_ndim)
-               CASE(0)
-                  td_file%i_n0d=td_file%i_n0d+1
-               CASE(1)
-                  td_file%i_n1d=td_file%i_n1d+1
-                  td_file%i_rhd=td_file%i_rhd+1
-               CASE(2)
-                  td_file%i_n2d=td_file%i_n2d+1
-                  td_file%i_rhd=td_file%i_rhd+1
-               CASE(3)
-                  td_file%i_n3d=td_file%i_n3d+1
-                  td_file%i_rhd=td_file%i_rhd+td_file%t_dim(3)%i_len
-            END SELECT
-
-            ! look for depth id
-            IF( INDEX(TRIM(fct_lower(td_file%t_var(ji)%c_name)),'depth')/=0 )THEN
-               IF( td_file%i_depthid == 0 )THEN
-                  td_file%i_depthid=ji
-               ELSE
-                  IF( td_file%i_depthid /= ji )THEN
-                     CALL logger_error("IOM CDF GET FILE VAR: find more"//&
-                        &  " than one depth variable in file "//&
-                        &  TRIM(td_file%c_name) )
+         ii=0
+         DO ji = 1, il_nvar
+            IF( .NOT. var_is_dummy(tl_var(ji)) )THEN
+               ii=ii+1
+               td_file%t_var(ii)=var_copy(tl_var(ji))
+               SELECT CASE(td_file%t_var(ii)%i_ndim)
+                  CASE(0)
+                     td_file%i_n0d=td_file%i_n0d+1
+                  CASE(1)
+                     td_file%i_n1d=td_file%i_n1d+1
+                     td_file%i_rhd=td_file%i_rhd+1
+                  CASE(2)
+                     td_file%i_n2d=td_file%i_n2d+1
+                     td_file%i_rhd=td_file%i_rhd+1
+                  CASE(3,4)
+                     td_file%i_n3d=td_file%i_n3d+1
+                     td_file%i_rhd=td_file%i_rhd+td_file%t_dim(3)%i_len
+               END SELECT
+
+               ! look for depth id
+               IF( INDEX(TRIM(fct_lower(td_file%t_var(ii)%c_name)),'depth')/=0 )THEN
+                  IF( td_file%i_depthid == 0 )THEN
+                     td_file%i_depthid=ji
+                  ELSE
+                     IF( td_file%i_depthid /= ji )THEN
+                        CALL logger_error("IOM CDF GET FILE VAR: find more"//&
+                           &  " than one depth variable in file "//&
+                           &  TRIM(td_file%c_name) )
+                     ENDIF
                   ENDIF
                ENDIF
-            ENDIF
-
-            ! look for time id
-            IF( INDEX(TRIM(fct_lower(td_file%t_var(ji)%c_name)),'time')/=0 )THEN
-               IF( td_file%i_timeid == 0 )THEN
-                  td_file%i_timeid=ji
-               ELSE
-                  il_attid=0
-                  IF( ASSOCIATED(td_file%t_var(ji)%t_att) )THEN
-                     il_attid=att_get_id(td_file%t_var(ji)%t_att(:),'calendar')
-                  ENDIF
-                  IF( il_attid /= 0 )THEN
+
+               ! look for time id
+               IF( INDEX(TRIM(fct_lower(td_file%t_var(ii)%c_name)),'time')/=0 )THEN
+                  IF( td_file%i_timeid == 0 )THEN
                      td_file%i_timeid=ji
-                  !ELSE
-                  !   CALL logger_error("IOM CDF GET FILE VAR: find more "//&
-                  !   &                 "than one time variable in file "//&
-                  !   &                 TRIM(td_file%c_name) )
+                  ELSE
+                     il_attid=0
+                     IF( ASSOCIATED(td_file%t_var(ii)%t_att) )THEN
+                        il_attid=att_get_id(td_file%t_var(ii)%t_att(:),'calendar')
+                     ENDIF
+                     IF( il_attid /= 0 )THEN
+                        td_file%i_timeid=ji
+                     !ELSE
+                     !   CALL logger_error("IOM CDF GET FILE VAR: find more "//&
+                     !   &                 "than one time variable in file "//&
+                     !   &                 TRIM(td_file%c_name) )
+                     ENDIF
                   ENDIF
                ENDIF
+
             ENDIF
-
          ENDDO
+
+         CALL var_clean(tl_var(:))
+         DEALLOCATE(tl_var)
 
       ELSE
@@ -605,6 +654,4 @@
       ELSE      
 
-         iom_cdf__read_dim_id%i_id=id_dimid
-
          CALL logger_trace( &
          &  " IOM CDF READ DIM: dimension "//TRIM(fct_str(id_dimid))//&
@@ -627,4 +674,6 @@
       ENDIF
 
+      iom_cdf__read_dim_id%i_id=id_dimid
+
    END FUNCTION iom_cdf__read_dim_id
    !-------------------------------------------------------------------
@@ -748,5 +797,5 @@
                IF( LEN(cl_value) < il_len )THEN
 
-                  CALL logger_error( &
+                  CALL logger_warn( &
                   &  " IOM CDF READ ATT: not enough space to put "//&
                   &  "attribute "//TRIM(cl_name) )
@@ -1223,4 +1272,6 @@
    !> @date September, 2014
    !> - force to use FillValue=1.e20 if no FillValue for coordinate variable.
+   !> @date September, 2015
+   !> - manage useless (dummy) attribute
    !
    !> @param[in] td_file   file structure
@@ -1250,4 +1301,5 @@
 
       ! loop indices
+      INTEGER(i4) :: ji
       !----------------------------------------------------------------
       ! check if file opened
@@ -1275,6 +1327,7 @@
          &                                il_natt )
          CALL iom_cdf__check(il_status,"IOM CDF READ VAR META: ")
+
          !!! fill variable dimension structure
-         tl_dim(:)=iom_cdf__read_var_dim( td_file, il_ndim, il_dimid(:) )
+         tl_dim(:)=iom_cdf__read_var_dim( td_file, il_ndim, cl_name, il_dimid(:) )
 
          IF( il_natt /= 0 )THEN
@@ -1353,4 +1406,11 @@
          &                                tl_att(:), id_id=id_varid )
 
+         !! look for dummy attribute
+         DO ji=il_natt,1,-1
+            IF( att_is_dummy(tl_att(ji)) )THEN
+               CALL var_del_att(iom_cdf__read_var_meta, tl_att(ji))
+            ENDIF
+         ENDDO
+
          ! clean
          CALL dim_clean(tl_dim(:))
@@ -1373,20 +1433,26 @@
    !> So the array of dimension structure of a variable is always compose of 4
    !> dimension (use or not). 
-   !
+   !>
+   !> @warn dummy dimension are not used. 
+   !>
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
    !> @date July, 2015 
    !> - Bug fix: use order to disorder table (see dim_init)
+   !> @date September, 2015
+   !> - check dummy dimension
    !>
    !> @param[in] td_file   file structure
    !> @param[in] id_ndim   number of dimension
+   !> @param[in] cd_name   variable name
    !> @param[in] id_dimid  array of dimension id
    !> @return array dimension structure 
    !-------------------------------------------------------------------
-   FUNCTION iom_cdf__read_var_dim(td_file, id_ndim, id_dimid)
+   FUNCTION iom_cdf__read_var_dim(td_file, id_ndim, cd_name, id_dimid)
       IMPLICIT NONE
       ! Argument      
       TYPE(TFILE),               INTENT(IN) :: td_file
       INTEGER(i4),               INTENT(IN) :: id_ndim
+      CHARACTER(LEN=*)         , INTENT(IN) :: cd_name
       INTEGER(i4), DIMENSION(:), INTENT(IN) :: id_dimid
 
@@ -1401,4 +1467,5 @@
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: ii
       !----------------------------------------------------------------
 
@@ -1415,16 +1482,32 @@
          CALL dim_clean(tl_dim(:))
 
-      ELSE IF( id_ndim > 0 .AND. id_ndim <= 4 )THEN
-
-
+      ELSE IF( id_ndim > 0 )THEN
+
+
+         ii=1
          DO ji = 1, id_ndim
-            CALL logger_debug( " IOM CDF READ VAR DIM: get variable "//&
-               &  "dimension "//TRIM(fct_str(ji)) )
-
-            il_xyzt2(ji)=td_file%t_dim(id_dimid(ji))%i_xyzt2
-
-            ! read dimension information
-            tl_dim(ji) = dim_init( td_file%t_dim(il_xyzt2(ji))%c_name, &
-            &                      td_file%t_dim(il_xyzt2(ji))%i_len )
+
+            !!! check no dummy dimension to be used
+            IF( ANY(td_file%t_dim(:)%i_id == id_dimid(ji)) )THEN
+               IF( ii > ip_maxdim )THEN
+                  CALL logger_error(" IOM CDF READ VAR DIM: "//&
+                  &  "too much dimensions for variable "//&
+                  &  TRIM(cd_name)//". check dummy configuration file.")
+               ENDIF
+
+               CALL logger_debug( " IOM CDF READ VAR DIM: get variable "//&
+                  &  "dimension "//TRIM(fct_str(ji)) )
+
+               il_xyzt2(ii)=td_file%t_dim(id_dimid(ji))%i_xyzt2
+
+               ! read dimension information
+               tl_dim(ii) = dim_init( td_file%t_dim(il_xyzt2(ii))%c_name, &
+               &                      td_file%t_dim(il_xyzt2(ii))%i_len )
+            
+               ii=ii+1
+            ELSE
+               CALL logger_debug( " IOM CDF READ VAR DIM: dummy variable "//&
+               &  "dimension "//TRIM(fct_str(ji))//" not used." )
+            ENDIF
          ENDDO
 
@@ -1436,9 +1519,4 @@
          ! clean
          CALL dim_clean(tl_dim(:))
-
-      ELSE
-
-         CALL logger_error(" IOM CDF READ VAR DIM: can't manage "//&
-         &              TRIM(fct_str(id_ndim))//" dimension(s)" )
 
       ENDIF
@@ -1943,4 +2021,6 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date September, 2015
+   !> - do not force to use zero as FillValue for any meshmask variable
    !
    !> @param[inout] td_file   file structure
@@ -1976,7 +2056,4 @@
       ! check if file and variable dimension conform
       IF( file_check_var_dim(td_file, td_var) )THEN
-
-         ! check variable dimension expected
-         CALL var_check_dim(td_var)
 
          ll_chg=.TRUE.
@@ -1998,5 +2075,19 @@
                CASE('nav_lon','nav_lat', &
                   & 'glamt','glamu','glamv','glamf', &
-                  & 'gphit','gphiu','gphiv','gphif')
+                  & 'gphit','gphiu','gphiv','gphif', &
+                  & 'e1t','e1u','e1v','e1f',         &
+                  & 'e2t','e2u','e2v','e2f','ff',    &
+                  & 'gcost','gcosu','gcosv','gcosf', &
+                  & 'gsint','gsinu','gsinv','gsinf', &
+                  & 'mbathy','misf','isf_draft',     &
+                  & 'hbatt','hbatu','hbatv','hbatf', &
+                  & 'gsigt','gsigu','gsigv','gsigf', &
+                  & 'e3t_0','e3u_0','e3v_0','e3w_0', &
+                  & 'e3f_0','gdepw_1d','gdept_1d',   &
+                  & 'e3tp','e3wp','gdepw_0','rx1',   &
+                  & 'gdept_0','gdepu','gdepv',       &
+                  & 'hdept','hdepw','e3w_1d','e3t_1d',&
+                  & 'tmask','umask','vmask','fmask'  )
+                  ! do not change for coordinates and meshmask variables
             END SELECT
          ENDIF
@@ -2118,41 +2209,39 @@
          ENDIF
 
-         IF( tl_var%t_att(ji)%i_type == NF90_CHAR )THEN
-            IF( TRIM(tl_var%t_att(ji)%c_value) /= '' )THEN
-               il_status = NF90_PUT_ATT(td_file%i_id, iom_cdf__write_var_def, &
-               &                        TRIM(tl_var%t_att(ji)%c_name),        &
-               &                        TRIM(tl_var%t_att(ji)%c_value)        )
-               CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR DEF: ")
-            ENDIF
-         ELSE
-            SELECT CASE(tl_var%t_att(ji)%i_type)
-               CASE(NF90_BYTE)
-                  il_status = NF90_PUT_ATT(td_file%i_id,                   &
-                  &                        iom_cdf__write_var_def,         &
-                  &                        TRIM(tl_var%t_att(ji)%c_name),  &
-                  &                        INT(tl_var%t_att(ji)%d_value(:),i1))
-               CASE(NF90_SHORT)
-                  il_status = NF90_PUT_ATT(td_file%i_id,                   &
-                  &                        iom_cdf__write_var_def,         &
-                  &                        TRIM(tl_var%t_att(ji)%c_name),  &
-                  &                        INT(tl_var%t_att(ji)%d_value(:),i2))
-               CASE(NF90_INT)
-                  il_status = NF90_PUT_ATT(td_file%i_id,                   &
-                  &                        iom_cdf__write_var_def,         &
-                  &                        TRIM(tl_var%t_att(ji)%c_name),  &
-                  &                        INT(tl_var%t_att(ji)%d_value(:),i4))
-               CASE(NF90_FLOAT)
-                  il_status = NF90_PUT_ATT(td_file%i_id,                   &
-                  &                        iom_cdf__write_var_def,         &
-                  &                        TRIM(tl_var%t_att(ji)%c_name),  &
-                  &                        REAL(tl_var%t_att(ji)%d_value(:),sp))
-               CASE(NF90_DOUBLE)
-                  il_status = NF90_PUT_ATT(td_file%i_id,                   &
-                  &                        iom_cdf__write_var_def,         &
-                  &                        TRIM(tl_var%t_att(ji)%c_name),  &
-                  &                        REAL(tl_var%t_att(ji)%d_value(:),dp))
-            END SELECT
-            CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR DEF: ")
-         ENDIF
+         SELECT CASE(tl_var%t_att(ji)%i_type)
+            CASE(NF90_CHAR)
+               IF( TRIM(tl_var%t_att(ji)%c_value) /= '' )THEN
+                  il_status = NF90_PUT_ATT(td_file%i_id, iom_cdf__write_var_def, &
+                  &                        TRIM(tl_var%t_att(ji)%c_name),        &
+                  &                        TRIM(tl_var%t_att(ji)%c_value)        )
+               ENDIF
+            CASE(NF90_BYTE)
+               il_status = NF90_PUT_ATT(td_file%i_id,                   &
+               &                        iom_cdf__write_var_def,         &
+               &                        TRIM(tl_var%t_att(ji)%c_name),  &
+               &                        INT(tl_var%t_att(ji)%d_value(:),i1))
+            CASE(NF90_SHORT)
+               il_status = NF90_PUT_ATT(td_file%i_id,                   &
+               &                        iom_cdf__write_var_def,         &
+               &                        TRIM(tl_var%t_att(ji)%c_name),  &
+               &                        INT(tl_var%t_att(ji)%d_value(:),i2))
+            CASE(NF90_INT)
+               il_status = NF90_PUT_ATT(td_file%i_id,                   &
+               &                        iom_cdf__write_var_def,         &
+               &                        TRIM(tl_var%t_att(ji)%c_name),  &
+               &                        INT(tl_var%t_att(ji)%d_value(:),i4))
+            CASE(NF90_FLOAT)
+               il_status = NF90_PUT_ATT(td_file%i_id,                   &
+               &                        iom_cdf__write_var_def,         &
+               &                        TRIM(tl_var%t_att(ji)%c_name),  &
+               &                        REAL(tl_var%t_att(ji)%d_value(:),sp))
+            CASE(NF90_DOUBLE)
+               il_status = NF90_PUT_ATT(td_file%i_id,                   &
+               &                        iom_cdf__write_var_def,         &
+               &                        TRIM(tl_var%t_att(ji)%c_name),  &
+               &                        REAL(tl_var%t_att(ji)%d_value(:),dp))
+         END SELECT
+         CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR DEF: ")
+
       ENDDO
 
@@ -2200,5 +2289,5 @@
          &  (td_var%d_value(:,:,:,:)-td_var%d_ofs)/td_var%d_scf
       END WHERE
-      
+
       jj=0
       DO ji = 1, ip_maxdim
@@ -2226,10 +2315,11 @@
 
       ! put value
-      CALL logger_trace( &
+      CALL logger_debug( &
       &  "IOM CDF WRITE VAR VALUE: put "//TRIM(td_var%c_name)//" value "//&
       &  "in file "//TRIM(td_file%c_name))
 
       il_status = NF90_PUT_VAR( td_file%i_id, td_var%i_id, dl_value(:,:,:,:))
-      CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR VALUE: ")
+      CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR VALUE ("//&
+         &  TRIM(td_var%c_name)//") :" )
 
       DEALLOCATE( dl_value )
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_dom.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_dom.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_dom.f90	(revision 7339)
@@ -234,5 +234,5 @@
                CALL logger_error( &
                &  " IOM DOM READ VAR: there is no variable with "//&
-               &  "name or standard name"//TRIM(cd_name)//&
+               &  "name or standard name "//TRIM(cd_name)//&
                &  " in processor/file "//TRIM(td_mpp%t_proc(1)%c_name))
             ENDIF
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_mpp.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_mpp.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_mpp.f90	(revision 7339)
@@ -415,5 +415,5 @@
             ELSE
 
-               CALL logger_error( &
+               CALL logger_fatal( &
                &  " IOM MPP READ VAR: there is no variable with "//&
                &  "name or standard name "//TRIM(cd_name)//&
@@ -648,7 +648,4 @@
          DO ji=1, td_mpp%i_nproc
             IF( td_mpp%t_proc(ji)%i_id /= 0 )THEN
-               !CALL file_del_att(td_mpp%t_proc(ji), 'periodicity')
-               !CALL file_del_att(td_mpp%t_proc(ji), 'ew_overlap')
-
                CALL iom_write_file(td_mpp%t_proc(ji), cd_dimorder)
             ELSE
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_rstdimg.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_rstdimg.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/iom_rstdimg.f90	(revision 7339)
@@ -395,5 +395,7 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !
+   !> @date January, 2016
+   !> - mismatch with "halo" indices
+   !>
    !> @param[inout] td_file   file structure
    !-------------------------------------------------------------------
@@ -494,34 +496,22 @@
       ENDIF
 
-      tl_att=att_init( "DOMAIN_position_first", (/il_impp(il_area), il_jmpp(il_area)/))
+      tl_att=att_init( "SUBDOMAIN_I_left_bottom_indices", il_impp(:) )
       CALL file_move_att(td_file, tl_att)
-
-      tl_att=att_init( "DOMAIN_position_last", (/il_lci(il_area), il_lcj(il_area)/))
+      tl_att=att_init( "SUBDOMAIN_J_left_bottom_indices", il_jmpp(:) )
       CALL file_move_att(td_file, tl_att)
 
-      tl_att=att_init( "DOMAIN_halo_size_start", (/il_ldi(il_area), il_ldj(il_area)/))
+      tl_att=att_init( "SUBDOMAIN_I_dimensions", il_lci(:))
       CALL file_move_att(td_file, tl_att)
-
-      tl_att=att_init( "DOMAIN_halo_size_end", (/il_lei(il_area), il_lej(il_area)/))
+      tl_att=att_init( "SUBDOMAIN_J_dimensions", il_lcj(:))
       CALL file_move_att(td_file, tl_att)
 
-      tl_att=att_init( "DOMAIN_I_position_first", il_impp(:) )
+      tl_att=att_init( "SUBDOMAIN_I_first_indoor_indices", il_ldi(:))
       CALL file_move_att(td_file, tl_att)
-      tl_att=att_init( "DOMAIN_J_position_first", il_jmpp(:) )
+      tl_att=att_init( "SUBDOMAIN_J_first_indoor_indices", il_ldj(:))
       CALL file_move_att(td_file, tl_att)
 
-      tl_att=att_init( "DOMAIN_I_position_last", il_lci(:) )
+      tl_att=att_init( "SUBDOMAIN_I_last_indoor_indices", il_lei(:))
       CALL file_move_att(td_file, tl_att)
-      tl_att=att_init( "DOMAIN_J_position_last", il_lcj(:) )
-      CALL file_move_att(td_file, tl_att)
-
-      tl_att=att_init( "DOMAIN_I_halo_size_start", il_ldi(:) )
-      CALL file_move_att(td_file, tl_att)
-      tl_att=att_init( "DOMAIN_J_halo_size_start", il_ldj(:) )
-      CALL file_move_att(td_file, tl_att)
-
-      tl_att=att_init( "DOMAIN_I_halo_size_end", il_lei(:) )
-      CALL file_move_att(td_file, tl_att)
-      tl_att=att_init( "DOMAIN_J_halo_size_end", il_lej(:) )
+      tl_att=att_init( "SUBDOMAIN_J_last_indoor_indices", il_lej(:))
       CALL file_move_att(td_file, tl_att)
 
@@ -1038,4 +1028,6 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date February, 2016
+   !> - use temporary array to read value from file
    !
    !> @param[in] td_file   file structure
@@ -1059,4 +1051,5 @@
       INTEGER(i4), DIMENSION(ip_maxdim)            :: il_count
 
+      REAL(dp),    DIMENSION(:,:,:)  , ALLOCATABLE :: dl_tmp
       REAL(dp),    DIMENSION(:,:,:,:), ALLOCATABLE :: dl_value
 
@@ -1142,7 +1135,10 @@
          IF( ALL(td_var%t_dim(1:3)%l_use) )THEN
             ! 3D variable (X,Y,Z)
+            ALLOCATE(dl_tmp( td_var%t_dim(1)%i_len, &
+            &                td_var%t_dim(2)%i_len, &
+            &                td_var%t_dim(4)%i_len) )           
             DO ji=1,td_var%t_dim(3)%i_len
                READ(td_file%i_id, IOSTAT=il_status, REC=td_var%i_rec +ji-1) &
-               &  dl_value(:,:,ji,:)
+               &  dl_tmp(:,:,:)
                CALL fct_err(il_status)
                IF( il_status /= 0 )THEN
@@ -1150,5 +1146,7 @@
                   &              TRIM(td_var%c_name))
                ENDIF
+               dl_value(:,:,ji,:)=dl_tmp(:,:,:)
             ENDDO
+            DEALLOCATE(dl_tmp)
          ELSEIF( ALL(td_var%t_dim(1:2)%l_use) )THEN
             ! 2D variable (X,Y)
@@ -1427,5 +1425,7 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !
+   !> @date January, 2016
+   !> - mismatch with "halo" indices
+   !>
    !> @param[inout] td_file   file structure
    !-------------------------------------------------------------------
@@ -1542,6 +1542,6 @@
       &         il_lei(il_nproc),  il_lej(il_nproc) )
 
-      ! get domain first poistion
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_I_position_first" )
+      ! get left bottom indices
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_I_left_bottom_indices" )
       il_impp(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1549,5 +1549,5 @@
       ENDIF
 
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_J_position_first" )
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_J_left_bottom_indices" )
       il_jmpp(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1555,11 +1555,11 @@
       ENDIF
       
-      ! check domain first poistion
+      ! check left bottom indices
       IF( ANY(il_impp(:)==0) .OR. ANY(il_jmpp(:)==0) )THEN
-         CALL logger_warn("WRITE FILE: no data for domain first position")
-      ENDIF
-
-      ! get domain last poistion
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_I_position_last" )
+         CALL logger_warn("WRITE FILE: no data for subdomain left bottom indices")
+      ENDIF
+
+      ! get subdomain dimensions
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_I_dimensions" )
       il_lci(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1567,5 +1567,5 @@
       ENDIF
 
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_J_position_last" )
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_J_dimensions" )
       il_lcj(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1573,11 +1573,11 @@
       ENDIF
 
-      ! check domain last poistion
+      ! check subdomain dimension
       IF( ANY(il_lci(:)==0) .OR. ANY(il_lcj(:)==0) )THEN
-         CALL logger_warn("WRITE FILE: no data for domain last position")
-      ENDIF
-
-      ! get halo size start
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_I_halo_size_start" )
+         CALL logger_warn("WRITE FILE: no data for subdomain dimensions")
+      ENDIF
+
+      ! get first indoor indices
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_I_first_indoor_indices" )
       il_ldi(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1585,5 +1585,5 @@
       ENDIF
 
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_J_halo_size_start" )
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_J_first_indoor_indices" )
       il_ldj(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1591,11 +1591,11 @@
       ENDIF
       
-      ! check halo size start
+      ! check first indoor indices
       IF( ANY(il_ldi(:)==0) .OR. ANY(il_ldj(:)==0) )THEN
-         CALL logger_warn("WRITE FILE: no data for halo size start")
-      ENDIF
-
-      ! get halo size end
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_I_halo_size_end" )
+         CALL logger_warn("WRITE FILE: no data for subdomain first indoor indices")
+      ENDIF
+
+      ! get last indoor indices
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_I_last_indoor_indices" )
       il_lei(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1603,5 +1603,5 @@
       ENDIF
 
-      il_ind=att_get_index( td_file%t_att, "DOMAIN_J_halo_size_end" )
+      il_ind=att_get_index( td_file%t_att, "SUBDOMAIN_J_last_indoor_indices" )
       il_lej(:) = 0
       IF( il_ind /= 0 )THEN
@@ -1609,7 +1609,7 @@
       ENDIF
 
-      ! check halo size end
+      ! check last indoor indices
       IF( ANY(il_lei(:)==0) .OR. ANY(il_lej(:)==0) )THEN
-         CALL logger_warn("WRITE FILE: no data for halo size end")
+         CALL logger_warn("WRITE FILE: no data for subdomain last indoor indices")
       ENDIF      
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/logger.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/logger.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/logger.f90	(revision 7339)
@@ -6,6 +6,8 @@
 !
 ! DESCRIPTION:
-!> @brief This module create logger file and allow to fill it depending of verbosity.
+!> @brief This module manage log file.
 !> @details
+!> This module create log file and fill it depending of verbosity.
+!>
 !> verbosity could be choosen between :
 !>    - trace : Most detailed information.
@@ -17,7 +19,9 @@
 !>    - error : Other runtime errors or unexpected conditions.
 !>    - fatal : Severe errors that cause premature termination.
-!>  default verbosity is warning
 !>    - none  : to not create and write any information in logger file.<br />
-!
+!>       @warn in this case only FATAL ERROR will be detected.<br />
+!>
+!> @note default verbosity is warning
+!>
 !> If total number of error exceeded maximum number 
 !> authorized, program stop.
@@ -35,4 +39,9 @@
 !> @code
 !> CALL logger_close()
+!> @endcode
+!>
+!> to clean logger file:<br/>
+!> @code
+!> CALL logger_clean()
 !> @endcode
 !>
@@ -104,4 +113,5 @@
 !>   CALL logger_footer()
 !>   CALL logger_close()
+!>   CALL logger_clean()
 !> @endcode
 !>
@@ -116,4 +126,5 @@
 !>   CALL logger_footer()
 !>   CALL logger_close()
+!>   CALL logger_clean()
 !> @endcode
 !
@@ -125,4 +136,6 @@
 !> - check verbosity validity
 !> - add 'none' verbosity level to not used logger file
+!> @date January, 2016
+!> - add logger_clean subroutine
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -144,4 +157,5 @@
    PUBLIC :: logger_open        !< create a log file with given verbosity
    PUBLIC :: logger_close       !< close log file
+   PUBLIC :: logger_clean       !< clean log structure
    PUBLIC :: logger_header      !< write header on log file
    PUBLIC :: logger_footer      !< write footer on log file
@@ -273,9 +287,9 @@
       IMPLICIT NONE
       ! local variable
-      INTEGER(i4) :: il_status
-      !----------------------------------------------------------------
-      IF( tm_logger%l_use )THEN
-         IF( tm_logger%i_id /= 0 )THEN
-            tm_logger%i_id = 0
+      INTEGER(i4)   :: il_status
+      !----------------------------------------------------------------
+      IF( tm_logger%l_use )THEN
+         IF( tm_logger%i_id /= 0 )THEN
+            !tm_logger%i_id = 0
             CLOSE( tm_logger%i_id, &
             &      IOSTAT=il_status)      
@@ -289,4 +303,18 @@
 
    END SUBROUTINE logger_close
+   !-------------------------------------------------------------------
+   !> @brief This subroutine clean a log structure.
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !-------------------------------------------------------------------
+   SUBROUTINE logger_clean()
+      IMPLICIT NONE
+      ! local variable
+      TYPE(TLOGGER) :: tl_logger
+      !----------------------------------------------------------------
+      tm_logger = tl_logger
+
+   END SUBROUTINE logger_clean
    !-------------------------------------------------------------------
    !> @brief This subroutine flushing output into log file.
@@ -537,8 +565,6 @@
       IF( tm_logger%l_use )THEN
          IF( tm_logger%i_id /= 0 )THEN
-            IF( TRIM(tm_logger%c_verb) /= 'none' )THEN
-               ! increment the error number
-               tm_logger%i_nerror=tm_logger%i_nerror+1
-            ENDIF
+            ! increment the error number
+            tm_logger%i_nerror=tm_logger%i_nerror+1
 
             IF( INDEX(TRIM(tm_logger%c_verb),'error')/=0 )THEN
@@ -571,4 +597,6 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date September, 2015
+   !> - stop program for FATAL ERROR if verbosity is none
    !
    !> @param[in] cd_msg message to write
@@ -598,4 +626,7 @@
              CALL logger_fatal('you must have create logger to use logger_fatal')
          ENDIF
+      ELSE
+         PRINT *,"FATAL ERROR :"//TRIM(cd_msg)
+         STOP
       ENDIF
    END SUBROUTINE logger_fatal
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/math.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/math.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/math.f90	(revision 7339)
@@ -1224,4 +1224,6 @@
          
       CASE('K')
+
+         ALLOCATE( dl_value(il_shape(1),il_shape(2),3) )
          ! compute derivative in k-direction
          DO jk=1,il_shape(3)
@@ -1266,7 +1268,7 @@
             ENDIF         
 
-            WHERE( dl_value(:,:, 2) /= dd_fill .AND. & ! jk
-               &   dl_value(:,:, 3) /= dd_fill .AND. & ! jk+1
-               &   dl_value(:,:, 1) /= dd_fill )       ! jk-1
+            WHERE( dl_value(:,:,2) /= dd_fill .AND. & ! jk
+               &   dl_value(:,:,3) /= dd_fill .AND. & ! jk+1
+               &   dl_value(:,:,1) /= dd_fill )       ! jk-1
 
                math_deriv_3D(:,:,jk)=&
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/merge_bathy.f90	(revision 7339)
@@ -9,9 +9,10 @@
 !> @file
 !> @brief 
-!> This program merge bathymetry file at boundaries.
+!> This program merges bathymetry file at boundaries.
 !>
 !> @details
 !> @section sec1 method
-!> Coarse grid Bathymetry is interpolated on fine grid. 
+!> Coarse grid Bathymetry is interpolated on fine grid 
+!> (nearest interpolation method is used).  
 !> Then fine Bathymetry and refined coarse bathymetry are merged at boundaries.<br/>
 !>    @f[BathyFine= Weight * BathyCoarse + (1-Weight)*BathyFine@f]
@@ -31,18 +32,14 @@
 !>    you could find a template of the namelist in templates directory.
 !>
-!>    merge_bathy.nam comprise 8 namelists:
+!>    merge_bathy.nam contains 7 namelists:
 !>       - logger namelist (namlog)
 !>       - config namelist (namcfg)
 !>       - coarse grid namelist (namcrs)
 !>       - fine grid namelist (namfin)
-!>       - variable namelist (namvar)
+!       - variable namelist (namvar)
 !>       - nesting namelist (namnst)
 !>       - boundary namelist (nambdy)
 !>       - output namelist (namout)
 !> 
-!>    @note 
-!>       All namelists have to be in file merge_bathy.nam, 
-!>       however variables of those namelists are all optional.
-!>
 !>    * _logger namelist (namlog)_:
 !>       - cn_logfile   : logger filename
@@ -52,5 +49,8 @@
 !>
 !>    * _config namelist (namcfg)_:
-!>       - cn_varcfg : variable configuration file (see ./SIREN/cfg/variable.cfg)
+!>       - cn_varcfg : variable configuration file 
+!> (see ./SIREN/cfg/variable.cfg)
+!>       - cn_dumcfg : useless (dummy) configuration file, for useless 
+!> dimension or variable (see ./SIREN/cfg/dummy.cfg).
 !>
 !>    * _coarse grid namelist (namcrs)_:
@@ -63,24 +63,24 @@
 !>       - in_perio1 : NEMO periodicity index
 !>
-!>    * _variable namelist (namvar)_:
-!>       - cn_varinfo : list of variable and extra information about request(s) 
-!>       to be used (separated by ',').<br/>
-!>          each elements of *cn_varinfo* is a string character.<br/>
-!>          it is composed of the variable name follow by ':', 
-!>          then request(s) to be used on this variable.<br/> 
-!>          request could be:
-!>             - int = interpolation method
-!> 
-!>                requests must be separated by ';'.<br/>
-!>                order of requests does not matter.<br/>
-!>
-!>          informations about available method could be find in 
-!>          @ref interp modules.<br/>
-!>          Example: 'bathymetry: int=cubic'
-!>          @note 
-!>             If you do not specify a method which is required, 
-!>             default one is apply.
-!>          @warning 
-!>             variable name must be __Bathymetry__ here.
+!    * _variable namelist (namvar)_:
+!       - cn_varinfo : list of variable and extra information about request(s) 
+!       to be used (separated by ',').<br/>
+!          each elements of *cn_varinfo* is a string character.<br/>
+!          it is composed of the variable name follow by ':', 
+!          then request(s) to be used on this variable.<br/> 
+!          request could be:
+!             - int = interpolation method
+! 
+!                requests must be separated by ';'.<br/>
+!                order of requests does not matter.<br/>
+!
+!          informations about available method could be find in 
+!          @ref interp modules.<br/>
+!          Example: 'bathymetry: int=cubic'
+!          @note 
+!             If you do not specify a method which is required, 
+!             default one is apply.
+!          @warning 
+!             variable name must be __Bathymetry__ here.
 !>
 !>    * _nesting namelist (namnst)_:
@@ -128,4 +128,6 @@
 !> - extrapolate all land points
 !> - add attributes with boundary string character (as in namelist)
+!> @date September, 2015
+!> - manage useless (dummy) variable, attributes, and dimension
 !>
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -207,4 +209,5 @@
    ! namcfg
    CHARACTER(LEN=lc)                       :: cn_varcfg = 'variable.cfg' 
+   CHARACTER(LEN=lc)                       :: cn_dumcfg = 'dummy.cfg'
 
    ! namcrs
@@ -216,6 +219,6 @@
    INTEGER(i4)                             :: in_perio1 = -1
 
-   ! namvar
-   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
+!   ! namvar
+!   CHARACTER(LEN=lc), DIMENSION(ip_maxvar) :: cn_varinfo = ''
 
    ! namnst
@@ -244,5 +247,6 @@
 
    NAMELIST /namcfg/ &  !< config namelist
-   &  cn_varcfg         !< variable configuration file
+   &  cn_varcfg, &       !< variable configuration file
+   &  cn_dumcfg          !< dummy configuration file
 
    NAMELIST /namcrs/ &  !< coarse grid namelist
@@ -254,8 +258,8 @@
    &  in_perio1         !< periodicity index
  
-   NAMELIST /namvar/ &  !< variable namelist
-   &  cn_varinfo        !< list of variable and interpolation 
-                        !< method to be used. 
-                        !< (ex: 'votemper|linear','vosaline|cubic' ) 
+!   NAMELIST /namvar/ &  !< variable namelist
+!   &  cn_varinfo        !< list of variable and interpolation 
+!                        !< method to be used. 
+!                        !< (ex: 'votemper|linear','vosaline|cubic' ) 
    
    NAMELIST /namnst/ &  !< nesting namelist
@@ -315,9 +319,16 @@
       CALL var_def_extra(TRIM(cn_varcfg))
 
+      ! get dummy variable
+      CALL var_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy dimension
+      CALL dim_get_dummy(TRIM(cn_dumcfg))
+      ! get dummy attribute
+      CALL att_get_dummy(TRIM(cn_dumcfg))
+
       READ( il_fileid, NML = namcrs )
       READ( il_fileid, NML = namfin )
-      READ( il_fileid, NML = namvar )
-      ! add user change in extra information
-      CALL var_chg_extra(cn_varinfo)
+!      READ( il_fileid, NML = namvar )
+!      ! add user change in extra information
+!      CALL var_chg_extra(cn_varinfo)
 
       READ( il_fileid, NML = namnst )
@@ -630,4 +641,6 @@
    !> @param[inout] dd_weight    array of weight
    !> @param[in] dd_fill         fillValue
+   !>
+   !> @todo improve boundary weight function
    !-------------------------------------------------------------------
    SUBROUTINE merge_bathy_get_boundary( td_bathy0, td_bathy1, td_bdy, &
@@ -690,4 +703,8 @@
                il_jmax1=td_bdy%t_seg(jl)%i_index
 
+               ! do not used grid point to compute 
+               ! boundaries indices (cf create_boundary)
+               ! as Bathymetry always on T point
+
             CASE('south')
 
@@ -703,4 +720,8 @@
                il_jmin1=td_bdy%t_seg(jl)%i_first
                il_jmax1=td_bdy%t_seg(jl)%i_last 
+
+               ! do not used grid point to compute 
+               ! boundaries indices (cf create_boundary)
+               ! as Bathymetry always on T point
 
             CASE('west')
@@ -777,4 +798,7 @@
             tl_var0=iom_dom_read_var(tl_bathy0,'Bathymetry',tl_dom0)
 
+            ! force to use nearest interpolation
+            tl_var0%c_interp(1)='nearest'
+
             ! close mpp files
             CALL iom_dom_close(tl_bathy0)
@@ -814,6 +838,14 @@
             CASE('north')
 
+!               ! npoint coarse
+!               il_width=td_bdy%t_seg(jl)%i_width-id_npoint
+!               ! compute "distance"
+!               dl_tmp1d(:)=(/(ji,ji=il_width-1,1,-1),(0,ji=1,id_npoint)/)
+!               ! compute weight on segment
+!               dl_tmp1d(:)= 0.5 + 0.5*COS( (dp_pi*dl_tmp1d(:)) / &
+!               &                           (il_width) )
+
                ! compute "distance"
-               dl_tmp1d(:)=(/(ji-1,ji=td_bdy%t_seg(jl)%i_width,1,-1)/)
+               dl_tmp1d(:)=(/(ji-1,ji=td_bdy%t_seg(jl)%i_width-1,1,-1),0/)
 
                ! compute weight on segment
@@ -831,5 +863,5 @@
 
                ! compute "distance"
-               dl_tmp1d(:)=(/(ji-1,ji=1,td_bdy%t_seg(jl)%i_width)/)               
+               dl_tmp1d(:)=(/0,(ji-1,ji=1,td_bdy%t_seg(jl)%i_width-1)/)               
 
                ! compute weight on segment
@@ -847,5 +879,5 @@
 
                ! compute "distance"
-               dl_tmp1d(:)=(/(ji-1,ji=td_bdy%t_seg(jl)%i_width,1,-1)/)
+               dl_tmp1d(:)=(/(ji-1,ji=td_bdy%t_seg(jl)%i_width-1,1,-1),0/)
 
                ! compute weight on segment
@@ -863,5 +895,5 @@
 
                ! compute "distance"
-               dl_tmp1d(:)=(/(ji-1,ji=1,td_bdy%t_seg(jl)%i_width)/)               
+               dl_tmp1d(:)=(/0,(ji-1,ji=1,td_bdy%t_seg(jl)%i_width-1)/)               
 
                ! compute weight on segment
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/mpp.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/mpp.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/mpp.f90	(revision 7339)
@@ -196,5 +196,11 @@
 ! REVISION HISTORY:
 !> @date November, 2013 - Initial Version
-!> @date November, 2014 - Fix memory leaks bug
+!> @date November, 2014 
+!> - Fix memory leaks bug
+!> @date October, 2015
+!> - improve way to compute domain layout
+!> @date January, 2016
+!> - allow to print layout file (use lm_layout, hard coded)
+!> - add mpp__compute_halo and mpp__read_halo
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -214,5 +220,6 @@
 
    ! type and variable
-   PUBLIC :: TMPP       !< mpp structure
+   PUBLIC  :: TMPP       !< mpp structure
+   PRIVATE :: TLAY       !< domain layout structure
 
    ! function and subroutine
@@ -239,13 +246,12 @@
    PUBLIC :: mpp_get_proc_size  !< get processor domain size
 
-   PRIVATE :: mpp__add_proc            ! add one proc strucutre in mpp structure
+   PRIVATE :: mpp__add_proc            ! add proc strucutre in mpp structure
+   PRIVATE :: mpp__add_proc_unit       ! add one proc strucutre in mpp structure
    PRIVATE :: mpp__del_proc            ! delete one proc strucutre in mpp structure
    PRIVATE :: mpp__del_proc_id         ! delete one proc strucutre in mpp structure, given procesor id
    PRIVATE :: mpp__del_proc_str        ! delete one proc strucutre in mpp structure, given procesor file structure 
    PRIVATE :: mpp__move_proc           ! overwrite proc strucutre in mpp structure
-   PRIVATE :: mpp__compute             ! compute domain decomposition
-   PRIVATE :: mpp__del_land            ! remove land sub domain from domain decomposition
+   PRIVATE :: mpp__create_layout       ! create mpp structure using domain layout
    PRIVATE :: mpp__optimiz             ! compute optimum domain decomposition
-   PRIVATE :: mpp__land_proc           ! check if processor is a land processor
    PRIVATE :: mpp__check_dim           ! check mpp structure dimension with proc or variable dimension
    PRIVATE :: mpp__check_proc_dim      ! check if processor and mpp structure use same dimension
@@ -267,7 +273,12 @@
    PRIVATE :: mpp__clean_unit          ! clean mpp strcuture
    PRIVATE :: mpp__clean_arr           ! clean array of mpp strcuture
+   PRIVATE :: mpp__compute_halo        ! compute subdomain indices defined with halo 
+   PRIVATE :: mpp__read_halo           ! read subdomain indices defined with halo
+
+   PRIVATE :: layout__init             ! initialise domain layout structure
+   PRIVATE :: layout__copy             ! clean domain layout structure
+   PRIVATE :: layout__clean            ! copy  domain layout structure
 
    TYPE TMPP !< mpp structure
-
       ! general 
       CHARACTER(LEN=lc)                  :: c_name = ''   !< base name 
@@ -284,5 +295,5 @@
 
       CHARACTER(LEN=lc)                  :: c_type = ''   !< type of the files (cdf, cdf4, dimg)
-      CHARACTER(LEN=lc)                  :: c_dom  = ''   !< type of domain (full, overlap, nooverlap)
+      CHARACTER(LEN=lc)                  :: c_dom  = ''   !< type of domain (full, noextra, nooverlap)
 
       INTEGER(i4)                        :: i_ndim = 0    !< number of dimensions used in mpp
@@ -290,10 +301,32 @@
 
       TYPE(TFILE), DIMENSION(:), POINTER :: t_proc => NULL()     !< files/processors composing mpp
-
    END TYPE
+
+   TYPE TLAY !< domain layout structure
+      INTEGER(i4)                          :: i_niproc = 0  !< number of processors following i
+      INTEGER(i4)                          :: i_njproc = 0  !< number of processors following j
+      INTEGER(i4)                          :: i_nland  = 0       !< number of land processors
+      INTEGER(i4)                          :: i_nsea   = 0       !< number of sea  processors
+      INTEGER(i4)                          :: i_mean   = 0       !< mean sea point per proc
+      INTEGER(i4)                          :: i_min    = 0       !< min  sea point per proc
+      INTEGER(i4)                          :: i_max    = 0       !< max  sea point per proc
+      INTEGER(i4), DIMENSION(:,:), POINTER :: i_msk   => NULL()  !< sea/land processor mask 
+      INTEGER(i4), DIMENSION(:,:), POINTER :: i_impp  => NULL()  !< i-indexes for mpp-subdomain left bottom 
+      INTEGER(i4), DIMENSION(:,:), POINTER :: i_jmpp  => NULL()  !< j-indexes for mpp-subdomain left bottom 
+      INTEGER(i4), DIMENSION(:,:), POINTER :: i_lci   => NULL()  !< i-dimensions of subdomain 
+      INTEGER(i4), DIMENSION(:,:), POINTER :: i_lcj   => NULL()  !< j-dimensions of subdomain 
+   END TYPE
+
+   ! module variable
+   INTEGER(i4) :: im_iumout = 44
+   LOGICAL     :: lm_layout =.FALSE.
 
    INTERFACE mpp_get_use
       MODULE PROCEDURE mpp__get_use_unit 
    END INTERFACE mpp_get_use
+
+   INTERFACE mpp__add_proc
+      MODULE PROCEDURE mpp__add_proc_unit 
+   END INTERFACE mpp__add_proc
 
    INTERFACE mpp_clean
@@ -560,9 +593,12 @@
             ALLOCATE( il_lci(td_mpp%i_niproc,td_mpp%i_njproc) )
             ALLOCATE( il_lcj(td_mpp%i_niproc,td_mpp%i_njproc) )
+            il_proc(:,:)=-1
+            il_lci(:,:) =-1
+            il_lcj(:,:) =-1
 
             DO jk=1,td_mpp%i_nproc
                ji=td_mpp%t_proc(jk)%i_iind
                jj=td_mpp%t_proc(jk)%i_jind
-               il_proc(ji,jj)=jk
+               il_proc(ji,jj)=jk-1
                il_lci(ji,jj)=td_mpp%t_proc(jk)%i_lci
                il_lcj(ji,jj)=td_mpp%t_proc(jk)%i_lcj
@@ -594,5 +630,4 @@
       ENDIF
 
-
 9400   FORMAT('     ***',20('*************',a3))
 9403   FORMAT('     *     ',20('         *   ',a3))
@@ -615,4 +650,9 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial version
+   !> @date September, 2015
+   !> - allow to define dimension with array of dimension structure
+   !> @date January, 2016
+   !> - use RESULT to rename output
+   !> - mismatch with "halo" indices
    !
    !> @param[in] cd_file   file name of one file composing mpp domain
@@ -627,32 +667,42 @@
    !> @param[in] id_perio  NEMO periodicity index
    !> @param[in] id_pivot  NEMO pivot point index F(0),T(1)
+   !> @param[in] td_dim    array of dimension structure
    !> @return mpp structure
    !-------------------------------------------------------------------
-   TYPE(TMPP) FUNCTION mpp__init_mask(cd_file, id_mask,              &
-   &                                  id_niproc, id_njproc, id_nproc,&
-   &                                  id_preci, id_precj,            &
-                                      cd_type, id_ew, id_perio, id_pivot)
+   FUNCTION mpp__init_mask(cd_file, id_mask,                   &
+   &                       id_niproc, id_njproc, id_nproc,     &
+   &                       id_preci, id_precj,                 &
+   &                       cd_type, id_ew, id_perio, id_pivot, &
+   &                       td_dim )                            &
+   & RESULT(td_mpp)
       IMPLICIT NONE
       ! Argument
-      CHARACTER(LEN=*),            INTENT(IN) :: cd_file
-      INTEGER(i4), DIMENSION(:,:), INTENT(IN) :: id_mask
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_niproc
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_njproc
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_nproc
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_preci
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_precj
-      CHARACTER(LEN=*),            INTENT(IN), OPTIONAL :: cd_type
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_ew
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_perio
-      INTEGER(i4),                 INTENT(IN), OPTIONAL :: id_pivot
+      CHARACTER(LEN=*),                  INTENT(IN) :: cd_file
+      INTEGER(i4), DIMENSION(:,:),       INTENT(IN) :: id_mask
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_niproc
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_njproc
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_nproc
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_preci
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_precj
+      CHARACTER(LEN=*),                  INTENT(IN), OPTIONAL :: cd_type
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_ew
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_perio
+      INTEGER(i4),                       INTENT(IN), OPTIONAL :: id_pivot
+      TYPE(TDIM) , DIMENSION(ip_maxdim), INTENT(IN), OPTIONAL :: td_dim
+
+      ! function
+      TYPE(TMPP) :: td_mpp
 
       ! local variable
-      CHARACTER(LEN=lc)                :: cl_type
-
-      INTEGER(i4)      , DIMENSION(2) :: il_shape
-
-      TYPE(TDIM)                      :: tl_dim
-
-      TYPE(TATT)                      :: tl_att
+      CHARACTER(LEN=lc)                            :: cl_type
+
+      INTEGER(i4)      , DIMENSION(2)              :: il_shape
+
+      TYPE(TDIM)                                   :: tl_dim
+
+      TYPE(TATT)                                   :: tl_att
+
+      TYPE(TLAY)                                   :: tl_lay
+
       ! loop indices
       INTEGER(i4) :: ji
@@ -660,5 +710,5 @@
 
       ! clean mpp
-      CALL mpp_clean(mpp__init_mask)
+      CALL mpp_clean(td_mpp)
 
       ! check type
@@ -669,31 +719,39 @@
          SELECT CASE(TRIM(cd_type))
             CASE('cdf')
-               mpp__init_mask%c_type='cdf'
+               td_mpp%c_type='cdf'
             CASE('dimg')
-               mpp__init_mask%c_type='dimg'
+               td_mpp%c_type='dimg'
             CASE DEFAULT
                CALL logger_warn( "MPP INIT: type "//TRIM(cd_type)//&
                & " unknown. type dimg will be used for mpp "//&
-               &  TRIM(mpp__init_mask%c_name) )
-               mpp__init_mask%c_type='dimg'
+               &  TRIM(td_mpp%c_name) )
+               td_mpp%c_type='dimg'
          END SELECT
       ELSE
-         mpp__init_mask%c_type=TRIM(file_get_type(cd_file))
+         td_mpp%c_type=TRIM(file_get_type(cd_file))
       ENDIF
 
       ! get mpp name
-      mpp__init_mask%c_name=TRIM(file_rename(cd_file))
+      td_mpp%c_name=TRIM(file_rename(cd_file))
 
       ! get global domain dimension
       il_shape(:)=SHAPE(id_mask)
 
-      tl_dim=dim_init('X',il_shape(1))
-      CALL mpp_add_dim(mpp__init_mask, tl_dim)
-
-      tl_dim=dim_init('Y',il_shape(2))
-      CALL mpp_add_dim(mpp__init_mask, tl_dim)
-
-      ! clean
-      CALL dim_clean(tl_dim)
+      IF( PRESENT(td_dim) )THEN
+         DO ji=1,ip_maxdim
+            IF( td_dim(ji)%l_use )THEN
+               CALL mpp_add_dim(td_mpp, td_dim(ji))
+            ENDIF
+         ENDDO
+      ELSE
+         tl_dim=dim_init('X',il_shape(1))
+         CALL mpp_add_dim(td_mpp, tl_dim)
+
+         tl_dim=dim_init('Y',il_shape(2))
+         CALL mpp_add_dim(td_mpp, tl_dim)
+
+         ! clean
+         CALL dim_clean(tl_dim)
+      ENDIF
 
       IF( (       PRESENT(id_niproc)  .AND. (.NOT. PRESENT(id_njproc))) .OR. &
@@ -703,125 +761,114 @@
       ELSE
          ! get number of processors following I and J
-         IF( PRESENT(id_niproc) ) mpp__init_mask%i_niproc=id_niproc
-         IF( PRESENT(id_njproc) ) mpp__init_mask%i_njproc=id_njproc
+         IF( PRESENT(id_niproc) ) td_mpp%i_niproc=id_niproc
+         IF( PRESENT(id_njproc) ) td_mpp%i_njproc=id_njproc
       ENDIF
 
       ! get maximum number of processors to be used
-      IF( PRESENT(id_nproc) ) mpp__init_mask%i_nproc = id_nproc
+      IF( PRESENT(id_nproc) ) td_mpp%i_nproc = id_nproc
 
       ! get overlap region length
-      IF( PRESENT(id_preci) ) mpp__init_mask%i_preci= id_preci
-      IF( PRESENT(id_precj) ) mpp__init_mask%i_precj= id_precj
+      IF( PRESENT(id_preci) ) td_mpp%i_preci= id_preci
+      IF( PRESENT(id_precj) ) td_mpp%i_precj= id_precj
 
       ! east-west overlap
-      IF( PRESENT(id_ew) ) mpp__init_mask%i_ew= id_ew
+      IF( PRESENT(id_ew) ) td_mpp%i_ew= id_ew
       ! NEMO periodicity
-      IF( PRESENT(id_perio) ) mpp__init_mask%i_perio= id_perio
-      IF( PRESENT(id_pivot) ) mpp__init_mask%i_pivot= id_pivot
-
-      IF( mpp__init_mask%i_nproc  /= 0 .AND. &
-      &   mpp__init_mask%i_niproc /= 0 .AND. &
-      &   mpp__init_mask%i_njproc /= 0 .AND. &
-      &   mpp__init_mask%i_nproc > &
-      &   mpp__init_mask%i_niproc * mpp__init_mask%i_njproc )THEN
+      IF( PRESENT(id_perio) ) td_mpp%i_perio= id_perio
+      IF( PRESENT(id_pivot) ) td_mpp%i_pivot= id_pivot
+
+      IF( td_mpp%i_nproc  /= 0 .AND. &
+      &   td_mpp%i_niproc /= 0 .AND. &
+      &   td_mpp%i_njproc /= 0 .AND. &
+      &   td_mpp%i_nproc > &
+      &   td_mpp%i_niproc * td_mpp%i_njproc )THEN
 
          CALL logger_error("MPP INIT: invalid domain decomposition ")
          CALL logger_debug("MPP INIT: "// &
-         & TRIM(fct_str(mpp__init_mask%i_nproc))//" > "//&
-         & TRIM(fct_str(mpp__init_mask%i_niproc))//" x "//&
-         & TRIM(fct_str(mpp__init_mask%i_njproc)) )
+         & TRIM(fct_str(td_mpp%i_nproc))//" > "//&
+         & TRIM(fct_str(td_mpp%i_niproc))//" x "//&
+         & TRIM(fct_str(td_mpp%i_njproc)) )
 
       ELSE
-
-         IF( mpp__init_mask%i_niproc /= 0 .AND. &
-         &   mpp__init_mask%i_njproc /= 0 )THEN
-            ! compute domain decomposition
-            CALL mpp__compute( mpp__init_mask )
-            ! remove land sub domain
-            CALL mpp__del_land( mpp__init_mask, id_mask )
-         ELSEIF( mpp__init_mask%i_nproc  /= 0 )THEN
+         IF( lm_layout )THEN
+            OPEN(im_iumout,FILE='processor.layout')
+            WRITE(im_iumout,*)
+            WRITE(im_iumout,*) ' optimisation de la partition'
+            WRITE(im_iumout,*) ' ----------------------------'
+            WRITE(im_iumout,*)
+         ENDIF
+
+         IF( td_mpp%i_niproc /= 0 .AND. &
+         &   td_mpp%i_njproc /= 0 )THEN
+            ! compute domain layout
+            tl_lay=layout__init( td_mpp, id_mask, td_mpp%i_niproc, td_mpp%i_njproc )
+            ! create mpp domain layout
+            CALL mpp__create_layout( td_mpp, tl_lay )
+            ! clean
+            CALL layout__clean( tl_lay )
+         ELSEIF( td_mpp%i_nproc  /= 0 )THEN
             ! optimiz
-            CALL mpp__optimiz( mpp__init_mask, id_mask )
+            CALL mpp__optimiz( td_mpp, id_mask, td_mpp%i_nproc )
 
          ELSE
             CALL logger_warn("MPP INIT: number of processor to be used "//&
             &                "not specify. force to one.")
-            mpp__init_mask%i_nproc  = 1
             ! optimiz
-            CALL mpp__optimiz( mpp__init_mask, id_mask )
+            CALL mpp__optimiz( td_mpp, id_mask, 1 )
          ENDIF
+
+
          CALL logger_info("MPP INIT: domain decoposition : "//&
-         &  'niproc('//TRIM(fct_str(mpp__init_mask%i_niproc))//') * '//&
-         &  'njproc('//TRIM(fct_str(mpp__init_mask%i_njproc))//') = '//&
-         &  'nproc('//TRIM(fct_str(mpp__init_mask%i_nproc))//')' )
+         &  'niproc('//TRIM(fct_str(td_mpp%i_niproc))//') * '//&
+         &  'njproc('//TRIM(fct_str(td_mpp%i_njproc))//') = '//&
+         &  'nproc('//TRIM(fct_str(td_mpp%i_nproc))//')' )
 
          ! get domain type
-         CALL mpp_get_dom( mpp__init_mask )
-
-         DO ji=1,mpp__init_mask%i_nproc
+         CALL mpp_get_dom( td_mpp )
+
+         DO ji=1,td_mpp%i_nproc
 
             ! get processor size
-            il_shape(:)=mpp_get_proc_size( mpp__init_mask, ji )
+            il_shape(:)=mpp_get_proc_size( td_mpp, ji )
 
             tl_dim=dim_init('X',il_shape(1))
-            CALL file_move_dim(mpp__init_mask%t_proc(ji), tl_dim)
+            CALL file_move_dim(td_mpp%t_proc(ji), tl_dim)
 
             tl_dim=dim_init('Y',il_shape(2))
-            CALL file_move_dim(mpp__init_mask%t_proc(ji), tl_dim)            
-
+            CALL file_move_dim(td_mpp%t_proc(ji), tl_dim)            
+
+            IF( PRESENT(td_dim) )THEN
+               IF( td_dim(jp_K)%l_use )THEN
+                  CALL file_move_dim(td_mpp%t_proc(ji), td_dim(jp_K))
+               ENDIF
+               IF( td_dim(jp_L)%l_use )THEN
+                  CALL file_move_dim(td_mpp%t_proc(ji), td_dim(jp_L))
+               ENDIF
+            ENDIF
             ! add type
-            mpp__init_mask%t_proc(ji)%c_type=TRIM(mpp__init_mask%c_type)
+            td_mpp%t_proc(ji)%c_type=TRIM(td_mpp%c_type)
 
             ! clean
             CALL dim_clean(tl_dim)
+
          ENDDO
 
          ! add global attribute
-         tl_att=att_init("DOMAIN_number_total",mpp__init_mask%i_nproc)
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init("DOMAIN_I_number_total",mpp__init_mask%i_niproc)
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init("DOMAIN_J_number_total",mpp__init_mask%i_njproc)
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init("DOMAIN_size_global",mpp__init_mask%t_dim(1:2)%i_len)
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_I_position_first", &
-         &                mpp__init_mask%t_proc(:)%i_impp )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_J_position_first", &
-         &                mpp__init_mask%t_proc(:)%i_jmpp )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_I_position_last", &
-         &                mpp__init_mask%t_proc(:)%i_lci )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_J_position_last", &
-         &                mpp__init_mask%t_proc(:)%i_lcj )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_I_halo_size_start", &
-         &                mpp__init_mask%t_proc(:)%i_ldi )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_J_halo_size_start", &
-         &                mpp__init_mask%t_proc(:)%i_ldj )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_I_halo_size_end", &
-         &                mpp__init_mask%t_proc(:)%i_lei )
-         CALL mpp_add_att(mpp__init_mask, tl_att)
-
-         tl_att=att_init( "DOMAIN_J_halo_size_end", &
-         &                mpp__init_mask%t_proc(:)%i_lej )
-         CALL mpp_add_att(mpp__init_mask, tl_att)         
-
-         ! clean
-         CALL att_clean(tl_att)
+         tl_att=att_init("DOMAIN_number_total",td_mpp%i_nproc)
+         CALL mpp_add_att(td_mpp, tl_att)
+
+         tl_att=att_init("DOMAIN_LOCAL",TRIM(td_mpp%c_dom))
+         CALL mpp_add_att(td_mpp, tl_att)
+
+         tl_att=att_init("DOMAIN_I_number_total",td_mpp%i_niproc)
+         CALL mpp_add_att(td_mpp, tl_att)
+
+         tl_att=att_init("DOMAIN_J_number_total",td_mpp%i_njproc)
+         CALL mpp_add_att(td_mpp, tl_att)
+
+         tl_att=att_init("DOMAIN_size_global",td_mpp%t_dim(1:2)%i_len)
+         CALL mpp_add_att(td_mpp, tl_att)
+
+         CALL mpp__compute_halo(td_mpp) 
       ENDIF
 
@@ -880,4 +927,6 @@
          il_mask(:,:,:)=var_get_mask(td_var)
          
+         CALL logger_info("MPP INIT: mask compute from variable "//&
+            &             TRIM(td_var%c_name))
          mpp__init_var=mpp_init( cd_file, il_mask(:,:,1),       &
          &                       id_niproc, id_njproc, id_nproc,&
@@ -907,9 +956,9 @@
    !>    - DOMAIN_halo_size_end
    !>  or the file is assume to be no mpp file.
-   !>  
-   !> 
    !>
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date January, 2016
+   !> - mismatch with "halo" indices, use mpp__compute_halo
    !
    !> @param[in] td_file   file strcuture
@@ -929,16 +978,16 @@
 
       ! local variable
-      TYPE(TMPP)  :: tl_mpp
-      
-      TYPE(TFILE) :: tl_file
-      
-      TYPE(TDIM)  :: tl_dim
-
-      TYPE(TATT)  :: tl_att
-
-      INTEGER(i4) :: il_nproc
-      INTEGER(i4) :: il_attid
-
+      INTEGER(i4)               :: il_nproc
+      INTEGER(i4)               :: il_attid
       INTEGER(i4), DIMENSION(2) :: il_shape
+
+      TYPE(TDIM)                :: tl_dim
+
+      TYPE(TATT)                :: tl_att
+
+      TYPE(TFILE)               :: tl_file
+
+      TYPE(TMPP)                :: tl_mpp
+
       ! loop indices
       INTEGER(i4) :: ji
@@ -956,5 +1005,4 @@
             ! open file
             CALL iom_open(tl_file)
-
             ! read first file domain decomposition
             tl_mpp=mpp__init_file_cdf(tl_file)
@@ -1029,28 +1077,6 @@
             CALL mpp_move_att(mpp__init_file, tl_att)
 
-            tl_att=att_init( "DOMAIN_I_position_first", mpp__init_file%t_proc(:)%i_impp )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_position_first", mpp__init_file%t_proc(:)%i_jmpp )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_position_last", mpp__init_file%t_proc(:)%i_lci )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_position_last", mpp__init_file%t_proc(:)%i_lcj )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_halo_size_start", mpp__init_file%t_proc(:)%i_ldi )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_halo_size_start", mpp__init_file%t_proc(:)%i_ldj )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_halo_size_end", mpp__init_file%t_proc(:)%i_lei )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_halo_size_end", mpp__init_file%t_proc(:)%i_lej )
-            CALL mpp_move_att(mpp__init_file, tl_att)
-            
+            CALL mpp__compute_halo(mpp__init_file)
+ 
             ! clean
             CALL mpp_clean(tl_mpp)
@@ -1130,5 +1156,8 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !> @date July, 2015 - add only use dimension in MPP structure
+   !> @date July, 2015 
+   !> - add only use dimension in MPP structure
+   !> @date January, 2016
+   !> - mismatch with "halo" indices, use mpp__read_halo
    !>
    !> @param[in] td_file   file strcuture
@@ -1218,55 +1247,5 @@
             tl_proc%t_dim(:)=dim_copy(td_file%t_dim(:))
 
-            ! DOMAIN_position_first
-            il_attid = 0
-            IF( ASSOCIATED(td_file%t_att) )THEN
-               il_attid=att_get_id( td_file%t_att, "DOMAIN_position_first" )
-            ENDIF
-            IF( il_attid /= 0 )THEN
-               tl_proc%i_impp = INT(td_file%t_att(il_attid)%d_value(1))
-               tl_proc%i_jmpp = INT(td_file%t_att(il_attid)%d_value(2))
-            ELSE
-               tl_proc%i_impp = 1
-               tl_proc%i_jmpp = 1
-            ENDIF
-
-            ! DOMAIN_position_last
-            il_attid = 0
-            IF( ASSOCIATED(td_file%t_att) )THEN
-               il_attid=att_get_id( td_file%t_att, "DOMAIN_position_last" )
-            ENDIF
-            IF( il_attid /= 0 )THEN
-               tl_proc%i_lci = INT(td_file%t_att(il_attid)%d_value(1)) + tl_proc%i_impp
-               tl_proc%i_lcj = INT(td_file%t_att(il_attid)%d_value(2)) + tl_proc%i_jmpp
-            ELSE
-               tl_proc%i_lci = mpp__init_file_cdf%t_dim(1)%i_len
-               tl_proc%i_lcj = mpp__init_file_cdf%t_dim(2)%i_len
-            ENDIF
-
-            ! DOMAIN_halo_size_start
-            il_attid = 0
-            IF( ASSOCIATED(td_file%t_att) )THEN
-               il_attid=att_get_id( td_file%t_att, "DOMAIN_halo_size_start" )
-            ENDIF
-            IF( il_attid /= 0 )THEN
-               tl_proc%i_ldi = INT(td_file%t_att(il_attid)%d_value(1))
-               tl_proc%i_ldj = INT(td_file%t_att(il_attid)%d_value(2))
-            ELSE
-               tl_proc%i_ldi = 1
-               tl_proc%i_ldj = 1
-            ENDIF
-
-            ! DOMAIN_halo_size_end
-            il_attid = 0
-            IF( ASSOCIATED(td_file%t_att) )THEN
-               il_attid=att_get_id( td_file%t_att, "DOMAIN_halo_size_end" )
-            ENDIF
-            IF( il_attid /= 0 )THEN
-               tl_proc%i_lei = INT(td_file%t_att(il_attid)%d_value(1))
-               tl_proc%i_lej = INT(td_file%t_att(il_attid)%d_value(2))
-            ELSE
-               tl_proc%i_lei = mpp__init_file_cdf%t_dim(1)%i_len
-               tl_proc%i_lej = mpp__init_file_cdf%t_dim(2)%i_len
-            ENDIF
+            CALL mpp__read_halo(tl_proc, mpp__init_file_cdf%t_dim(:) )
 
             ! add attributes
@@ -1278,20 +1257,4 @@
             CALL file_move_att(tl_proc, tl_att)
 
-            tl_att=att_init( "DOMAIN_position_first", &
-            &                (/tl_proc%i_impp, tl_proc%i_jmpp /) )
-            CALL file_move_att(tl_proc, tl_att)
-
-            tl_att=att_init( "DOMAIN_position_last", &
-            &                (/tl_proc%i_lci, tl_proc%i_lcj /) )
-            CALL file_move_att(tl_proc, tl_att)
-
-            tl_att=att_init( "DOMAIN_halo_size_start", &
-            &                (/tl_proc%i_ldi, tl_proc%i_ldj /) )
-            CALL file_move_att(tl_proc, tl_att)
-
-            tl_att=att_init( "DOMAIN_halo_size_end", &
-            &                (/tl_proc%i_lei, tl_proc%i_lej /) )
-            CALL file_move_att(tl_proc, tl_att)
-
             ! add processor to mpp structure
             CALL mpp__add_proc(mpp__init_file_cdf, tl_proc)
@@ -1299,4 +1262,5 @@
             ! clean 
             CALL file_clean(tl_proc)
+            CALL dim_clean(tl_dim)
             CALL att_clean(tl_att)
          ENDIF
@@ -1307,5 +1271,6 @@
          &  " do not exist")
 
-      ENDIF      
+      ENDIF
+
    END FUNCTION mpp__init_file_cdf
    !-------------------------------------------------------------------
@@ -1317,5 +1282,7 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
-   !
+   !> @date January, 2016
+   !> - mismatch with "halo" indices, use mpp__compute_halo
+   !>
    !> @param[in] td_file   file strcuture
    !> @return mpp structure
@@ -1336,4 +1303,13 @@
       INTEGER(i4)       :: il_pni, il_pnj, il_pnij          ! domain decomposition
       INTEGER(i4)       :: il_area                          ! domain index
+
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_lci
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ldi
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_lei
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_impp
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_lcj
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ldj
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_lej
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_jmpp
 
       LOGICAL           ::  ll_exist
@@ -1389,4 +1365,13 @@
             ALLOCATE( mpp__init_file_rstdimg%t_proc(il_pnij) , stat=il_status )
 
+            ALLOCATE(il_lci (il_pnij))
+            ALLOCATE(il_lcj (il_pnij))
+            ALLOCATE(il_ldi (il_pnij))
+            ALLOCATE(il_ldj (il_pnij))
+            ALLOCATE(il_lei (il_pnij))
+            ALLOCATE(il_lej (il_pnij))
+            ALLOCATE(il_impp(il_pnij))
+            ALLOCATE(il_jmpp(il_pnij))
+
             tl_proc=file_copy(td_file)
             ! remove dimension from file
@@ -1411,12 +1396,12 @@
             &     il_area,                         &
             &     il_iglo, il_jglo,                &
-            &     mpp__init_file_rstdimg%t_proc(:)%i_lci,    &
-            &     mpp__init_file_rstdimg%t_proc(:)%i_lcj,    &
-            &     mpp__init_file_rstdimg%t_proc(:)%i_ldi,    &
-            &     mpp__init_file_rstdimg%t_proc(:)%i_ldj,    &
-            &     mpp__init_file_rstdimg%t_proc(:)%i_lei,    &
-            &     mpp__init_file_rstdimg%t_proc(:)%i_lej,    &
-            &     mpp__init_file_rstdimg%t_proc(:)%i_impp,   &
-            &     mpp__init_file_rstdimg%t_proc(:)%i_jmpp
+            &     il_lci(1:il_pnij),    &
+            &     il_lcj(1:il_pnij),    &
+            &     il_ldi(1:il_pnij),    &
+            &     il_ldj(1:il_pnij),    &
+            &     il_lei(1:il_pnij),    &
+            &     il_lej(1:il_pnij),    &
+            &     il_impp(1:il_pnij),   &
+            &     il_jmpp(1:il_pnij)
             CALL fct_err(il_status)
             IF( il_status /= 0 )THEN
@@ -1424,4 +1409,22 @@
                &              TRIM(td_file%c_name))
             ENDIF
+
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_lci = il_lci (1:il_pnij)
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_lcj = il_lcj (1:il_pnij) 
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_ldi = il_ldi (1:il_pnij) 
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_ldj = il_ldj (1:il_pnij) 
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_lei = il_lei (1:il_pnij) 
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_lej = il_lej (1:il_pnij) 
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_impp= il_impp(1:il_pnij)
+            mpp__init_file_rstdimg%t_proc(1:il_pnij)%i_jmpp= il_jmpp(1:il_pnij)
+
+            DEALLOCATE(il_lci) 
+            DEALLOCATE(il_lcj) 
+            DEALLOCATE(il_ldi) 
+            DEALLOCATE(il_ldj) 
+            DEALLOCATE(il_lei) 
+            DEALLOCATE(il_lej) 
+            DEALLOCATE(il_impp)
+            DEALLOCATE(il_jmpp)
 
             ! global domain size
@@ -1435,4 +1438,5 @@
 
             DO ji=1,mpp__init_file_rstdimg%i_nproc
+
                ! get file name
                cl_file =  file_rename(td_file%c_name,ji)
@@ -1445,23 +1449,4 @@
                CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att) 
 
-               tl_att=att_init( "DOMAIN_position_first", &
-               &                (/mpp__init_file_rstdimg%t_proc(ji)%i_impp, &
-               &                  mpp__init_file_rstdimg%t_proc(ji)%i_jmpp /) )
-               CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att)
-
-               tl_att=att_init( "DOMAIN_position_last", &
-               &                (/mpp__init_file_rstdimg%t_proc(ji)%i_lci, &
-               &                  mpp__init_file_rstdimg%t_proc(ji)%i_lcj /) )
-               CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att)
-
-               tl_att=att_init( "DOMAIN_halo_size_start", &
-               &                (/mpp__init_file_rstdimg%t_proc(ji)%i_ldi, &
-               &                  mpp__init_file_rstdimg%t_proc(ji)%i_ldj /) )
-               CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att)               
-
-               tl_att=att_init( "DOMAIN_halo_size_end", &
-               &                (/mpp__init_file_rstdimg%t_proc(ji)%i_lei, &
-               &                  mpp__init_file_rstdimg%t_proc(ji)%i_lej /) )
-               CALL file_move_att(mpp__init_file_rstdimg%t_proc(ji), tl_att)
             ENDDO
  
@@ -1486,35 +1471,7 @@
             CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
 
-            tl_att=att_init( "DOMAIN_I_position_first", &
-            &                 mpp__init_file_rstdimg%t_proc(:)%i_impp )
-            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_position_first", &
-            &                 mpp__init_file_rstdimg%t_proc(:)%i_jmpp )
-            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_position_last", &
-            &                 mpp__init_file_rstdimg%t_proc(:)%i_lci )
-            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_position_last", &
-            &                 mpp__init_file_rstdimg%t_proc(:)%i_lcj )
-            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_halo_size_start", &
-            &                 mpp__init_file_rstdimg%t_proc(:)%i_ldi )
-            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_halo_size_start", &
-            &                 mpp__init_file_rstdimg%t_proc(:)%i_ldj )
-            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
-
-            tl_att=att_init( "DOMAIN_I_halo_size_end", &
-            &                 mpp__init_file_rstdimg%t_proc(:)%i_lei )
-            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
-
-            tl_att=att_init( "DOMAIN_J_halo_size_end", &
-            &                 mpp__init_file_rstdimg%t_proc(:)%i_lej )
-            CALL mpp_move_att(mpp__init_file_rstdimg, tl_att)
+            CALL mpp_get_dom( mpp__init_file_rstdimg )
+
+            CALL mpp__compute_halo( mpp__init_file_rstdimg )
 
             ! clean
@@ -1598,5 +1555,5 @@
       ! Argument
       TYPE(TMPP), INTENT(INOUT) :: td_mpp
-      TYPE(TVAR), INTENT(IN)    :: td_var
+      TYPE(TVAR), INTENT(INOUT) :: td_var
 
       ! local variable
@@ -1646,4 +1603,7 @@
                ! check used dimension 
                IF( mpp__check_dim(td_mpp, td_var) )THEN
+         
+                  ! check variable dimension expected
+                  CALL var_check_dim(td_var)
 
                   ! update dimension if need be
@@ -1915,5 +1875,5 @@
       TYPE(TVAR) :: tl_var
       !----------------------------------------------------------------
-      ! copy variable
+      ! copy variablie
       tl_var=var_copy(td_var)
 
@@ -1942,5 +1902,5 @@
    !> - check proc type
    !-------------------------------------------------------------------
-   SUBROUTINE mpp__add_proc( td_mpp, td_proc )
+   SUBROUTINE mpp__add_proc_unit( td_mpp, td_proc )
       IMPLICIT NONE
       ! Argument
@@ -1957,4 +1917,12 @@
       CHARACTER(LEN=lc)                            :: cl_name
       !----------------------------------------------------------------
+
+!      ALLOCATE(tl_proc(1))
+!      tl_proc(1)=file_copy(td_proc)
+!
+!      CALL mpp__add_proc(td_mpp, tl_proc(:))
+!
+!      CALL file_clean(tl_proc(:))
+!      DEALLOCATE(tl_proc)
 
       ! check file name
@@ -2056,5 +2024,6 @@
 
       ENDIF
-   END SUBROUTINE mpp__add_proc
+
+   END SUBROUTINE mpp__add_proc_unit
    !-------------------------------------------------------------------
    !> @brief
@@ -2575,33 +2544,352 @@
    !-------------------------------------------------------------------
    !> @brief
-   !>    This subroutine compute domain decomposition for niproc and njproc 
-   !> processors following I and J.
-   !>
+   !>    This function initialise domain layout
+   !> 
    !> @detail
-   !> To do so, it need to know :
-   !> - global domain dimension
-   !> - overlap region length
-   !> - number of processors following I and J
+   !> Domain layout is first compute, with domain dimension, overlap between subdomain,
+   !> and the number of processors following I and J.
+   !> Then the number of sea/land processors is compute with mask
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial version
+   !> @date October, 2015 - Initial version
+   !
+   !> @param[in] td_mpp mpp strcuture
+   !> @param[in] id_mask   sub domain mask (sea=1, land=0)
+   !> @pâram[in] id_niproc number of processors following I
+   !> @pâram[in] id_njproc number of processors following J
+   !> @return domain layout structure
+   !-------------------------------------------------------------------
+   FUNCTION layout__init( td_mpp, id_mask, id_niproc, id_njproc ) RESULT(td_lay)
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TMPP)                 , INTENT(IN) :: td_mpp
+      INTEGER(i4), DIMENSION(:,:), INTENT(IN) :: id_mask
+      INTEGER(i4)                , INTENT(IN) :: id_niproc
+      INTEGER(i4)                , INTENT(IN) :: id_njproc
+
+      ! function
+      TYPE(TLAY) :: td_lay
+
+      ! local variable
+      INTEGER(i4) :: ii1, ii2
+      INTEGER(i4) :: ij1, ij2
+
+      INTEGER(i4) :: il_ldi
+      INTEGER(i4) :: il_ldj
+      INTEGER(i4) :: il_lei
+      INTEGER(i4) :: il_lej
+
+      INTEGER(i4) :: il_isize !< i-direction maximum sub domain size 
+      INTEGER(i4) :: il_jsize !< j-direction maximum sub domain size
+      INTEGER(i4) :: il_resti !<  
+      INTEGER(i4) :: il_restj !<  
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
+      !----------------------------------------------------------------
+
+      ! intialise
+      td_lay%i_niproc=id_niproc
+      td_lay%i_njproc=id_njproc
+
+      CALL logger_info( "MPP COMPUTE LAYOUT: compute domain layout with "//&
+      &               TRIM(fct_str(td_lay%i_niproc))//" x "//&
+      &               TRIM(fct_str(td_lay%i_njproc))//" processors")
+
+      ! maximum size of sub domain
+      il_isize = ((td_mpp%t_dim(1)%i_len - 2*td_mpp%i_preci + (td_lay%i_niproc-1))/ &
+      &           td_lay%i_niproc) + 2*td_mpp%i_preci
+      il_jsize = ((td_mpp%t_dim(2)%i_len - 2*td_mpp%i_precj + (td_lay%i_njproc-1))/ &
+      &           td_lay%i_njproc) + 2*td_mpp%i_precj
+
+      il_resti = MOD(td_mpp%t_dim(1)%i_len - 2*td_mpp%i_preci, td_lay%i_niproc)
+      il_restj = MOD(td_mpp%t_dim(2)%i_len - 2*td_mpp%i_precj, td_lay%i_njproc)
+      IF( il_resti == 0 ) il_resti = td_lay%i_niproc
+      IF( il_restj == 0 ) il_restj = td_lay%i_njproc
+
+      ! compute dimension of each sub domain
+      ALLOCATE( td_lay%i_lci(td_lay%i_niproc,td_lay%i_njproc) )
+      ALLOCATE( td_lay%i_lcj(td_lay%i_niproc,td_lay%i_njproc) )
+
+      td_lay%i_lci( 1          : il_resti       , : ) = il_isize
+      td_lay%i_lci( il_resti+1 : td_lay%i_niproc, : ) = il_isize-1
+
+      td_lay%i_lcj( : , 1          : il_restj       ) = il_jsize
+      td_lay%i_lcj( : , il_restj+1 : td_lay%i_njproc) = il_jsize-1
+
+      ! compute first index of each sub domain
+      ALLOCATE( td_lay%i_impp(td_lay%i_niproc,td_lay%i_njproc) )
+      ALLOCATE( td_lay%i_jmpp(td_lay%i_niproc,td_lay%i_njproc) )
+
+      td_lay%i_impp(:,:)=1
+      td_lay%i_jmpp(:,:)=1
+
+      IF( td_lay%i_niproc > 1 )THEN
+         DO jj=1,td_lay%i_njproc
+            DO ji=2,td_lay%i_niproc
+               td_lay%i_impp(ji,jj) = td_lay%i_impp(ji-1,jj) + &
+               &                       td_lay%i_lci (ji-1,jj) - 2*td_mpp%i_preci
+            ENDDO
+         ENDDO
+      ENDIF
+
+      IF( td_lay%i_njproc > 1 )THEN
+         DO jj=2,td_lay%i_njproc
+            DO ji=1,td_lay%i_niproc
+               td_lay%i_jmpp(ji,jj) = td_lay%i_jmpp(ji,jj-1) + &
+               &                       td_lay%i_lcj (ji,jj-1) - 2*td_mpp%i_precj
+            ENDDO
+         ENDDO 
+      ENDIF
+
+      ALLOCATE(td_lay%i_msk(td_lay%i_niproc,td_lay%i_njproc))
+      td_lay%i_msk(:,:)=0
+      ! init number of sea/land proc
+      td_lay%i_nsea=0
+      td_lay%i_nland=td_lay%i_njproc*td_lay%i_niproc
+
+      ! check if processor is land or sea
+      DO jj = 1,td_lay%i_njproc
+         DO ji = 1,td_lay%i_niproc
+
+            ! compute first and last indoor indices
+            ! west boundary
+            IF( ji == 1 )THEN
+               il_ldi = 1 
+            ELSE
+               il_ldi = 1 + td_mpp%i_preci
+            ENDIF
+
+            ! south boundary
+            IF( jj == 1 )THEN
+               il_ldj = 1 
+            ELSE
+               il_ldj = 1 + td_mpp%i_precj
+            ENDIF
+
+            ! east boundary
+            IF( ji == td_mpp%i_niproc )THEN
+               il_lei = td_lay%i_lci(ji,jj)
+            ELSE
+               il_lei = td_lay%i_lci(ji,jj) - td_mpp%i_preci
+            ENDIF
+
+            ! north boundary
+            IF( jj == td_mpp%i_njproc )THEN
+               il_lej = td_lay%i_lcj(ji,jj)
+            ELSE
+               il_lej = td_lay%i_lcj(ji,jj) - td_mpp%i_precj
+            ENDIF
+
+            ii1=td_lay%i_impp(ji,jj) + il_ldi - 1
+            ii2=td_lay%i_impp(ji,jj) + il_lei - 1
+
+            ij1=td_lay%i_jmpp(ji,jj) + il_ldj - 1
+            ij2=td_lay%i_jmpp(ji,jj) + il_lej - 1
+
+            td_lay%i_msk(ji,jj)=SUM( id_mask(ii1:ii2,ij1:ij2) )
+            IF( td_lay%i_msk(ji,jj) > 0 )THEN ! sea
+               td_lay%i_nsea =td_lay%i_nsea +1
+               td_lay%i_nland=td_lay%i_nland-1
+            ENDIF
+
+         ENDDO
+      ENDDO
+
+      CALL logger_info( "MPP COMPUTE LAYOUT: sea proc "//TRIM(fct_str(td_lay%i_nsea)))
+      CALL logger_info( "MPP COMPUTE LAYOUT: land proc "//TRIM(fct_str(td_lay%i_nland)))
+      CALL logger_info( "MPP COMPUTE LAYOUT: sum "//TRIM(fct_str( SUM(td_lay%i_msk(:,:)))))
+
+      td_lay%i_mean= SUM(td_lay%i_msk(:,:)) / td_lay%i_nsea
+      td_lay%i_min = MINVAL(td_lay%i_msk(:,:),td_lay%i_msk(:,:)/=0)
+      td_lay%i_max = MAXVAL(td_lay%i_msk(:,:))
+
+      IF( lm_layout )THEN
+         ! print info 
+         WRITE(im_iumout,*) ' '
+         WRITE(im_iumout,*) " jpni=",td_lay%i_niproc ," jpnj=",td_lay%i_njproc
+         WRITE(im_iumout,*) " jpi= ",il_isize," jpj= ",il_jsize
+         WRITE(im_iumout,*) " iresti=",td_mpp%i_preci," irestj=",td_mpp%i_precj
+
+
+         WRITE(im_iumout,*) ' nombre de processeurs       ',td_lay%i_niproc*td_lay%i_njproc
+         WRITE(im_iumout,*) ' nombre de processeurs mer   ',td_lay%i_nsea
+         WRITE(im_iumout,*) ' nombre de processeurs terre ',td_lay%i_nland
+         WRITE(im_iumout,*) ' moyenne de recouvrement     ',td_lay%i_mean
+         WRITE(im_iumout,*) ' minimum de recouvrement     ',td_lay%i_min
+         WRITE(im_iumout,*) ' maximum de recouvrement     ',td_lay%i_max
+      ENDIF
+
+   END FUNCTION layout__init
+   !-------------------------------------------------------------------
+   !> @brief 
+   !>  This subroutine clean domain layout strcuture.
+   !>
+   !> @author J.Paul
+   !> @date October, 2015 - Initial version
+   !>
+   !> @param[inout] td_lay domain layout strcuture
+   !-------------------------------------------------------------------
+   SUBROUTINE layout__clean( td_lay )
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TLAY),  INTENT(INOUT) :: td_lay
+      !----------------------------------------------------------------
+
+      IF( ASSOCIATED(td_lay%i_msk) )THEN
+         DEALLOCATE(td_lay%i_msk)
+      ENDIF
+      IF( ASSOCIATED(td_lay%i_impp) )THEN
+         DEALLOCATE(td_lay%i_impp)
+      ENDIF
+      IF( ASSOCIATED(td_lay%i_jmpp) )THEN
+         DEALLOCATE(td_lay%i_jmpp)
+      ENDIF
+      IF( ASSOCIATED(td_lay%i_lci) )THEN
+         DEALLOCATE(td_lay%i_lci)
+      ENDIF
+      IF( ASSOCIATED(td_lay%i_lcj) )THEN
+         DEALLOCATE(td_lay%i_lcj)
+      ENDIF
+
+      td_lay%i_niproc=0
+      td_lay%i_njproc=0
+      td_lay%i_nland =0
+      td_lay%i_nsea  =0
+
+      td_lay%i_mean  =0
+      td_lay%i_min   =0
+      td_lay%i_max   =0
+
+   END SUBROUTINE layout__clean
+   !-------------------------------------------------------------------
+   !> @brief
+   !> This subroutine copy domain layout structure in another one.
+   !>
+   !> @warning do not use on the output of a function who create or read a
+   !> structure (ex: tl_seg=seg__copy(seg__init()) is forbidden).
+   !> This will create memory leaks.
+   !> @warning to avoid infinite loop, do not use any function inside 
+   !> this subroutine
+   !>
+   !> @author J.Paul
+   !> @date October, 2015 - Initial Version
+   !
+   !> @param[in] td_lay   domain layout structure
+   !> @return copy of input domain layout structure
+   !-------------------------------------------------------------------
+   FUNCTION layout__copy( td_lay )
+      IMPLICIT NONE
+      ! Argument
+      TYPE(TLAY), INTENT(IN)  :: td_lay
+      ! function
+      TYPE(TLAY) :: layout__copy
+
+      ! local variable
+      INTEGER(i4), DIMENSION(2)                :: il_shape
+      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_tmp
+      ! loop indices
+      !----------------------------------------------------------------
+
+      ! copy scalar 
+      layout__copy%i_niproc   = td_lay%i_niproc
+      layout__copy%i_njproc   = td_lay%i_njproc
+      layout__copy%i_nland    = td_lay%i_nland 
+      layout__copy%i_nsea     = td_lay%i_nsea  
+      layout__copy%i_mean     = td_lay%i_mean  
+      layout__copy%i_min      = td_lay%i_min   
+      layout__copy%i_max      = td_lay%i_max   
+
+      ! copy pointers
+      IF( ASSOCIATED(layout__copy%i_msk) )THEN
+         DEALLOCATE(layout__copy%i_msk)
+      ENDIF
+      IF( ASSOCIATED(td_lay%i_msk) )THEN
+         il_shape(:)=SHAPE(td_lay%i_msk(:,:))
+         ALLOCATE( layout__copy%i_msk(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_msk(:,:)=td_lay%i_msk(:,:)
+      ENDIF
+
+      IF( ASSOCIATED(layout__copy%i_msk) ) DEALLOCATE(layout__copy%i_msk)
+      IF( ASSOCIATED(td_lay%i_msk) )THEN
+         il_shape(:)=SHAPE(td_lay%i_msk(:,:))
+         ALLOCATE(il_tmp(il_shape(jp_I),il_shape(jp_J)))
+         il_tmp(:,:)=td_lay%i_msk(:,:)
+
+         ALLOCATE( layout__copy%i_msk(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_msk(:,:)=il_tmp(:,:)
+
+         DEALLOCATE(il_tmp)
+      ENDIF
+
+      IF( ASSOCIATED(layout__copy%i_impp) ) DEALLOCATE(layout__copy%i_impp)
+      IF( ASSOCIATED(td_lay%i_impp) )THEN
+         il_shape(:)=SHAPE(td_lay%i_impp(:,:))
+         ALLOCATE(il_tmp(il_shape(jp_I),il_shape(jp_J)))
+         il_tmp(:,:)=td_lay%i_impp(:,:)
+
+         ALLOCATE( layout__copy%i_impp(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_impp(:,:)=il_tmp(:,:)
+
+         DEALLOCATE(il_tmp)
+      ENDIF
+
+      IF( ASSOCIATED(layout__copy%i_jmpp) ) DEALLOCATE(layout__copy%i_jmpp)
+      IF( ASSOCIATED(td_lay%i_jmpp) )THEN
+         il_shape(:)=SHAPE(td_lay%i_jmpp(:,:))
+         ALLOCATE(il_tmp(il_shape(jp_I),il_shape(jp_J)))
+         il_tmp(:,:)=td_lay%i_jmpp(:,:)
+
+         ALLOCATE( layout__copy%i_jmpp(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_jmpp(:,:)=il_tmp(:,:)
+
+         DEALLOCATE(il_tmp)
+      ENDIF
+
+      IF( ASSOCIATED(layout__copy%i_lci) ) DEALLOCATE(layout__copy%i_lci)
+      IF( ASSOCIATED(td_lay%i_lci) )THEN
+         il_shape(:)=SHAPE(td_lay%i_lci(:,:))
+         ALLOCATE(il_tmp(il_shape(jp_I),il_shape(jp_J)))
+         il_tmp(:,:)=td_lay%i_lci(:,:)
+
+         ALLOCATE( layout__copy%i_lci(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_lci(:,:)=il_tmp(:,:)
+
+         DEALLOCATE(il_tmp)
+      ENDIF
+
+      IF( ASSOCIATED(layout__copy%i_lcj) ) DEALLOCATE(layout__copy%i_lcj)
+      IF( ASSOCIATED(td_lay%i_lcj) )THEN
+         il_shape(:)=SHAPE(td_lay%i_lcj(:,:))
+         ALLOCATE(il_tmp(il_shape(jp_I),il_shape(jp_J)))
+         il_tmp(:,:)=td_lay%i_lcj(:,:)
+
+         ALLOCATE( layout__copy%i_lcj(il_shape(jp_I),il_shape(jp_J)) )
+         layout__copy%i_lcj(:,:)=il_tmp(:,:)
+
+         DEALLOCATE(il_tmp)
+      ENDIF
+
+   END FUNCTION layout__copy
+   !-------------------------------------------------------------------
+   !> @brief
+   !>    This subroutine create mpp structure using domain layout
+   !>
+   !> @detail
+   !
+   !> @author J.Paul
+   !> @date October, 2015 - Initial version
    !
    !> @param[inout] td_mpp mpp strcuture
-   !-------------------------------------------------------------------
-   SUBROUTINE mpp__compute( td_mpp )
+   !> @param[in] td_lay domain layout structure
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__create_layout( td_mpp, td_lay )
       IMPLICIT NONE
       ! Argument
       TYPE(TMPP), INTENT(INOUT) :: td_mpp
+      TYPE(TLAY), INTENT(IN   ) :: td_lay
 
       ! local variable
-      INTEGER(i4)                              :: il_isize !< i-direction maximum sub domain size 
-      INTEGER(i4)                              :: il_jsize !< j-direction maximum sub domain size
-      INTEGER(i4)                              :: il_resti !<  
-      INTEGER(i4)                              :: il_restj !<  
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_nlci
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_nlcj
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_impp
-      INTEGER(i4), DIMENSION(:,:), ALLOCATABLE :: il_jmpp
-
       CHARACTER(LEN=lc)                        :: cl_file
       TYPE(TFILE)                              :: tl_proc
@@ -2617,195 +2905,154 @@
       td_mpp%i_nproc=0
 
-      CALL logger_trace( "MPP COMPUTE: compute domain decomposition with "//&
-      &               TRIM(fct_str(td_mpp%i_niproc))//" x "//&
-      &               TRIM(fct_str(td_mpp%i_njproc))//" processors")
-      ! maximum size of sub domain
-      il_isize = ((td_mpp%t_dim(1)%i_len - 2*td_mpp%i_preci + (td_mpp%i_niproc-1))/ &
-      &           td_mpp%i_niproc) + 2*td_mpp%i_preci
-      il_jsize = ((td_mpp%t_dim(2)%i_len - 2*td_mpp%i_precj + (td_mpp%i_njproc-1))/ &
-      &           td_mpp%i_njproc) + 2*td_mpp%i_precj
-
-      il_resti = MOD(td_mpp%t_dim(1)%i_len - 2*td_mpp%i_preci, td_mpp%i_niproc)
-      il_restj = MOD(td_mpp%t_dim(2)%i_len - 2*td_mpp%i_precj, td_mpp%i_njproc)
-      IF( il_resti == 0 ) il_resti = td_mpp%i_niproc
-      IF( il_restj == 0 ) il_restj = td_mpp%i_njproc
-
-      ! compute dimension of each sub domain
-      ALLOCATE( il_nlci(td_mpp%i_niproc,td_mpp%i_njproc) )
-      ALLOCATE( il_nlcj(td_mpp%i_niproc,td_mpp%i_njproc) )
-
-      il_nlci( 1 : il_resti                , : ) = il_isize
-      il_nlci( il_resti+1 : td_mpp%i_niproc, : ) = il_isize-1
-
-      il_nlcj( : , 1 : il_restj                ) = il_jsize
-      il_nlcj( : , il_restj+1 : td_mpp%i_njproc) = il_jsize-1
-
-      ! compute first index of each sub domain
-      ALLOCATE( il_impp(td_mpp%i_niproc,td_mpp%i_njproc) )
-      ALLOCATE( il_jmpp(td_mpp%i_niproc,td_mpp%i_njproc) )
-
-      il_impp(:,:)=1
-      il_jmpp(:,:)=1
-
-      DO jj=1,td_mpp%i_njproc
-         DO ji=2,td_mpp%i_niproc
-            il_impp(ji,jj)=il_impp(ji-1,jj)+il_nlci(ji-1,jj)-2*td_mpp%i_preci
+      CALL logger_debug( "MPP CREATE LAYOUT: create domain decomposition with "//&
+      &               TRIM(fct_str(td_lay%i_niproc))//" x "//&
+      &               TRIM(fct_str(td_lay%i_njproc))//" = "//&
+      &               TRIM(fct_str(td_lay%i_nsea))//" processors")
+
+      IF( lm_layout )THEN
+         WRITE(im_iumout,*) ' choix optimum'
+         WRITE(im_iumout,*) ' ============='
+         WRITE(im_iumout,*)
+         ! print info 
+         WRITE(im_iumout,*) ' '
+         WRITE(im_iumout,*) " jpni=",td_lay%i_niproc ," jpnj=",td_lay%i_njproc
+         WRITE(im_iumout,*) " iresti=",td_mpp%i_preci," irestj=",td_mpp%i_precj
+
+
+         WRITE(im_iumout,*) ' nombre de processeurs       ',td_lay%i_niproc*td_lay%i_njproc
+         WRITE(im_iumout,*) ' nombre de processeurs mer   ',td_lay%i_nsea
+         WRITE(im_iumout,*) ' nombre de processeurs terre ',td_lay%i_nland
+         WRITE(im_iumout,*) ' moyenne de recouvrement     ',td_lay%i_mean
+         WRITE(im_iumout,*) ' minimum de recouvrement     ',td_lay%i_min
+         WRITE(im_iumout,*) ' maximum de recouvrement     ',td_lay%i_max
+      ENDIF
+
+      td_mpp%i_niproc=td_lay%i_niproc
+      td_mpp%i_njproc=td_lay%i_njproc
+      !td_mpp%i_nproc =td_lay%i_nsea
+
+      IF( td_mpp%i_niproc*td_mpp%i_njproc == td_lay%i_nsea )THEN
+         IF( td_lay%i_nsea == 1 )THEN
+            td_mpp%c_dom='full'
+         ELSE
+            td_mpp%c_dom='nooverlap'
+         ENDIF
+      ELSE
+            td_mpp%c_dom='noextra'
+      ENDIF
+      
+      jk=0
+      DO jj=1,td_lay%i_njproc
+         DO ji=1,td_lay%i_niproc
+
+            IF( td_lay%i_msk(ji,jj) >= 1 )THEN
+
+               ! get processor file name
+               cl_file=file_rename(td_mpp%c_name,jk)
+               ! initialise file structure
+               tl_proc=file_init(cl_file,td_mpp%c_type)
+
+               ! procesor id
+               tl_proc%i_pid=jk
+
+               tl_att=att_init("DOMAIN_number",tl_proc%i_pid)
+               CALL file_add_att(tl_proc, tl_att)
+
+               ! processor indices
+               tl_proc%i_iind=ji
+               tl_proc%i_jind=jj
+
+               ! fill processor dimension and first indices
+               tl_proc%i_impp = td_lay%i_impp(ji,jj)
+               tl_proc%i_jmpp = td_lay%i_jmpp(ji,jj)
+
+               tl_proc%i_lci  = td_lay%i_lci(ji,jj)
+               tl_proc%i_lcj  = td_lay%i_lcj(ji,jj)
+
+               ! compute first and last indoor indices
+               
+               ! west boundary
+               IF( ji == 1 )THEN
+                  tl_proc%i_ldi = 1 
+                  tl_proc%l_ctr = .TRUE.
+               ELSE
+                  tl_proc%i_ldi = 1 + td_mpp%i_preci
+               ENDIF
+
+               ! south boundary
+               IF( jj == 1 )THEN
+                  tl_proc%i_ldj = 1 
+                  tl_proc%l_ctr = .TRUE.
+               ELSE
+                  tl_proc%i_ldj = 1 + td_mpp%i_precj
+               ENDIF
+
+               ! east boundary
+               IF( ji == td_mpp%i_niproc )THEN
+                  tl_proc%i_lei = td_lay%i_lci(ji,jj)
+                  tl_proc%l_ctr = .TRUE.
+               ELSE
+                  tl_proc%i_lei = td_lay%i_lci(ji,jj) - td_mpp%i_preci
+               ENDIF
+
+               ! north boundary
+               IF( jj == td_mpp%i_njproc )THEN
+                  tl_proc%i_lej = td_lay%i_lcj(ji,jj)
+                  tl_proc%l_ctr = .TRUE.
+               ELSE
+                  tl_proc%i_lej = td_lay%i_lcj(ji,jj) - td_mpp%i_precj
+               ENDIF
+
+               ! add processor to mpp structure
+               CALL mpp__add_proc(td_mpp, tl_proc)
+
+               ! clean
+               CALL att_clean(tl_att)
+               CALL file_clean(tl_proc)
+
+               ! update proc number
+               jk=jk+1 !ji+(jj-1)*td_lay%i_niproc
+
+            ENDIF
          ENDDO
       ENDDO
 
-      DO jj=2,td_mpp%i_njproc
-         DO ji=1,td_mpp%i_niproc
-            il_jmpp(ji,jj)=il_jmpp(ji,jj-1)+il_nlcj(ji,jj-1)-2*td_mpp%i_precj
-         ENDDO
-      ENDDO 
-
-      DO jj=1,td_mpp%i_njproc
-         DO ji=1,td_mpp%i_niproc
-
-            jk=ji+(jj-1)*td_mpp%i_niproc
-
-            ! get processor file name
-            cl_file=file_rename(td_mpp%c_name,jk)
-            ! initialise file structure
-            tl_proc=file_init(cl_file,td_mpp%c_type)
-
-            ! procesor id
-            tl_proc%i_pid=jk
-
-            tl_att=att_init("DOMAIN_number",tl_proc%i_pid)
-            CALL file_add_att(tl_proc, tl_att)
-
-            ! processor indices
-            tl_proc%i_iind=ji
-            tl_proc%i_jind=jj
-
-            ! fill processor dimension and first indices
-            tl_proc%i_impp = il_impp(ji,jj)
-            tl_proc%i_jmpp = il_jmpp(ji,jj)
-
-            tl_att=att_init( "DOMAIN_poistion_first", &
-            &                (/tl_proc%i_impp, tl_proc%i_jmpp/) )
-            CALL file_add_att(tl_proc, tl_att)
-
-            tl_proc%i_lci  = il_nlci(ji,jj)
-            tl_proc%i_lcj  = il_nlcj(ji,jj)
-
-            tl_att=att_init( "DOMAIN_poistion_last", &
-            &                (/tl_proc%i_lci, tl_proc%i_lcj/) )
-            CALL file_add_att(tl_proc, tl_att)
-
-            ! compute first and last indoor indices
-            
-            ! west boundary
-            IF( ji == 1 )THEN
-               tl_proc%i_ldi = 1 
-               tl_proc%l_ctr = .TRUE.
-            ELSE
-               tl_proc%i_ldi = 1 + td_mpp%i_preci
-            ENDIF
-
-            ! south boundary
-            IF( jj == 1 )THEN
-               tl_proc%i_ldj = 1 
-               tl_proc%l_ctr = .TRUE.
-            ELSE
-               tl_proc%i_ldj = 1 + td_mpp%i_precj
-            ENDIF
-
-            ! east boundary
-            IF( ji == td_mpp%i_niproc )THEN
-               tl_proc%i_lei = il_nlci(ji,jj)
-               tl_proc%l_ctr = .TRUE.
-            ELSE
-               tl_proc%i_lei = il_nlci(ji,jj) - td_mpp%i_preci
-            ENDIF
-
-            ! north boundary
-            IF( jj == td_mpp%i_njproc )THEN
-               tl_proc%i_lej = il_nlcj(ji,jj)
-               tl_proc%l_ctr = .TRUE.
-            ELSE
-               tl_proc%i_lej = il_nlcj(ji,jj) - td_mpp%i_precj
-            ENDIF
-
-            tl_att=att_init( "DOMAIN_halo_size_start", &
-            &                (/tl_proc%i_ldi, tl_proc%i_ldj/) )
-            CALL file_add_att(tl_proc, tl_att)
-            tl_att=att_init( "DOMAIN_halo_size_end", &
-            &                (/tl_proc%i_ldi, tl_proc%i_ldj/) )
-            CALL file_add_att(tl_proc, tl_att)
-
-            ! add processor to mpp structure
-            CALL mpp__add_proc(td_mpp, tl_proc)
-
-            ! clean
-            CALL att_clean(tl_att)
-            CALL file_clean(tl_proc)
-
-         ENDDO
-      ENDDO
-
-      DEALLOCATE( il_impp, il_jmpp )
-      DEALLOCATE( il_nlci, il_nlcj )
-
-   END SUBROUTINE mpp__compute
+   END SUBROUTINE mpp__create_layout
    !-------------------------------------------------------------------
    !> @brief 
-   !>  This subroutine remove land processor from domain decomposition.
-   !>
+   !>  This subroutine optimize the number of sub domain to be used, given mask.
+   !> @details
+   !>  Actually it get the domain decomposition with the most land 
+   !>  processors removed.
+   !>  If no land processor could be removed, it get the decomposition with the
+   !>  most sea processors.
+   !
    !> @author J.Paul
    !> @date November, 2013 - Initial version
-   !>
+   !> @date October, 2015
+   !> - improve way to compute domain layout 
+   !> @date February, 2016
+   !> - new criteria for domain layout in case no land proc
+   !
    !> @param[inout] td_mpp mpp strcuture
-   !> @param[in] id_mask   sub domain mask (sea=1, land=0)
-   !-------------------------------------------------------------------
-   SUBROUTINE mpp__del_land( td_mpp, id_mask )
+   !> @param[in] id_mask   sub domain mask (sea=1, land=0) 
+   !> @pram[in] id_nproc maximum number of processor to be used
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__optimiz( td_mpp, id_mask, id_nproc )
       IMPLICIT NONE
       ! Argument
       TYPE(TMPP),                  INTENT(INOUT) :: td_mpp
       INTEGER(i4), DIMENSION(:,:), INTENT(IN)    :: id_mask
-
-      ! loop indices
-      INTEGER(i4) :: jk
-      !----------------------------------------------------------------
-
-      IF( ASSOCIATED(td_mpp%t_proc) )THEN
-         jk=1
-         DO WHILE( jk <= td_mpp%i_nproc )
-            IF( mpp__land_proc(td_mpp, jk, id_mask(:,:)) )THEN
-               CALL mpp__del_proc(td_mpp, jk)
-            ELSE
-               jk=jk+1
-            ENDIF
-         ENDDO
-      ELSE
-         CALL logger_error("MPP DEL LAND: domain decomposition not define.")
-      ENDIF
-
-   END SUBROUTINE mpp__del_land
-   !-------------------------------------------------------------------
-   !> @brief 
-   !>  This subroutine optimize the number of sub domain to be used, given mask.
-   !> @details
-   !>  Actually it get the domain decomposition with the most land 
-   !>  processor removed.
-   !
-   !> @author J.Paul
-   !> @date November, 2013 - Initial version
-   !
-   !> @param[inout] td_mpp mpp strcuture
-   !> @param[in] id_mask   sub domain mask (sea=1, land=0) 
-   !-------------------------------------------------------------------
-   SUBROUTINE mpp__optimiz( td_mpp, id_mask )
-      IMPLICIT NONE
-      ! Argument
-      TYPE(TMPP),                  INTENT(INOUT) :: td_mpp
-      INTEGER(i4), DIMENSION(:,:), INTENT(IN)    :: id_mask
+      INTEGER(i4)                , INTENT(IN)    :: id_nproc
 
       ! local variable
-      TYPE(TMPP)  :: tl_mpp
-      INTEGER(i4) :: il_maxproc
-
-      TYPE(TFILE), DIMENSION(:), ALLOCATABLE :: tl_proc
+      TYPE(TLAY) :: tl_lay
+      TYPE(TLAY) :: tl_sav
+
+      REAL(dp)   :: dl_min
+      REAL(dp)   :: dl_max
+      REAL(dp)   :: dl_ratio
+      REAL(dp)   :: dl_sav
+
       ! loop indices
       INTEGER(i4) :: ji
@@ -2814,129 +3061,68 @@
 
       CALL logger_trace("MPP OPTIMIZ: look for best domain decomposition")
-      tl_mpp=mpp_copy(td_mpp)
-
-      ! save maximum number of processor to be used
-      il_maxproc=td_mpp%i_nproc
+      dl_sav=0
       ! 
-      td_mpp%i_nproc=0
-      DO ji=1,il_maxproc
-         DO jj=1,il_maxproc
-
-            ! clean mpp processor
-            IF( ASSOCIATED(tl_mpp%t_proc) )THEN
-               CALL file_clean(tl_mpp%t_proc(:))
-               DEALLOCATE(tl_mpp%t_proc)
-            ENDIF
-
-            ! compute domain decomposition
-            tl_mpp%i_niproc=ji
-            tl_mpp%i_njproc=jj
-            
-            CALL mpp__compute( tl_mpp )
-            
-            ! remove land sub domain
-            CALL mpp__del_land( tl_mpp, id_mask )
-
-            CALL logger_info("MPP OPTIMIZ: number of processor "//&
-            &   TRIM(fct_str(ji))//"x"//TRIM(fct_str(jj))//"="//&
-            &   TRIM(fct_str(tl_mpp%i_nproc)) )
-            IF( tl_mpp%i_nproc > td_mpp%i_nproc .AND. &
-            &   tl_mpp%i_nproc <= il_maxproc )THEN
-               ! save optimiz decomposition 
-
-               CALL logger_info("MPP OPTIMIZ:save this decomposition "//&
-               &   TRIM(fct_str(ji))//"x"//TRIM(fct_str(jj))//"="//&
-               &   TRIM(fct_str(tl_mpp%i_nproc)) )
-
-               ! clean mpp
-               CALL mpp_clean(td_mpp)
-
-               ! save processor array
-               ALLOCATE( tl_proc(tl_mpp%i_nproc) )
-               tl_proc(:)=file_copy(tl_mpp%t_proc(:))
-
-               ! remove pointer on processor array
-               CALL file_clean(tl_mpp%t_proc(:))
-               DEALLOCATE(tl_mpp%t_proc)
- 
-               ! save data except processor array
-               td_mpp=mpp_copy(tl_mpp)
-
-               ! save processor array
-               ALLOCATE( td_mpp%t_proc(td_mpp%i_nproc) )
-               td_mpp%t_proc(:)=file_copy(tl_proc(:))
-
-               ! clean
-               CALL file_clean( tl_proc(:) )
-               DEALLOCATE(tl_proc)
-
-            ENDIF
-            
+      DO ji=1,id_nproc
+         DO jj=1,id_nproc
+
+            ! compute domain layout
+            tl_lay=layout__init( td_mpp, id_mask, ji,jj )
+            IF( tl_lay%i_nsea <= id_nproc )THEN
+
+               IF( ASSOCIATED(tl_sav%i_lci) )THEN
+                  IF( tl_sav%i_nland /= 0 )THEN
+                     ! look for layout with most land proc
+                     IF( tl_lay%i_nland > tl_sav%i_nland    .OR. &
+                     &   ( tl_lay%i_nland == tl_sav%i_nland .AND. &
+                     &     tl_lay%i_min   >  tl_sav%i_min   ) )THEN
+                        ! save optimiz layout
+                        CALL logger_info("MPP OPTIMIZ:save this decomposition "//&
+                        &   TRIM(fct_str(ji))//"x"//TRIM(fct_str(jj))//"="//&
+                        &   TRIM(fct_str(tl_lay%i_nsea)) )
+
+                        tl_sav=layout__copy(tl_lay)
+                     ENDIF
+                  ELSE ! tl_sav%i_nland == 0
+                     ! look for layout with most sea proc 
+                     ! and "square" cell 
+                     dl_min=MIN(tl_lay%i_lci(1,1),tl_lay%i_lcj(1,1))
+                     dl_max=MAX(tl_lay%i_lci(1,1),tl_lay%i_lcj(1,1))
+                     dl_ratio=dl_min/dl_max
+                     IF( tl_lay%i_nsea > tl_sav%i_nsea    .OR. &
+                     &   ( tl_lay%i_nsea == tl_sav%i_nsea .AND. &
+                     &     dl_ratio   >  dl_sav ) )THEN
+                        ! save optimiz layout
+                        CALL logger_info("MPP OPTIMIZ:save this decomposition "//&
+                        &   TRIM(fct_str(ji))//"x"//TRIM(fct_str(jj))//"="//&
+                        &   TRIM(fct_str(tl_lay%i_nsea)) )
+
+                        tl_sav=layout__copy(tl_lay)
+                        dl_sav=dl_ratio
+                     ENDIF
+                  ENDIF
+               ELSE
+                  ! init tl_sav
+                  tl_sav=layout__copy(tl_lay)
+
+                  dl_min=MIN(tl_sav%i_lci(1,1),tl_sav%i_lcj(1,1))
+                  dl_max=MAX(tl_sav%i_lci(1,1),tl_sav%i_lcj(1,1))
+                  dl_sav=dl_min/dl_max
+               ENDIF
+
+            ENDIF
+
+            ! clean
+            CALL layout__clean( tl_lay )
+
          ENDDO
       ENDDO
 
+      ! create mpp domain layout
+      CALL mpp__create_layout(td_mpp, tl_sav)
+
       ! clean
-      CALL mpp_clean(tl_mpp)
+      CALL layout__clean( tl_sav )
 
    END SUBROUTINE mpp__optimiz
-   !-------------------------------------------------------------------
-   !> @brief
-   !>    This function check if processor is a land processor.
-   !>
-   !> @author J.Paul
-   !> @date November, 2013 - Initial version
-   !>
-   !> @param[in] td_mpp    mpp strcuture
-   !> @param[in] id_proc   processor id
-   !> @param[in] id_mask   sub domain mask (sea=1, land=0)
-   !-------------------------------------------------------------------
-   LOGICAL FUNCTION mpp__land_proc( td_mpp , id_proc, id_mask )
-      IMPLICIT NONE
-      ! Argument
-      TYPE(TMPP),                  INTENT(IN) :: td_mpp
-      INTEGER(i4),                 INTENT(IN) :: id_proc
-      INTEGER(i4), DIMENSION(:,:), INTENT(IN) :: id_mask
-
-      ! local variable
-      INTEGER(i4), DIMENSION(2) :: il_shape
-      !----------------------------------------------------------------
-
-      CALL logger_trace("MPP LAND PROC: check processor "//TRIM(fct_str(id_proc))//&
-      &  " of mpp "//TRIM(td_mpp%c_name) )
-      mpp__land_proc=.FALSE.
-      IF( ASSOCIATED(td_mpp%t_proc) )THEN
-
-         il_shape(:)=SHAPE(id_mask)
-         IF( il_shape(1) /= td_mpp%t_dim(1)%i_len .OR. &
-         &   il_shape(2) /= td_mpp%t_dim(2)%i_len )THEN
-             CALL logger_debug("MPP LAND PROC: mask size ("//&
-             &                  TRIM(fct_str(il_shape(1)))//","//&
-             &                  TRIM(fct_str(il_shape(2)))//")")
-             CALL logger_debug("MPP LAND PROC: domain size ("//&
-             &                  TRIM(fct_str(td_mpp%t_dim(1)%i_len))//","//&
-             &                  TRIM(fct_str(td_mpp%t_dim(2)%i_len))//")")
-             CALL logger_error("MPP LAND PROC: mask and domain size differ")
-         ELSE
-            IF( ALL(id_mask( td_mpp%t_proc(id_proc)%i_impp +            &
-            &                       td_mpp%t_proc(id_proc)%i_ldi - 1 : &
-            &                td_mpp%t_proc(id_proc)%i_impp +            &
-            &                       td_mpp%t_proc(id_proc)%i_lei - 1,  &
-            &                td_mpp%t_proc(id_proc)%i_jmpp +            &
-            &                       td_mpp%t_proc(id_proc)%i_ldj - 1 : &
-            &                td_mpp%t_proc(id_proc)%i_jmpp +            &
-            &                       td_mpp%t_proc(id_proc)%i_lej - 1)  &
-            &      /= 1 ) )THEN
-               ! land domain
-               CALL logger_info("MPP LAND PROC: processor "//TRIM(fct_str(id_proc))//&
-               &             " is land processor")
-               mpp__land_proc=.TRUE.
-            ENDIF
-         ENDIF
-
-      ELSE
-         CALL logger_error("MPP LAND PROC: domain decomposition not define.")
-      ENDIF
-
-   END FUNCTION mpp__land_proc
    !-------------------------------------------------------------------
    !> @brief 
@@ -3195,12 +3381,15 @@
          SELECT CASE(TRIM(td_mpp%c_dom))
             CASE('full')
-               il_i1 = 1 ; il_i2 = td_mpp%t_dim(1)%i_len
-               il_j1 = 1 ; il_j2 = td_mpp%t_dim(2)%i_len
-            CASE('overlap')
-                il_i1 = td_mpp%t_proc(id_procid)%i_impp
-                il_j1 = td_mpp%t_proc(id_procid)%i_jmpp
-
-                il_i2 = il_i1 + td_mpp%t_proc(id_procid)%i_lci - 1 
-                il_j2 = il_j1 + td_mpp%t_proc(id_procid)%i_lcj - 1 
+               il_i1 = 1 
+               il_j1 = 1 
+
+               il_i2 = td_mpp%t_dim(1)%i_len
+               il_j2 = td_mpp%t_dim(2)%i_len
+            CASE('noextra')
+               il_i1 = td_mpp%t_proc(id_procid)%i_impp
+               il_j1 = td_mpp%t_proc(id_procid)%i_jmpp
+
+               il_i2 = il_i1 + td_mpp%t_proc(id_procid)%i_lci - 1 
+               il_j2 = il_j1 + td_mpp%t_proc(id_procid)%i_lcj - 1 
             CASE('nooverlap')
                il_i1 = td_mpp%t_proc(id_procid)%i_impp + &
@@ -3214,5 +3403,6 @@
                &        td_mpp%t_proc(id_procid)%i_lej - 1
             CASE DEFAULT
-               CALL logger_error("MPP GET PROC INDEX: invalid decomposition type.")
+               CALL logger_error("MPP GET PROC INDEX: invalid "//&
+                  &              "decomposition type.")
          END SELECT
 
@@ -3264,5 +3454,5 @@
                il_jsize = td_mpp%t_dim(2)%i_len
 
-            CASE('overlap')
+            CASE('noextra')
 
                 il_isize = td_mpp%t_proc(id_procid)%i_lci
@@ -3308,5 +3498,5 @@
       IF( ASSOCIATED(td_mpp%t_proc) )THEN
 
-         IF( td_mpp%i_niproc == 0 .AND. td_mpp%i_niproc == 0 )THEN
+         IF( td_mpp%i_niproc == 0 .AND. td_mpp%i_njproc == 0 )THEN
             CALL logger_info("MPP GET DOM: use indoor indices to get domain "//&
             &             "decomposition type.")
@@ -3323,5 +3513,5 @@
             &       td_mpp%t_proc(1)%i_lcj                     )     )THEN
 
-               td_mpp%c_dom='overlap'
+               td_mpp%c_dom='noextra'
 
             ELSEIF((td_mpp%t_proc(1)%t_dim(1)%i_len ==                     &
@@ -3368,5 +3558,5 @@
                td_mpp%c_dom='nooverlap'
             ELSE
-               td_mpp%c_dom='overlap'
+               td_mpp%c_dom='noextra'
             ENDIF
 
@@ -3386,4 +3576,6 @@
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date September 2015
+   !> - do not check used dimension here
    !>
    !> @param[in] td_mpp mpp structure
@@ -3398,4 +3590,9 @@
 
       ! local variable
+      CHARACTER(LEN=lc) :: cl_dim
+      LOGICAL :: ll_error
+      LOGICAL :: ll_warn
+
+      INTEGER(i4)       :: il_ind
 
       ! loop indices
@@ -3403,28 +3600,70 @@
       !----------------------------------------------------------------
       mpp__check_var_dim=.TRUE.
+
       ! check used dimension 
-      IF( ANY( td_var%t_dim(:)%l_use .AND. &
-      &        td_var%t_dim(:)%i_len /= td_mpp%t_dim(:)%i_len) )THEN
+      ll_error=.FALSE.
+      ll_warn=.FALSE.
+      DO ji=1,ip_maxdim
+         il_ind=dim_get_index( td_mpp%t_dim(:), &
+         &                     TRIM(td_var%t_dim(ji)%c_name), &
+         &                     TRIM(td_var%t_dim(ji)%c_sname))
+         IF( il_ind /= 0 )THEN
+            IF( td_var%t_dim(ji)%l_use  .AND. &
+            &   td_mpp%t_dim(il_ind)%l_use .AND. &
+            &   td_var%t_dim(ji)%i_len /= td_mpp%t_dim(il_ind)%i_len )THEN
+               IF( INDEX( TRIM(td_var%c_axis), &
+               &          TRIM(fct_upper(td_var%t_dim(ji)%c_name))) == 0 )THEN
+                  ll_warn=.TRUE.
+               ELSE
+                  ll_error=.TRUE.
+               ENDIF
+            ENDIF
+         ENDIF
+      ENDDO
+
+      IF( ll_error )THEN
+
+         cl_dim='(/'
+         DO ji = 1, td_mpp%i_ndim
+            IF( td_mpp%t_dim(ji)%l_use )THEN
+               cl_dim=TRIM(cl_dim)//&
+               &  TRIM(fct_upper(td_mpp%t_dim(ji)%c_sname))//':'//&
+               &  TRIM(fct_str(td_mpp%t_dim(ji)%i_len))//','
+            ENDIF
+         ENDDO
+         cl_dim=TRIM(cl_dim)//'/)'
+         CALL logger_debug( " mpp dimension: "//TRIM(cl_dim) )
+
+         cl_dim='(/'
+         DO ji = 1, td_var%i_ndim
+            IF( td_var%t_dim(ji)%l_use )THEN
+               cl_dim=TRIM(cl_dim)//&
+               &  TRIM(fct_upper(td_var%t_dim(ji)%c_sname))//':'//&
+               &  TRIM(fct_str(td_var%t_dim(ji)%i_len))//','
+            ENDIF
+         ENDDO
+         cl_dim=TRIM(cl_dim)//'/)'
+         CALL logger_debug( " variable dimension: "//TRIM(cl_dim) )
 
          mpp__check_var_dim=.FALSE.
 
-         CALL logger_debug( &
-         &  " mpp dimension: "//TRIM(fct_str(td_mpp%i_ndim))//&
-         &  " variable dimension: "//TRIM(fct_str(td_var%i_ndim)) )
-         DO ji = 1, ip_maxdim
-            CALL logger_debug( &
-            &  "MPP CHECK DIM: for dimension "//&
-            &  TRIM(td_mpp%t_dim(ji)%c_name)//&
-            &  ", mpp length: "//&
-            &  TRIM(fct_str(td_mpp%t_dim(ji)%i_len))//&
-            &  ", variable length: "//&
-            &  TRIM(fct_str(td_var%t_dim(ji)%i_len))//&
-            &  ", variable used "//TRIM(fct_str(td_var%t_dim(ji)%l_use)))
-         ENDDO
-
          CALL logger_error( &
-         &  "MPP CHECK DIM: variable and mpp dimension differ"//&
+         &  " MPP CHECK VAR DIM: variable and file dimension differ"//&
          &  " for variable "//TRIM(td_var%c_name)//&
-         &  " and mpp "//TRIM(td_mpp%c_name))
+         &  " and file "//TRIM(td_mpp%c_name))
+
+      ELSEIF( ll_warn )THEN
+         CALL logger_warn( &
+         &  " MPP CHECK VAR DIM: variable and file dimension differ"//&
+         &  " for variable "//TRIM(td_var%c_name)//&
+         &  " and file "//TRIM(td_mpp%c_name)//". you should use"//&
+         &  " var_check_dim to remove useless dimension.")
+      ELSE
+
+         IF( td_var%i_ndim >  td_mpp%i_ndim )THEN
+            CALL logger_info("MPP CHECK VAR DIM: variable "//&
+            &  TRIM(td_var%c_name)//" use more dimension than file "//&
+            &  TRIM(td_mpp%c_name)//" do until now.")
+         ENDIF
 
       ENDIF
@@ -3583,4 +3822,278 @@
       ENDIF
    END FUNCTION mpp_recombine_var
+   !-------------------------------------------------------------------
+   !> @brief This subroutine read subdomain indices defined with halo
+   !> (NEMO netcdf way)
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !>
+   !> @param[inout] td_file   mpp structure
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__read_halo(td_file, td_dimglo) 
+   IMPLICIT NONE
+      ! Argument      
+      TYPE(TFILE)              , INTENT(INOUT) :: td_file
+      TYPE(TDIM) , DIMENSION(:), INTENT(IN   ) :: td_dimglo
+
+      ! local variable
+      INTEGER(i4)       :: il_attid
+      INTEGER(i4)       :: il_ifirst
+      INTEGER(i4)       :: il_jfirst
+      INTEGER(i4)       :: il_ilast
+      INTEGER(i4)       :: il_jlast
+      INTEGER(i4)       :: il_ihalostart
+      INTEGER(i4)       :: il_jhalostart
+      INTEGER(i4)       :: il_ihaloend
+      INTEGER(i4)       :: il_jhaloend
+
+      CHARACTER(LEN=lc) :: cl_dom
+      !----------------------------------------------------------------
+
+      ! DOMAIN_position_first
+      il_attid = 0
+      IF( ASSOCIATED(td_file%t_att) )THEN
+         il_attid=att_get_id( td_file%t_att, "DOMAIN_position_first" )
+      ENDIF
+      IF( il_attid /= 0 )THEN
+         il_ifirst = INT(td_file%t_att(il_attid)%d_value(1))
+         il_jfirst = INT(td_file%t_att(il_attid)%d_value(2))
+      ELSE
+         il_ifirst = 1
+         il_jfirst = 1
+      ENDIF
+
+      ! DOMAIN_position_last
+      il_attid = 0
+      IF( ASSOCIATED(td_file%t_att) )THEN
+         il_attid=att_get_id( td_file%t_att, "DOMAIN_position_last" )
+      ENDIF
+      IF( il_attid /= 0 )THEN
+         il_ilast = INT(td_file%t_att(il_attid)%d_value(1))
+         il_jlast = INT(td_file%t_att(il_attid)%d_value(2))
+      ELSE
+         il_ilast = td_file%t_dim(1)%i_len
+         il_jlast = td_file%t_dim(2)%i_len
+      ENDIF
+
+      ! DOMAIN_halo_size_start
+      il_attid = 0
+      IF( ASSOCIATED(td_file%t_att) )THEN
+         il_attid=att_get_id( td_file%t_att, "DOMAIN_halo_size_start" )
+      ENDIF
+      IF( il_attid /= 0 )THEN
+         il_ihalostart = INT(td_file%t_att(il_attid)%d_value(1))
+         il_jhalostart = INT(td_file%t_att(il_attid)%d_value(2))
+      ELSE
+         il_ihalostart = 0
+         il_jhalostart = 0
+      ENDIF
+
+      ! DOMAIN_halo_size_end
+      il_attid = 0
+      IF( ASSOCIATED(td_file%t_att) )THEN
+         il_attid=att_get_id( td_file%t_att, "DOMAIN_halo_size_end" )
+      ENDIF
+      IF( il_attid /= 0 )THEN
+         il_ihaloend = INT(td_file%t_att(il_attid)%d_value(1))
+         il_jhaloend = INT(td_file%t_att(il_attid)%d_value(2))
+      ELSE
+         il_ihaloend = 0
+         il_jhaloend = 0
+      ENDIF
+
+      IF( (td_dimglo(jp_I)%i_len == td_file%t_dim(jp_I)%i_len) .AND. &
+        & (td_dimglo(jp_J)%i_len == td_file%t_dim(jp_J)%i_len) )THEN
+         cl_dom='full'
+      ELSEIF( il_ihalostart == 0 .AND. il_jhalostart == 0 .AND. &
+           &  il_ihaloend == 0 .AND. il_jhaloend == 0 )THEN
+         cl_dom='nooverlap'
+      ELSE
+         cl_dom='noextra'
+      ENDIF
+
+      SELECT CASE(TRIM(cl_dom))
+         CASE('full')
+            td_file%i_impp = il_ifirst 
+            td_file%i_jmpp = il_jfirst
+            td_file%i_lci  = td_file%t_dim(jp_I)%i_len 
+            td_file%i_lcj  = td_file%t_dim(jp_J)%i_len
+            td_file%i_ldi  = il_ihalostart + 1
+            td_file%i_ldj  = il_jhalostart + 1
+            td_file%i_lei  = td_file%t_dim(jp_I)%i_len - il_ihaloend
+            td_file%i_lej  = td_file%t_dim(jp_J)%i_len - il_jhaloend
+         CASE('noextra')
+            td_file%i_impp = il_ifirst
+            td_file%i_jmpp = il_jfirst
+            td_file%i_lci  = td_file%t_dim(jp_I)%i_len
+            td_file%i_lcj  = td_file%t_dim(jp_J)%i_len
+            td_file%i_ldi  = il_ihalostart + 1
+            td_file%i_ldj  = il_jhalostart + 1
+            td_file%i_lei  = td_file%i_lci - il_ihaloend
+            td_file%i_lej  = td_file%i_lcj - il_jhaloend
+         CASE('nooverlap') !!!?????
+            td_file%i_impp = il_ifirst
+            td_file%i_jmpp = il_jfirst
+            td_file%i_lci  = td_file%t_dim(jp_I)%i_len
+            td_file%i_lcj  = td_file%t_dim(jp_J)%i_len
+            td_file%i_ldi  = 1
+            td_file%i_ldj  = 1 
+            td_file%i_lei  = td_file%t_dim(jp_I)%i_len
+            td_file%i_lej  = td_file%t_dim(jp_J)%i_len
+      END SELECT
+
+   END SUBROUTINE mpp__read_halo
+   !-------------------------------------------------------------------
+   !> @brief This subroutine compute subdomain indices defined with halo
+   !> (NEMO netcdf way)
+   !>
+   !> @author J.Paul
+   !> @date January, 2016 - Initial Version
+   !>
+   !> @param[inout] td_mpp   mpp structure
+   !-------------------------------------------------------------------
+   SUBROUTINE mpp__compute_halo(td_mpp) 
+   IMPLICIT NONE
+      ! Argument      
+      TYPE(TMPP)      , INTENT(INOUT) :: td_mpp
+
+      ! local variable
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ifirst
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_jfirst
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ilast
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_jlast
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ihalostart
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_jhalostart
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_ihaloend
+      INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_jhaloend
+
+      TYPE(TATT)                             :: tl_att
+
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      ALLOCATE( il_ifirst    (td_mpp%i_nproc) )
+      ALLOCATE( il_jfirst    (td_mpp%i_nproc) )
+
+      ALLOCATE( il_ilast     (td_mpp%i_nproc) )
+      ALLOCATE( il_jlast     (td_mpp%i_nproc) )
+
+      ALLOCATE( il_ihalostart(td_mpp%i_nproc) )
+      ALLOCATE( il_jhalostart(td_mpp%i_nproc) )
+
+      ALLOCATE( il_ihaloend  (td_mpp%i_nproc) )
+      ALLOCATE( il_jhaloend  (td_mpp%i_nproc) )
+
+      SELECT CASE(TRIM(td_mpp%c_dom))
+         CASE('full')
+            
+            il_ifirst(:)=td_mpp%t_proc(:)%i_impp
+            il_jfirst(:)=td_mpp%t_proc(:)%i_jmpp
+            
+            il_ilast(:)=td_mpp%t_proc(:)%i_impp + td_mpp%t_proc(:)%t_dim(jp_I)%i_len - 1
+            il_jlast(:)=td_mpp%t_proc(:)%i_jmpp + td_mpp%t_proc(:)%t_dim(jp_J)%i_len - 1
+
+            il_ihalostart(:)=td_mpp%t_proc(:)%i_ldi-1
+            il_jhalostart(:)=td_mpp%t_proc(:)%i_ldj-1
+            
+            il_ihaloend(:)=td_mpp%t_proc(:)%t_dim(jp_I)%i_len - td_mpp%t_proc(:)%i_lei
+            il_jhaloend(:)=td_mpp%t_proc(:)%t_dim(jp_J)%i_len - td_mpp%t_proc(:)%i_lej
+
+         CASE('noextra')
+            
+            il_ifirst(:)=td_mpp%t_proc(:)%i_impp
+            il_jfirst(:)=td_mpp%t_proc(:)%i_jmpp
+
+            il_ilast(:) =td_mpp%t_proc(:)%i_impp + td_mpp%t_proc(:)%i_lci - 1
+            il_jlast(:) =td_mpp%t_proc(:)%i_jmpp + td_mpp%t_proc(:)%i_lcj - 1
+            
+            il_ihalostart(:)=td_mpp%t_proc(:)%i_ldi-1
+            il_jhalostart(:)=td_mpp%t_proc(:)%i_ldj-1
+            
+            il_ihaloend(:)=td_mpp%t_proc(:)%i_lci - td_mpp%t_proc(:)%i_lei
+            il_jhaloend(:)=td_mpp%t_proc(:)%i_lcj - td_mpp%t_proc(:)%i_lej
+
+         CASE('nooverlap')
+
+            il_ifirst(:)=td_mpp%t_proc(:)%i_impp + td_mpp%t_proc(:)%i_ldi - 1
+            il_jfirst(:)=td_mpp%t_proc(:)%i_jmpp + td_mpp%t_proc(:)%i_ldj - 1
+
+            il_ilast(:)=td_mpp%t_proc(:)%i_impp + td_mpp%t_proc(:)%i_lei - 1
+            il_jlast(:)=td_mpp%t_proc(:)%i_jmpp + td_mpp%t_proc(:)%i_lej - 1
+
+            il_ihalostart(:)=0
+            il_jhalostart(:)=0
+
+            il_ihaloend(:)=0
+            il_jhaloend(:)=0
+
+         CASE DEFAULT
+            CALL logger_fatal("MPP INIT: invalid "//&
+            &              "decomposition type.")                     
+      END SELECT
+
+      DO ji=1,td_mpp%i_nproc
+         tl_att=att_init( "DOMAIN_position_first", &
+         &                (/ il_ifirst(ji), il_jfirst(ji) /) )
+         CALL file_move_att(td_mpp%t_proc(ji), tl_att)      
+
+         tl_att=att_init( "DOMAIN_position_last", &
+         &                (/ il_ilast(ji), il_jlast(ji) /) )
+         CALL file_move_att(td_mpp%t_proc(ji), tl_att)
+
+         tl_att=att_init( "DOMAIN_halo_size_start", &
+         &                (/ il_ihalostart(ji), il_jhalostart(ji) /) )
+         CALL file_move_att( td_mpp%t_proc(ji), tl_att)               
+
+         tl_att=att_init( "DOMAIN_halo_size_end", &
+         &                (/ il_ihaloend(ji), il_jhaloend(ji) /) )
+         CALL file_move_att( td_mpp%t_proc(ji), tl_att)
+      ENDDO
+
+      DEALLOCATE( il_ifirst    )
+      DEALLOCATE( il_jfirst    )
+ 
+      DEALLOCATE( il_ilast     )
+      DEALLOCATE( il_jlast     )
+ 
+      DEALLOCATE( il_ihalostart)
+      DEALLOCATE( il_jhalostart)
+
+      DEALLOCATE( il_ihaloend  )
+      DEALLOCATE( il_jhaloend  )
+
+      !impp
+      tl_att=att_init( "SUBDOMAIN_I_left_bottom_indices", td_mpp%t_proc(:)%i_impp)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      tl_att=att_init( "SUBDOMAIN_J_left_bottom_indices", td_mpp%t_proc(:)%i_jmpp)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      ! lci
+      tl_att=att_init( "SUBDOMAIN_I_dimensions", td_mpp%t_proc(:)%i_lci)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      tl_att=att_init( "SUBDOMAIN_J_dimensions", td_mpp%t_proc(:)%i_lcj)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      ! ldi
+      tl_att=att_init( "SUBDOMAIN_I_first_indoor_indices", td_mpp%t_proc(:)%i_ldi)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      tl_att=att_init( "SUBDOMAIN_J_first_indoor_indices", td_mpp%t_proc(:)%i_ldj)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      ! lei
+      tl_att=att_init( "SUBDOMAIN_I_last_indoor_indices", td_mpp%t_proc(:)%i_lei)
+      CALL mpp_move_att(td_mpp, tl_att)
+
+      tl_att=att_init( "SUBDOMAIN_J_last_indoor_indices", td_mpp%t_proc(:)%i_lej)
+      CALL mpp_move_att(td_mpp, tl_att)         
+
+      ! clean
+      CALL att_clean(tl_att)
+
+   END SUBROUTINE mpp__compute_halo
 END MODULE mpp
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/multi.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/multi.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/multi.f90	(revision 7339)
@@ -173,4 +173,6 @@
    !> @date July, 2015 
    !> - check if variable to be read is in file
+   !> @date January, 2016
+   !> - read variable dimensions
    !>
    !> @param[in] cd_varfile   variable location information (from namelist) 
@@ -187,17 +189,19 @@
 
       ! local variable
-      CHARACTER(LEN=lc) :: cl_name
-      CHARACTER(LEN=lc) :: cl_lower
-      CHARACTER(LEN=lc) :: cl_file
-      CHARACTER(LEN=lc) :: cl_matrix
-
-      INTEGER(i4)       :: il_nvar
-      INTEGER(i4)       :: il_varid
-
-      LOGICAL           :: ll_dim
-
-      TYPE(TVAR)        :: tl_var
-
-      TYPE(TMPP)        :: tl_mpp
+      CHARACTER(LEN=lc)                :: cl_name
+      CHARACTER(LEN=lc)                :: cl_lower
+      CHARACTER(LEN=lc)                :: cl_file
+      CHARACTER(LEN=lc)                :: cl_matrix
+
+      INTEGER(i4)                      :: il_nvar
+      INTEGER(i4)                      :: il_varid
+
+      LOGICAL                          :: ll_dim
+
+      TYPE(TDIM), DIMENSION(ip_maxdim) :: tl_dim
+
+      TYPE(TVAR)                       :: tl_var
+
+      TYPE(TMPP)                       :: tl_mpp
 
       ! loop indices
@@ -216,6 +220,6 @@
 
          IF( LEN(TRIM(cl_file)) == lc )THEN
-            CALL logger_fatal("MULTI INIT: file name too long (==256)."//&
-            &  " check namelist.")
+            CALL logger_fatal("MULTI INIT: file name too long (>"//&
+            &          TRIM(fct_str(lc))//"). check namelist.")
          ENDIF
 
@@ -243,5 +247,4 @@
                   ! 
                   tl_mpp=mpp_init( file_init(TRIM(cl_file)) )
-
                   ! define variable
                   IF( TRIM(fct_lower(cl_lower)) /= 'all' )THEN
@@ -255,8 +258,14 @@
                      ENDIF
 
-                     ! clean var
+                     ! get (global) variable dimension
+                     tl_dim(jp_I)=dim_copy(tl_mpp%t_dim(jp_I))
+                     tl_dim(jp_J)=dim_copy(tl_mpp%t_dim(jp_J))
+                     tl_dim(jp_K)=dim_copy(tl_mpp%t_proc(1)%t_var(il_varid)%t_dim(jp_K))
+                     tl_dim(jp_L)=dim_copy(tl_mpp%t_proc(1)%t_var(il_varid)%t_dim(jp_L))
+
+                     ! clean all varible
                      CALL mpp_del_var(tl_mpp)
 
-                     tl_var=var_init(TRIM(cl_lower))
+                     tl_var=var_init(TRIM(cl_lower), td_dim=tl_dim(:))
 
                      ! add variable
@@ -272,5 +281,5 @@
 
                      DO jk=tl_mpp%t_proc(1)%i_nvar,1,-1
-                        
+
                         ! check if variable is dimension
                         ll_dim=.FALSE.
@@ -379,10 +388,10 @@
       ! print file
       IF( td_multi%i_nmpp /= 0 .AND. ASSOCIATED(td_multi%t_mpp) )THEN
-         WRITE(*,'(/a,i3)') 'MULTI: total number of mpp: ',&
+         WRITE(*,'(/a,i3)') 'MULTI: total number of file(s): ',&
          &  td_multi%i_nmpp
-         WRITE(*,'(6x,a,i3)') ' total number of variable: ',&
+         WRITE(*,'(6x,a,i3)') ' total number of variable(s): ',&
          &  td_multi%i_nvar
          DO ji=1,td_multi%i_nmpp
-            WRITE(*,'(3x,3a)') 'MPP FILE ',TRIM(td_multi%t_mpp(ji)%c_name),&
+            WRITE(*,'(3x,3a)') 'FILE ',TRIM(td_multi%t_mpp(ji)%c_name),&
             & ' CONTAINS'
             DO jj=1,td_multi%t_mpp(ji)%t_proc(1)%i_nvar
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/phycst.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/phycst.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/phycst.f90	(revision 7339)
@@ -12,4 +12,6 @@
 ! REVISION HISTORY:
 !> @date November, 2013 - Initial Version
+!> @date September, 2015
+!> - add physical constant to compute meshmask
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -23,16 +25,30 @@
    PUBLIC :: dp_pi      !< pi
    PUBLIC :: dp_eps     !< epsilon value
-   PUBLIC :: dp_rearth  !< earth radius (km)
+   PUBLIC :: dp_rearth  !< earth radius [m]
    PUBLIC :: dp_deg2rad !< degree to radian ratio 
    PUBLIC :: dp_rad2deg !< radian to degree ratio 
    PUBLIC :: dp_delta   !<  
+   PUBLIC :: dp_omega   !< earth rotation parameter [s-1] 
+   PUBLIC :: dp_day     !< day                                [s]
+   PUBLIC :: dp_siyea   !< sideral year                       [s]
+   PUBLIC :: dp_siday   !< sideral day                        [s]
+
+   REAL(wp), PUBLIC ::   rday = 24.*60.*60.     !: day                                [s]
+   REAL(wp), PUBLIC ::   rsiyea                 !: sideral year                       [s]
+   REAL(wp), PUBLIC ::   rsiday                 !: sideral day                        [s]
 
    REAL(dp), PARAMETER :: dp_pi = 3.14159274101257_dp
    REAL(dp), PARAMETER :: dp_eps = EPSILON(1._dp)
-   REAL(dp), PARAMETER :: dp_rearth = 6871._dp
+   REAL(dp), PARAMETER :: dp_rearth = 6371229._dp
    REAL(dp), PARAMETER :: dp_deg2rad = dp_pi/180.0
    REAL(dp), PARAMETER :: dp_rad2deg = 180.0/dp_pi
 
+   REAL(dp), PARAMETER :: dp_day = 24.*60.*60.     
+   REAL(dp), PARAMETER :: dp_siyea = 365.25_wp * dp_day * &
+      &  2._wp * dp_pi / 6.283076_dp
+   REAL(dp), PARAMETER :: dp_siday = dp_day / ( 1._wp + dp_day / dp_siyea )
+
    REAL(dp), PARAMETER :: dp_delta=1.e-6
+   REAL(dp), PARAMETER :: dp_omega= 2._dp * dp_pi / dp_siday
 END MODULE phycst
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/variable.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/variable.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/variable.f90	(revision 7339)
@@ -285,4 +285,6 @@
 !> @date July, 2015 
 !> - add subroutine var_chg_unit to change unit of output variable
+!> @date Spetember, 2015
+!> - manage useless (dummy) variable
 !
 !> @note Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -305,4 +307,6 @@
 
    PUBLIC :: tg_varextra !< array of variable structure with extra information.
+
+   PRIVATE :: cm_dumvar  !< dummy variable array
 
    ! function and subroutine
@@ -334,4 +338,6 @@
    PUBLIC :: var_chg_extra     !< read variable namelist information, and modify extra information.
    PUBLIC :: var_check_dim     !< check variable dimension expected
+   PUBLIC :: var_get_dummy     !< fill dummy variable array
+   PUBLIC :: var_is_dummy      !< check if variable is defined as dummy variable
 
    PRIVATE :: var__init          ! initialize variable structure without array of value
@@ -445,4 +451,6 @@
                                                         !< fill when running var_def_extra() 
 
+   CHARACTER(LEN=lc), DIMENSION(ip_maxdum), SAVE :: cm_dumvar !< dummy variable
+
    INTERFACE var_init
       MODULE PROCEDURE var__init       ! initialize variable structure without array of value
@@ -6698,8 +6706,8 @@
    !> given variable name or standard name. 
    !>
-   !> @warning only variable read from file, have an id.
-   !>
    !> @author J.Paul
    !> @date November, 2013 - Initial Version
+   !> @date July, 2015
+   !> - check long name
    !
    !> @param[in] td_var       array of variable structure
@@ -6735,4 +6743,11 @@
          ELSE IF( fct_lower(td_var(ji)%c_stdname) == fct_lower(cd_name) .AND.&
          &    TRIM(fct_lower(td_var(ji)%c_stdname)) /= '' )THEN
+            
+            var_get_id=td_var(ji)%i_id
+            EXIT
+
+         ! look for variable long name
+         ELSE IF( fct_lower(td_var(ji)%c_longname) == fct_lower(cd_name) .AND.&
+         &    TRIM(fct_lower(td_var(ji)%c_longname)) /= '' )THEN
             
             var_get_id=td_var(ji)%i_id
@@ -6775,6 +6790,7 @@
       IF( ASSOCIATED(td_var%d_value) )THEN
 
-         CALL logger_trace( "VAR GET MASK: create mask from variable "//&
-         &               TRIM(td_var%c_name) )
+         CALL logger_debug( "VAR GET MASK: create mask from variable "//&
+         &               TRIM(td_var%c_name)//", FillValue ="//&
+         &               TRIM(fct_str(td_var%d_fill)))
          var_get_mask(:,:,:)=1
          WHERE( td_var%d_value(:,:,:,1) == td_var%d_fill )
@@ -7279,8 +7295,12 @@
 
       ! local variable
+      CHARACTER(LEN=lc) :: cl_tmp
+
       INTEGER(i4)       :: il_ind
+      
       TYPE(TATT)        :: tl_att
 
       ! loop indices
+      INTEGER(i4)       :: ji
       !----------------------------------------------------------------
 
@@ -7335,6 +7355,14 @@
                td_var%c_axis=TRIM(tg_varextra(il_ind)%c_axis)
                ! create attibute
-               tl_att=att_init('axis',TRIM(td_var%c_axis))
-               CALL var_move_att(td_var, tl_att)               
+               IF( TRIM(fct_upper(td_var%c_name)) == TRIM(td_var%c_axis) )THEN
+                  tl_att=att_init('axis',TRIM(td_var%c_axis))
+               ELSE
+                  cl_tmp=""
+                  DO ji=LEN(TRIM(td_var%c_axis)),1,-1
+                     cl_tmp=TRIM(cl_tmp)//" "//TRIM(td_var%c_axis(ji:ji))
+                  ENDDO
+                  tl_att=att_init('associate',TRIM(ADJUSTL(cl_tmp)))
+               ENDIF
+               CALL var_move_att(td_var, tl_att)
             ENDIF
 
@@ -7402,4 +7430,8 @@
             ENDIF
 
+         ELSE
+            CALL logger_warn("VAR GET EXTRA: no extra information on "//&
+               &  "variable "//TRIM(td_var%c_name)//". you should define it"//&
+               &  " (see variable.cfg).")
          ENDIF
 
@@ -7425,4 +7457,6 @@
    !> - change way to get information in namelist, 
    !> value follows string "min ="
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7447,4 +7481,5 @@
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
       !----------------------------------------------------------------
       ! init
@@ -7457,6 +7492,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'min')
          IF( il_ind /= 0 )THEN
-            cl_min=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('min')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_min=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7470,6 +7510,7 @@
             &  TRIM(fct_str(var__get_min))//" for variable "//TRIM(cd_name) )
          ELSE
-            CALL logger_error("VAR GET MIN: invalid minimum value for "//&
-            &  "variable "//TRIM(cd_name)//". check namelist." )
+            CALL logger_error("VAR GET MIN: invalid minimum value ("//&
+               & TRIM(cl_min)//") for variable "//TRIM(cd_name)//&
+               & ". check namelist." )
          ENDIF
       ENDIF
@@ -7489,4 +7530,6 @@
    !> - change way to get information in namelist, 
    !> value follows string "max ="
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7511,4 +7554,5 @@
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
       !----------------------------------------------------------------
       ! init
@@ -7521,6 +7565,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'max')
          IF( il_ind /= 0 )THEN
-            cl_max=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('max')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_max=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7550,4 +7599,6 @@
    !> @author J.Paul
    !> @date June, 2015 - Initial Version
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7574,4 +7625,5 @@
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
       !----------------------------------------------------------------
       ! init
@@ -7584,6 +7636,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'unf')
          IF( il_ind /= 0 )THEN
-            cl_unf=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('unf')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_unf=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7626,4 +7683,6 @@
    !> - change way to get information in namelist, 
    !> value follows string "int ="
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7663,6 +7722,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'int')
          IF( il_ind /= 0 )THEN
-            cl_int=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('int')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_int=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7746,4 +7810,6 @@
    !> - change way to get information in namelist, 
    !> value follows string "ext ="
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7778,6 +7844,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'ext')
          IF( il_ind /= 0 )THEN
-            cl_ext=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('ext')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_ext=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7822,4 +7893,6 @@
    !> - change way to get information in namelist, 
    !> value follows string "flt ="
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !>
    !> @param[in] cd_name      variable name
@@ -7852,6 +7925,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'flt')
          IF( il_ind /= 0 )THEN
-            cl_flt=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('flt')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               cl_flt=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -7925,4 +8003,6 @@
    !> @author J.Paul
    !> @date June, 2015 - Initial Version
+   !> @date Feb, 2016
+   !> - check character just after keyword
    !
    !> @param[in] cd_name      variable name
@@ -7946,4 +8026,5 @@
       ! loop indices
       INTEGER(i4) :: ji
+      INTEGER(i4) :: jj
       !----------------------------------------------------------------
 
@@ -7955,6 +8036,11 @@
          il_ind=INDEX(TRIM(cl_tmp),'unt')
          IF( il_ind /= 0 )THEN
-            var__get_unt=fct_split(cl_tmp,2,'=')
-            EXIT
+            ! check character just after
+            jj=il_ind+LEN('unt')
+            IF(  TRIM(cl_tmp(jj:jj)) == ' ' .OR. &
+            &    TRIM(cl_tmp(jj:jj)) == '=' )THEN
+               var__get_unt=fct_split(cl_tmp,2,'=')
+               EXIT
+            ENDIF
          ENDIF
          ji=ji+1
@@ -8101,8 +8187,8 @@
 
             !- change scale factor and offset to avoid mistake
-            tl_att=att_init('scale_factor',1)
+            tl_att=att_init('scale_factor',1._dp)
             CALL var_move_att(td_var, tl_att)
 
-            tl_att=att_init('add_offset',0)
+            tl_att=att_init('add_offset',0._dp)
             CALL var_move_att(td_var, tl_att)
          ENDIF
@@ -8356,4 +8442,96 @@
 
    END FUNCTION var_to_date
+   !-------------------------------------------------------------------
+   !> @brief This subroutine fill dummy variable array
+   !
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !
+   !> @param[in] cd_dummy dummy configuration file
+   !-------------------------------------------------------------------
+   SUBROUTINE var_get_dummy( cd_dummy )
+      IMPLICIT NONE
+      ! Argument
+      CHARACTER(LEN=*), INTENT(IN) :: cd_dummy
+
+      ! local variable
+      INTEGER(i4)   :: il_fileid
+      INTEGER(i4)   :: il_status
+
+      LOGICAL       :: ll_exist
+
+      ! loop indices
+      ! namelist
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumvar
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumdim
+      CHARACTER(LEN=lc), DIMENSION(ip_maxdum) :: cn_dumatt
+
+      !----------------------------------------------------------------
+      NAMELIST /namdum/ &   !< dummy namelist
+      &  cn_dumvar, &       !< variable  name
+      &  cn_dumdim, &       !< dimension name
+      &  cn_dumatt          !< attribute name
+      !----------------------------------------------------------------
+
+      ! init
+      cm_dumvar(:)=''
+
+      ! read namelist
+      INQUIRE(FILE=TRIM(cd_dummy), EXIST=ll_exist)
+      IF( ll_exist )THEN
+    
+         il_fileid=fct_getunit()
+   
+         OPEN( il_fileid, FILE=TRIM(cd_dummy), &
+         &                FORM='FORMATTED',       &
+         &                ACCESS='SEQUENTIAL',    &
+         &                STATUS='OLD',           &
+         &                ACTION='READ',          &
+         &                IOSTAT=il_status)
+         CALL fct_err(il_status)
+         IF( il_status /= 0 )THEN
+            CALL logger_fatal("DIM GET DUMMY: opening "//TRIM(cd_dummy))
+         ENDIF
+   
+         READ( il_fileid, NML = namdum )
+         cm_dumvar(:)=cn_dumvar(:)
+
+         CLOSE( il_fileid )
+
+      ENDIF
+   
+   END SUBROUTINE var_get_dummy
+   !-------------------------------------------------------------------
+   !> @brief This function check if variable is defined as dummy variable
+   !> in configuraton file
+   !>
+   !> @author J.Paul
+   !> @date September, 2015 - Initial Version
+   !
+   !> @param[in] td_var variable structure
+   !> @return true if variable is dummy variable 
+   !-------------------------------------------------------------------
+   FUNCTION var_is_dummy(td_var)
+      IMPLICIT NONE
+
+      ! Argument      
+      TYPE(TVAR), INTENT(IN) :: td_var
+      
+      ! function
+      LOGICAL :: var_is_dummy
+      
+      ! loop indices
+      INTEGER(i4) :: ji
+      !----------------------------------------------------------------
+
+      var_is_dummy=.FALSE.
+      DO ji=1,ip_maxdum
+         IF( fct_lower(td_var%c_name) == fct_lower(cm_dumvar(ji)) )THEN
+            var_is_dummy=.TRUE.
+            EXIT
+         ENDIF
+      ENDDO
+
+   END FUNCTION var_is_dummy
 END MODULE var
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/vgrid.f90
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/vgrid.f90	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/src/vgrid.f90	(revision 7339)
@@ -291,4 +291,12 @@
    END SUBROUTINE vgrid_zgr_z
    !-------------------------------------------------------------------
+   !> @brief This subroutine
+   !>
+   !> @todo add subroutine description
+   !>
+   !> @param[inout] dd_bathy
+   !> @param[in] dd_gdepw
+   !> @param[in] dd_hmin
+   !> @param[in] dd_fill
    !-------------------------------------------------------------------
    SUBROUTINE vgrid_zgr_bat( dd_bathy, dd_gdepw, dd_hmin, dd_fill )
@@ -371,5 +379,5 @@
    !>         - gdept, gdepw and e3 are positives
    !>         - gdept_ps, gdepw_ps and e3_ps are positives
-   !
+   !>
    !> @author A. Bozec, G. Madec
    !> @date February, 2009 - F90: Free form and module
@@ -386,4 +394,5 @@
    !> @param[in] dd_e3zps_min
    !> @param[in] dd_e3zps_rat
+   !> @param[in] dd_fill
    !-------------------------------------------------------------------
    SUBROUTINE vgrid_zgr_zps( id_mbathy, dd_bathy, id_jpkmax, &
@@ -495,5 +504,5 @@
    !> ** Action  : - update mbathy: level bathymetry (in level index)
    !>              - update bathy : meter bathymetry (in meters)
-
+   !>
    !> @author G.Madec
    !> @date Marsh, 2008 - Original code
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_bathy.nam
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_bathy.nam	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_bathy.nam	(revision 7339)
@@ -1,4 +1,4 @@
 &namlog
-   cn_logfile="bathy_out.log"
+   cn_logfile=
    cn_verbosity=
    in_maxerror=
@@ -6,5 +6,6 @@
 
 &namcfg
-   cn_varcfg="./cfg/variable.cfg"
+   cn_varcfg=
+   cn_dumcfg=
 /
 
@@ -16,4 +17,6 @@
 &namfin
    cn_coord1=
+   in_perio1=
+   ln_fillclosed=
 /
 
@@ -29,4 +32,4 @@
 
 &namout
-   cn_fileout="bathy_out.nc"      
+   cn_fileout=
 /
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_boundary.nam
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_boundary.nam	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_boundary.nam	(revision 7339)
@@ -1,4 +1,4 @@
 &namlog
-   cn_logfile="boundary.log"
+   cn_logfile=
    cn_verbosity=
    in_maxerror =
@@ -6,5 +6,6 @@
 
 &namcfg
-   cn_varcfg="./cfg/variable.cfg"
+   cn_varcfg=
+   cn_dumcfg=
 /
 
@@ -41,6 +42,6 @@
 
 &namvar
+   cn_varfile=
    cn_varinfo=
-   cn_varfile=
 /
 
@@ -63,5 +64,5 @@
 
 &namout
-   cn_fileout="boundary_out.nc"      
+   cn_fileout=
    dn_dayofs=
    ln_extrap=
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_coord.nam
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_coord.nam	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_coord.nam	(revision 7339)
@@ -1,4 +1,4 @@
 &namlog
-   cn_logfile="coord_out.log"
+   cn_logfile=
    cn_verbosity=
    in_maxerror=
@@ -6,5 +6,6 @@
 
 &namcfg
-   cn_varcfg="./cfg/variable.cfg"
+   cn_varcfg=
+   cn_dumcfg=
 /
 
@@ -29,5 +30,5 @@
 
 &namout
-   cn_fileout="coord_out.nc"
+   cn_fileout=
 /
 
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_restart.nam
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_restart.nam	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/create_restart.nam	(revision 7339)
@@ -1,10 +1,11 @@
 &namlog
-   cn_logfile="restart_out.log"
+   cn_logfile=
    cn_verbosity=
-   in_maxerror =
+   in_maxerror=
 /
 
 &namcfg
-   cn_varcfg="./cfg/variable.cfg"
+   cn_varcfg=
+   cn_dumcfg=
 /
 
@@ -41,6 +42,6 @@
 
 &namvar
+   cn_varfile=
    cn_varinfo=
-   cn_varfile=
 /
 
@@ -51,7 +52,7 @@
 
 &namout
-   cn_fileout="restart_out.nc"      
+   cn_fileout=
    ln_extrap=
-   in_nipro=
+   in_niproc=
    in_njproc=
    in_nproc=
Index: branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/merge_bathy.nam
===================================================================
--- branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/merge_bathy.nam	(revision 7338)
+++ branches/2016/dev_NOC_2016/NEMOGCM/TOOLS/SIREN/templates/merge_bathy.nam	(revision 7339)
@@ -1,10 +1,11 @@
 &namlog
-   cn_logfile="merge_out.log"
+   cn_logfile=
    cn_verbosity=
-   in_maxerror =
+   in_maxerror=
 /
 
 &namcfg
-   cn_varcfg="./cfg/variable.cfg"
+   cn_varcfg=
+   cn_dumcfg=
 /
 
@@ -17,8 +18,4 @@
    cn_bathy1=
    in_perio1=
-/
-
-&namvar
-   cn_varinfo=
 /
 
@@ -41,4 +38,4 @@
 
 &namout
-   cn_fileout="merge_out.nc"      
+   cn_fileout=
 /
